]> git.earman.xyz Git - emacsinit.git/commitdiff
Cleanup, add some explanations
authorrearman <rearman@r717.net>
Mon, 11 May 2026 13:05:49 +0000 (09:05 -0400)
committerrearman <rearman@r717.net>
Mon, 11 May 2026 13:05:49 +0000 (09:05 -0400)
README.org

index 93049f48ed4f93cc58846193af58254eada6afac..efdd69e000fd12a69580cd5e47cc44a07f9f9671 100644 (file)
 ;;; Code:
 
 #+END_SRC
-* Initial
+* Load libraries
+Libraries Not from the package manager
 #+BEGIN_SRC emacs-lisp
   (dolist (path '("sedit-mouse/" "themes/" "re/"))
       (add-to-list 'load-path (concat user-emacs-directory path)))
 
   (dolist (file '(pass-alike eng-paper-theme sedit-mouse))
        (require file))
-
+#+END_SRC
+* OS specific stuff
+#+BEGIN_SRC emacs-lisp
   (setq w32-recognize-altgr 'nil)
 
   (unless (equal system-type 'windows-nt)
@@ -36,8 +39,7 @@
        (find-alternate-file (concat "/sudo:root@localhost:" buffer-file-name)))))
 
 #+END_SRC
-* Packages
-Add melpa, and reduce the declarations by setting defaults
+* Add melpa, and reduce the declarations by setting defaults
 #+BEGIN_SRC emacs-lisp
 (require 'package)
 
@@ -66,7 +68,7 @@ Add melpa, and reduce the declarations by setting defaults
   :hook
   (corfu-mode . corfu-popupinfo-mode)
   :custom
-  (corfu-popupinfo-delay '(1.0 . 0.01)) ; start with M-t, fast refresh once on
+  (corfu-popupinfo-delay '(1.0 . 0.01)) ; start after one second, fast refresh once on
   (corfu-popupinfo-hide nil)
   :config
   (corfu-popupinfo-mode))
@@ -93,7 +95,7 @@ Needs to be demanded so I don't have to manually load it
   (global-page-break-lines-mode))
 #+END_SRC
 * AucTeX and pdftools
-Make AucTeX use pdftools, prompt for master file, synctex, etc.
+Make AucTeX use pdftools, prompt for master file, synctex, etc.  Be sure to run =pdf-tools-install= before first use.
 #+BEGIN_SRC emacs-lisp
 (use-package pdf-tools)
 
@@ -113,7 +115,6 @@ Make AucTeX use pdftools, prompt for master file, synctex, etc.
 (use-package csv-mode
   :config
   (add-hook 'csv-mode-hook 'csv-align-mode))
-
 #+END_SRC
 * Markdown Mode
 Make markdown act more like org when I'm forced to use it
@@ -565,6 +566,7 @@ Shows the trash file as a dired buffer
 (keymap-global-set "<remap> <upcase-word>" #'upcase-dwim) ; M-u
 #+END_SRC
 * Tabs
+I want *TABS*, not spaces, dammit.  Globally overwrite the tab key to insert the tab character.  This makes it so that many things (completion) will have to be triggered with =C-i= instead, but I don't think it's necessarily bad to have things like that on a control combo instead of overloading the tab key at the expense of being able to actually insert tabs.
 #+BEGIN_SRC emacs-lisp
 ;; Tabs
 (setq-default indent-tabs-mode t
@@ -610,8 +612,17 @@ Shows the trash file as a dired buffer
       history-delete-duplicates t
       disabled-command-function nil
       save-interprogram-paste-before-kill t
-      confirm-kill-processes nil
-      recenter-positions '(2 middle -3))
+      confirm-kill-processes nil)
+
+(keymap-global-set "C-x M-f" #'find-file-at-point)
+(keymap-global-set "C-x C-b" #'buffer-menu)
+(keymap-global-set "C-x M-b" #'buffer-menu-other-window)
+(keymap-global-set "C-x k" #'kill-current-buffer)
+(keymap-global-set "C-x K" #'kill-buffer)
+#+END_SRC
+* Recentering and page-by-page navigation
+#+BEGIN_SRC emacs-lisp
+(setq recenter-positions '(2 middle -3))
 
 (defun re/recenter-advice (&rest _)
   "Recenter to page start."
@@ -624,18 +635,15 @@ Shows the trash file as a dired buffer
 (keymap-global-set "C-x C-p" #'backward-page)
 (keymap-global-set "<next>" #'forward-page)
 (keymap-global-set "<prior>" #'backward-page)
-
+#+END_SRC
+* Macro to open something in its own named frame
+Start a repl in a new frame, open dired in a new frame, etc. etc.
+#+BEGIN_SRC
 (defmacro re/open-with-new-frame (frname function)
   "Run the function in its own named frame."
   `(progn
      (select-frame (make-frame '((name . ,(eval frname)))))
      (call-interactively ,function)))
-
-(keymap-global-set "C-x M-f" #'find-file-at-point)
-(keymap-global-set "C-x C-b" #'buffer-menu)
-(keymap-global-set "C-x M-b" #'buffer-menu-other-window)
-(keymap-global-set "C-x k" #'kill-current-buffer)
-(keymap-global-set "C-x K" #'kill-buffer)
 #+END_SRC
 * Motion
 #+BEGIN_SRC emacs-lisp
@@ -708,6 +716,8 @@ If in org-mode, call `org-end-of-line' first."
 (keymap-global-set "C-," #'previous-buffer)
 (keymap-global-set "C-<tab>" (lambda () (interactive) (switch-to-buffer nil))) ; toggle last two buffers
 (keymap-global-set "<mouse-4>" #'previous-buffer) ; Back button
+(keymap-global-set "<mouse-5>" #'next-buffer) ; Forward button
+;; Disable M-mouse for window manager bindings
 (keymap-global-unset "M-<down-mouse-1>")
 (keymap-global-unset "M-<drag-mouse-1>")
 (keymap-global-unset "M-<mouse-1>")
@@ -717,13 +727,16 @@ If in org-mode, call `org-end-of-line' first."
 * Search
 #+BEGIN_SRC emacs-lisp
 ;; Search
-(defun re/isearch-forward-use-region ()
-  "Search text in region if active, otherwise normal forward search."
-  (interactive)
+(defun re/add-region-to-search-ring ()
   (when (use-region-p)
     (add-to-history 'search-ring
                    (buffer-substring (region-beginning) (region-end)))
-    (deactivate-mark))
+    (deactivate-mark)))
+
+(defun re/isearch-forward-use-region ()
+  "Search text in region if active, otherwise normal forward search."
+  (interactive)
+  (re/add-region-to-search-ring)
   (isearch-forward))
 
 (keymap-global-set "C-s" #'re/isearch-forward-use-region)
@@ -731,10 +744,7 @@ If in org-mode, call `org-end-of-line' first."
 (defun re/isearch-backward-use-region ()
   "Search text in region if active, otherwise normal backward search."
   (interactive)
-  (when (use-region-p)
-    (add-to-history 'search-ring
-                   (buffer-substring (region-beginning) (region-end)))
-    (deactivate-mark))
+  (re/add-region-to-search-ring)
   (isearch-backward))
 
 (keymap-global-set "C-r" #'re/isearch-backward-use-region)
@@ -1019,20 +1029,20 @@ Start from bottom if given a negative line number."
 #+END_SRC
 * Cleanup on write
 #+BEGIN_SRC emacs-lisp
-  (defun re/flush-extra-lines ()
-      "Change all groups of blank lines to 1 blank line."
-      (interactive)
-      (save-excursion (mark-whole-buffer)
-                     (replace-regexp "^\n+"
-                                     "\n"
-                                     nil
-                                     (region-beginning)
-                                     (region-end))))
-  ;; Cleanup on write
-  (setq require-final-newline t)
-  (add-hook 'before-save-hook #'re/flush-extra-lines)
-  (add-hook 'before-save-hook #'whitespace-cleanup)
-  (add-hook 'after-save-hook #'executable-make-buffer-file-executable-if-script-p)
+(defun re/flush-extra-lines ()
+  "Change all groups of blank lines to 1 blank line."
+  (interactive)
+  (save-excursion (mark-whole-buffer)
+                 (replace-regexp "^\n+"
+                                 "\n"
+                                 nil
+                                 (region-beginning)
+                                 (region-end))))
+
+(setq require-final-newline t)
+(add-hook 'before-save-hook #'re/flush-extra-lines)
+(add-hook 'before-save-hook #'whitespace-cleanup)
+(add-hook 'after-save-hook #'executable-make-buffer-file-executable-if-script-p)
 #+END_SRC
 * Control
 #+BEGIN_SRC emacs-lisp
@@ -1068,7 +1078,7 @@ Stolen from emacsredux.com."
 (keymap-global-set "C-x S" (lambda () (interactive) (save-some-buffers t))) ; don't ask
 (keymap-global-set "C-x c" #'delete-frame) ; delete a frame without asking about saving files
 #+END_SRC
-* Versioning and Backups
+* Version-control mode
 #+BEGIN_SRC emacs-lisp
 ;; Versioning and Backups
 (defun re/vc-clone ()
@@ -1079,6 +1089,8 @@ Prompt for url and local dir."
         (dir (read-string "Local Dir: " (file-name-base url))))
     (vc-git-clone url dir nil)))
 
+(keymap-global-set "C-x v C" #'re/vc-clone)
+
 (defun re/vc-show-branches (&optional arg)
   "Display all Git branches in a separate buffer.
 Remotes as well when arg."
@@ -1096,6 +1108,8 @@ Remotes as well when arg."
     (goto-char (point-min))
     (special-mode)))
 
+(keymap-global-set "C-x v b b" #'re/vc-show-branches)
+
 (defun re/vc-fetch (&optional arg)
   "Interactively fetch with vc-mode.
 Allows separate fetch in addition to pull.  Only care about git.
@@ -1116,13 +1130,7 @@ With arg, ask for remote, otherwise fetch all."
     (goto-char (point-min))
     (special-mode)))
 
-(setq vc-make-backup-files nil
-      vc-handled-backends '(Git)
-      vc-git-diff-switches '("--patch-with-stat" "--histogram")
-      vc-git-log-switches '("--oneline" "--all" "--graph")
-      vc-git-log-edit-summary-target-len 50
-      vc-git-log-edit-summary-max-len 70
-      vc-find-revision-no-save t)
+(keymap-global-set "C-x v f" #'re/vc-fetch)
 
 (setq vc-git-root-log-format
       `("%d %h %ai %an: %s"
@@ -1138,20 +1146,27 @@ With arg, ask for remote, otherwise fetch all."
         (3 'change-log-name)
         (4 'change-log-date))))
 
+(add-hook 'vc-dir-mode-hook
+         (lambda ()
+           (keymap-set vc-dir-mode-map "b b" #'re/vc-show-branches)
+           (keymap-set vc-dir-mode-map "f" #'re/vc-fetch)))
+
+(setq vc-make-backup-files nil
+      vc-handled-backends '(Git)
+      vc-git-diff-switches '("--patch-with-stat" "--histogram")
+      vc-git-log-switches '("--oneline" "--all" "--graph")
+      vc-git-log-edit-summary-target-len 50
+      vc-git-log-edit-summary-max-len 70
+      vc-find-revision-no-save t)
+#+END_SRC
+* Backups
+#+BEGIN_SRC emacs-lisp
+
 (setq backup-directory-alist `((".*" . "~/emacs-backups/"))
       backup-by-copying t
       delete-old-versions t
       kept-new-versions 5
       kept-old-versions 5)
-
-(keymap-global-set "C-x v C" #'re/vc-clone)
-(keymap-global-set "C-x v b b" #'re/vc-show-branches)
-(keymap-global-set "C-x v f" #'re/vc-fetch)
-
-(add-hook 'vc-dir-mode-hook
-         (lambda ()
-           (keymap-set vc-dir-mode-map "b b" #'re/vc-show-branches)
-           (keymap-set vc-dir-mode-map "f" #'re/vc-fetch)))
 #+END_SRC
 * Any Lisp Repl
 #+BEGIN_SRC emacs-lisp
@@ -1224,6 +1239,7 @@ For a non-repl, use `newline' or similar."
                          (re/balance-and-eval-sexp #'eval-print-last-sexp)))))
 #+END_SRC
 * IELM
+Rarely used, but nice to have when I want it.
 #+BEGIN_SRC emacs-lisp
 ;; IELM
 (add-hook 'ielm-mode-hook
@@ -1244,6 +1260,14 @@ For a non-repl, use `newline' or similar."
 ;; Eshell
 (keymap-global-set "C-c e" #'eshell)
 
+(defun eshell-quit-or-delete-char (arg)
+  "Delete char if at one, quit eshell if on empty prompt.
+Stolen from https://depp.brause.cc/dotemacs"
+  (interactive "p")
+  (if (and (eolp) (looking-back eshell-prompt-regexp 0 t))
+      (eshell-life-is-too-much)
+    (delete-char arg)))
+
 (add-hook 'eshell-mode-hook
          (lambda ()
            (keymap-set eshell-mode-map "C-d" #'eshell-quit-or-delete-char)
@@ -1254,14 +1278,6 @@ For a non-repl, use `newline' or similar."
              (keymap-set eshell-mode-map
                          "]"
                          (re/balance-and-eval-sexp eval-function)))))
-
-(defun eshell-quit-or-delete-char (arg)
-  "Delete char if at one, quit eshell if on empty prompt.
-Stolen from https://depp.brause.cc/dotemacs"
-  (interactive "p")
-  (if (and (eolp) (looking-back eshell-prompt-regexp 0 t))
-      (eshell-life-is-too-much)
-    (delete-char arg)))
 #+END_SRC
 * C-mode
 #+BEGIN_SRC emacs-lisp
@@ -1295,8 +1311,7 @@ Stolen from https://depp.brause.cc/dotemacs"
 #+BEGIN_SRC emacs-lisp
 ;; Auto-Revert
 (global-auto-revert-mode t)
-(setq global-auto-revert-non-file-buffers t
-      global-auto-revert-ignore-modes '(Buffer-menu-mode))
+(setq global-auto-revert-non-file-buffers t)
 #+END_SRC
 * Crash HandliƋ
 #+BEGIN_SRC emacs-lisp
@@ -1314,7 +1329,7 @@ Stolen from https://depp.brause.cc/dotemacs"
   _ -)
 
 (define-skeleton skel-org-block
-  "Add an elisp source block to an org file."
+  "Add a source block to an org file."
   ""
   "#+BEGIN_SRC"
   \n
@@ -1331,17 +1346,17 @@ Stolen from https://depp.brause.cc/dotemacs"
   \n
   "#+END_SRC")
 
-(setq abbrev-file-name (expand-file-name "abbrev_defs" user-emacs-directory)
-      save-abbrevs 'silently)
+(setq save-abbrevs 'silently)
 
 (dolist (hook '(org-mode-hook howm-mode-hook))
   (add-hook hook #'abbrev-mode))
 #+END_SRC
 * Customization Framework
+Disable it by making it save to a temp file (stolen from prot)
 #+BEGIN_SRC emacs-lisp
-;; Customization framework
-;; Disable by making a temp file (stolen from prot)
 (setq custom-file (make-temp-file "emacs-custom-"))
-
+#+END_SRC
+* Footer
+#+BEGIN_SRC emacs-lisp
 ;;; config.el ends here
 #+END_SRC