From: rearman Date: Tue, 14 May 2024 14:05:09 +0000 (-0400) Subject: Cleanup and re-organize X-Git-Url: https://git.earman.xyz/?a=commitdiff_plain;h=ca1bcdcd0a6e721ffb65d8fbdda781304c350b32;p=emacsinit.git Cleanup and re-organize --- diff --git a/init.org b/init.org index d6b3b4d..16a2f8e 100644 --- a/init.org +++ b/init.org @@ -90,6 +90,7 @@ There are no GNU Police (yet), but I feel nicer by adding this in. :PROPERTIES: :ID: df50b909-93f9-4e98-981e-fdc396c28f28 :END: +Version 30.0 brings android support - let's try it out. This makes emacs play nice with termux. See [[https://sourceforge.net/projects/android-ports-for-gnu-emacs/files/termux][SourceForge]]. #+BEGIN_SRC emacs-lisp :tangle ./early-init.el (when (equal system-type 'android) (defvar termux-path "/data/data/com.termux/files/usr/bin") @@ -189,9 +190,10 @@ Non-gnu is in the defaults now, so I only need to add melpa. :PROPERTIES: :ID: 659c9663-b387-45d5-8386-c3a356b3766e :END: -I don't need these on a windows PC. +I don't need these on a windows PC or android. #+BEGIN_SRC emacs-lisp -(unless (equal system-type 'windows-nt) +(unless (or (equal system-type 'windows-nt) + (equal system-type 'android)) (use-package slime :ensure t) (use-package ledger-mode :ensure t @@ -199,17 +201,6 @@ I don't need these on a windows PC. ((:map ledger-mode-map ("C-c s" . ledger-sort-buffer))))) #+END_SRC -*** eink-emacs -:PROPERTIES: -:ID: 771a81f1-105d-44e6-9e94-51e2623a1549 -:END: -I wanted a minimal (mostly b+w) theme. Now I just use the default theme. -#+BEGIN_SRC emacs-lisp -;; (use-package eink-theme -;; :ensure t -;; :init -;; (load-theme 'eink t)) -#+END_SRC *** visual-fill-column :PROPERTIES: :ID: ffbdc9f9-4ec4-401f-9f97-1e0d74b72c49 @@ -330,19 +321,6 @@ I need to open binary files with their own editor. Disgusting. '(file)))) #+END_SRC -*** org-transclusion -:PROPERTIES: -:ID: ca1fd8bf-db66-4ed4-926b-1f89e211522d -:END: -Awesome package - adds transclusions. - -#+BEGIN_SRC emacs-lisp -(use-package org-transclusion - :ensure t - :bind (("" . org-transclusion-add) - ("C-c n t" . org-transclusion-mode))) -#+END_SRC - *** acme-mouse :PROPERTIES: :ID: 936ffd88-1955-4d84-ad96-fb1744d5a6e9 @@ -370,9 +348,6 @@ Starting to do some work with LaTeX, surprised this is not in base, but org is. :ID: 6488cb21-1bb0-4b7d-93fb-c04dc4e04024 :END: This section has '/base/' emacs customization. All the general stuff. - -I so far have kept most of my setq declarations in one place, only recently splitting them into multiple declarations from one large one. - *** Defaults :PROPERTIES: :ID: 6319f5d5-0763-4e41-a67b-90fb18d77e80 @@ -437,6 +412,7 @@ I want to avoid ever seeing an error about missing newlines at the end of a file #+BEGIN_SRC emacs-lisp (setq require-final-newline t) #+END_SRC + **** Auto Revert :PROPERTIES: :ID: 6d36da61-2373-433c-a7df-cc62511ee1ad @@ -445,6 +421,7 @@ When files change on disk, and there are no changes in the open buffer, revert t #+BEGIN_SRC emacs-lisp (global-auto-revert-mode t) #+END_SRC + **** Segfault recovery :PROPERTIES: :ID: e014f4e7-c131-463c-9d8f-f16530faea83 @@ -454,6 +431,7 @@ These are directly from [[https://depp.brause.cc/dotemacs/][depp.brause.cc/dotem (setq attempt-stack-overflow-recovery nil attempt-orderly-shutdown-on-fatal-signal nil) #+END_SRC + **** Whitespace and chmod on save :PROPERTIES: :ID: 2375de4d-f558-47f1-aea1-581240a0039a @@ -508,14 +486,6 @@ Save pastes from elsewhere into the kill-ring, and don't ask me about killing pr confirm-kill-processes nil) #+END_SRC -**** Scrolling -:PROPERTIES: -:ID: 532b73e8-c97c-4862-b079-789702385362 -:END: -#+BEGIN_SRC emacs-lisp -(setq scroll-preserve-screen-position t) -#+END_SRC - **** Windmove :PROPERTIES: :ID: 1c8d7229-796f-446a-8ae8-247cd6164a12 @@ -559,7 +529,6 @@ I want nice symbols to look at When I'm on a beginning/ending paren, I find the default of only highlighting the parens too hard to see, and highlighting the whole thing too garish. Therefore, this setup tries to underline the expression, with minimal highlighting. Show matching parens immediately, and "highlight" the whole expression. - #+BEGIN_SRC emacs-lisp (setq show-paren-delay 0 show-paren-style 'expression) @@ -701,8 +670,7 @@ Org special keys - do logical things with =C-a/e/k=, and adjust subtree level wh :PROPERTIES: :ID: e7426184-8474-45d8-b0c4-a4a2ed99101d :END: -Don't open links in another window, just use the current one - +Don't open links in another window, just use the current one. This variable is otherwise as default. #+BEGIN_SRC emacs-lisp (setq org-link-frame-setup '((vm . vm-visit-folder-other-frame) (vm-imap . vm-visit-imap-folder-other-frame) @@ -730,7 +698,7 @@ Let me refile anywhere, use outline paths, confirm when creating parent nodes. (setq org-refile-targets '((nil :maxlevel . 9) (org-agenda-files :maxlevel . 9)) org-refile-use-outline-path 'file - org-refile-allow-creating-parent-nodes '(confirm)) + org-refile-allow-creating-parent-nodes 'confirm) #+END_SRC *** Keywords @@ -753,7 +721,7 @@ Set up some more todo keywords :PROPERTIES: :ID: 1aa94af1-7a65-4ad1-8ac5-dd919252b4ab :END: -Add some much-used tags with shortcuts +Add some much-used tags with shortcuts. #+BEGIN_SRC emacs-lisp (setq org-tag-alist '((:startgroup . nil) ("need" . ?n) @@ -787,7 +755,7 @@ Go back to previous view on quit, always start on current day, warn me for 30 da :PROPERTIES: :ID: 12d59694-3e27-4e53-8ba3-7c341a0d1c2d :END: -Set up the agenda view. Access it with =C-c a SPC=. +Set up the agenda view. Access it with ~C-c a SPC~, [[id:3281906e-1f44-4abb-9f9d-0a0a39221752][or ~F2~]]. #+BEGIN_SRC emacs-lisp (setq org-agenda-custom-commands '((" " "Agenda" ((agenda "" nil) @@ -804,6 +772,19 @@ Set up the agenda view. Access it with =C-c a SPC=. (tags-todo "standard" ((org-agenda-overriding-header "Changes to Standard"))))))) #+END_SRC + +**** Custom Agenda on Single key +:PROPERTIES: +:ID: c921d7e6-63ef-4a89-851a-0f3a122e9fa0 +: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) + "Show my custom agenda." + (interactive "P") + (org-agenda arg " ")) +#+END_SRC + **** Column View :PROPERTIES: :ID: b30e7269-c0ba-4014-9fb9-e03e6734a4db @@ -944,21 +925,6 @@ Start up =abbrev-mode= for org "#+FILETAGS: wo# workorder customer city state topics\n") #+END_SRC -***** Meeting properties block -:PROPERTIES: -:ID: ed945d25-1df8-4108-8b06-69a852be0a4c -:END: -Superceded by [[*Templates][Meeting Capture Template]] -#+BEGIN_SRC emacs-lisp -;; (define-skeleton skel-meeting-properties -;; "Insert the org title and filetags for a meeting" -;; "" -;; "#+TITLE: " -;; _ - -;; " Meeting\n" -;; "#+FILETAGS: meeting date customer city state attendees topics\n") -#+END_SRC - **** Bind the snippets (in the =abbrev-file-name= file) :PROPERTIES: :ID: 1e9362ab-d7da-4d87-bef4-9a6c39530832 @@ -1066,18 +1032,6 @@ Stolen from https://github.com/larstvei/dot-emacs." (add-hook 'after-save-hook 'tangle-init) #+END_SRC -*** Custom Agenda on Single key -:PROPERTIES: -:ID: c921d7e6-63ef-4a89-851a-0f3a122e9fa0 -: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) - "Show my custom agenda." - (interactive "P") - (org-agenda arg " ")) -#+END_SRC - *** Bindings :PROPERTIES: :ID: adf21035-f2f1-443b-a599-4ce4f282a2ff @@ -1248,6 +1202,7 @@ Makes a closing paren execute the sexp." :PROPERTIES: :ID: 68c34ab5-7149-49f5-91e8-fcea22d98fcd :END: +~C-l~ to clear buffer, send on close paren. #+BEGIN_SRC emacs-lisp (keymap-global-set "C-c i" 'ielm) (add-hook 'ielm-mode-hook @@ -1271,7 +1226,7 @@ Most of these are to re-create something from vim/readline/sam/acme. Some are j :PROPERTIES: :ID: 9f4775e4-6c76-46d6-b4e0-7dbce717907a :END: -Bind =find-file-at-point= and =bookmark-jump-other-window=. +Bind ~find-file-at-point~ and ~bookmark-jump-other-window~. #+BEGIN_SRC emacs-lisp (keymap-global-set "C-x M-f" 'find-file-at-point) (keymap-global-set "C-x r B" 'bookmark-jump-other-window) @@ -1281,7 +1236,7 @@ Bind =find-file-at-point= and =bookmark-jump-other-window=. :PROPERTIES: :ID: da7cd3d7-1b85-48d3-8f68-e6b496e184ea :END: -I like putting redo on =C-\=. Easier for me to remember than the =C-M-_= default. +I like putting redo on ~C-\~. Easier for me to remember than the ~C-M-_~ default. #+BEGIN_SRC emacs-lisp (keymap-global-set "C-\\" 'undo-redo) #+END_SRC @@ -1311,7 +1266,7 @@ I took this from [[https://whattheemacsd.com][whattheemacsd.com]]. It is occasi (keymap-global-set "C-x C-r" 'rename-current-buffer-file) #+END_SRC -**** Buffer Handling +**** Buffer Menu :PROPERTIES: :ID: 485c4ac3-839f-4289-a4c9-43da1a3ae048 :END: @@ -1321,7 +1276,11 @@ Usually I want the buffer menu in the same window I am already on. Occasionally (keymap-global-set "C-x M-b" 'buffer-menu-other-window) #+END_SRC -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. +**** Switch to Scratch +:PROPERTIES: +:ID: 2d37f85a-de5a-408c-a6ce-4b8078a95775 +: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 () "Bring up the scratch buffer as the only visible buffer." @@ -1337,7 +1296,7 @@ I often want to bring up the scratch buffer in my current window, and sometimes :PROPERTIES: :ID: 76950919-72fc-4d2c-becf-9ef702b906f1 :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=. +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 () "A wrapper for join-line to make it go in the right direction." @@ -1422,7 +1381,10 @@ Bind =C-z= to zap-up-to-char, sice zap-to-char is on =M-z=. :ID: 80589df3-9a23-4b2c-b103-9263db7efaab :END: =C-w= is very much engrained for killing back one word, as is =C-u= for killing back to the beginning of the line. [[http://unix-kb.cat-v.org/][These have been standard bindings since TENEX...]] - +****** =C-w= +:PROPERTIES: +:ID: dd0452c4-59c0-4c05-9ace-8988f28d736d +:END: I didn't want to re-bind =C-w= away from =kill-region=, so I made it do both. #+BEGIN_SRC emacs-lisp @@ -1436,6 +1398,10 @@ I didn't want to re-bind =C-w= away from =kill-region=, so I made it do both. (keymap-global-set "C-w" 'kill-bword-or-region) #+END_SRC +****** =C-u= +:PROPERTIES: +:ID: 6bd8af3f-f277-4328-9037-020c9529a1ee +:END: 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 @@ -1466,10 +1432,15 @@ I want =Home= and =End= to take me to the top and bottom of the file. (keymap-global-set "" 'beginning-of-buffer) (keymap-global-set "" 'end-of-buffer) #+END_SRC + ***** Beginning of line :PROPERTIES: :ID: e8ddfa3d-4be7-4da7-bf6a-5dee3fcac91f :END: +****** ~smart-beginning-of-line~ +:PROPERTIES: +:ID: 7b9d4bde-5ed4-4618-899e-4a0a82359f7f +:END: I have the infamous =smart-beginning-of-line= command here. #+BEGIN_SRC emacs-lisp (defun smart-beginning-of-line () @@ -1482,8 +1453,11 @@ line. Stolen from BrettWitty's dotemacs github repo." (and (= oldpos (point)) (beginning-of-line)))) #+END_SRC - -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=. +****** Play nice with ~visual-line-mode~ +:PROPERTIES: +:ID: c8ad20f0-755c-4075-ae97-a43d4869cca9 +: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 () "Move point to first non-whitespace character or beginning-of-line. @@ -1499,7 +1473,10 @@ as a visual-line respecter." (and (= oldpos (point)) (beginning-of-visual-line)))) #+END_SRC - +****** Re-mappings +:PROPERTIES: +:ID: 4a8e9670-2783-4f4a-ada7-f1837a8632be +: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) @@ -1526,7 +1503,7 @@ I don't want line numbers in the margin unless I am actively trying to go to a l :PROPERTIES: :ID: 7e9a99eb-18fd-4254-a20c-a1cb2fe0584d :END: -I ripped this defun and binding from [[https://github.com/lem-project/lem][lem]]. Can't live without it now. +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) (interactive) @@ -1549,7 +1526,6 @@ I made these bindings to put my more-used commands on better keys, and swap them (keymap-global-set "C-S-S" 'isearch-forward-regexp) (keymap-global-set "C-S-R" 'isearch-backward-regexp) #+END_SRC - *** Elisp/Eval bindings :PROPERTIES: :ID: 05c8bf80-e35f-49bc-97b0-b6caccb63ab6 @@ -1565,7 +1541,8 @@ Some old Emacs-like editor (Edwin?) used this binding, so I put it in here. Les :END: These defuns are here so that I can use doas/sudo over tramp to edit /local/ files requiring root permissions. Doas for BSD, Sudo for Linux, nothing for Windows. #+BEGIN_SRC emacs-lisp -(unless (equal system-type 'windows-nt) +(unless (or (equal system-type 'windows-nt) + (equal system-type 'android)) (if(equal system-type 'berkeley-unix) (defun doas () "Use TRAMP to reopen the current buffer as root using doas." @@ -1605,12 +1582,18 @@ Use this when aveva can't find ass with both hands." :ID: 69a05305-6b16-4abf-bf9a-b858d9a7e642 :END: General Math defuns, often used in later defuns. - +**** Exponentiation +:PROPERTIES: +:ID: 14d9a8c0-2984-4d53-b933-01366b286208 +:END: I'm tired of writing out ='expt=, and I want to use the same notation every other programming language does. #+BEGIN_SRC emacs-lisp (defalias '^ 'expt) #+END_SRC - +**** Square, Cube, and Inv +:PROPERTIES: +:ID: 871f50e4-447e-4da0-b86f-ec253c7d48cf +:END: Define square, cube, and inv for brevity of common usages. #+BEGIN_SRC emacs-lisp (defun square (x)