X-Git-Url: https://git.shemshak.org/~bandali/configs/blobdiff_plain/d7dee82420a04e5c92e5b5ad316e14a49bd4d689..2698f1c3182b77dbfb532d3799539395d160c9b4:/.emacs.d/init.el?ds=inline diff --git a/.emacs.d/init.el b/.emacs.d/init.el index 958f457..8836a1b 100644 --- a/.emacs.d/init.el +++ b/.emacs.d/init.el @@ -1,6 +1,6 @@ ;;; init.el --- bandali's emacs configuration -*- lexical-binding: t -*- -;; Copyright (C) 2018-2020 Amin Bandali +;; Copyright (C) 2018-2021 Amin Bandali ;; This program is free software: you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by @@ -17,9 +17,8 @@ ;;; Commentary: -;; GNU Emacs configuration of Amin Bandali, computer scientist, -;; Free Software activist, and GNU maintainer & webmaster. Packages -;; are installed through using Borg for a fully reproducible setup. +;; GNU Emacs configuration of bandali, free software activist, +;; computing scientist, and GNU maintainer and volunteer. ;; Over the years, I've taken inspiration from configurations of many ;; great people. Some that I can remember off the top of my head are: @@ -76,28 +75,27 @@ (format "[%s]" (number-to-string exwm-workspace-current-index)))))))) - - ;; make some mode-line spaces smaller - (setq-default - mode-line-format - (mapcar - (lambda (x) - (if (and (stringp x) (or (string= x " ") (string= x " "))) - " " - x)) - mode-line-format) - mode-line-buffer-identification - (propertized-buffer-identification "%10b"))) + (when (version< emacs-version "28") + ;; manually make some mode-line spaces smaller + ;; (version<= "28" emacs-version) can do an awesome job at this + ;; out of the box if `mode-line-compact' is set to t (see below) + (setq-default + mode-line-format + (mapcar + (lambda (x) + (if (and (stringp x) + (or (string= x " ") + (string= x " "))) + " " + x)) + mode-line-format) + mode-line-buffer-identification + (propertized-buffer-identification "%10b")))) (add-hook 'after-init-hook #'b/post-init) ;; increase number of lines kept in *Messages* log (setq message-log-max 20000) -;; optionally, uncomment to supress some byte-compiler warnings -;; (see C-h v byte-compile-warnings RET for more info) -;; (setq byte-compile-warnings -;; '(not free-vars unresolved noruntime lexical make-local)) - ;;; whoami @@ -137,28 +135,19 @@ This sets each user option VAR's value to the corresponding VALUE. ;; (package-generate-description-file d "refinery-theme-pkg.el")) (run-with-idle-timer 0.01 nil #'require 'package) (with-eval-after-load 'package - (when (= (length package-archives) 1) - (csetq - package-archives - `(,@package-archives - ;; ("bndl" . "https://p.bndl.org/elpa/") - ("org" . "https://orgmode.org/elpa/")) - package-load-list - '(;; GNU ELPA - (ivy "0.13.1") - (counsel "0.13.1") - (swiper "0.13.1") - (debbugs "0.26") - (delight "1.7") - (ebdb "0.6.19") - (orgalist "1.13") - (rt-liberation "1.31") - (yasnippet "0.14.0") - ;; bndl - (refinery-theme "0.1.1") - ;; Org ELPA - (org-plus-contrib "20201005")))) - (package-initialize)) + ;; (csetq + ;; ;; package-archives + ;; ;; `(,@package-archives + ;; ;; ("bndl" . "https://p.bndl.org/elpa/")) + ;; package-load-list + ;; '(;; GNU ELPA + ;; (debbugs "0.29") + ;; (delight "1.7") + ;; (emms "7.7") + ;; (expand-region "0.11.0") + ;; (rt-liberation "2.4") + ;; (yasnippet "0.14.0"))) +(package-initialize)) (csetq package-archive-upload-base "/ssh:caffeine:~/www/p/elpa") @@ -224,72 +213,81 @@ This sets each user option VAR's value to the corresponding VALUE. ;;;; C-level customizations (csetq + ;; line-spacing 3 + ;; completion case sensitivity + completion-ignore-case t + read-buffer-completion-ignore-case t ;; minibuffer enable-recursive-minibuffers t resize-mini-windows t - ;; more useful frame titles - ;; frame-title-format '("" invocation-name " - " - ;; (:eval - ;; (if (buffer-file-name) - ;; (abbreviate-file-name (buffer-file-name)) - ;; "%b"))) - ;; i don't feel like jumping out of my chair every now and again; so - ;; don't BEEP! at me, emacs + ;; mode-line + mode-line-compact t + ;; i don't feel like jumping out of my chair every now and again; + ;; so...don't *BEEP* at me, emacs =) ring-bell-function 'ignore ;; better scrolling - ;; scroll-margin 1 - ;; scroll-conservatively 10000 - scroll-step 1 - scroll-conservatively 101 - scroll-preserve-screen-position 1 + ;; scroll-conservatively 101 + scroll-conservatively 15 + ;; scroll-preserve-screen-position 1 ;; focus follows mouse - mouse-autoselect-window t) + ;; mouse-autoselect-window t + ) (setq-default - ;; always use space for indentation - indent-tabs-mode nil - tab-width 4 ;; case-sensitive search (and `dabbrev-expand') ;; case-fold-search nil - ;; cursor shape - cursor-type t) - -(set-fontset-font t 'arabic "Vazir") - -;; unicode support -;; (dolist (ft (fontset-list)) -;; (set-fontset-font -;; ft -;; 'unicode -;; (font-spec :name "Source Code Pro" :size 14)) -;; (set-fontset-font -;; ft -;; 'unicode -;; (font-spec :name "DejaVu Sans Mono") -;; nil -;; 'append) -;; ;; (set-fontset-font -;; ;; ft -;; ;; 'unicode -;; ;; (font-spec -;; ;; :name "Symbola monospacified for DejaVu Sans Mono") -;; ;; nil -;; ;; 'append) -;; ;; (set-fontset-font -;; ;; ft -;; ;; #x2115 ; ℕ -;; ;; (font-spec :name "DejaVu Sans Mono") -;; ;; nil -;; ;; 'append) -;; (set-fontset-font -;; ft -;; (cons ?Α ?ω) -;; (font-spec :name "DejaVu Sans Mono" :size 14) -;; nil -;; 'prepend)) + ;; always use space for indentation + indent-tabs-mode nil + tab-width 4) + +(when (display-graphic-p) + (set-fontset-font t 'arabic "Vazir")) +;; ;; (set-frame-font "Drafting Mono-14:weight=light" nil t) +;; (set-frame-font "Drafting Mono:pixelsize=16" nil t) +;; (set-face-attribute 'bold nil :weight 'semi-bold) ;;;; Elisp-level customizations +;; (define-key minibuffer-local-completion-map +;; "\t" #'minibuffer-force-complete) + +;; (with-eval-after-load 'icomplete + +;; (setq icomplete-on-del-error-function #'abort-recursive-edit) + +;; (defun b/icomplete-fido-backward-updir () +;; "Delete char before or go up directory, like `ido-mode'." +;; (interactive) +;; (if (and (eq (char-before) ?/) +;; (eq (icomplete--category) 'file)) +;; (save-excursion +;; (goto-char (1- (point))) +;; (when (search-backward "/" (point-min) t) +;; (delete-region (1+ (point)) (point-max)))) +;; (condition-case nil +;; (call-interactively #'delete-backward-char) +;; (error +;; (when icomplete-on-del-error-function +;; (funcall icomplete-on-del-error-function)))))) + +;; (define-key icomplete-fido-mode-map +;; (kbd "DEL") #'b/icomplete-fido-backward-updir)) + +;; (with-eval-after-load 'subr +;; (keyboard-translate ?\( ?\[) +;; (keyboard-translate ?\) ?\]) +;; (keyboard-translate ?\[ ?\() +;; (keyboard-translate ?\] ?\)) + +;; ;; (keyboard-translate ?\( ?\() +;; ;; (keyboard-translate ?\) ?\)) +;; ;; (keyboard-translate ?\[ ?\[) +;; ;; (keyboard-translate ?\] ?\]) +;; ) + +;; minibuffer +(csetq read-file-name-completion-ignore-case t) + ;; startup ;; don't need to see the startup echo area message (advice-add #'display-startup-echo-area-message :override #'ignore) @@ -316,7 +314,7 @@ This sets each user option VAR's value to the corresponding VALUE. ;; auto-save auto-save-file-name-transforms `((".*" ,(b/var "auto-save/") t)) ;; insert newline at the end of files - require-final-newline t + ;; require-final-newline t ;; open read-only file buffers in view-mode ;; (enables niceties like `q' for quit) view-read-only t) @@ -335,27 +333,33 @@ This sets each user option VAR's value to the corresponding VALUE. (global-auto-revert-mode 1) ;; time and battery in mode-line -(csetq - display-time-default-load-average nil - display-time-format " %a %b %-e %-l:%M%P" - display-time-mail-icon '(image :type xpm - :file "gnus/gnus-pointer.xpm" - :ascent center) - display-time-use-mail-icon t) -(require 'time) -(display-time-mode) - -(csetq battery-mode-line-format " %p%% %t") -(require 'battery) -(display-battery-mode) - -(require 'fringe) -;; smaller fringe -;; (fringe-mode '(3 . 1)) -(fringe-mode nil) +(run-with-idle-timer 0.1 nil #'require 'time) +(with-eval-after-load 'time + (csetq + display-time-default-load-average nil + display-time-format " %a %b %-e %-l:%M%P" + display-time-mail-icon '(image :type xpm + :file "gnus/gnus-pointer.xpm" + :ascent center) + display-time-use-mail-icon t + zoneinfo-style-world-list + `(,@zoneinfo-style-world-list + ("Etc/UTC" "UTC") + ("Asia/Tehran" "Tehran") + ("Australia/Melbourne" "Melbourne"))) + (display-time-mode)) + +(run-with-idle-timer 0.1 nil #'require 'battery) +(with-eval-after-load 'battery + (csetq battery-mode-line-format " %p%% %t") + (display-battery-mode)) + +;; (with-eval-after-load 'fringe +;; ;; smaller fringe +;; (fringe-mode '(3 . 1))) -(require 'winner) ;; enable winner-mode (C-h f winner-mode RET) +(require 'winner) (winner-mode 1) (with-eval-after-load 'compile @@ -384,6 +388,7 @@ This sets each user option VAR's value to the corresponding VALUE. (csetq ;; allow scrolling in Isearch isearch-allow-scroll t + isearch-lazy-count t ;; search for non-ASCII characters: i’d like non-ASCII characters such ;; as ‘’“”«»‹›áⓐ𝒶 to be selected when i search for their ASCII ;; counterpart. shoutout to @@ -427,16 +432,34 @@ This sets each user option VAR's value to the corresponding VALUE. ;; this will fail if gpg>=2.1 is not available epg-pinentry-mode 'loopback) -;; (require 'pinentry) -;; workaround for systemd-based distros: -;; (setq pinentry--socket-dir server-socket-dir) -;; (pinentry-start) - ;; auth-source (csetq auth-sources '("~/.authinfo.gpg") authinfo-hidden (regexp-opt '("password" "client-secret" "token"))) +;; info +(with-eval-after-load 'info + (add-to-list + 'Info-directory-list + (expand-file-name + (convert-standard-filename "info/") source-directory))) + +;; faces +(when (display-graphic-p) + (with-eval-after-load 'faces + (let* ((grey "#e7e7e7") + ;; (darker-grey "#d9d9d9") + ;; (box ;; 'unspecified + ;; `(;; :line-width -1 + ;; :style released-button)) + ) + (set-face-attribute 'mode-line nil + :background grey ;; :box box + ) + ;; (set-face-attribute 'mode-line-inactive nil + ;; :background darker-grey :box box) + ))) + ;;; Useful utilities @@ -519,13 +542,14 @@ Make N (default: 1) copies of the current line or region." (global-set-key (kbd "C-a") #'b/move-indentation-or-beginning-of-line) (global-set-key (kbd "C-c a i") #'ielm) (global-set-key (kbd "C-c d") #'b/duplicate-line-or-region) +(global-set-key (kbd "C-c j") #'b/join-line-top) (global-set-key (kbd "C-S-j") #'b/join-line-top) (global-set-key (kbd "C-c x") #'execute-extended-command) ;; evaling and macro-expanding (global-set-key (kbd "C-c e b") #'eval-buffer) (global-set-key (kbd "C-c e e") #'eval-last-sexp) -(global-set-key (kbd "C-c e p") #'pp-macroexpand-last-sexp) +(global-set-key (kbd "C-c e m") #'pp-macroexpand-last-sexp) (global-set-key (kbd "C-c e r") #'eval-region) ;; emacs things @@ -537,21 +561,19 @@ Make N (default: 1) copies of the current line or region." (global-set-key (kbd "C-c f .") #'find-file) (global-set-key (kbd "C-c f d") #'find-name-dired) (global-set-key (kbd "C-c f l") #'find-library) +(global-set-key (kbd "C-c f p") #'find-file-at-point) ;; frames (global-set-key (kbd "C-c F m") #'make-frame-command) (global-set-key (kbd "C-c F d") #'delete-frame) ;; help/describe -(global-set-key (kbd "C-S-h C") #'describe-char) (global-set-key (kbd "C-S-h F") #'describe-face) ;; (global-set-key (kbd "C-x k") #'b/kill-current-buffer) ;; (global-set-key (kbd "C-x K") #'kill-buffer) -;; (global-set-key (kbd "C-x s") #'save-buffer) -;; (global-set-key (kbd "C-x S") #'save-some-buffers) -(define-key emacs-lisp-mode-map (kbd "") #'b/add-elisp-section) +(define-key emacs-lisp-mode-map (kbd "C-") #'b/add-elisp-section) (when (display-graphic-p) (global-unset-key (kbd "C-z"))) @@ -568,9 +590,7 @@ Make N (default: 1) copies of the current line or region." (require 'bandali-org) -(require 'bandali-theme) - -;; (require 'bandali-magit) +;; (require 'bandali-theme) ;; recently opened files (csetq recentf-max-saved-items 2000 @@ -578,52 +598,30 @@ Make N (default: 1) copies of the current line or region." (run-with-idle-timer 0.2 nil #'require 'recentf) (with-eval-after-load 'recentf ;; (add-to-list 'recentf-keep #'file-remote-p) - (recentf-mode)) + (recentf-mode) -;; needed for history for counsel -(csetq amx-save-file (b/var "amx-save.el")) -(add-to-list 'load-path (b/lisp "s")) -(add-to-list 'load-path (b/lisp "amx")) -(run-with-idle-timer 0.3 nil #'require 'amx) -(with-eval-after-load 'amx - (amx-mode)) - -(require 'bandali-ivy) + (defun b/recentf-open () + "Use `completing-read' to \\[find-file] a recent file." + (interactive) + (find-file + (completing-read "Find recent file: " recentf-list))) + (global-set-key (kbd "C-c f r") #'b/recentf-open)) + +;; (fido-mode 1) +;; (defun b/icomplete--fido-mode-setup () +;; "Customizations to `fido-mode''s minibuffer." +;; (when (and icomplete-mode (icomplete-simple-completing-p)) +;; (setq-local +;; ;; icomplete-compute-delay 0.1 +;; ;; icomplete-hide-common-prefix t +;; icomplete-separator " · " +;; completion-styles '(basic substring partial-completion flex)))) +;; (add-hook 'minibuffer-setup-hook #'b/icomplete--fido-mode-setup 1) (require 'bandali-eshell) (require 'bandali-ibuffer) -;; outline -;; (with-eval-after-load 'outline -;; (when (featurep 'which-key) -;; (which-key-add-key-based-replacements -;; "C-c @" "outline" -;; "s-O" "outline")) -;; (define-key outline-minor-mode-map (kbd "") -;; #'outline-toggle-children) -;; (define-key outline-minor-mode-map (kbd "M-p") -;; #'outline-previous-visible-heading) -;; (define-key outline-minor-mode-map (kbd "M-n") -;; #'outline-next-visible-heading) -;; (defvar b/outline-prefix-map) -;; (define-prefix-command 'b/outline-prefix-map) -;; (define-key outline-minor-mode-map (kbd "s-O") -;; 'b/outline-prefix-map) -;; (define-key b/outline-prefix-map (kbd "TAB") -;; #'outline-toggle-children) -;; (define-key b/outline-prefix-map (kbd "a") -;; #'outline-hide-body) -;; (define-key b/outline-prefix-map (kbd "H") -;; #'outline-hide-body) -;; (define-key b/outline-prefix-map (kbd "S") -;; #'outline-show-all) -;; (define-key b/outline-prefix-map (kbd "h") -;; #'outline-hide-subtree) -;; (define-key b/outline-prefix-map (kbd "s") -;; #'outline-show-subtree)) -;; (add-hook 'prog-mode-hook #'outline-minor-mode) - (require 'bandali-dired) (with-eval-after-load 'help @@ -648,15 +646,12 @@ Make N (default: 1) copies of the current line or region." (csetq shr-max-width 80) -;; Email (with Gnus, message, and EBDB) +;; Email (with Gnus, message, and smtpmail) (require 'bandali-gnus) -(with-eval-after-load 'sendmail - (csetq sendmail-program (executable-find "msmtp") - ;; message-sendmail-extra-arguments '("-v" "-d") - mail-specify-envelope-from t - mail-envelope-from 'header)) (require 'bandali-message) -(require 'bandali-ebdb) +;; (with-eval-after-load 'smtpmail +;; (csetq smtpmail-queue-mail t +;; smtpmail-queue-dir (concat b/maildir "queue/"))) ;; IRC (with ERC) (require 'bandali-erc) @@ -694,7 +689,8 @@ Make N (default: 1) copies of the current line or region." ;; yanking (pasting) what I'd originally intended to. save-interprogram-paste-before-kill t) (with-eval-after-load 'simple - (column-number-mode 1)) + (column-number-mode 1) + (line-number-mode 1)) ;; save minibuffer history (require 'savehist) @@ -724,19 +720,6 @@ Make N (default: 1) copies of the current line or region." (with-eval-after-load 'flyspell (csetq flyspell-mode-line-string " fly")) -;; flycheck -;; (run-with-idle-timer 0.6 nil #'require 'flycheck) -;; (with-eval-after-load 'flycheck -;; (csetq -;; ;; Use the load-path from running Emacs when checking elisp files -;; flycheck-emacs-lisp-load-path 'inherit -;; ;; Only flycheck when I actually save the buffer -;; flycheck-check-syntax-automatically '(mode-enabled save) -;; flycheck-mode-line-prefix "flyc")) -;; (define-key flycheck-mode-map (kbd "M-P") #'flycheck-previous-error) -;; (define-key flycheck-mode-map (kbd "M-N") #'flycheck-next-error) -;; (add-hook 'prog-mode-hook #'flycheck-mode) - ;; ispell ;; http://endlessparentheses.com/ispell-and-apostrophes.html ;; (run-with-idle-timer 0.6 nil #'require 'ispell) @@ -816,9 +799,6 @@ Make N (default: 1) copies of the current line or region." (with-eval-after-load 'css-mode (csetq css-indent-offset 2)) -;; po-mode -;; (add-hook 'po-mode-hook (lambda nil (run-with-timer 0.1 nil 'View-exit))) - ;; auctex ;; (csetq font-latex-fontify-sectioning 'color) @@ -881,12 +861,6 @@ Make N (default: 1) copies of the current line or region." ;; highlight TODOs in buffers (global-hl-todo-mode)) -(add-to-list 'load-path (b/lisp "page-break-lines")) -(run-with-idle-timer 0.5 nil #'require 'page-break-lines) -(with-eval-after-load 'page-break-lines - (csetq page-break-lines-max-width fill-column) - (global-page-break-lines-mode)) - ;; expand-region (global-set-key (kbd "C-=") #'er/expand-region) @@ -900,7 +874,7 @@ Make N (default: 1) copies of the current line or region." (defconst yas-verbosity-cur yas-verbosity) (setq yas-verbosity 2) (csetq yas-snippet-dirs `(,(b/etc "yasnippet/snippets"))) - (add-to-list 'yas-snippet-dirs "~/src/git/guix/etc/snippets" t) + ;; (add-to-list 'yas-snippet-dirs "~/src/git/guix/etc/snippets" t) (yas-reload-all) (setq yas-verbosity yas-verbosity-cur) @@ -930,18 +904,6 @@ Make N (default: 1) copies of the current line or region." (setq debbugs-gnu-current-suppress t) (debbugs-gnu debbugs-gnu-default-severities '("gnuzilla")))) -(global-set-key (kbd "C-c D G b") ; bug-guix - (lambda () - (interactive) - (setq debbugs-gnu-current-suppress t) - (debbugs-gnu debbugs-gnu-default-severities - '("guix")))) -(global-set-key (kbd "C-c D G p") ; guix-patches - (lambda () - (interactive) - (setq debbugs-gnu-current-suppress t) - (debbugs-gnu debbugs-gnu-default-severities - '("guix-patches")))) ;; url and url-cache (csetq @@ -976,16 +938,6 @@ Make N (default: 1) copies of the current line or region." (other-window 1))) (global-set-key (kbd "C-c w q") #'quit-window) -(run-with-idle-timer 0.6 nil #'require 'windmove) -(global-set-key (kbd "C-c w h") #'windmove-left) -(global-set-key (kbd "C-c w j") #'windmove-down) -(global-set-key (kbd "C-c w k") #'windmove-up) -(global-set-key (kbd "C-c w l") #'windmove-right) -(global-set-key (kbd "C-c w H") #'windmove-swap-states-left) -(global-set-key (kbd "C-c w J") #'windmove-swap-states-down) -(global-set-key (kbd "C-c w K") #'windmove-swap-states-up) -(global-set-key (kbd "C-c w L") #'windmove-swap-states-right) - ;; pass ;; (global-set-key (kbd "C-c a p") #'pass) ;; (add-hook 'pass-mode-hook #'View-exit) @@ -1004,9 +956,11 @@ Make N (default: 1) copies of the current line or region." (add-hook 'latex-mode-hook #'reftex-mode) ;; dmenu -;; (csetq -;; dmenu-prompt-string "run: " -;; dmenu-save-file (b/var "dmenu-items")) +(add-to-list 'load-path (b/lisp "dmenu")) +(with-eval-after-load 'dmenu + (csetq dmenu-prompt-string "run: " + dmenu-save-file (b/var "dmenu-items"))) +(autoload 'dmenu "dmenu" nil t) ;; eosd ? @@ -1015,12 +969,15 @@ Make N (default: 1) copies of the current line or region." (with-eval-after-load 'delight (delight 'auto-fill-function " f" "simple") (delight 'abbrev-mode "" "abbrev") - (delight 'page-break-lines-mode "" "page-break-lines") - (delight 'ivy-mode "" "ivy") - (delight 'counsel-mode "" "counsel") (delight 'mml-mode " mml" "mml") (delight 'yas-minor-mode "" "yasnippet")) +;; po-mode +(require 'bandali-po) + +(with-eval-after-load 'emms + (csetq emms-directory (b/var "emms"))) + ;;; Post initialization