]> git.earman.xyz Git - emacsinit.git/commitdiff
Add centered-cursor-mode
authorrearman <rearman@r717.net>
Mon, 8 Apr 2024 16:41:59 +0000 (12:41 -0400)
committerrearman <rearman@r717.net>
Mon, 8 Apr 2024 16:41:59 +0000 (12:41 -0400)
init.org

index 70690711ac61b905b0c1b2178dfa877ddf0da88d..2d8b7dbc41bad0f142cef5c50866c1ebdaf94863 100644 (file)
--- a/init.org
+++ b/init.org
@@ -64,7 +64,7 @@ Set the GC threshold to max during startup, then set it back to a value that is
       gc-cons-percentage 0.6)
 
 (add-hook 'after-init-hook #'(lambda () (setq gc-cons-threshold (* 1024 1024 25)
-                                        gc-cons-percentage 0.1)))
+                                         gc-cons-percentage 0.1)))
 #+END_SRC
 
 ** Basic UI preferences
@@ -87,7 +87,7 @@ I am no longer using the default theme, so that config is no longer here, but [[
 
 #+BEGIN_SRC emacs-lisp :tangle ./early-init.el
 (setq default-frame-alist '((fullscreen . maximized)
-                           (vertical-scroll-bars . nil)))
+                            (vertical-scroll-bars . nil)))
 #+END_SRC
 
 ** Misc/odd issues
@@ -232,15 +232,15 @@ I need to open binary files with their own editor.  Disgusting.
   (openwith-mode t))
 
 (setq openwith-associations (list
-                            (list (openwith-make-extension-regexp
-                                   '("xls" "xlsx" "doc" "docx"
-                                     "ppt" "odt" "ods" "odg" "odp"))
-                                  "LibreOffice"
-                                  '(file))
-                            (list (openwith-make-extension-regexp
-                                   '("adpro"))
-                                  "ProductivitySuite"
-                                  '(file))))
+                             (list (openwith-make-extension-regexp
+                                    '("xls" "xlsx" "doc" "docx"
+                                      "ppt" "odt" "ods" "odg" "odp"))
+                                   "LibreOffice"
+                                   '(file))
+                             (list (openwith-make-extension-regexp
+                                    '("adpro"))
+                                   "ProductivitySuite"
+                                   '(file))))
 #+END_SRC
 
 *** org-transclusion
@@ -250,7 +250,7 @@ Awesome package - adds transclusions, don't know how similar to Xanadu it is, bu
 (use-package org-transclusion
   :ensure t
   :bind (("<f12>" . org-transclusion-add)
-        ("C-c n t" . org-transclusion-mode)))
+         ("C-c n t" . org-transclusion-mode)))
 #+END_SRC
 
 *** acme-mouse
@@ -267,6 +267,20 @@ Starting to do some work with LaTeX, surprised this is not in base, but org is.
   :defer t)
 #+END_SRC
 
+*** centered-cursor-mode
+Trying out the (veritcally) centered cursor, heard about it on [[gemini://gem.librehacker.com/gemlog/starlog/20240228-0.gmi][gemini]]
+#+BEGIN_SRC emacs-lisp
+(use-package centered-cursor-mode
+  :ensure t
+  :custom
+  (ccm-recenter-at-end-of-file t)
+  (ccm-step-delay 0)
+  :config
+  (global-centered-cursor-mode t))
+
+#+END_SRC
+
+
 ** Non-Package customization
 This section has '/base/' emacs customization.  All the general stuff.
 
@@ -277,9 +291,9 @@ I want these things every time, or at least setting them this way worked when a
 
 #+BEGIN_SRC emacs-lisp
 (setq-default indicate-empty-lines t
-             fill-column 80
-             cursor-type 'bar
-             cursor-in-non-selected-windows 'hollow)
+              fill-column 80
+              cursor-type 'bar
+              cursor-in-non-selected-windows 'hollow)
 #+END_SRC
 
 *** Backup/Autosave
@@ -387,11 +401,11 @@ Highlight current line in all buffers, even if inactive.
 I want nice symbols to look at
 #+BEGIN_SRC emacs-lisp
 (setq prettify-symbols-alist '(("lambda" . 955)
-                              ("delta" . 120517)
-                              ("epsilon" . 120518)
-                              ("->" . 8594)
-                              ("<=" . 8804)
-                              (">=" . 8805)))
+                               ("delta" . 120517)
+                               ("epsilon" . 120518)
+                               ("->" . 8594)
+                               ("<=" . 8804)
+                               (">=" . 8805)))
 (global-prettify-symbols-mode t)
 #+END_SRC
 
@@ -409,8 +423,8 @@ Make the paren "highlight" the same color as the background, and add underline.
 
 #+BEGIN_SRC emacs-lisp
 (set-face-attribute 'show-paren-match nil
-                   :background 'unspecified
-                   :underline t)
+                    :background 'unspecified
+                    :underline t)
 #+END_SRC
 
 *** Modeline
@@ -431,29 +445,29 @@ Please use Tabs in C files, I'm BEGGING.  Absolutely ridiculous that there's no
 (defun 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))
-        (offset (- (1+ column) anchor))
-        (steps (floor offset c-basic-offset)))
+         (column (c-langelem-2nd-pos c-syntactic-element))
+         (offset (- (1+ column) anchor))
+         (steps (floor offset c-basic-offset)))
     (* (max steps 1)
        c-basic-offset)))
 
 (add-hook 'c-mode-common-hook
-         (lambda ()
-           ;; Add kernel style
-           (c-add-style
-            "linux-tabs-only"
-            '("linux"
-              (c-offsets-alist
-               (arglist-cont-nonempty
-                c-lineup-gcc-asm-reg
-                c-lineup-arglist-tabs-only))))))
+          (lambda ()
+            ;; Add kernel style
+            (c-add-style
+             "linux-tabs-only"
+             '("linux"
+               (c-offsets-alist
+                (arglist-cont-nonempty
+                 c-lineup-gcc-asm-reg
+                 c-lineup-arglist-tabs-only))))))
 
 (add-hook 'c-mode-hook
-         (lambda ()
-           (setq indent-tabs-mode t)
-           (setq show-trailing-whitespace t)
-           (setq c-backspace-function 'backward-delete-char) ;; don't expand my tabs, just delete them.
-           (c-set-style "linux-tabs-only")))
+          (lambda ()
+            (setq indent-tabs-mode t)
+            (setq show-trailing-whitespace t)
+            (setq c-backspace-function 'backward-delete-char) ;; don't expand my tabs, just delete them.
+            (c-set-style "linux-tabs-only")))
 #+END_SRC
 
 *** Windows-Specific
@@ -461,10 +475,10 @@ Use =recycle bin=, DON'T use =AltGr=, and tell emacs where =diff= is.
 #+BEGIN_SRC emacs-lisp
 (when (equal system-type 'windows-nt)
   (setq delete-by-moving-to-trash t
-       ediff-diff-program "\"c:/Program Files/Git/usr/bin/diff.exe\""
-       ediff-diff3-program "\"c:/Program Files/Git/usr/bin/diff3.exe\""
-       diff-command "\"c:/Program Files/Git/usr/bin/diff.exe\""
-       w32-recognize-altgr 'nil))
+        ediff-diff-program "\"c:/Program Files/Git/usr/bin/diff.exe\""
+        ediff-diff3-program "\"c:/Program Files/Git/usr/bin/diff3.exe\""
+        diff-command "\"c:/Program Files/Git/usr/bin/diff.exe\""
+        w32-recognize-altgr 'nil))
 #+END_SRC
 
 ** org configuration
@@ -522,7 +536,7 @@ Tell org where everything is
 Let me refile anywhere, use outline paths, confirm when creating parent nodes.
 #+BEGIN_SRC emacs-lisp
 (setq org-refile-targets '((nil :maxlevel . 9)
-                          (org-agenda-files :maxlevel . 9))
+                           (org-agenda-files :maxlevel . 9))
       org-refile-use-outline-path 'file
       org-refile-allow-creating-parent-nodes '(confirm))
 #+END_SRC
@@ -531,49 +545,49 @@ Let me refile anywhere, use outline paths, confirm when creating parent nodes.
 Set up some more todo keywords
 #+BEGIN_SRC emacs-lisp
 (setq org-todo-keywords '((sequence "TODO(t)"
-                                   "WAITING(w@/!)"
-                                   "IN-PROGRESS(i!)"
-                                   "APPT(a!)"
-                                   "|"
-                                   "DELEGATED(l@)"
-                                   "DONE(d!/@)"
-                                   "CANCELLED(c@)")))
+                                    "WAITING(w@/!)"
+                                    "IN-PROGRESS(i!)"
+                                    "APPT(a!)"
+                                    "|"
+                                    "DELEGATED(l@)"
+                                    "DONE(d!/@)"
+                                    "CANCELLED(c@)")))
 #+END_SRC
 
 Set up the agenda view. Access it with =C-c a SPC=.
 #+BEGIN_SRC emacs-lisp
 (setq org-agenda-custom-commands '((" " "Agenda"
-                                   ((agenda "" nil)
-                                    (todo "APPT"
-                                          ((org-agenda-overriding-header "Appointments")))
-                                    (tags "need"
-                                          ((org-agenda-overriding-header "Needed Items")))
-                                    (tags "REFILE"
-                                          ((org-agenda-overriding-header "Tasks to Refile")))
-                                    (tags-todo "TODO=\"IN-PROGRESS\"-REFILE"
-                                          ((org-agenda-overriding-header "In Progress")))
-                                    (tags-todo "TODO=\"WAITING\"-REFILE"
-                                          ((org-agenda-overriding-header "Halted")))
-                                    (tags-todo "-TODO=\"WAITING\"-TODO=\"IN-PROGRESS\"-REFILE-JOURNAL"
-                                          ((org-agenda-overriding-header "Filed Tasks")))))))
+                                    ((agenda "" nil)
+                                     (todo "APPT"
+                                           ((org-agenda-overriding-header "Appointments")))
+                                     (tags "need"
+                                           ((org-agenda-overriding-header "Needed Items")))
+                                     (tags "REFILE"
+                                           ((org-agenda-overriding-header "Tasks to Refile")))
+                                     (tags-todo "TODO=\"IN-PROGRESS\"-REFILE"
+                                           ((org-agenda-overriding-header "In Progress")))
+                                     (tags-todo "TODO=\"WAITING\"-REFILE"
+                                           ((org-agenda-overriding-header "Halted")))
+                                     (tags-todo "-TODO=\"WAITING\"-TODO=\"IN-PROGRESS\"-REFILE-JOURNAL"
+                                           ((org-agenda-overriding-header "Filed Tasks")))))))
 #+END_SRC
 
 Tag filtering
 #+BEGIN_SRC emacs-lisp
 (setq org-tag-alist '((:startgroup . nil)
-                      ("@errand" . ?e)
-                      ("@office" . ?o)
-                      ("need" . ?n)
-                      (:endgroup . nil)))
+                       ("@errand" . ?e)
+                       ("@office" . ?o)
+                       ("need" . ?n)
+                       (:endgroup . nil)))
 #+END_SRC
 
 *** Templates
 Capture Templates per my proclivities.
 #+BEGIN_SRC emacs-lisp
 (setq org-capture-templates '(("n" "Note" entry (file org-default-notes-file) "* %u %?")
-                             ("t" "TODO" entry (file org-default-notes-file) "* TODO %?\n%U\n")
-                             ("a" "Appointment" entry (file+olp+datetree org-journal-file) "* APPT %?\nSCHEDULED: %t" :time-prompt t)
-                             ("j" "Journal" entry (file+olp+datetree org-journal-file) "* %?\n%U\n")))
+                              ("t" "TODO" entry (file org-default-notes-file) "* TODO %?\n%U\n")
+                              ("a" "Appointment" entry (file+olp+datetree org-journal-file) "* APPT %?\nSCHEDULED: %t" :time-prompt t)
+                              ("j" "Journal" entry (file+olp+datetree org-journal-file) "* %?\n%U\n")))
 #+END_SRC
 
 *** Abbreviations + Snippets
