]> git.earman.xyz Git - emacsinit.git/commitdiff
Most defuns get an "re/" prefix
authorrearman <rearman@r717.net>
Thu, 30 May 2024 12:57:39 +0000 (08:57 -0400)
committerrearman <rearman@r717.net>
Thu, 30 May 2024 12:57:39 +0000 (08:57 -0400)
Math defuns don't, since they are meant to be terse/explanatory.
The "sudo" and "doas" defuns don't, since they are meant to be used as replacements for the shell commands.

init.org

index ab0e79f6e898574b790d0cbb85c39198e0a37b81..83dd99fe0c638666746d6188ec6bc5cdd839f83a 100644 (file)
--- a/init.org
+++ b/init.org
@@ -216,12 +216,12 @@ A godsend.  Finally, I can have visual-line-mode without having to read lines th
 
 Also make a defun/binding to toggle it as needed.
 #+BEGIN_SRC emacs-lisp
-(defun toggle-visual-fill-column-mode ()
+(defun re/toggle-visual-fill-column-mode ()
 "Toggles `visual-fill-column-mode."
   (interactive)
   (visual-fill-column-mode 'toggle))
 
-(keymap-global-set "C-c v" 'toggle-visual-fill-column-mode)
+(keymap-global-set "C-c v" 're/toggle-visual-fill-column-mode)
 
 #+END_SRC
 
@@ -605,7 +605,7 @@ Show me column number and filesize
 :END:
 Please use Tabs in C files, I'm BEGGING.  Absolutely ridiculous that there's no simple variable to select Tabs ONLY for indentation.
 #+BEGIN_SRC emacs-lisp
-(defun c-lineup-arglist-tabs-only (ignored)
+(defun re/c-lineup-arglist-tabs-only (ignored)
   "Line up argument lists by tabs, not spaces. Stolen from https://kernel.org/doc/html/v4.10/process/coding-style.html"
   (let* ((anchor (c-langelem-pos c-syntactic-element))
          (column (c-langelem-2nd-pos c-syntactic-element))
@@ -623,7 +623,7 @@ Please use Tabs in C files, I'm BEGGING.  Absolutely ridiculous that there's no
                (c-offsets-alist
                 (arglist-cont-nonempty
                  c-lineup-gcc-asm-reg
-                 c-lineup-arglist-tabs-only))))))
+                 re/c-lineup-arglist-tabs-only))))))
 
 (add-hook 'c-mode-hook
           (lambda ()
@@ -684,7 +684,7 @@ I like putting redo on ~C-\~. Easier for me to remember than the ~C-M-_~ default
 :END:
 I took this from [[https://whattheemacsd.com][whattheemacsd.com]].  It is occasionally handy.
 #+BEGIN_SRC emacs-lisp
-(defun rename-current-buffer-file ()
+(defun re/rename-current-buffer-file ()
   "Renames the current buffer and the file it is visiting."
   (interactive)
   (let ((name (buffer-name))
@@ -701,7 +701,7 @@ I took this from [[https://whattheemacsd.com][whattheemacsd.com]].  It is occasi
           (message "File '%s' successfully renamed to '%s'"
                    name (file-name-nondirectory new-name)))))))
 
-(keymap-global-set "C-x C-r" 'rename-current-buffer-file)
+(keymap-global-set "C-x C-r" 're/rename-current-buffer-file)
 #+END_SRC
 **** Buffer Menu
 :PROPERTIES:
@@ -719,14 +719,14 @@ Usually I want the buffer menu in the same window I am already on.  Occasionally
 :END:
 I often want to bring up the scratch buffer in my current window, and sometimes I want only one window that is the scratch buffer.  Emacs 29 added the ~scratch-buffer~ function, so one less defun needed here.
 #+BEGIN_SRC emacs-lisp
-(defun scratch-only ()
+(defun re/scratch-only ()
   "Bring up the scratch buffer as the only visible buffer."
   (interactive)
   (scratch-buffer)
   (delete-other-windows))
 
 (keymap-global-set "<f5>" 'scratch-buffer)
-(keymap-global-set "S-<f5>" 'scratch-only)
+(keymap-global-set "S-<f5>" 're/scratch-only)
 #+END_SRC
 
 **** Line joining
@@ -735,12 +735,12 @@ I often want to bring up the scratch buffer in my current window, and sometimes
 :END:
 The ~M-^~ binding is handy, but usually I want the ed/sam/vi join function, which pulls the next line up into the current line.  I bind this to ~M-j~.
 #+BEGIN_SRC emacs-lisp
-(defun backward-join-line ()
+(defun re/backward-join-line ()
   "A wrapper for join-line to make it go in the right direction."
   (interactive)
   (join-line 0))
 
-(keymap-global-set "M-j" 'backward-join-line)
+(keymap-global-set "M-j" 're/backward-join-line)
 #+END_SRC
 
 **** Line opening
@@ -750,7 +750,7 @@ The ~M-^~ binding is handy, but usually I want the ed/sam/vi join function, whic
 The default behavior of =open-line= is ridiculous.  It acheives the same function as hitting =RET=.  I don't want to split the current line, I want to OPEN a new one, and usually go to it.  These wrappers remedy that.
 
 #+BEGIN_SRC emacs-lisp
-(defun open-line-below (n)
+(defun re/open-line-below (n)
   "Creates a new empty line below the current line and moves to it."
   (interactive "*p")
   (end-of-line)
@@ -758,7 +758,7 @@ The default behavior of =open-line= is ridiculous.  It acheives the same functio
   (call-interactively (next-line))
   (indent-for-tab-command))
 
-(defun open-line-above (n)
+(defun re/open-line-above (n)
   "Creates a new empty line above the current line."
   (interactive "*p")
   (beginning-of-line)
@@ -769,8 +769,8 @@ The default behavior of =open-line= is ridiculous.  It acheives the same functio
 I Bind the previous functions to =C-o= and =M-o=.
 
 #+BEGIN_SRC emacs-lisp
-(keymap-global-set "C-o" 'open-line-below)
-(keymap-global-set "M-o" 'open-line-above)
+(keymap-global-set "C-o" 're/open-line-below)
+(keymap-global-set "M-o" 're/open-line-above)
 #+END_SRC
 
 **** Commenting
@@ -779,7 +779,7 @@ I Bind the previous functions to =C-o= and =M-o=.
 :END:
 I stole this directly from [[https://depp.brause.cc/dotemacs][depp.brause.cc/dotemacs]].  Very good, simple solution.
 #+BEGIN_SRC emacs-lisp
-(defun my-comment-dwim ()
+(defun re/comment-dwim ()
   "Comment region if active, otherwise comment line.
 Stolen from https://depp.brause.cc/dotemacs"
   (interactive)
@@ -788,7 +788,7 @@ Stolen from https://depp.brause.cc/dotemacs"
     (comment-or-uncomment-region (line-beginning-position)
                                  (line-end-position))))
 
-(keymap-global-set "M-;" 'my-comment-dwim)
+(keymap-global-set "M-;" 're/comment-dwim)
 #+END_SRC
 
 **** Killing
@@ -825,14 +825,14 @@ Bind =C-z= to zap-up-to-char, sice zap-to-char is on =M-z=.
 I didn't want to re-bind =C-w= away from =kill-region=, so I made it do both.
 
 #+BEGIN_SRC emacs-lisp
-(defun kill-bword-or-region ()
+(defun re/kill-bword-or-region ()
   "Kill region if active, otherwise kill back one word."
   (interactive)
   (if (use-region-p)
       (call-interactively 'kill-region)
     (call-interactively 'backward-kill-word)))
 
-(keymap-global-set "C-w" 'kill-bword-or-region)
+(keymap-global-set "C-w" 're/kill-bword-or-region)
 #+END_SRC
 
 ****** =C-u=
@@ -842,12 +842,12 @@ I didn't want to re-bind =C-w= away from =kill-region=, so I made it do both.
 There is no pre-made function to kill backward to the beginning of line from point, so I made one that passes the correct argument to =kill-line=, and bound it to =C-u=.
 
 #+BEGIN_SRC emacs-lisp
-(defun backward-kill-line ()
+(defun re/backward-kill-line ()
   "Kill back to beginning of line from point."
   (interactive)
   (kill-line 0))
 
-(keymap-global-set "C-u" 'backward-kill-line)
+(keymap-global-set "C-u" 're/backward-kill-line)
 #+END_SRC
 
 Since =C-u= is =universal-argument=, I put that functionality on =M-'=.
@@ -880,7 +880,7 @@ I want =Home= and =End= to take me to the top and bottom of the file.
 :END:
 I have the infamous =smart-beginning-of-line= command here.
 #+BEGIN_SRC emacs-lisp
-(defun smart-beginning-of-line ()
+(defun re/smart-beginning-of-line ()
   "Move point to first non-whitespace character or beginning-of-line.
 If point was already at that position, move point to beginning of
 line.  Stolen from BrettWitty's dotemacs github repo."
@@ -896,7 +896,7 @@ line.  Stolen from BrettWitty's dotemacs github repo."
 :END:
 I had issues with ~smart-beginning-of-line~ in ~visual-line-mode~, so ~smart-beginning-of-visual-line~ was created.  It implements part of ~back-to-indentation~, but with changes to use ~beginning-of-visual-line~ instead of ~beginning-of-line~.
 #+BEGIN_SRC emacs-lisp
-(defun smart-beginning-of-visual-line ()
+(defun re/smart-beginning-of-visual-line ()
   "Move point to first non-whitespace character or beginning-of-line.
 If point was already at that position, move point to beginning of
 line. Stolen from BrettWitty's dotemacs github repo.  Modified to
@@ -916,10 +916,10 @@ as a visual-line respecter."
 :END:
 Remap =move-beginning-of-line=, then remap =beginning-of-visual-line= when going into =visual-line-mode=.  A simple remap would not work for =visual-line-mode=, so I explicitly set =C-a=.
 #+BEGIN_SRC emacs-lisp
-(global-set-key [remap move-beginning-of-line] 'smart-beginning-of-line)
+(global-set-key [remap move-beginning-of-line] 're/smart-beginning-of-line)
 (add-hook 'visual-line-mode-hook
           (lambda ()
-            (keymap-global-set "C-a" 'smart-beginning-of-visual-line)))
+            (keymap-global-set "C-a" 're/smart-beginning-of-visual-line)))
 #+END_SRC
 ***** Line Numbers on move only
 :PROPERTIES:
@@ -927,14 +927,14 @@ Remap =move-beginning-of-line=, then remap =beginning-of-visual-line= when going
 :END:
 I don't want line numbers in the margin unless I am actively trying to go to a line.  I override =goto-line= with this function, which shows line numbers, asks me where I want to go, and then hides line numbers.
 #+BEGIN_SRC emacs-lisp
-(defun my-goto-line ()
+(defun re/goto-line ()
   "Show line numbers before going to line, then hide them again."
   (interactive)
   (display-line-numbers-mode 1)
   (call-interactively 'goto-line)
   (display-line-numbers-mode -1))
 
-(global-set-key [remap goto-line] 'my-goto-line)
+(global-set-key [remap goto-line] 're/goto-line)
 #+END_SRC
 ***** Other window or split window
 :PROPERTIES:
@@ -942,13 +942,13 @@ I don't want line numbers in the margin unless I am actively trying to go to a l
 :END:
 I ripped this defun and binding from [[https://github.com/lem-project/lem][lem]].  Can't live without it now. Does similar things as [[id:1c8d7229-796f-446a-8ae8-247cd6164a12][Windmove]], but without having to specify a direction.
 #+BEGIN_SRC emacs-lisp
-(defun other-window-or-split-window (&optional window)
+(defun re/other-window-or-split-window (&optional window)
   (interactive)
   (if (= (count-windows) 1)
       (funcall split-window-preferred-function window)
     (other-window 1)))
 
-(keymap-global-set "C-M-o" 'other-window-or-split-window)
+(keymap-global-set "C-M-o" 're/other-window-or-split-window)
 #+END_SRC
 **** Search and Replace
 :PROPERTIES:
@@ -992,7 +992,7 @@ Some old Emacs-like editor (Edwin?) used this binding, so I put it in here.  Les
 :END:
 I wanted something like what the Genera environment has, where putting in a final close-paren will send the command, without having to hit enter.  This is a general command, used by [[id:325c01c5-b877-4281-adff-ea956bdb5f2c][Eshell]], [[id:664ba0e7-0826-4868-9480-e1338a6e9f63][Ielm]], and
 #+BEGIN_SRC emacs-lisp
-(defun send-on-close-paren (executor)
+(defun re/send-on-close-paren (executor)
   "Generalizes sending an execute on close paren.
 When a sexp is complete - that is when parens balance as you type - execute it."
   (interactive)
@@ -1033,7 +1033,7 @@ These defuns are here so that I can use doas/sudo over tramp to edit /local/ fil
 If you've ever had the /pleasure/ of using Aveva (*Formerly WonderWare*) version 2020, you'll understand.
 #+BEGIN_SRC emacs-lisp
 (when (equal system-type 'windows-nt)
-  (defun unfuck-aveva-license ()
+  (defun re/unfuck-aveva-license ()
     "Remove the offending xml files.
 Use this when aveva can't find ass with both hands."
     (interactive)
@@ -1413,7 +1413,7 @@ Set up the agenda view. Access it with ~C-c a SPC~, [[id:3281906e-1f44-4abb-9f9d
 :END:
 Stolen from [[https://emacs.stackexchange.com/questions/864/how-to-bind-a-key-to-a-specific-agenda-command-list-in-org-mode][Stack Exchange]]
 #+BEGIN_SRC emacs-lisp
-(defun org-agenda-show-custom (&optional arg)
+(defun re/org-agenda-show-custom (&optional arg)
   "Show my custom agenda."
   (interactive "P")
   (org-agenda arg " "))
@@ -1421,7 +1421,7 @@ Stolen from [[https://emacs.stackexchange.com/questions/864/how-to-bind-a-key-to
 
 Do it again for main agenda
 #+BEGIN_SRC emacs-lisp
-(defun org-show-agenda (&optional arg)
+(defun re/org-show-agenda (&optional arg)
   "Show the main agenda"
   (interactive "P")
   (org-agenda arg "a"))
@@ -1590,11 +1590,11 @@ Start up =abbrev-mode= for org
 :END:
 A function to automatically archive *DONE* items in an org file.  I sometimes use this as an after-save-hook header declaration as such:
 #+BEGIN_SRC emacs-lisp :tangle no
--*- after-save-hook: (org-auto-archive) -*-
+-*- after-save-hook: (re/org-auto-archive) -*-
 #+END_SRC
 
 #+BEGIN_SRC emacs-lisp
-(defun org-auto-archive ()
+(defun re/org-auto-archive ()
   "Automatically archive completed tasks in an org file.
 Intended for use as an after-save-hook."
   (interactive)
@@ -1609,7 +1609,7 @@ Intended for use as an after-save-hook."
 
 Also add that defun to =safe-local-variables= so that emacs will run it.
 #+BEGIN_SRC emacs-lisp
-(setq safe-local-variable-values '((after-save-hook org-auto-archive)))
+(setq safe-local-variable-values '((after-save-hook re/org-auto-archive)))
 #+END_SRC
 
 *** Auto-Generate IDs
@@ -1631,7 +1631,7 @@ Generate an ID when I capture someting, and when I try to link to it.  Stolen fr
 :END:
 Automatically generate unique IDs if not already created.  Stolen from [[https://stackoverflow.com/questions/13340616/assign-ids-to-every-entry-in-org-mode][Stack Overflow]]
 #+BEGIN_SRC emacs-lisp
-(defun org-auto-generate-ids-in-file ()
+(defun re/org-auto-generate-ids-in-file ()
   "Add ID properties to all headlines in the current
  file which do not already have one."
   (interactive)
@@ -1642,7 +1642,7 @@ Run this on save of any org-mode file
 #+BEGIN_SRC emacs-lisp
 (add-hook 'org-mode-hook
           (lambda ()
-            (add-hook 'before-save-hook 'org-auto-generate-ids-in-file nil 'local)))
+            (add-hook 'before-save-hook 're/org-auto-generate-ids-in-file nil 'local)))
 #+END_SRC
 
 *** Tangling
@@ -1666,7 +1666,7 @@ Don't make a new window for source-code edits, and keep indentation consistent.
 :END:
 Make a function to tangle this file, and run it on save.
 #+BEGIN_SRC emacs-lisp
-(defun tangle-init ()
+(defun re/tangle-init ()
   "Tangle and compile init.org.
 Stolen from https://github.com/larstvei/dot-emacs."
   (when (equal (buffer-file-name)
@@ -1674,7 +1674,7 @@ Stolen from https://github.com/larstvei/dot-emacs."
     (let ((prog-mode-hook nil))
       (org-babel-tangle))))
 
-(add-hook 'after-save-hook 'tangle-init)
+(add-hook 'after-save-hook 're/tangle-init)
 #+END_SRC
 
 *** Bindings
@@ -1691,8 +1691,8 @@ The usual bindings.
 (keymap-global-set "C-c a" 'org-agenda)
 (keymap-global-set "C-c c" 'org-capture)
 (keymap-global-set "C-c b" 'org-switchb)
-(keymap-global-set "<f8>" 'org-agenda-show-custom)
-(keymap-global-set "<f6>" 'org-show-agenda)
+(keymap-global-set "<f8>" 're/org-agenda-show-custom)
+(keymap-global-set "<f6>" 're/org-show-agenda)
 #+END_SRC
 
 **** Mode-Specific
@@ -1755,11 +1755,11 @@ Here are the various customizations I have for eshell.
 I wanted something like what the Genera environment has, where putting in a final close-paren will send the command, without having to hit enter. See [[id:325c01c5-b877-4281-adff-ea956bdb5f2c][Send on Close-Paren]].
 
 #+BEGIN_SRC emacs-lisp
-(defun eshell-send-on-close-paren ()
+(defun re/eshell-send-on-close-paren ()
   "Makes eshell act somewhat like genera.
 Makes a closing paren execute the sexp."
   (interactive)
-  (send-on-close-paren 'eshell-send-input))
+  (re/send-on-close-paren 'eshell-send-input))
 #+END_SRC
 
 *** Quit or delete-char
@@ -1787,7 +1787,7 @@ I have only been able to get these to work when they are within an add-hook lamb
 #+BEGIN_SRC emacs-lisp
 (add-hook 'eshell-mode-hook
           (lambda ()
-            (keymap-set eshell-mode-map ")" 'eshell-send-on-close-paren)
+            (keymap-set eshell-mode-map ")" 're/eshell-send-on-close-paren)
             (keymap-set eshell-mode-map "C-d" 'eshell-quit-or-delete-char)))
 #+END_SRC
 ** ielm configuration
@@ -1802,11 +1802,11 @@ I wanted something more like a standard lisp REPL in emacs.  Found =ielm=.
 I wanted something like what the Genera environment has, where putting in a final close-paren will send the command, without having to hit enter. See [[id:325c01c5-b877-4281-adff-ea956bdb5f2c][Send on Close-Paren]].
 
 #+BEGIN_SRC emacs-lisp
-(defun ielm-send-on-close-paren ()
+(defun re/ielm-send-on-close-paren ()
   "Makes ielm act somewhat like genera.
 Makes a closing paren execute the sexp."
   (interactive)
-  (send-on-close-paren 'ielm-send-input))
+  (re/send-on-close-paren 'ielm-send-input))
 #+END_SRC
 *** Persistent command history
 :PROPERTIES:
@@ -1817,7 +1817,7 @@ Makes a closing paren execute the sexp."
 :ID:       6db9d990-00e7-44ec-a83c-b2999fa8db73
 :END:
 #+BEGIN_SRC emacs-lisp
-(defun g-ielm-init-history ()
+(defun re/ielm-init-history ()
   "Stolen from https://n16f.net/blog/making-ielm-more-comfortable."
   (let ((path (expand-file-name "ielm/history" user-emacs-directory)))
     (make-directory (file-name-directory path) t)
@@ -1826,19 +1826,19 @@ Makes a closing paren execute the sexp."
                 comint-input-ignoredups t)
     (comint-read-input-ring))
 
-(add-hook 'ielm-mode-hook 'g-ielm-init-history)
+(add-hook 'ielm-mode-hook 're/ielm-init-history)
 #+END_SRC
 **** Write History
 :PROPERTIES:
 :ID:       f7f1df1f-9531-4ef6-b66f-dc0d46295864
 :END:
 #+BEGIN_SRC emacs-lisp
-(defun g-ielm-write-history (&rest _args)
+(defun re/ielm-write-history (&rest _args)
   "Stolen from https://n16f.net/blog/making-ielm-more-comfortable."
   (with-file-modes #o600
     (comint-write-input-ring)))
 
-(advice-add 'ielm-send-input :after 'g-ielm-write-history)
+(advice-add 'ielm-send-input :after 're/ielm-write-history)
 #+END_SRC
 *** Bindings
 :PROPERTIES:
@@ -1850,7 +1850,7 @@ Makes a closing paren execute the sexp."
 (add-hook 'ielm-mode-hook
           (lambda ()
             (keymap-set inferior-emacs-lisp-mode-map "C-l" 'comint-clear-buffer)
-            (keymap-set inferior-emacs-lisp-mode-map ")" 'ielm-send-on-close-paren)))
+            (keymap-set inferior-emacs-lisp-mode-map ")" 're/ielm-send-on-close-paren)))
 #+END_SRC
 ** Customize system
 :PROPERTIES: