From: rearman Date: Thu, 9 May 2024 16:25:06 +0000 (-0400) Subject: Org-links use ids, auto-generate ids on save, capture X-Git-Url: https://git.earman.xyz/?a=commitdiff_plain;h=0c4f5ddd670af9bcbe2dccf32dc197cdf01f780b;p=emacsinit.git Org-links use ids, auto-generate ids on save, capture --- diff --git a/init.org b/init.org index 3d5535b..947d2d1 100644 --- a/init.org +++ b/init.org @@ -3,6 +3,9 @@ #+PROPERTY: header-args:emacs-lisp :tangle yes :results silent :export code * Introduction +:PROPERTIES: +:ID: 92e3c7e3-febf-46ac-ae1b-650d57c31240 +:END: This is my emacs configuration. It is meant to be used across linux, windows, and BSD. I use windows only at work (Industrial Controls). I use emacs often as an advanced programmable calculator. Lots of inspiration taken from: @@ -11,12 +14,24 @@ Lots of inspiration taken from: - [[https://github.com/sachac/.emacs.d][github.com/sachac/.emacs.d]] ** A note on version checking +:PROPERTIES: +:ID: 6ff82e4f-1e11-43d5-afca-8cf905eea937 +:END: I keep my emacs installs at the latest release, so I don't worry about checking for versions in my init unless I happen to update on linux/BSD before the windows binaries are released. That being said, I am currently on version 29.3. ** Latinization +:PROPERTIES: +:ID: 7afb5b82-e888-483b-9988-7fbc50839cb6 +:END: I believe that all scientific knowledge, and by extension computational knowledge, should be shared in Latin. That is to say I intend to facilitate Latin's return as the default language for global knowledge sharing. To be consistent, I will soon be translating as much of this file as possible into Latin. Monitus es. * Meta Configuration +:PROPERTIES: +:ID: edd4ed35-bf17-46ce-96a1-4c78aed06c1e +:END: I have taken this mostly whole-hog from [[https://github.com/larstvei/dot-emacs][github.com/larstvei/dot-emacs]]. The idea is that this bare-bones init.el is available when the repo is pulled in, but gets overwritten on emacs' first run. Emacs will need to be re-started after that initial run, since =early-init.el= will be created, and some packages will be installed. ** Init.el +:PROPERTIES: +:ID: e0f3f2eb-a3ad-4c60-963f-263d07f3a98c +:END: This is the repo's =init.el= file, which bootstraps the real =init.el=. #+BEGIN_SRC emacs-lisp :tangle no ;;; This file replaces itself with the real config at first run @@ -32,22 +47,37 @@ This is the repo's =init.el= file, which bootstraps the real =init.el=. #+END_SRC ** Git init.el tracking +:PROPERTIES: +:ID: 2d505071-c9ca-4747-bf5a-7543b50f053e +:END: *** Disable Tracking +:PROPERTIES: +:ID: 524b42ee-76a1-4061-a6a9-55106c4167ed +:END: There is no reason to track the =init.el= that is generated. Run the following command to make git ignore the generated file, but keep the dummy init. #+BEGIN_SRC sh :tangle no git update-index --assume-unchanged init.el #+END_SRC *** Enable Tracking +:PROPERTIES: +:ID: 5adcac01-ab6a-4556-a160-06c2498d61e5 +:END: If changes to the dummy-init are needed, track those by running #+BEGIN_SRC sh :tangle no git update-index --no-assume-unchanged init.el #+END_SRC * Early init +:PROPERTIES: +:ID: 4420cd35-3101-4ee2-bc61-964e08b06174 +:END: This file was introduced in Emacs 27. I use it for speeding up init, removing all the UI stuff I don't want, etc. Maybe superfluous, but I do get startup times on the order of /0.015/ seconds. ** The normal header +:PROPERTIES: +:ID: 994087b6-1707-4cc2-9555-988ae9d4a51d +:END: There are no GNU Police (yet), but I feel nicer by adding this in. #+BEGIN_SRC emacs-lisp :tangle ./early-init.el ;;; early-init.el -*- lexical-binding: t; -*- @@ -58,6 +88,9 @@ There are no GNU Police (yet), but I feel nicer by adding this in. #+END_SRC ** GC thrashing +:PROPERTIES: +:ID: d95e3549-b3ad-4aeb-a229-739a871b6c4b +:END: Set the GC threshold to max during startup, then set it back to a value that is somewhat more sane than the default /800kb/. #+BEGIN_SRC emacs-lisp :tangle ./early-init.el @@ -69,6 +102,9 @@ Set the GC threshold to max during startup, then set it back to a value that is #+END_SRC ** Basic UI preferences +:PROPERTIES: +:ID: c60bc3a8-d04a-4cbd-8039-fee1e2ecf9ee +:END: I want no menus, no tool-bars, left-side scroll-bars, no blinking cursor, no messages when starting up, make resizing work properly, and start up maximized. I just want the scratch buffer with a report on =emacs-init-time=. #+BEGIN_SRC emacs-lisp :tangle ./early-init.el (menu-bar-mode -1) @@ -86,6 +122,9 @@ I want no menus, no tool-bars, left-side scroll-bars, no blinking cursor, no mes #+END_SRC ** Misc/odd issues +:PROPERTIES: +:ID: 086a73ac-b883-4783-aa87-e6ad3ac54398 +:END: Avoid a weird issue on windows where opening emacs via an [[https://www.autohotkey.com/][AutoHotKey]] binding causes emacs to load in the AutoHotKey directory. #+BEGIN_SRC emacs-lisp :tangle ./early-init.el @@ -93,6 +132,9 @@ Avoid a weird issue on windows where opening emacs via an [[https://www.autohotk #+END_SRC ** The normal footer +:PROPERTIES: +:ID: ae3aa94e-27f2-4845-b306-effae05c79ac +:END: #+BEGIN_SRC emacs-lisp :tangle ./early-init.el (provide 'early-init) @@ -100,7 +142,13 @@ Avoid a weird issue on windows where opening emacs via an [[https://www.autohotk #+END_SRC * Main init +:PROPERTIES: +:ID: fabe0435-21bb-4336-bd5d-01a7344265a9 +:END: ** Header +:PROPERTIES: +:ID: 33be7f35-74f6-4d1d-bf58-673a7a475665 +:END: #+BEGIN_SRC emacs-lisp ;;; init.el --- Quae configurare -*- lexical-binding: t; -*- @@ -111,8 +159,14 @@ Avoid a weird issue on windows where opening emacs via an [[https://www.autohotk #+END_SRC ** Packages +:PROPERTIES: +:ID: dff50446-ba25-48d0-a126-75bc8a1087e3 +:END: Load packages first, so there is no question about dependencies later in the file. *** Package Repositories +:PROPERTIES: +:ID: 43c60653-1584-4ba5-8dfd-358b96897b33 +:END: Non-gnu is in the defaults now, so I only need to add melpa. #+BEGIN_SRC emacs-lisp @@ -121,6 +175,9 @@ Non-gnu is in the defaults now, so I only need to add melpa. #+END_SRC *** Packages I don't want on my work computers +:PROPERTIES: +:ID: 659c9663-b387-45d5-8386-c3a356b3766e +:END: I don't need these on a windows PC. #+BEGIN_SRC emacs-lisp (unless (equal system-type 'windows-nt) @@ -132,6 +189,9 @@ I don't need these on a windows PC. #+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 @@ -140,6 +200,9 @@ I wanted a minimal (mostly b+w) theme. Now I just use the default theme. ;; (load-theme 'eink t)) #+END_SRC *** visual-fill-column +:PROPERTIES: +:ID: ffbdc9f9-4ec4-401f-9f97-1e0d74b72c49 +:END: A godsend. Finally, I can have visual-line-mode without having to read lines that are 1980 pixels wide! Also set word wrap, and make the split for help do what I want on big screens. #+BEGIN_SRC emacs-lisp @@ -164,9 +227,15 @@ Also make a defun/binding to toggle it as needed. #+END_SRC *** corfu +:PROPERTIES: +:ID: 13511ed2-bc09-469d-b71a-2c8a082f65fc +:END: I used =company-mode= for a long time. I tried corfu and haven't looked back. It is smaller, and does everything I was doing with company. **** Main Corfu +:PROPERTIES: +:ID: 86e4a1b4-7734-42de-a5fc-aca9ea93d532 +:END: The basics for corfu. Auto popup after one letter, enable globally. #+BEGIN_SRC emacs-lisp @@ -181,6 +250,9 @@ The basics for corfu. Auto popup after one letter, enable globally. #+END_SRC **** corfu-popupinfo +:PROPERTIES: +:ID: da81efaa-3669-4700-90cb-2e95c434a453 +:END: This comes with base corfu, but is configured separately. #+BEGIN_SRC emacs-lisp @@ -198,6 +270,9 @@ This comes with base corfu, but is configured separately. #+END_SRC *** expand-region +:PROPERTIES: +:ID: 3cdd5e3a-2f7d-4c12-8b77-1f8f6f6ed494 +:END: Seldom used, but nothing else does it. #+BEGIN_SRC emacs-lisp @@ -206,6 +281,9 @@ Seldom used, but nothing else does it. #+END_SRC *** magit +:PROPERTIES: +:ID: 2af0acc8-e7fb-47d4-9bd8-fa1edd18a1b4 +:END: I use magit occasionally. I put this sparse configuration here mostly for a speed boost, by making magit only load when I explicitly call for it. #+BEGIN_SRC emacs-lisp @@ -218,6 +296,9 @@ I use magit occasionally. I put this sparse configuration here mostly for a spe #+END_SRC *** openwith +:PROPERTIES: +:ID: d5826618-b99b-4f71-b6f5-58ec937924d9 +:END: I need to open binary files with their own editor. Disgusting. #+BEGIN_SRC emacs-lisp @@ -239,6 +320,9 @@ I need to open binary files with their own editor. Disgusting. #+END_SRC *** org-transclusion +:PROPERTIES: +:ID: ca1fd8bf-db66-4ed4-926b-1f89e211522d +:END: Awesome package - adds transclusions. #+BEGIN_SRC emacs-lisp @@ -249,12 +333,18 @@ Awesome package - adds transclusions. #+END_SRC *** acme-mouse +:PROPERTIES: +:ID: 936ffd88-1955-4d84-ad96-fb1744d5a6e9 +:END: Not a package in the strict sense, just a .el file - pulled from [[https://github.com/akrito/acme-mouse/]] and modified to meet changes to the old =cl= package. #+BEGIN_SRC emacs-lisp (load (concat user-emacs-directory "acme-mouse.el")) #+END_SRC *** AUCTeX +:PROPERTIES: +:ID: 3053fb45-ac60-4c80-9041-ba5afb9dfaa0 +:END: Starting to do some work with LaTeX, surprised this is not in base, but org is. #+BEGIN_SRC emacs-lisp (use-package auctex @@ -263,11 +353,17 @@ Starting to do some work with LaTeX, surprised this is not in base, but org is. #+END_SRC ** Non-Package customization +:PROPERTIES: +: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 +:END: I want these things every time, or at least setting them this way worked when a regular =setq= didn't. #+BEGIN_SRC emacs-lisp @@ -278,8 +374,14 @@ I want these things every time, or at least setting them this way worked when a #+END_SRC *** Backup/Autosave +:PROPERTIES: +:ID: caa6e592-9e74-42a7-837a-f7c650a43b11 +:END: I originally had some autosave items in here, but the defaults appeared to be doing basically what I wanted anyway. **** Backups +:PROPERTIES: +:ID: 64316516-6335-403d-9045-fb565466fca6 +:END: Make backups for vc-controlled files, don't clobber symlinks, and put everything into =~/emacs-backups/=. #+BEGIN_SRC emacs-lisp (setq vc-make-backup-files t @@ -288,6 +390,9 @@ Make backups for vc-controlled files, don't clobber symlinks, and put everything #+END_SRC **** Old versions +:PROPERTIES: +:ID: 03c827f2-b478-40fa-8b29-81ef6661811f +:END: Keep 10 versions, 5 'old' and 5 'new'. Delete anything older. #+BEGIN_SRC emacs-lisp (setq delete-old-versions t @@ -296,23 +401,38 @@ Keep 10 versions, 5 'old' and 5 'new'. Delete anything older. #+END_SRC *** File handling +:PROPERTIES: +:ID: 871b5b3f-d905-48b1-a305-036dccfc3df5 +:END: **** Final Newline +:PROPERTIES: +:ID: 34ddec70-6977-4f2d-bd72-b0a240d659ec +:END: 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 +:END: When files change on disk, and there are no changes in the open buffer, revert to the on-disk version. #+BEGIN_SRC emacs-lisp (global-auto-revert-mode t) #+END_SRC **** Segfault recovery +:PROPERTIES: +:ID: e014f4e7-c131-463c-9d8f-f16530faea83 +:END: These are directly from [[https://depp.brause.cc/dotemacs/][depp.brause.cc/dotemacs/]]. They are intended to make Emacs drop changes and die when a segfault happens, rather than attempt to save potentially corrupted data. #+BEGIN_SRC emacs-lisp (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 +:END: I want to strip all trailing whitespace on save, and I want to make all shell scripts executable at the same time. #+BEGIN_SRC emacs-lisp (add-hook 'before-save-hook 'whitespace-cleanup) @@ -320,6 +440,9 @@ I want to strip all trailing whitespace on save, and I want to make all shell sc #+END_SRC *** Minibuffer interaction +:PROPERTIES: +:ID: 32d9a1c6-7890-4d05-b241-5dcb83e9b848 +:END: I don't want emacs to beep or blink at me, I want y/n instead of the default yes/no, I don't care for clicking on things in the minibuffer, I like seeing my commands echoed almost immediately, I want history to only show me unique commands, and I want case-insensitive buffer switching. #+BEGIN_SRC emacs-lisp @@ -332,7 +455,13 @@ I don't want emacs to beep or blink at me, I want y/n instead of the default yes #+END_SRC *** Buffer interaction +:PROPERTIES: +:ID: 3961ab16-6a8f-4706-9511-4e26db0d4853 +:END: **** General +:PROPERTIES: +:ID: 3cd5a48b-92b4-47fb-a203-9d460a583d09 +:END: Close unused buffers after 3 days. #+BEGIN_SRC emacs-lisp (midnight-mode t) @@ -355,11 +484,17 @@ Save pastes from elsewhere into the kill-ring, and don't ask me about killing pr #+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 +:END: I originally had custom defuns and bindings to do this, but then I found out it was built in... #+BEGIN_SRC emacs-lisp (windmove-default-keybindings 'control) @@ -368,6 +503,9 @@ I originally had custom defuns and bindings to do this, but then I found out it #+END_SRC *** Buffer looks +:PROPERTIES: +:ID: 225b0716-b552-4166-b71f-0b54256a08a8 +:END: I want nice symbols to look at #+BEGIN_SRC emacs-lisp (setq prettify-symbols-alist '(("lambda" . 955) @@ -380,6 +518,9 @@ I want nice symbols to look at #+END_SRC *** Parens +:PROPERTIES: +:ID: de1b05fb-6127-485d-a4f2-2d2476e0fc4c +:END: 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. @@ -397,6 +538,9 @@ Make the paren "highlight" the same color as the background, and add underline. #+END_SRC *** Modeline +:PROPERTIES: +:ID: cf373f6a-1f7a-4b97-b5a3-a216ab5b0b31 +:END: Funny name for the frame #+BEGIN_SRC emacs-lisp (setq frame-title-format "Poor Man's LispM") @@ -409,6 +553,9 @@ Show me column number and filesize #+END_SRC *** C-Style +:PROPERTIES: +:ID: ffea9a43-63e9-42f8-8b3d-6d2b4339b667 +: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) @@ -440,6 +587,9 @@ Please use Tabs in C files, I'm BEGGING. Absolutely ridiculous that there's no #+END_SRC *** Windows-Specific +:PROPERTIES: +:ID: 609a563c-bcdf-4ac0-94de-ce6601db7460 +:END: Use =recycle bin=, DON'T use =AltGr=, and tell emacs where =diff= is. #+BEGIN_SRC emacs-lisp (when (equal system-type 'windows-nt) @@ -451,8 +601,14 @@ Use =recycle bin=, DON'T use =AltGr=, and tell emacs where =diff= is. #+END_SRC ** org configuration +:PROPERTIES: +:ID: 3ace6f84-14f7-4d64-a78c-b46b4a1ca66c +:END: My (now-sprawling) org configuration *** Startup options +:PROPERTIES: +:ID: 86db2539-2da8-49a5-852d-19f99dd81393 +:END: Start folded, and show stars as indentation. #+BEGIN_SRC emacs-lisp (setq org-startup-folded t @@ -460,7 +616,10 @@ Start folded, and show stars as indentation. #+END_SRC *** Basics -Don't split my line, just make a new one, follow links with return, export tables as csvs, and use an absolute path for links (while shortening home to ~). +:PROPERTIES: +:ID: d7161d70-f42c-43da-b454-974604d2b005 +:END: +Don't split my line, just make a new one, follow links with return, export tables as csvs, and use an absolute path for other links (while shortening home to ~). #+BEGIN_SRC emacs-lisp (setq org-M-RET-may-split-line nil org-return-follows-link t @@ -469,6 +628,9 @@ Don't split my line, just make a new one, follow links with return, export table #+END_SRC *** TO-DO options +:PROPERTIES: +:ID: 28154d92-b384-4d0e-bf9d-35bd9de59f58 +:END: Select with single key, enforce sub-tasks, only change the color of the keyword. #+BEGIN_SRC emacs-lisp (setq org-use-fast-todo-selection 'expert @@ -480,6 +642,9 @@ Select with single key, enforce sub-tasks, only change the color of the keyword. #+END_SRC *** Navigation +:PROPERTIES: +:ID: 7c85b584-936b-4763-90c0-3de8fabc36ae +:END: Make the =C-c C-j= binding more useful #+BEGIN_SRC emacs-lisp (setq org-goto-interface 'outline-path-completion @@ -488,7 +653,13 @@ Make the =C-c C-j= binding more useful #+END_SRC *** Bindings - +:PROPERTIES: +:ID: adf21035-f2f1-443b-a599-4ce4f282a2ff +:END: +**** Global +:PROPERTIES: +:ID: 3281906e-1f44-4abb-9f9d-0a0a39221752 +:END: The usual bindings. #+BEGIN_SRC emacs-lisp (keymap-global-set "C-c l" 'org-store-link) @@ -497,7 +668,24 @@ The usual bindings. (keymap-global-set "C-c b" 'org-switchb) #+END_SRC +**** Mode-Specific +:PROPERTIES: +:ID: 99906320-74b0-4414-8d87-1ce1ddddad97 +:END: +Give me logical in/out-denting on the easier binding. +#+BEGIN_SRC emacs-lisp +(add-hook 'org-mode-hook + (lambda () + (keymap-set org-mode-map "M-" 'org-shiftmetaright) + (keymap-set org-mode-map "M-" 'org-shiftmetaleft) + (keymap-set org-mode-map "M-S-" 'org-metaright) + (keymap-set org-mode-map "M-S-" 'org-metaleft))) +#+END_SRC + *** Special keys & subtree yanking +:PROPERTIES: +:ID: 396b69c0-7078-420a-9be3-5bf478a87584 +:END: Org special keys - do logical things with =C-a/e/k=, and adjust subtree level when yanking. #+BEGIN_SRC emacs-lisp (setq org-special-ctrl-a/e t @@ -506,6 +694,9 @@ Org special keys - do logical things with =C-a/e/k=, and adjust subtree level wh #+END_SRC *** File Opening +:PROPERTIES: +:ID: e7426184-8474-45d8-b0c4-a4a2ed99101d +:END: Don't open links in another window, just use the current one #+BEGIN_SRC emacs-lisp @@ -516,6 +707,9 @@ Don't open links in another window, just use the current one (wl . wl-other-frame))) #+END_SRC *** Directories +:PROPERTIES: +:ID: 5fbbe7e3-8da5-453e-b7a3-45eee036d662 +:END: Tell org where everything is #+BEGIN_SRC emacs-lisp (setq org-directory "~/org" @@ -524,6 +718,9 @@ Tell org where everything is org-journal-file "~/org/journal.org") #+END_SRC *** Refile +:PROPERTIES: +:ID: 4cca59d2-f47a-4e9d-8c22-162a81aac629 +:END: Let me refile anywhere, use outline paths, confirm when creating parent nodes. #+BEGIN_SRC emacs-lisp (setq org-refile-targets '((nil :maxlevel . 9) @@ -533,6 +730,9 @@ Let me refile anywhere, use outline paths, confirm when creating parent nodes. #+END_SRC *** Keywords +:PROPERTIES: +:ID: 8505da9e-71ae-42da-a5ff-8e80ca96dd30 +:END: Set up some more todo keywords #+BEGIN_SRC emacs-lisp (setq org-todo-keywords '((sequence "TODO(t)" @@ -546,6 +746,9 @@ Set up some more todo keywords #+END_SRC *** Tag Filtering +:PROPERTIES: +:ID: 1aa94af1-7a65-4ad1-8ac5-dd919252b4ab +:END: Add some much-used tags with shortcuts #+BEGIN_SRC emacs-lisp (setq org-tag-alist '((:startgroup . nil) @@ -555,7 +758,13 @@ Add some much-used tags with shortcuts #+END_SRC *** Agenda +:PROPERTIES: +:ID: f9839acc-459b-42be-983d-3b3609d470cf +:END: **** General options +:PROPERTIES: +:ID: a0e6d683-63ac-4cfe-b2fc-4eb0d096f704 +:END: Go back to previous view on quit, always start on current day, warn me for 30 days of a deadline, use the current window for the agenda, and don't show tags. #+BEGIN_SRC emacs-lisp (setq org-agenda-restore-windows-after-quit t @@ -566,6 +775,9 @@ Go back to previous view on quit, always start on current day, warn me for 30 da #+END_SRC **** Custom View +:PROPERTIES: +:ID: 12d59694-3e27-4e53-8ba3-7c341a0d1c2d +:END: Set up the agenda view. Access it with =C-c a SPC=. #+BEGIN_SRC emacs-lisp (setq org-agenda-custom-commands '((" " "Agenda" @@ -584,6 +796,9 @@ Set up the agenda view. Access it with =C-c a SPC=. ((org-agenda-overriding-header "Changes to Standard"))))))) #+END_SRC **** Column View +:PROPERTIES: +:ID: b30e7269-c0ba-4014-9fb9-e03e6734a4db +:END: Set up the format for column view. #+BEGIN_SRC emacs-lisp (setq org-columns-default-format "%50ITEM(Task) %10CLOCKSUM %16TIMESTAMP_IA" @@ -591,6 +806,9 @@ Set up the format for column view. #+END_SRC **** Clock settings +:PROPERTIES: +:ID: 31a4e74d-dab5-43dc-9953-b3beb6db9150 +:END: Resume clocking when emacs restarts, save&load running clock and history on exit/startup, resume last task on clock-in if clock is open, resume active clock without prompt, include current clocking task in reports, and make the clocktable look nice. #+BEGIN_SRC emacs-lisp (org-clock-persistence-insinuate) @@ -603,6 +821,9 @@ Resume clocking when emacs restarts, save&load running clock and history on exit #+END_SRC *** Templates +:PROPERTIES: +:ID: ab7c773c-5a03-4c7b-be8a-318f2b3fd0db +:END: Capture Templates per my proclivities. #+BEGIN_SRC emacs-lisp (setq org-capture-templates '(("n" "Note" entry (file org-default-notes-file) @@ -614,7 +835,7 @@ Capture Templates per my proclivities. :clock-in t :clock-resume t) ("m" "Meeting" entry (file+olp+datetree org-journal-file) - "* %? :meeting:%^g \n%t\n** Attendees\n*** \n** Notes\n** Action Items\n*** TODO " + "* %? :meeting:%^g \n%t\n** Notes\n** Action Items\n*** TODO " :clock-in t :clock-resume t) ("a" "Appointment" entry (file+olp+datetree org-journal-file) @@ -625,7 +846,13 @@ Capture Templates per my proclivities. #+END_SRC *** Abbreviations & Snippets +:PROPERTIES: +:ID: d4d9cdef-583a-4fad-9cb2-17a80e093374 +:END: **** Abbrev-Mode settings +:PROPERTIES: +:ID: ce23e846-972f-46c7-b7a6-b313b4149e79 +:END: Start up =abbrev-mode= for org #+BEGIN_SRC emacs-lisp (add-hook 'org-mode-hook #'abbrev-mode) @@ -634,7 +861,13 @@ Start up =abbrev-mode= for org #+END_SRC **** Skeletons +:PROPERTIES: +:ID: fffe9361-bae6-4ceb-8a71-5d06e711528d +:END: ***** Emacs Lisp source Block +:PROPERTIES: +:ID: eb47039c-d264-4a61-8da8-7659cbc02b62 +:END: #+BEGIN_SRC emacs-lisp (define-skeleton skel-org-block-elisp "Insert an org emacs lisp block" @@ -645,6 +878,9 @@ Start up =abbrev-mode= for org #+END_SRC ***** Facility properties block +:PROPERTIES: +:ID: 30630b60-66ca-40ed-a30b-9a95a2be7c70 +:END: #+BEGIN_SRC emacs-lisp (define-skeleton skel-facility-properties "Insert the org title and filetags for a new facility." @@ -659,6 +895,9 @@ Start up =abbrev-mode= for org #+END_SRC ***** Person properties block +:PROPERTIES: +:ID: 0e57ecbf-b0f5-4f7c-ad1d-d3ef69cb7581 +:END: #+BEGIN_SRC emacs-lisp (define-skeleton skel-person-properties "Insert the org title and filetags for a person." @@ -672,6 +911,9 @@ Start up =abbrev-mode= for org #+END_SRC ***** Workorder properties block +:PROPERTIES: +:ID: a0062c3f-caf0-4de4-9d95-0dffc04eba31 +:END: #+BEGIN_SRC emacs-lisp (define-skeleton skel-workorder-properties "Insert the org title and filetags for a workorder" @@ -682,6 +924,9 @@ Start up =abbrev-mode= for org #+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 @@ -690,11 +935,13 @@ Superceded by [[*Templates][Meeting Capture Template]] ;; "#+TITLE: " ;; _ - ;; " Meeting\n" -;; "#+FILETAGS: meeting date customer city state attend -ees topics\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 +:END: #+BEGIN_SRC emacs-lisp :tangle ./abbrev_defs ;;-*-coding: utf-8;-*- (define-abbrev-table 'org-mode-abbrev-table @@ -706,6 +953,9 @@ ees topics\n") #+END_SRC *** Auto-archive +:PROPERTIES: +:ID: f1e0b6cf-023f-44e3-a489-15fa04208cd3 +: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) -*- @@ -730,8 +980,47 @@ Also add that defun to =safe-local-variables= so that emacs will run it. (setq safe-local-variable-values '((after-save-hook org-auto-archive))) #+END_SRC +*** Auto-Generate IDs +:PROPERTIES: +:ID: f2660fb6-f995-4b5b-a01c-6bf8b5d9c894 +:END: +**** On Capture +:PROPERTIES: +:ID: b40f11e3-8569-4fcd-b083-f1b682f23dc1 +:END: +Generate an ID when I capture someting, and when I try to link to it. Stolen from [[https://stackoverflow.com/questions/13340616/assign-ids-to-every-entry-in-org-mode][Stack Overflow]] +#+BEGIN_SRC emacs-lisp +(setq org-id-link-to-org-use-id t) +#+END_SRC + +**** Existing File +:PROPERTIES: +:ID: 4120cfb4-59d5-441d-abaa-b49f847f5b90 +: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 () + "Add ID properties to all headlines in the current + file which do not already have one." + (interactive) + (org-map-entries 'org-id-get-create)) +#+END_SRC + +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))) +#+END_SRC + *** Tangling +:PROPERTIES: +:ID: f0c4710a-0172-41bc-9744-4fd48872d4a2 +:END: **** Settings +:PROPERTIES: +:ID: 3d8f6700-07a2-4e1e-b3c7-7d77afdcf85c +:END: Don't make a new window for source-code edits, and keep indentation consistent. #+BEGIN_SRC emacs-lisp (setq org-src-window-setup 'current-window @@ -740,6 +1029,9 @@ Don't make a new window for source-code edits, and keep indentation consistent. #+END_SRC **** Auto-tangle init.org +:PROPERTIES: +:ID: cd914118-d6e7-485d-b27e-3172f3b77af9 +:END: Make a function to tangle this file, and run it on save. #+BEGIN_SRC emacs-lisp (defun tangle-init () @@ -754,6 +1046,9 @@ Stolen from https://github.com/larstvei/dot-emacs." #+END_SRC ** Dired configuration +:PROPERTIES: +:ID: 245c157b-036f-4489-b221-193691a7f94b +:END: Make dired use the same switches I prefer for =ls=, give me a simpler listing, and default to using its current buffer for visiting a file, rather than creating a new one. #+BEGIN_SRC emacs-lisp (setq dired-listing-switches "-alv --group-directories-first") @@ -766,13 +1061,22 @@ Make dired use the same switches I prefer for =ls=, give me a simpler listing, a #+END_SRC ** Eshell configuration +:PROPERTIES: +:ID: 700392e5-d07b-474f-baa9-f563b4a6197f +:END: Here are the various customizations I have for eshell. *** Binding to start eshell +:PROPERTIES: +:ID: 9178eac2-5f69-4574-ae47-b491374f643f +:END: #+BEGIN_SRC emacs-lisp (keymap-global-set "C-c s" 'eshell) #+END_SRC *** Make it play nice with corfu +:PROPERTIES: +:ID: dc7f2345-2ee3-4883-90ff-b0a8c25c9422 +:END: #+BEGIN_SRC emacs-lisp (add-hook 'eshell-mode-hook (lambda () @@ -781,6 +1085,9 @@ Here are the various customizations I have for eshell. #+END_SRC *** Send on Close-Paren +:PROPERTIES: +:ID: 325c01c5-b877-4281-adff-ea956bdb5f2c +: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. #+BEGIN_SRC emacs-lisp @@ -794,6 +1101,9 @@ Makes a closing paren execute the sexp." #+END_SRC *** Quit or delete-char +:PROPERTIES: +:ID: ed19265d-4b5c-426b-8c74-cf36939a8b8f +:END: I want =C-d= to end the shell if it is on an empty line, otherwise act normally. #+BEGIN_SRC emacs-lisp @@ -807,6 +1117,9 @@ Stolen from https://depp.brause.cc/dotemacs" #+END_SRC *** Bind the defuns +:PROPERTIES: +:ID: eac8b87a-0ca9-4d0f-8cd4-1d1538ec16d0 +:END: I have only been able to get these to work when they are within an add-hook lambda. #+BEGIN_SRC emacs-lisp @@ -816,8 +1129,14 @@ I have only been able to get these to work when they are within an add-hook lamb (keymap-set eshell-mode-map "C-d" 'eshell-quit-or-delete-char))) #+END_SRC ** ielm configuration +:PROPERTIES: +:ID: e7a7b861-8f63-4036-9f68-59fb954a7561 +:END: I wanted something more like a standard lisp REPL in emacs. Found =ielm=. *** Send on Close-Paren +:PROPERTIES: +:ID: 664ba0e7-0826-4868-9480-e1338a6e9f63 +: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. #+BEGIN_SRC emacs-lisp @@ -830,7 +1149,13 @@ Makes a closing paren execute the sexp." (ielm-send-input))) #+END_SRC *** Persistent command history +:PROPERTIES: +:ID: 19726597-2a2e-4059-9447-d7e90696fe08 +:END: **** Read History +:PROPERTIES: +:ID: 6db9d990-00e7-44ec-a83c-b2999fa8db73 +:END: #+BEGIN_SRC emacs-lisp (defun g-ielm-init-history () "Stolen from https://n16f.net/blog/making-ielm-more-comfortable." @@ -844,6 +1169,9 @@ Makes a closing paren execute the sexp." (add-hook 'ielm-mode-hook 'g-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) "Stolen from https://n16f.net/blog/making-ielm-more-comfortable." @@ -853,6 +1181,9 @@ Makes a closing paren execute the sexp." (advice-add 'ielm-send-input :after 'g-ielm-write-history) #+END_SRC *** Bindings +:PROPERTIES: +:ID: 68c34ab5-7149-49f5-91e8-fcea22d98fcd +:END: #+BEGIN_SRC emacs-lisp (keymap-global-set "C-c i" 'ielm) (add-hook 'ielm-mode-hook @@ -861,12 +1192,21 @@ Makes a closing paren execute the sexp." (keymap-set inferior-emacs-lisp-mode-map ")" 'ielm-send-on-close-paren))) #+END_SRC ** Defuns and Bindings +:PROPERTIES: +:ID: c9362b6e-5e89-4d4c-b358-58236816f698 +:END: I have quite a few math and work-related defuns, and fewer editing ones. Inversely, I have more editing related bindings than work-related ones. This makes sense, considering my usage patterns. *** Editing +:PROPERTIES: +:ID: e235c02e-dfdd-41c3-93ec-42f44594488f +:END: Most of these are to re-create something from vim/readline/sam/acme. Some are just helper functions or wrappers. **** Visiting Files +:PROPERTIES: +:ID: 9f4775e4-6c76-46d6-b4e0-7dbce717907a +:END: 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) @@ -874,12 +1214,18 @@ Bind =find-file-at-point= and =bookmark-jump-other-window=. #+END_SRC **** Undo/redo +:PROPERTIES: +:ID: da7cd3d7-1b85-48d3-8f68-e6b496e184ea +:END: 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 **** Renaming Files +:PROPERTIES: +:ID: 11b46ac1-befc-4920-8672-24a01333ca1f +:END: I took this from [[https://whattheemacsd.com][whattheemacsd.com]]. It is occasionally handy. #+BEGIN_SRC emacs-lisp (defun rename-current-buffer-file () @@ -902,6 +1248,9 @@ 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 +:PROPERTIES: +:ID: 485c4ac3-839f-4289-a4c9-43da1a3ae048 +:END: Usually I want the buffer menu in the same window I am already on. Occasionally I want it in a different window. Bind accordingly. #+BEGIN_SRC emacs-lisp (keymap-global-set "C-x C-b" 'buffer-menu) @@ -921,6 +1270,9 @@ I often want to bring up the scratch buffer in my current window, and sometimes #+END_SRC **** Line joining +: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=. #+BEGIN_SRC emacs-lisp (defun backward-join-line () @@ -932,6 +1284,9 @@ The =M-^= binding is handy, but usually I want the ed/sam/vi join function, whic #+END_SRC **** Line opening +:PROPERTIES: +:ID: fb7d3259-0e5c-4330-9da9-14c5c1f051e8 +:END: 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 @@ -959,6 +1314,9 @@ I Bind the previous functions to =C-o= and =M-o=. #+END_SRC **** Commenting +:PROPERTIES: +:ID: eb1fa08e-66f0-4620-9e93-eed42fe770b7 +: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 () @@ -974,19 +1332,31 @@ Stolen from https://depp.brause.cc/dotemacs" #+END_SRC **** Killing +:PROPERTIES: +:ID: 4b90fe0e-ffe5-4aca-b46b-9fd9980bda69 +:END: ***** Kill Whole Line +:PROPERTIES: +:ID: ed167953-3a6c-4dce-9045-372c6c73cd00 +:END: Bind =kill-whole-line= to =C-S-K= for something somewhat pnemonic. #+BEGIN_SRC emacs-lisp (keymap-global-set "C-S-K" 'kill-whole-line) #+END_SRC ***** Zap up to char +:PROPERTIES: +:ID: 44c6ede5-89a0-496c-9a1f-d0d1e69ad727 +:END: Bind =C-z= to zap-up-to-char, sice zap-to-char is on =M-z=. #+BEGIN_SRC emacs-lisp (keymap-global-set "C-z" 'zap-up-to-char) #+END_SRC ***** UNIX C-w and C-u +:PROPERTIES: +: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...]] I didn't want to re-bind =C-w= away from =kill-region=, so I made it do both. @@ -1020,13 +1390,22 @@ Since =C-u= is =universal-argument=, I put that functionality on =M-'=. #+END_SRC **** Moving +:PROPERTIES: +:ID: e8c8fd42-e96a-4804-8ce0-6e3ab4d9233d +:END: ***** Home/End +:PROPERTIES: +:ID: 9f81584b-4ce1-48ff-b69f-b0bab2c1d0c5 +:END: I want =Home= and =End= to take me to the top and bottom of the file. #+BEGIN_SRC emacs-lisp (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: I have the infamous =smart-beginning-of-line= command here. #+BEGIN_SRC emacs-lisp (defun smart-beginning-of-line () @@ -1065,6 +1444,9 @@ Remap =move-beginning-of-line=, then remap =beginning-of-visual-line= when going (keymap-global-set "C-a" 'smart-beginning-of-visual-line))) #+END_SRC ***** Line Numbers on move only +:PROPERTIES: +:ID: 2a73fd23-0869-4d5b-b727-8fa2486dc99b +: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 () @@ -1077,6 +1459,9 @@ I don't want line numbers in the margin unless I am actively trying to go to a l (global-set-key [remap goto-line] 'my-goto-line) #+END_SRC ***** Other window or split window +: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. #+BEGIN_SRC emacs-lisp (defun other-window-or-split-window (&optional window) @@ -1088,6 +1473,9 @@ I ripped this defun and binding from [[https://github.com/lem-project/lem][lem]] (keymap-global-set "C-M-o" 'other-window-or-split-window) #+END_SRC **** Search and Replace +:PROPERTIES: +:ID: 32daa74b-39b2-4275-bd88-55e9f9d0ffb5 +:END: I made these bindings to put my more-used commands on better keys, and swap them with the less-used ones. #+BEGIN_SRC emacs-lisp (keymap-global-set "M-s ." 'isearch-forward-thing-at-point) @@ -1101,12 +1489,18 @@ I made these bindings to put my more-used commands on better keys, and swap them #+END_SRC *** Elisp/Eval bindings +:PROPERTIES: +:ID: 05c8bf80-e35f-49bc-97b0-b6caccb63ab6 +:END: Some old Emacs-like editor (Edwin?) used this binding, so I put it in here. Less used than the =C-M-x= =eval-defun= binding, but occasionally nice to have. #+BEGIN_SRC emacs-lisp (keymap-global-set "C-M-z" 'eval-region) #+END_SRC *** *NIX +:PROPERTIES: +:ID: ecfe90a8-05d6-468b-b82a-5558c4a226c1 +: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) @@ -1128,6 +1522,9 @@ These defuns are here so that I can use doas/sudo over tramp to edit /local/ fil #+END_SRC *** Windows +:PROPERTIES: +:ID: 857da290-c22e-4e38-a427-714527cf392f +:END: 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) @@ -1142,6 +1539,9 @@ Use this when aveva can't find ass with both hands." #+END_SRC *** Math +:PROPERTIES: +:ID: 69a05305-6b16-4abf-bf9a-b858d9a7e642 +:END: General Math defuns, often used in later defuns. I'm tired of writing out ='expt=, and I want to use the same notation every other programming language does. @@ -1165,6 +1565,9 @@ Define square, cube, and inv for brevity of common usages. #+END_SRC *** Unit Conversions +:PROPERTIES: +:ID: d756d65e-aca5-4718-af09-aaecbbd62f99 +:END: The rest of the world decided to self-castrate because some French guys told them things Definitely Made More Sense if everything was divisible by 10. I'm convinced the average Frenchman simply couldn't grasp fractions, and that's why he came up with this crap. What's 1/3 of a meter? What's 1/3 of a yard? And 1/3 of a foot? How likely are you to need to divide a measurement by 3 when you're building something? Maybe the [[https://dozenal.org/][Dozenal]] people were right all along. Anyway, I'm now forced to convert into proper units daily because of this grave error. #+BEGIN_SRC emacs-lisp @@ -1204,6 +1607,9 @@ Applies `c->k' to `f->c'." #+END_SRC *** Electrical +:PROPERTIES: +:ID: 8c0d72bc-b8ba-4f9f-be49-876bd624c2ae +:END: These defuns are all about electronics. Effective impedance, amps to volts, and back again. #+BEGIN_SRC emacs-lisp (defun eff-imp (r1 &optional r2) @@ -1229,6 +1635,9 @@ Divides the voltage by the effective impedance calculated with #+END_SRC *** PLC +:PROPERTIES: +:ID: 850536ef-64b6-44d6-9b64-61d2a4ed050a +:END: The nitty-gritty. These defuns build on the previous ones to help me do various calculations related to analog signals and how they interact with [[https://en.wikipedia.org/wiki/Programmable_logic_controller][PLCs]], also called PACs. Counts, volts, amps, bit-resolutions, and relating them to each other. #+BEGIN_SRC emacs-lisp (defun max-counts (resolution) @@ -1285,6 +1694,9 @@ calculate `amps->counts'. Otherwise ignore r1/r2 and calculate #+END_SRC *** Refrigeration +:PROPERTIES: +:ID: 18225f24-139e-4707-8935-03a6cf48290a +:END: More nitty-gritty. These are for calculating specific refrigeration-related things. Somewhat specialized. #+BEGIN_SRC emacs-lisp (defun cfm-circ (fpm radius) @@ -1317,6 +1729,9 @@ lb of air." #+END_SRC ** Customize system +:PROPERTIES: +:ID: 2fb88065-0c84-4b55-8c5a-59d78a15b134 +:END: I do not use the customize system. I don't want to see it if I don't have to. #+BEGIN_SRC emacs-lisp (setq custom-file (expand-file-name "custom.el" user-emacs-directory)) @@ -1327,6 +1742,9 @@ I do not use the customize system. I don't want to see it if I don't have to. #+END_SRC ** Footer +:PROPERTIES: +:ID: 812ba715-1cfe-4f36-baac-71936332b474 +:END: #+BEGIN_SRC emacs-lisp ;;; hic terminatur init.el