@@ -691,7 +705,7 @@ Make a function to tangle this file, and run it on save.
   "Tangle and compile init.org.
 Stolen from https://github.com/larstvei/dot-emacs."
   (when (equal (buffer-file-name)
-              (expand-file-name (concat user-emacs-directory "init.org")))
+               (expand-file-name (concat user-emacs-directory "init.org")))
     (let ((prog-mode-hook nil))
       (org-babel-tangle))))
 
@@ -702,9 +716,9 @@ Stolen from https://github.com/larstvei/dot-emacs."
 For some reason, the org people decided that =verbatim= doesn't actually mean =verbatim=!  This attempts to fix that.  I found this solution at [[https://emacs.stackexchange.com/questions/13820/inline-verbatim-and-code-with-quotes-in-org-mode][stackexchange]].
 #+BEGIN_SRC emacs-lisp
 (eval-after-load "org" '(lambda ()
-                         (setcar (nthcdr 2 org-emphasis-regexp-components) " \t\r\n,")
-                         (org-set-emph-re 'org-emphasis-regexp-components org-emphasis-regexp-components)
-                         (org-element--set-regexps)))
+                          (setcar (nthcdr 2 org-emphasis-regexp-components) " \t\r\n,")
+                          (org-set-emph-re 'org-emphasis-regexp-components org-emphasis-regexp-components)
+                          (org-element--set-regexps)))
 #+END_SRC
 
 *** File Opening
