X-Git-Url: https://git.shemshak.org/~bandali/configs/blobdiff_plain/fcf818a86ba770d32d9698d1e1603f1d06b206d7..ae80aec8f2b66828843852b9643db6ed8f9f9eae:/.emacs.d/init.el diff --git a/.emacs.d/init.el b/.emacs.d/init.el index 7f1471d..f8a44e7 100644 --- a/.emacs.d/init.el +++ b/.emacs.d/init.el @@ -34,71 +34,7 @@ ;;; Code: -;;; Emacs initialization - -(defvar b/before-user-init-time (current-time) - "Value of `current-time' when Emacs begins loading `user-init-file'.") -(defvar b/emacs-initialized nil - "Whether Emacs has been initialized.") - -(when (not (bound-and-true-p b/emacs-initialized)) - (message "Loading Emacs...done (%.3fs)" - (float-time (time-subtract b/before-user-init-time - before-init-time)))) - -;; temporarily increase `gc-cons-threshhold' and `gc-cons-percentage' -;; during startup to reduce garbage collection frequency. clearing -;; `file-name-handler-alist' seems to help reduce startup time too. -(defvar b/gc-cons-threshold gc-cons-threshold) -(defvar b/gc-cons-percentage gc-cons-percentage) -(defvar b/file-name-handler-alist file-name-handler-alist) -(setq gc-cons-threshold (* 30 1024 1024) ; 30 MiB - gc-cons-percentage 0.6 - file-name-handler-alist nil - ;; sidesteps a bug when profiling with esup - esup-child-profile-require-level 0) - -;; set them back to their defaults once we're done initializing -(defun b/post-init () - "My post-initialize function, run after loading `user-init-file'." - (setq b/emacs-initialized t - gc-cons-threshold b/gc-cons-threshold - gc-cons-percentage b/gc-cons-percentage - file-name-handler-alist b/file-name-handler-alist) - (when (featurep 'exwm-workspace) - (with-eval-after-load 'exwm-workspace - (setq-default - mode-line-format - (append - mode-line-format - '((:eval - (format - "[%s]" (number-to-string - exwm-workspace-current-index)))))))) - (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) - - -;;; whoami - +;; whoami (setq user-full-name "Amin Bandali" user-mail-address "bandali@gnu.org") @@ -124,7 +60,6 @@ ;; (debbugs "0.29") ;; (delight "1.7") ;; (emms "7.7") - ;; (expand-region "0.11.0") ;; (rt-liberation "2.4") ;; (yasnippet "0.14.0"))) (package-initialize)) @@ -134,7 +69,7 @@ ;;; Initial setup -;; keep ~/.emacs.d clean +;; Keep ~/.emacs.d clean. (defvar b/etc-dir (expand-file-name (convert-standard-filename "etc/") user-emacs-directory) @@ -157,29 +92,23 @@ "Expand filename FILE relative to `b/lisp-dir'." (expand-file-name (convert-standard-filename file) b/lisp-dir)) -(setq - auto-save-list-file-prefix (b/var "auto-save/sessions/") - nsm-settings-file (b/var "nsm-settings.el")) - -;; separate custom file (don't want it mixing with init.el) +;; Separate custom file (don't want it mixing with init.el). (with-eval-after-load 'custom (setq custom-file (b/etc "custom.el")) (when (file-exists-p custom-file) (load custom-file)) - ;; while at it, treat themes as safe - ;; (setf custom-safe-themes t) - ;; only one custom theme at a time + ;; Only one custom theme at a time. ;; (defadvice load-theme (before clear-previous-themes activate) ;; "Clear existing theme settings instead of layering them" ;; (mapc #'disable-theme custom-enabled-themes)) ) -;; load the secrets file if it exists, otherwise show a warning +;; Load the secrets file if it exists, otherwise show a warning. ;; (with-demoted-errors ;; (load (b/etc "secrets"))) -;; start up emacs server. see -;; https://www.gnu.org/software/emacs/manual/html_node/emacs/Emacs-Server.html#Emacs-Server +;; Start up emacs server: +;; https://www.gnu.org/software/emacs/manual/html_node/emacs/Emacs-Server.html (run-with-idle-timer 0.5 nil #'require 'server) (with-eval-after-load 'server (declare-function server-edit "server") @@ -198,20 +127,24 @@ read-buffer-completion-ignore-case t enable-recursive-minibuffers t resize-mini-windows t + message-log-max 20000 mode-line-compact t ;; mouse-autoselect-window t - scroll-conservatively 101 + scroll-conservatively 15 scroll-preserve-screen-position 1 - ;; i don't feel like jumping out of my chair every now and again; - ;; so...don't *BEEP* at me, emacs =) + ;; 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) (setq-default - ;; case-sensitive search (and `dabbrev-expand') + ;; Case-sensitive search (and `dabbrev-expand'). ;; case-fold-search nil - ;; always use space for indentation - indent-tabs-mode nil - tab-width 4) + indent-tabs-mode nil ; always use space for indentation + tab-width 4 + indicate-buffer-boundaries 'left) + +;; Lazy-person-friendly yes/no prompts. +(defalias 'yes-or-no-p #'y-or-n-p) (when (display-graphic-p) (set-fontset-font t 'arabic "Vazir")) @@ -221,86 +154,43 @@ ;;;; Elisp-level customizations -;; (define-key minibuffer-local-completion-map -;; "\t" #'minibuffer-force-complete) +(with-eval-after-load 'minibuffer + (setq read-file-name-completion-ignore-case t)) -;; (with-eval-after-load 'icomplete - -;; (setq icomplete-on-del-error-function #'abort-recursive-edit) +;; `startup' +(setq auto-save-list-file-prefix (b/var "auto-save/sessions/")) -;; (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 'files + (setq + ;; backups (C-h v make-backup-files RET) + backup-by-copying t + backup-directory-alist (list (cons "." (b/var "backup/"))) + version-control t + delete-old-versions t + ;; auto-save + auto-save-file-name-transforms `((".*" ,(b/var "auto-save/") t)) + ;; insert newline at the end of files + ;; require-final-newline t + ;; open read-only file buffers in view-mode + ;; (enables niceties like `q' for quit) + view-read-only t)) + +;; `novice' +(setq disabled-command-function nil) -;; subr +;; `subr' ;; (keyboard-translate ?\( ?\[) ;; (keyboard-translate ?\) ?\]) ;; (keyboard-translate ?\[ ?\() ;; (keyboard-translate ?\] ?\)) -;; minibuffer -(setq 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) -(setq - ;; i want *scratch* as my startup buffer - initial-buffer-choice t - ;; i don't need the default hint - initial-scratch-message nil - ;; use customizable text-mode as major mode for *scratch* - ;; (initial-major-mode 'text-mode) - ;; inhibit buffer list when more than 2 files are loaded - inhibit-startup-buffer-menu t - ;; don't need to see the startup screen or echo area message - inhibit-startup-screen t - inhibit-startup-echo-area-message user-login-name) - -;; files -(setq - ;; backups (C-h v make-backup-files RET) - backup-by-copying t - backup-directory-alist (list (cons "." (b/var "backup/"))) - version-control t - delete-old-versions t - ;; auto-save - auto-save-file-name-transforms `((".*" ,(b/var "auto-save/") t)) - ;; insert newline at the end of files - ;; require-final-newline t - ;; open read-only file buffers in view-mode - ;; (enables niceties like `q' for quit) - view-read-only t) - -;; novice -;; disable disabled commands -(setq disabled-command-function nil) - -;; lazy-person-friendly yes/no prompts -(defalias 'yes-or-no-p #'y-or-n-p) - -;; autorevert: enable automatic reloading of changed buffers and files -(setq - ;; auto-revert-verbose nil - global-auto-revert-non-file-buffers nil) -(require 'autorevert) -(global-auto-revert-mode 1) +(run-with-idle-timer 0.1 nil #'require 'autorevert) +(with-eval-after-load 'autorevert + (setq + ;; auto-revert-verbose nil + global-auto-revert-non-file-buffers nil) + (global-auto-revert-mode 1)) -;; time and battery in mode-line (run-with-idle-timer 0.1 nil #'require 'time) (with-eval-after-load 'time (setq @@ -326,11 +216,11 @@ ;; ;; smaller fringe ;; (fringe-mode '(3 . 1))) -;; enable winner-mode (C-h f winner-mode RET) -(require 'winner) -(winner-mode 1) +(run-with-idle-timer 0.5 nil #'require 'winner) +(with-eval-after-load 'winner + (winner-mode 1)) -(run-with-idle-timer 0.1 nil #'require 'windmove) +(run-with-idle-timer 0.5 nil #'require 'windmove) (with-eval-after-load 'windmove (setq windmove-wrap-around t) (global-set-key (kbd "M-H") #'windmove-left) @@ -360,60 +250,62 @@ ad-do-it)) (ad-activate 'compilation-start)) -;; isearch -(setq - ;; 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 - ;; http://endlessparentheses.com/new-in-emacs-25-1-easily-search-non-ascii-characters.html - search-default-mode #'char-fold-to-regexp) - -;; replace -;; uncomment to extend the above behaviour to query-replace -;; (setq replace-char-fold t) - -;; vc +(with-eval-after-load 'isearch + (setq + ;; 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 + ;; http://endlessparentheses.com/new-in-emacs-25-1-easily-search-non-ascii-characters.html + search-default-mode #'char-fold-to-regexp)) + +;; (with-eval-after-load 'replace +;; ;; Uncomment to extend the above behaviour to query-replace. +;; (setq replace-char-fold t)) + +;; `vc' (global-set-key (kbd "C-x v C-=") #'vc-ediff) (with-eval-after-load 'vc-git (setq vc-git-print-log-follow t vc-git-show-stash 0)) -(setq ediff-window-setup-function 'ediff-setup-windows-plain - ediff-split-window-function 'split-window-horizontally) (with-eval-after-load 'ediff + (setq ediff-window-setup-function 'ediff-setup-windows-plain + ediff-split-window-function 'split-window-horizontally) (add-hook 'ediff-after-quit-hook-internal #'winner-undo)) -;; face-remap -(setq - ;; gentler font resizing - text-scale-mode-step 1.05) +(with-eval-after-load 'face-remap + (setq + ;; Gentler font resizing. + text-scale-mode-step 1.05)) (run-with-idle-timer 0.4 nil #'require 'mwheel) -(setq mouse-wheel-scroll-amount '(1 ((shift) . 1)) ; one line at a time - mouse-wheel-progressive-speed nil ; don't accelerate scrolling - mouse-wheel-follow-mouse t) ; scroll window under mouse +(with-eval-after-load 'mwheel + (setq + mouse-wheel-scroll-amount '(1 ((shift) . 1)) ; one line at a time + mouse-wheel-progressive-speed nil ; don't accelerate scrolling + mouse-wheel-follow-mouse t)) ; scroll window under mouse (run-with-idle-timer 0.4 nil #'require 'pixel-scroll) (with-eval-after-load 'pixel-scroll (pixel-scroll-mode 1)) -;; epg-config -(setq - epg-gpg-program (executable-find "gpg") - ;; ask for GPG passphrase in minibuffer - ;; this will fail if gpg>=2.1 is not available - epg-pinentry-mode 'loopback) +(with-eval-after-load 'epg-config + (setq + epg-gpg-program (executable-find "gpg") + ;; Ask for GPG passphrase in minibuffer. + ;; Will fail if gpg >= 2.1 is not available. + epg-pinentry-mode 'loopback)) -;; auth-source -(setq - auth-sources '("~/.authinfo.gpg") - authinfo-hidden (regexp-opt '("password" "client-secret" "token"))) +(with-eval-after-load 'auth-source + (setq + auth-sources '("~/.authinfo.gpg") + authinfo-hidden + (regexp-opt '("password" "client-secret" "token")))) -;; info (with-eval-after-load 'info (setq Info-directory-list @@ -422,7 +314,6 @@ (convert-standard-filename "info/") source-directory) "/usr/share/info/"))) -;; faces (when (display-graphic-p) (with-eval-after-load 'faces (let ((grey "#e7e7e7")) @@ -431,6 +322,23 @@ :background grey :inherit 'fixed-pitch)))) +(when (version< emacs-version "28") + ;; Manually make some `mode-line' spaces smaller. Emacs 28 (and + ;; above) does a terrific job at this out of the box when + ;; `mode-line-compact' is set to t (see above)." + (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"))) + ;;; Useful utilities @@ -467,12 +375,6 @@ For disabling the behaviour for certain buffers and/or modes." (make-local-variable 'mouse-autoselect-window) (setq mouse-autoselect-window nil)) -(defun b/kill-current-buffer () - "Kill the current buffer." - ;; also see https://redd.it/64xb3q - (interactive) - (kill-buffer (current-buffer))) - (defun b/move-indentation-or-beginning-of-line (arg) "Move to the indentation or to the beginning of line." (interactive "^p") @@ -489,6 +391,15 @@ For disabling the behaviour for certain buffers and/or modes." (interactive) (join-line 1)) +(defun b/*scratch* () + "Switch to `*scratch*' buffer, creating it if it does not + exist." + (interactive) + (let ((fun (if (functionp #'get-scratch-buffer-create) + #'get-scratch-buffer-create ; (version<= "29" emacs-version) + #'startup--get-buffer-create-scratch))) ; (version< emacs-version "29") + (switch-to-buffer (funcall fun)))) + (defun b/duplicate-line-or-region (&optional n) "Duplicate the current line, or region (if active). Make N (default: 1) copies of the current line or region." @@ -511,16 +422,28 @@ Make N (default: 1) copies of the current line or region." "Invert the `default' face (swap its background and foreground). Effectively a very simple light/dark theme toggle switch." (interactive) - (invert-face 'default)) + (invert-face 'default (selected-frame)) + (invert-face 'mode-line (selected-frame))) + +(defun b/export-frame () + (interactive) + ;; TODO: ask for fn and/or take as arg + (let* ((fn (make-temp-file "emacs" nil ".pdf")) + (data (x-export-frames nil 'pdf))) + (with-temp-file fn + (insert data)) + (kill-new fn) + (message fn))) ;;; General key bindings (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 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 s c") #'b/*scratch*) (global-set-key (kbd "C-c x") #'execute-extended-command) (global-set-key (kbd "C-c v") #'b/invert-default-face) @@ -548,9 +471,6 @@ Effectively a very simple light/dark theme toggle switch." ;; help/describe (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) - (define-key emacs-lisp-mode-map (kbd "C-") #'b/add-elisp-section) (when (display-graphic-p) @@ -571,10 +491,11 @@ Effectively a very simple light/dark theme toggle switch." ;; (require 'bandali-theme) ;; recently opened files -(setq recentf-max-saved-items 2000 - recentf-save-file (b/var "recentf-save.el")) (run-with-idle-timer 0.2 nil #'require 'recentf) (with-eval-after-load 'recentf + (setq + recentf-max-saved-items 2000 + recentf-save-file (b/var "recentf-save.el")) ;; (add-to-list 'recentf-keep #'file-remote-p) (recentf-mode) @@ -585,6 +506,31 @@ Effectively a very simple light/dark theme toggle switch." (completing-read "Find recent file: " recentf-list))) (global-set-key (kbd "C-c f r") #'b/recentf-open)) +;; (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)) + ;; (fido-mode 1) ;; (defun b/icomplete--fido-mode-setup () ;; "Customizations to `fido-mode''s minibuffer." @@ -607,7 +553,6 @@ Effectively a very simple light/dark theme toggle switch." (setq help-window-select t)) (with-eval-after-load 'help-mode - ;; local key bindings (define-key help-mode-map (kbd "p") #'backward-button) (define-key help-mode-map (kbd "n") #'forward-button)) @@ -641,80 +586,79 @@ Effectively a very simple light/dark theme toggle switch." scpaste-scp-destination "p:~")) (autoload 'scpaste "scpaste" nil t) (autoload 'scpaste-region "scpaste" nil t) -(global-set-key (kbd "C-c a p p") #'scpaste) -(global-set-key (kbd "C-c a p r") #'scpaste-region) +(global-set-key (kbd "C-c p p") #'scpaste) +(global-set-key (kbd "C-c p r") #'scpaste-region) ;;; Editing -;; display Lisp objects at point in the echo area -(when (version< "25" emacs-version) +(when (featurep 'eldoc) + ;; Display Lisp objects at point in the echo area. (with-eval-after-load 'eldoc (setq eldoc-minor-mode-string " eldoc") (global-eldoc-mode))) ;; highlight matching parens -(require 'paren) -(show-paren-mode) +(run-with-idle-timer 0.2 nil #'require 'paren) +(with-eval-after-load 'paren + (show-paren-mode)) -;; (require 'elec-pair) -;; (electric-pair-mode) +;; (run-with-idle-timer 0.2 nil #'require 'elec-pair) +;; (with-eval-after-load 'elec-pair +;; (electric-pair-mode)) -(setq - ;; Save what I copy into clipboard from other applications into Emacs' - ;; kill-ring, which would allow me to still be able to easily access - ;; it in case I kill (cut or copy) something else inside Emacs before - ;; yanking (pasting) what I'd originally intended to. - save-interprogram-paste-before-kill t) (with-eval-after-load 'simple + (setq + ;; Save what I copy into clipboard from other applications into Emacs' + ;; kill-ring, which would allow me to still be able to easily access + ;; it in case I kill (cut or copy) something else inside Emacs before + ;; yanking (pasting) what I'd originally intended to. + save-interprogram-paste-before-kill t) (column-number-mode 1) (line-number-mode 1)) -;; save minibuffer history -(require 'savehist) -(setq savehist-file (b/var "savehist.el")) -(savehist-mode) -(add-to-list 'savehist-additional-variables 'kill-ring) +(run-with-idle-timer 0.2 nil #'require 'savehist) +(with-eval-after-load 'savehist + ;; Save minibuffer history. + (setq savehist-file (b/var "savehist.el")) + (savehist-mode) + (add-to-list 'savehist-additional-variables 'kill-ring)) -;; automatically save place in files -(when (version< "25" emacs-version) +;; Automatically save place in files. +(run-with-idle-timer 0.2 nil #'require 'saveplace nil 'noerror) +(with-eval-after-load 'saveplace (setq save-place-file (b/var "save-place.el")) (save-place-mode)) -(defun indicate-buffer-boundaries-left () - (setq indicate-buffer-boundaries 'left)) (with-eval-after-load 'prog-mode (global-prettify-symbols-mode)) -(add-hook 'prog-mode-hook #'indicate-buffer-boundaries-left) - -(define-key text-mode-map (kbd "C-") #'b/insert-asterism) -(add-hook 'text-mode-hook #'indicate-buffer-boundaries-left) -(add-hook 'text-mode-hook #'flyspell-mode) (add-to-list 'auto-mode-alist '("\\.*rc$" . conf-mode)) - (add-to-list 'auto-mode-alist '("\\.bashrc$" . sh-mode)) (with-eval-after-load 'flyspell (setq flyspell-mode-line-string " fly")) -;; ispell -;; http://endlessparentheses.com/ispell-and-apostrophes.html +(with-eval-after-load 'text-mode + (add-hook 'text-mode-hook #'flyspell-mode) + (define-key text-mode-map (kbd "C-") #'b/insert-asterism)) + +;; ;; http://endlessparentheses.com/ispell-and-apostrophes.html ;; (run-with-idle-timer 0.6 nil #'require 'ispell) ;; (with-eval-after-load 'ispell -;; ;; ’ can be part of a word +;; ;; ’ can be part of a word. ;; (setq ispell-local-dictionary-alist ;; `((nil "[[:alpha:]]" "[^[:alpha:]]" ;; "['\x2019]" nil ("-B") nil utf-8)) ;; ispell-program-name (executable-find "hunspell")) -;; ;; don't send ’ to the subprocess +;; ;; Don't send ’ to the subprocess. ;; (defun endless/replace-apostrophe (args) ;; (cons (replace-regexp-in-string ;; "’" "'" (car args)) ;; (cdr args))) ;; (advice-add #'ispell-send-string :filter-args ;; #'endless/replace-apostrophe) -;; ;; convert ' back to ’ from the subprocess +;; ;; Convert ' back to ’ from the subprocess. ;; (defun endless/replace-quote (args) ;; (if (not (derived-mode-p 'org-mode)) ;; args @@ -724,8 +668,8 @@ Effectively a very simple light/dark theme toggle switch." ;; (advice-add #'ispell-parse-output :filter-args ;; #'endless/replace-quote)) -;; abbrev -(setq abbrev-file-name (b/etc "abbrev.el")) +(with-eval-after-load 'abbrev + (setq abbrev-file-name (b/etc "abbrev.el"))) (add-hook 'text-mode-hook #'abbrev-mode) @@ -736,7 +680,6 @@ Effectively a very simple light/dark theme toggle switch." (setq indent-tabs-mode nil)) (add-hook 'lisp-interaction-mode-hook #'indent-spaces-mode)) -;; alloy (add-to-list 'load-path (b/lisp "alloy-mode")) (autoload 'alloy-mode "alloy-mode" nil t) (with-eval-after-load 'alloy-mode @@ -750,14 +693,12 @@ Effectively a very simple light/dark theme toggle switch." ;; ;; (line-end-position) ;; ;; alloy-basic-offset))) ;; (indent-to (+ (current-column) alloy-basic-offset))) - ;; local key bindings (define-key alloy-mode-map (kbd "RET") #'electric-newline-and-maybe-indent) ;; (define-key alloy-mode-map (kbd "TAB") #'b/alloy-simple-indent) (define-key alloy-mode-map (kbd "TAB") #'indent-for-tab-command)) (add-to-list 'auto-mode-alist '("\\.\\(als\\|dsh\\)\\'" . alloy-mode)) (add-hook 'alloy-mode-hook (lambda nil (setq-local indent-tabs-mode nil))) -;; lean ;; (eval-when-compile (defvar lean-mode-map)) ;; (run-with-idle-timer 0.4 nil #'require 'lean-mode) ;; (with-eval-after-load 'lean-mode @@ -777,8 +718,8 @@ Effectively a very simple light/dark theme toggle switch." (with-eval-after-load 'css-mode (setq css-indent-offset 2)) -;; auctex -;; (setq font-latex-fontify-sectioning 'color) +;; (with-eval-after-load 'auctex +;; (setq font-latex-fontify-sectioning 'color)) (with-eval-after-load 'tex-mode (cl-delete-if @@ -789,29 +730,22 @@ Effectively a very simple light/dark theme toggle switch." (run-with-idle-timer 0.5 nil #'require 'cmake-mode) (with-eval-after-load 'cmake-mode - (setq cmake-tab-width 4) + ;; (setq cmake-tab-width 4) (add-to-list 'load-path (b/lisp "cmake-font-lock")) (run-with-idle-timer 0.5 nil #'require 'cmake-font-lock)) ;;; Emacs enhancements & auxiliary packages +(with-eval-after-load 'nsm + (setq nsm-settings-file (b/var "nsm-settings.el"))) + (with-eval-after-load 'man (setq Man-width 80)) -(defun b/*scratch* () - "Switch to `*scratch*' buffer, creating it if it does not exist." - (interactive) - (let ((fun (if (functionp #'get-scratch-buffer-create) - #'get-scratch-buffer-create ; (version<= "29" emacs-version) - #'startup--get-buffer-create-scratch))) ; (version< emacs-version "29") - (switch-to-buffer (funcall fun)))) -(global-set-key (kbd "C-c s") #'b/*scratch*) - ;; ,---- ;; | make pretty boxed quotes like this ;; `---- -(add-to-list 'load-path (b/lisp "boxquote")) (run-with-idle-timer 0.6 nil #'require 'boxquote) (with-eval-after-load 'boxquote (defvar b/boxquote-prefix-map) @@ -841,12 +775,9 @@ Effectively a very simple light/dark theme toggle switch." (add-to-list 'load-path (b/lisp "hl-todo")) (run-with-idle-timer 0.5 nil #'require 'hl-todo) (with-eval-after-load 'hl-todo - ;; highlight TODOs in buffers + ;; Highlight TODO in buffers. (global-hl-todo-mode)) -;; expand-region -(global-set-key (kbd "C-=") #'er/expand-region) - (run-with-idle-timer 0.6 nil #'require 'yasnippet) (with-eval-after-load 'yasnippet (declare-function yas-reload-all @@ -872,7 +803,7 @@ Effectively a very simple light/dark theme toggle switch." (yas-global-mode)) -;; debbugs +;; `debbugs' (global-set-key (kbd "C-c D d") #'debbugs-gnu) (global-set-key (kbd "C-c D b") #'debbugs-gnu-bugs) (global-set-key (kbd "C-c D e") ; bug-gnu-emacs @@ -888,49 +819,50 @@ Effectively a very simple light/dark theme toggle switch." (debbugs-gnu debbugs-gnu-default-severities '("gnuzilla")))) -;; url and url-cache -(setq - url-configuration-directory (b/var "url/configuration/") - url-cache-directory (b/var "url/cache/")) - -;; eww -(setq eww-download-directory (file-name-as-directory - (getenv "XDG_DOWNLOAD_DIR"))) -(global-set-key (kbd "C-c a e w") #'eww) - -;; ;; org-ref -;; (setq -;; reftex-default-bibliography '("~/usr/org/references.bib") -;; org-ref-default-bibliography '("~/usr/org/references.bib") -;; org-ref-bibliography-notes "~/usr/org/notes.org" -;; org-ref-pdf-directory "~/usr/org/bibtex-pdfs/") - -;; fill-column-indicator ? - -;; window -(setq split-width-threshold 150) -(global-set-key (kbd "C-c w s l") - (lambda () - (interactive) - (split-window-right) - (other-window 1))) -(global-set-key (kbd "C-c w s j") - (lambda () - (interactive) - (split-window-below) - (other-window 1))) -(global-set-key (kbd "C-c w q") #'quit-window) +(with-eval-after-load 'url + (setq url-configuration-directory (b/var "url/configuration/"))) -;; pass -;; (global-set-key (kbd "C-c a p") #'pass) -;; (add-hook 'pass-mode-hook #'View-exit) +(with-eval-after-load 'url-cache + (setq url-cache-directory (b/var "url/cache/"))) -;; reftex -;; uncomment to disable reftex-cite's default choice of previous word +(with-eval-after-load 'eww + (setq + eww-download-directory + (file-name-as-directory (getenv "XDG_DOWNLOAD_DIR")))) +(global-set-key (kbd "C-c e w") #'eww) + +;; (with-eval-after-load 'org-ref +;; (setq +;; reftex-default-bibliography '("~/usr/org/references.bib") +;; org-ref-default-bibliography '("~/usr/org/references.bib") +;; org-ref-bibliography-notes "~/usr/org/notes.org" +;; org-ref-pdf-directory "~/usr/org/bibtex-pdfs/")) + +(run-with-idle-timer + 0.2 nil #'require 'display-fill-column-indicator nil 'noerror) +(with-eval-after-load 'display-fill-column-indicator + (global-display-fill-column-indicator-mode 1)) + +(with-eval-after-load 'window + (setq split-width-threshold 150) + (global-set-key (kbd "C-c w s l") + (lambda () + (interactive) + (split-window-right) + (other-window 1))) + (global-set-key (kbd "C-c w s j") + (lambda () + (interactive) + (split-window-below) + (other-window 1))) + (global-set-key (kbd "C-c w q") #'quit-window)) + +;; Uncomment to disable reftex-cite's default choice of previous word. ;; (with-eval-after-load 'reftex ;; (require 'reftex-cite) ;; (defun reftex-get-bibkey-default () -;; "If the cursor is in a citation macro, return the word before the macro." +;; "If the cursor is in a citation macro, return the word before +;; the macro." ;; (let* ((macro (reftex-what-macro 1))) ;; (save-excursion ;; (when (and macro (string-match "cite" (car macro))) @@ -938,16 +870,12 @@ Effectively a very simple light/dark theme toggle switch." ;; (reftex-this-word))))) (add-hook 'latex-mode-hook #'reftex-mode) -;; dmenu (add-to-list 'load-path (b/lisp "dmenu")) (with-eval-after-load 'dmenu (setq dmenu-prompt-string "run: " dmenu-save-file (b/var "dmenu-items"))) (autoload 'dmenu "dmenu" nil t) -;; eosd ? - -;; delight (run-with-idle-timer 0.5 nil #'require 'delight) (with-eval-after-load 'delight (delight 'auto-fill-function " f" "simple") @@ -955,7 +883,6 @@ Effectively a very simple light/dark theme toggle switch." (delight 'mml-mode " mml" "mml") (delight 'yas-minor-mode "" "yasnippet")) -;; po-mode (require 'bandali-po) (with-eval-after-load 'emms @@ -966,21 +893,4 @@ Effectively a very simple light/dark theme toggle switch." (with-eval-after-load 'ffs (global-set-key (kbd "C-c f s") #'ffs)) -(defun b/export-frame () - (interactive) - ;; TODO: ask for fn and/or take as arg - (let* ((fn (make-temp-file "emacs" nil ".pdf")) - (data (x-export-frames nil 'pdf))) - (with-temp-file fn - (insert data)) - (kill-new fn) - (message fn))) - - -;;; Post initialization - -(message "Loading %s...done (%.3fs)" user-init-file - (float-time (time-subtract (current-time) - b/before-user-init-time))) - ;;; init.el ends here