@@ -712,10 +726,10 @@ Don't open links in another window, just use the current one
 
 #+BEGIN_SRC emacs-lisp
 (setq org-link-frame-setup '((vm . vm-visit-folder-other-frame)
-                            (vm-imap . vm-visit-imap-folder-other-frame)
-                            (gnus . org-gnus-no-new-news)
-                            (file . find-file)
-                            (wl . wl-other-frame)))
+                             (vm-imap . vm-visit-imap-folder-other-frame)
+                             (gnus . org-gnus-no-new-news)
+                             (file . find-file)
+                             (wl . wl-other-frame)))
 #+END_SRC
 ** Dired configuration
 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.
@@ -723,10 +737,10 @@ Make dired use the same switches I prefer for =ls=, give me a simpler listing, a
 (setq dired-listing-switches "-alv --group-directories-first")
 
 (add-hook 'dired-mode-hook
-         (lambda ()
-           (dired-hide-details-mode t)
-           (keymap-set dired-mode-map
-             "RET" 'dired-find-alternate-file)))
+          (lambda ()
+            (dired-hide-details-mode t)
+            (keymap-set dired-mode-map
+              "RET" 'dired-find-alternate-file)))
 #+END_SRC
 
 ** Eshell configuration
@@ -741,8 +755,8 @@ Here are the various customizations I have for eshell.
 
 #+BEGIN_SRC emacs-lisp
 (add-hook 'eshell-mode-hook (lambda ()
-                             (setq-local corfu-auto nil)
-                             (corfu-mode)))
+                              (setq-local corfu-auto nil)
+                              (corfu-mode)))
 #+END_SRC
 
 *** Send on Close-Paren
@@ -755,7 +769,7 @@ Makes a closing paren execute the sexp."
   (interactive)
   (insert-char ?\))
   (when (= 0 (car (syntax-ppss)))
-        (eshell-send-input)))
+         (eshell-send-input)))
 #+END_SRC
 
 *** Quit or delete-char
@@ -776,9 +790,9 @@ 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 "C-d" 'eshell-quit-or-delete-char)))
+          (lambda ()
+            (keymap-set eshell-mode-map ")" 'eshell-send-on-close-paren)
+            (keymap-set eshell-mode-map "C-d" 'eshell-quit-or-delete-char)))
 #+END_SRC
 
 ** Defuns and Bindings
@@ -807,18 +821,18 @@ I took this from [[https://whattheemacsd.com][whattheemacsd.com]].  It is occasi
   "Renames the current buffer and the file it is visiting."
   (interactive)
   (let ((name (buffer-name))
-       (filename (buffer-file-name)))
+        (filename (buffer-file-name)))
     (if (not (and filename (file-exists-p filename)))
-       (error "Buffer '%s' is not visiting a file!" name)
+        (error "Buffer '%s' is not visiting a file!" name)
       (let ((new-name (read-file-name "New name: " filename)))
-       (if (get-buffer new-name)
-           (error "A buffer named '%s' already exists!" new-name)
-         (rename-file filename new-name 1)
-         (rename-buffer new-name)
-         (set-visited-file-name new-name)
-         (set-buffer-modified-p nil)
-         (message "File '%s' successfully renamed to '%s'"
-                  name (file-name-nondirectory new-name)))))))
+        (if (get-buffer new-name)
+            (error "A buffer named '%s' already exists!" new-name)
+          (rename-file filename new-name 1)
+          (rename-buffer new-name)
+          (set-visited-file-name new-name)
+          (set-buffer-modified-p nil)
+          (message "File '%s' successfully renamed to '%s'"
+                   name (file-name-nondirectory new-name)))))))
 
 (keymap-global-set "C-x C-r" 'rename-current-buffer-file)
 #+END_SRC
@@ -889,7 +903,7 @@ Stolen from https://depp.brause.cc/dotemacs"
   (if (use-region-p)
       (comment-or-uncomment-region (region-beginning) (region-end))
     (comment-or-uncomment-region (line-beginning-position)
-                                (line-end-position))))
+                                 (line-end-position))))
 
 (keymap-global-set "M-;" 'my-comment-dwim)
 #+END_SRC
@@ -956,7 +970,7 @@ line.  Stolen from BrettWitty's dotemacs github repo."
   (let ((oldpos (point)))
     (back-to-indentation)
     (and (= oldpos (point))
-        (beginning-of-line))))
+         (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=.
@@ -973,15 +987,15 @@ as a visual-line respecter."
     (skip-syntax-forward " " (line-end-position))
     (backward-prefix-chars)
     (and (= oldpos (point))
-        (beginning-of-visual-line))))
+         (beginning-of-visual-line))))
 #+END_SRC
 
 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)
 (add-hook 'visual-line-mode-hook
-         (lambda ()
-           (keymap-global-set "C-a" 'smart-beginning-of-visual-line)))
+          (lambda ()
+            (keymap-global-set "C-a" 'smart-beginning-of-visual-line)))
 #+END_SRC
 
 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.
@@ -1029,19 +1043,19 @@ These defuns are here so that I can use doas/sudo over tramp to edit /local/ fil
 (unless (equal system-type 'windows-nt)
   (if(equal system-type 'berkeley-unix)
       (defun doas ()
-       "Use TRAMP to reopen the current buffer as root using doas."
-       (interactive)
-       (when buffer-file-name
-         (find-alternate-file
-          (concat "/doas:root@localhost:"
-                  buffer-file-name))))
+        "Use TRAMP to reopen the current buffer as root using doas."
+        (interactive)
+        (when buffer-file-name
+          (find-alternate-file
+           (concat "/doas:root@localhost:"
+                   buffer-file-name))))
     (defun sudo ()
       "Use TRAMP to reopen the current buffer as root using sudo."
       (interactive)
       (when buffer-file-name
-       (find-alternate-file
-        (concat "/doas:root@localhost:"
-                buffer-file-name))))))
+        (find-alternate-file
+         (concat "/doas:root@localhost:"
+                 buffer-file-name))))))
 #+END_SRC
 
 *** Windows
@@ -1053,7 +1067,7 @@ If you've ever had the /pleasure/ of using Aveva (*Formerly WonderWare*) version
 Use this when aveva can't find ass with both hands."
     (interactive)
     (let ((xml1 "c:/ProgramData/AVEVA/Licensing/License API2/Data/LocalAcquireInfo.xml")
-         (xml2 "c:/ProgramData/AVEVA/Licensing/License API2/Data/LocalBackEndAcquireInfo.xml"))
+          (xml2 "c:/ProgramData/AVEVA/Licensing/License API2/Data/LocalBackEndAcquireInfo.xml"))
       (when (file-exists-p xml1) (delete-file xml1))
       (when (file-exists-p xml2) (delete-file xml2)))))
 #+END_SRC
@@ -1177,21 +1191,21 @@ current signal.  With a current signal, use r1 and maybe r2 to
 calculate `amps->counts'.  Otherwise ignore r1/r2 and calculate
 `volts->counts'."
   (cond ((or (equal 'v type)
-            (equal 'V type))
-        (list (volts->counts upper vmax resolution)
-              (volts->counts lower vmax resolution)))
-       ((or (equal 'i type)
-            (equal 'I type))
-        (list (amps->counts upper vmax resolution r1 r2)
-              (amps->counts lower vmax resolution r1 r2)))))
+             (equal 'V type))
+         (list (volts->counts upper vmax resolution)
+               (volts->counts lower vmax resolution)))
+        ((or (equal 'i type)
+             (equal 'I type))
+         (list (amps->counts upper vmax resolution r1 r2)
+               (amps->counts lower vmax resolution r1 r2)))))
 
 (defun scaleval (pmax pmin emax emin &optional ai)
   "Calculate the slope and offset given PLC Max/Min and Eng. Max/Min.
 With optional argument `ai', also calculate a final scaled value from an input."
   (let* ((div (/ (- pmax pmin) (- (float emax) (float emin))))
-        (ofst (- emin (/ pmin div))))
+         (ofst (- emin (/ pmin div))))
     (if (eq nil ai)
-       (list div ofst)
+        (list div ofst)
       (list div ofst (+ ofst (/ ai div))))))
 #+END_SRC
 
@@ -1214,16 +1228,16 @@ Inputs are temp (F) and humidity (%).  Returns a list of
 Saturated Water Pressure, Humidity Ratio, and Grains of water per
 lb of air."
   (let* ((sat-water-press (+ .0182795
-                            (* temp .001029904)
-                            (* (square temp) 0.00002579408)
-                            (* (cube temp) (* 2.400493 (^ 10 -7)))
-                            (* (^ temp 4) (* 8.100939 (^ 10 -10)))
-                            (* (^ temp 5) (* 3.256805 (^ 10 -11)))
-                            (* (^ temp 6) (* -1.001922 (^ 10 -13)))
-                            (* (^ temp 7) (* 2.44161 (^ 10 -16)))))
-        (hum-press (* (/ humidity 100.0) sat-water-press))
-        (hum-ratio (/ (* hum-press 0.62198) (- 14.7 hum-press)))
-        (gns-water-lb-air (* hum-ratio 7000)))
+                             (* temp .001029904)
+                             (* (square temp) 0.00002579408)
+                             (* (cube temp) (* 2.400493 (^ 10 -7)))
+                             (* (^ temp 4) (* 8.100939 (^ 10 -10)))
+                             (* (^ temp 5) (* 3.256805 (^ 10 -11)))
+                             (* (^ temp 6) (* -1.001922 (^ 10 -13)))
+                             (* (^ temp 7) (* 2.44161 (^ 10 -16)))))
+         (hum-press (* (/ humidity 100.0) sat-water-press))
+         (hum-ratio (/ (* hum-press 0.62198) (- 14.7 hum-press)))
+         (gns-water-lb-air (* hum-ratio 7000)))
     (list sat-water-press hum-ratio gns-water-lb-air)))
 #+END_SRC