* Load libraries
Libraries Not from the package manager
#+BEGIN_SRC emacs-lisp
- (dolist (path '("sedit-mouse/" "themes/"))
- (add-to-list 'load-path (concat user-emacs-directory path)))
+(dolist (path '("sedit-mouse/" "themes/"))
+ (add-to-list 'load-path (concat user-emacs-directory path)))
- (dolist (file '(eng-paper-theme sedit-mouse))
- (require file))
+(dolist (file '(eng-paper-theme sedit-mouse))
+ (require file))
#+END_SRC
* OS specific stuff
#+BEGIN_SRC emacs-lisp
- (setq w32-recognize-altgr 'nil)
-
- (unless (equal system-type 'windows-nt)
- (setq trash-directory "~/Trash/")
- (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))))
- (defun sudo ()
- "Use TRAMP to reopen the current buffer as root using sudo."
- (interactive)
- (when buffer-file-name
- (find-alternate-file (concat "/sudo:root@localhost:" buffer-file-name)))))
+(setq w32-recognize-altgr 'nil)
+
+(unless (equal system-type 'windows-nt)
+ (setq trash-directory "~/Trash/")
+ (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))))
+ (defun sudo ()
+ "Use TRAMP to reopen the current buffer as root using sudo."
+ (interactive)
+ (when buffer-file-name
+ (find-alternate-file (concat "/sudo:root@localhost:" buffer-file-name)))))
#+END_SRC
* Packages
(setq-default TeX-master nil)
(add-to-list 'TeX-view-program-selection '(output-pdf "PDF Tools"))
(setq TeX-auto-save t
- TeX-parse-self t
- TeX-PDF-mode t
- TeX-source-correlate-start-server t)
+ TeX-parse-self t
+ TeX-PDF-mode t
+ TeX-source-correlate-start-server t)
(add-hook 'TeX-after-compilation-finished-functions
- #'TeX-revert-document-buffer))
+ #'TeX-revert-document-buffer))
#+END_SRC
** CSV Mode
#+BEGIN_SRC emacs-lisp
(setq markdown-special-ctrl-a/e t)
:bind
(:map markdown-mode-map
- ("M-<right>" . markdown-demote)
- ("M-<left>" . markdown-promote)
- ("M-<up>" . markdown-move-up)
- ("M-<down>" . markdown-move-down)
- ("C-M-u" . markdown-up-heading)
- ("C-M-b" . markdown-outline-previous-same-level)
- ("C-M-f" . markdown-outline-next-same-level)
- ("C-M-p" . markdown-outline-previous)
- ("C-M-n" . markdown-outline-next)))
+ ("M-<right>" . markdown-demote)
+ ("M-<left>" . markdown-promote)
+ ("M-<up>" . markdown-move-up)
+ ("M-<down>" . markdown-move-down)
+ ("C-M-u" . markdown-up-heading)
+ ("C-M-b" . markdown-outline-previous-same-level)
+ ("C-M-f" . markdown-outline-next-same-level)
+ ("C-M-p" . markdown-outline-previous)
+ ("C-M-n" . markdown-outline-next)))
(use-package edit-indirect :after 'markdown-mode)
#+END_SRC
** Sly
#+BEGIN_SRC emacs-lisp
- (defun re/sly-repl-new-frame (&optional arg)
- "Start a SLY repl in a new frame."
- (interactive "P")
- (re/open-with-new-frame "SLY" #'sly))
+(defun re/sly-repl-new-frame (&optional arg)
+ "Start a SLY repl in a new frame."
+ (interactive "P")
+ (re/open-with-new-frame "SLY" #'sly))
- (defun re/sly-quit-current-lisp ()
- "Quit the current lisp repl connection without prompting."
- (interactive)
- (sly-quit-lisp nil nil))
+(defun re/sly-quit-current-lisp ()
+ "Quit the current lisp repl connection without prompting."
+ (interactive)
+ (sly-quit-lisp nil nil))
- (defun re/sly-connect-stump (&optional arg)
- "Connect to my typical stumpwm instance."
- (interactive "P")
- (sly-connect "localhost" 4004))
+(defun re/sly-connect-stump (&optional arg)
+ "Connect to my typical stumpwm instance."
+ (interactive "P")
+ (sly-connect "localhost" 4004))
- (use-package sly
- :config
- (setq inferior-lisp-program "sbcl"
- sly-net-coding-system 'utf-8-unix
- sly-command-switch-to-existing-lisp 'always)
- (let ((core (expand-file-name "~/sbcl.core-for-sly")))
- (when (file-exists-p core)
- (setq sly-lisp-implementations (list `(sbcl ("sbcl" "--core" ,core))))))
- :bind
- (:map sly-mrepl-mode-map
- (")" . (lambda () (interactive) (re/send-on-close-paren #'sly-mrepl-return)))
- ("]" . (lambda () (interactive) (re/balance-and-eval-sexp #'sly-mrepl-return)))
- ("C-c q" . re/sly-quit-current-lisp)))
+(use-package sly
+ :config
+ (setq inferior-lisp-program "sbcl"
+ sly-net-coding-system 'utf-8-unix
+ sly-command-switch-to-existing-lisp 'always)
+ (let ((core (expand-file-name "~/sbcl.core-for-sly")))
+ (when (file-exists-p core)
+ (setq sly-lisp-implementations (list `(sbcl ("sbcl" "--core" ,core))))))
+ :bind
+ (:map sly-mrepl-mode-map
+ (")" . (lambda () (interactive) (re/send-on-close-paren #'sly-mrepl-return)))
+ ("]" . (lambda () (interactive) (re/balance-and-eval-sexp #'sly-mrepl-return)))
+ ("C-c q" . re/sly-quit-current-lisp)))
#+END_SRC
*** Eldoc settings
Sly really doesn't play well with elodc in the minibuffer, so here are some settings to make it better.
#+BEGIN_SRC emacs-lisp
(add-to-list 'display-buffer-alist
- '("^\\*eldoc" display-buffer-in-direction
- (direction . 'down)
- (window-height . 4)))
+ '("^\\*eldoc" display-buffer-in-direction
+ (direction . 'down)
+ (window-height . 4)))
(keymap-global-set "C-c d" #'eldoc) ; force eldoc to show in minibuffer
(keymap-global-set "C-c D" #'eldoc-doc-buffer) ; open eldoc buffer when it's getting spammed
#+END_SRC
** Geiser
#+BEGIN_SRC emacs-lisp
- (use-package geiser
- :config
- (if (equal system-type 'windows-nt)
- (setq geiser-chicken-binary '("C:/tools/chicken/bin/csi.exe" "-:c"))
- (setq geiser-chicken-binary "csi -:c"))
- (setq scheme-program-name geiser-chicken-binary
- geiser-active-implementations '(chicken))
- (add-hook 'scheme-mode-hook 'geiser-mode)
- :bind
- (:map geiser-repl-mode-map
- (")" . (lambda () (interactive) (re/send-on-close-paren #'geiser-repl-maybe-send)))
- ("]" . (lambda () (interactive) (re/balance-and-eval-sexp #'geiser-repl-maybe-send)))))
-
- (use-package geiser-chicken :after 'geiser)
+(use-package geiser
+ :config
+ (if (equal system-type 'windows-nt)
+ (setq geiser-chicken-binary '("C:/tools/chicken/bin/csi.exe" "-:c"))
+ (setq geiser-chicken-binary "csi -:c"))
+ (setq scheme-program-name geiser-chicken-binary
+ geiser-active-implementations '(chicken))
+ (add-hook 'scheme-mode-hook 'geiser-mode)
+ :bind
+ (:map geiser-repl-mode-map
+ (")" . (lambda () (interactive) (re/send-on-close-paren #'geiser-repl-maybe-send)))
+ ("]" . (lambda () (interactive) (re/balance-and-eval-sexp #'geiser-repl-maybe-send)))))
+
+(use-package geiser-chicken :after 'geiser)
#+END_SRC
** Forth
*** TODO Try out this mode for gforth
** ORG
*** Load in the package and set bindings
#+BEGIN_SRC emacs-lisp
- (use-package org
- :config
- (require 'org-mouse)
- :bind
- (("C-c l" . org-store-link)
- ("C-c a" . org-agenda)
- ("C-c c" . org-capture)
- ("C-c b" . org-switchb)
- ("<f10>" . org-clock-out)
- ("<f2>" . org-clock-goto)
- :map org-mode-map
- ("M-<right>" . org-shiftmetaright)
- ("M-<left>" . org-shiftmetaleft)
- ("M-S-<right>" . org-metaright)
- ("M-S-<left>" . org-metaleft)
- ("C-M-h" . org-mark-subtree)
- ("C-M-u" . org-up-element)
- ("C-M-d" . org-down-element)
- ("C-M-b" . org-backward-heading-same-level)
- ("C-M-f" . org-forward-heading-same-level)
- ("C-M-p" . org-previous-visible-heading)
- ("C-M-n" . org-next-visible-heading)
- ("<f9>" . org-clock-in)))
-
- (use-package org-transclusion
- :after
- org
- :bind
- (("C-c t" . org-transclusion-mode)))
+(use-package org
+ :config
+ (require 'org-mouse)
+ :bind
+ (("C-c l" . org-store-link)
+ ("C-c a" . org-agenda)
+ ("C-c c" . org-capture)
+ ("C-c b" . org-switchb)
+ ("<f10>" . org-clock-out)
+ ("<f2>" . org-clock-goto)
+ :map org-mode-map
+ ("M-<right>" . org-shiftmetaright)
+ ("M-<left>" . org-shiftmetaleft)
+ ("M-S-<right>" . org-metaright)
+ ("M-S-<left>" . org-metaleft)
+ ("C-M-h" . org-mark-subtree)
+ ("C-M-u" . org-up-element)
+ ("C-M-d" . org-down-element)
+ ("C-M-b" . org-backward-heading-same-level)
+ ("C-M-f" . org-forward-heading-same-level)
+ ("C-M-p" . org-previous-visible-heading)
+ ("C-M-n" . org-next-visible-heading)
+ ("<f9>" . org-clock-in)))
+
+(use-package org-transclusion
+ :after
+ org
+ :bind
+ (("C-c t" . org-transclusion-mode)))
#+END_SRC
*** Configuration
**** General options
#+BEGIN_SRC emacs-lisp
(with-eval-after-load 'org-mode (add-to-list 'org-export-backends 'md))
-(setq org-startup-indented nil
+(setq org-startup-indented t
org-indent-indentation-per-level tab-width
org-startup-folded 'fold
org-startup-with-inline-images t
;; (add-hook 'org-agenda-mode-hook #'hl-line-mode)
(setq org-agenda-files (append '("~/org/")
- (file-expand-wildcards "~/projects/*/")
- (file-expand-wildcards "~/.emacs.d/config.org"))
+ (file-expand-wildcards "~/projects/*/")
+ (file-expand-wildcards "~/.emacs.d/config.org"))
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
org-tag-alist '((:startgroup)
- ("call" . ?c)
- ("email" . ?e)
- ("errand" . ?r)
- (:endgroup)
- ("jobpc" . ?j)
- ("license" . ?l))
+ ("call" . ?c)
+ ("email" . ?e)
+ ("errand" . ?r)
+ (:endgroup)
+ ("jobpc" . ?j)
+ ("license" . ?l))
org-todo-keywords '((sequence "TODO(t)" "WAITING(w@)" "|" "DONE(d)" "BELAYED(b@)" "GIVEN(g@)")
- (sequence "MEETING(m)" "|" "MET(M)"))
+ (sequence "MEETING(m)" "|" "MET(M)"))
org-todo-keyword-faces '(("WAITING" :foreground "#e85400" :weight bold)
- ("MEETING" :foreground "#315e9a" :weight bold))
+ ("MEETING" :foreground "#315e9a" :weight bold))
org-agenda-restore-windows-after-quit t
org-agenda-start-on-weekday nil
org-agenda-span 'day
org-deadline-warning-days 30
org-agenda-window-setup 'current-window
org-agenda-time-grid '((daily today remove-match)
- (600 800 1200 1700 1800)
- " ――――― "
- "")
+ (600 800 1200 1700 1800)
+ " ――――― "
+ "")
org-agenda-tags-column 50
+ org-agenda-remove-tags t
org-agenda-skip-additional-timestamps-same-entry t
org-agenda-skip-deadline-if-done t
org-agenda-skip-scheduled-if-done t
org-agenda-prefix-format '((agenda . " %?-12t% s")
- (todo . " ")
- (tags . " ")
- (search . " "))
+ (todo . " ")
+ (tags . " ")
+ (search . " "))
org-agenda-scheduled-leaders '("BOOKED: " "Booked %2d d. ago: ")
org-agenda-deadline-leaders '("DEADLINE: " "In %3d d.: " "%2d d. ago: ")
org-read-date-prefer-future 'time
(defvar *re/org-agenda-undertakings*
'(tags "open" ((org-agenda-skip-function
- '(org-agenda-skip-entry-if 'notregexp "^\\*\\* "))
- (org-agenda-overriding-header "UNDERTAKINGS:"))))
+ '(org-agenda-skip-entry-if 'notregexp "^\\*\\* "))
+ (org-agenda-overriding-header "UNDERTAKINGS:"))))
(defvar *re/org-agenda-waiting*
- '(todo "WAITING" ((org-agenda-overriding-header "WAITING:"))))
+ '(todo "WAITING" ((org-agenda-skip-function
+ '(org-agenda-skip-entry-if 'regexp "^\\*\\* "))
+ (org-agenda-overriding-header "WAITING:"))))
(defvar *re/org-agenda-two-week-overview*
'(agenda "" ((org-agenda-span 14)
- (org-agenda-start-day "+1d")
- (org-agenda-start-on-weekday nil)
- (org-agenda-overriding-header "TWO-WEEK UPCOMING:"))))
+ (org-agenda-start-day "+1d")
+ (org-agenda-start-on-weekday nil)
+ (org-agenda-overriding-header "TWO-WEEK UPCOMING:"))))
(setq org-agenda-custom-commands `(("f" "Maybe Someday" tags "someday" ((org-agenda-overriding-header "SOMEDAY:")))
- ("i" "Inbox" ,@*re/org-agenda-inbox*)
- ("l" "Licenses" tags "license" ((org-agenda-overriding-header "LICENSES:")))
- ("n" "Next Actions" ,@*re/org-agenda-todo*)
- ("p" "JobPCs" tags "jobpc" ((org-agenda-overriding-header "JOB PCS:")))
- ("u" "Undertakings" ,@*re/org-agenda-undertakings*)
- ("w" "Waiting" ,@*re/org-agenda-waiting*)
- ("o" "Overview" ((agenda "" ((org-agenda-compact-blocks t)))
- ,,*re/org-agenda-inbox*
- ,,*re/org-agenda-todo*
- ,,*re/org-agenda-undertakings*
- ,,*re/org-agenda-two-week-overview*
- ,,*re/org-agenda-waiting*))))
+ ("i" "Inbox" ,@*re/org-agenda-inbox*)
+ ("l" "Licenses" tags "license" ((org-agenda-overriding-header "LICENSES:")))
+ ("n" "Next Actions" ,@*re/org-agenda-todo*)
+ ("p" "JobPCs" tags "jobpc" ((org-agenda-overriding-header "JOB PCS:")))
+ ("u" "Undertakings" ,@*re/org-agenda-undertakings*)
+ ("w" "Waiting" ,@*re/org-agenda-waiting*)
+ ("o" "Overview" ((agenda "" ((org-agenda-compact-blocks t)))
+ ,,*re/org-agenda-inbox*
+ ,,*re/org-agenda-todo*
+ ,,*re/org-agenda-undertakings*
+ ,,*re/org-agenda-two-week-overview*
+ ,,*re/org-agenda-waiting*))))
#+END_SRC
***** Capture Templates
#+BEGIN_SRC emacs-lisp
- (setq org-capture-templates '(("i" "Inbox" entry
- (file "gtd.org")
- "* %^{Description} :inbox:\n%U\n%?"
- :prepend t
- :clock-in t
- :clock-resume t)
- ("u" "Undertaking" entry
- (file+olp "gtd.org" "Undertakings")
- "* %^{Description}\n%U\n%?"
- :prepend t
- :clock-in t
- :clock-resume t)
- ("m" "Meeting" entry
- (file+olp "gtd.org" "Meetings")
- "* MEETING %^{Description}\n%^{Scheduled:}T\n%?"
- :prepend t
- :clock-in t
- :clock-resume t)
- ("p" "Phone Call" entry
- (file "gtd.org")
- "* %^{Description} :call:\n%U\n%?"
- :prepend t
- :clock-in t
- :clock-resume t)))
+(setq org-capture-templates '(("i" "Inbox" entry
+ (file "gtd.org")
+ "* %^{Description} :inbox:\n%U\n%?"
+ :prepend t)
+ ("n" "Next Action" entry
+ (file "gtd.org")
+ "* %^{Description} \n%U\n%?"
+ :prepend t)
+ ("u" "Undertaking" entry
+ (file+olp "gtd.org" "Undertakings")
+ "* %^{Description}\n%U\n%?"
+ :prepend t)
+ ("m" "Meeting" entry
+ (file+olp "gtd.org" "Meetings")
+ "* MEETING %^{Description}\n%^{Scheduled:}T\n%?"
+ :prepend t)
+ ("p" "Phone Call" entry
+ (file "gtd.org")
+ "* %^{Description} :call:\n%U\n%?"
+ :prepend t)))
#+END_SRC
**** IDs
#+BEGIN_SRC emacs-lisp
org-id-method 'ts
org-clone-delete-id t
org-attach-id-to-path-function-list '(org-attach-id-ts-folder-format
- org-attach-id-uuid-folder-format))
+ org-attach-id-uuid-folder-format))
(defun re/org-auto-generate-ids-in-file ()
"Add ID properties to all headlines in the current
(interactive)
(message "Saving all org-agenda-files buffers...")
(save-some-buffers t
- (lambda ()
- (when (member (buffer-file-name) org-agenda-files) t)))
+ (lambda ()
+ (when (member (buffer-file-name) org-agenda-files) t)))
(message "Saving all org-agenda-files buffers... done"))
(advice-add 'org-refile :after (lambda (&rest _) (re/org-save-all)))
(interactive)
(message "Archiving all completed tasks in org-agenda-files...")
(org-map-entries (lambda ()
- (org-archive-subtree)
- (setq org-map-continue-from (org-element-property
- :begin
- (org-element-at-point))))
- "/DONE"
- 'agenda)
+ (org-archive-subtree)
+ (setq org-map-continue-from (org-element-property
+ :begin
+ (org-element-at-point))))
+ "/DONE"
+ 'agenda)
(message "Archiving all completed tasks in org-agenda-files... done"))
(setq org-archive-location (concat "~/org/old.org_keep::datetree/")
On-again, off-again relationship with this one
*** Load package and add bindings
#+BEGIN_SRC emacs-lisp
- (use-package howm
- :bind
- (("<f6>" . howm-menu)
- ("S-<f6>" . re/howm-menu-new-frame)
- :map howm-mode-map
- ("C-c , k" . re/howm-create-keyword)
- ("C-c , =" . howm-narrow-to-memo)))
+(use-package howm
+ :bind
+ (("<f6>" . howm-menu)
+ ("S-<f6>" . re/howm-menu-new-frame)
+ :map howm-mode-map
+ ("C-c , k" . re/howm-create-keyword)
+ ("C-c , =" . howm-narrow-to-memo)))
#+END_SRC
*** Config
**** General settings
#+BEGIN_SRC emacs-lisp
(setq howm-template '("= %title%cursor #inbox\n%date %file\n\n"
- "= %title%cursor #meeting\n%date %file\n\nAttendees: \n"
- "= @%title%cursor\n%date %file\n\n")
+ "= %title%cursor #meeting\n%date %file\n\nAttendees: \n"
+ "= @%title%cursor\n%date %file\n\n")
howm-keyword-file "~/howm/.howm-keys"
howm-history-file "~/howm/.howm-history"
howm-menu-file "~/.emacs.d/0000-00-00-000000.txt"
"Reads a keyword from the minibuffer and appends it to the keywords file."
(interactive)
(append-to-file (concat (read-string "New Keyword: ")
- "\n")
- nil
- howm-keyword-file
- "\n"))
+ "\n")
+ nil
+ howm-keyword-file
+ "\n"))
#+END_SRC
**** Menu config
#+BEGIN_SRC emacs-lisp
(defun re/howm-menu-legend ()
(cl-labels ((p (text face) (propertize text 'font-lock-face face)))
(concat (format "Top %s" howm-menu-todo-num)
- " "
- (p "!Deadline" howm-reminder-deadline-face)
- "/"
- (p "+ToDo" howm-reminder-todo-face)
- "/"
- (p "@Schedule" howm-reminder-schedule-face)
- "/"
- (p "~Defer" howm-reminder-defer-face)
- "/"
- (p "-Reminder" howm-reminder-normal-face)
- " Entries:")))
+ " "
+ (p "!Deadline" howm-reminder-deadline-face)
+ "/"
+ (p "+ToDo" howm-reminder-todo-face)
+ "/"
+ (p "@Schedule" howm-reminder-schedule-face)
+ "/"
+ (p "~Defer" howm-reminder-defer-face)
+ "/"
+ (p "-Reminder" howm-reminder-normal-face)
+ " Entries:")))
(with-eval-after-load 'howm
(dolist (aldr-additions '(("\\[Mtg\\]" (lambda (&optional dummy) (howm-create 2)))
- ("\\[Person\\]" (lambda (&optional dummy) (howm-create 3)))))
+ ("\\[Person\\]" (lambda (&optional dummy) (howm-create 3)))))
(add-to-list 'action-lock-default-rules aldr-additions t))
(add-to-list 'howm-menu-allow 're/howm-menu-legend)
;; add coloring for custom "waiting" state
(add-to-list 'howm-reminder-font-lock-keywords
- `(,(howm-reminder-regexp "[w]") (0 howm-reminder-defer-face prepend))
- t)
+ `(,(howm-reminder-regexp "[w]") (0 howm-reminder-defer-face prepend))
+ t)
(add-hook howm-mode-hook 'howm-mode-set-buffer-name))
#+END_SRC
(use-package trashed
:config
(setq trashed-action-confirmer 'y-or-n-p
- trashed-use-header-line t
- trashed-sort-key '("Date deleted" . t)
- trashed-date-format "%Y-%m-%d %H:%M:%S"))
+ trashed-use-header-line t
+ trashed-sort-key '("Date deleted" . t)
+ trashed-date-format "%Y-%m-%d %H:%M:%S"))
#+END_SRC
** Use mu4e on my home pcs
#+BEGIN_SRC emacs-lisp
:ensure nil
:config
(setq mail-user-agent 'message-user-agent
- message-send-mail-function 'smtpmail-send-it
- message-citation-line-format "Quoth %f :\n"
- smtpmail-default-smtp-server "mail.earman.xyz"
- smtpmail-smtp-server "mail.earman.xyz"
- smtpmail-smtp-service 587
- smtpmail-stream-type 'starttls
- smtpmail-local-domain "earman.xyz"
- smtpmail-queue-mail nil
- smtpmail-queue-dir "~/mail/Outbox/cur"
- user-mail-address "iv@earman.xyz"
- user-full-name "Rush N. Earman IV"
- message-signature "Rush Earman IV, PE"
- message-kill-buffer-on-exit t
- mu4e-get-mail-command "mbsync -a"
- mu4e-update-interval (* 10 60)
- mu4e-change-filenames-when-moving t
- mu4e-use-fancy-chars t
- mu4e-attachment-dir "~/downloads"
- mu4e-compose-reply-to-address "iv@earman.xyz"
- mu4e-maildir "~/mail"
- mu4e-drafts-folder "/Drafts"
- mu4e-sent-folder "/Sent"
- mu4e-trash-folder "/Trash"
- mu4e-maildir-shortcuts '((:maildir "/Inbox" :key ?i)
- (:maildir "/Sent" :key ?s)
- (:maildir "/Trash" :key ?t)
- (:maildir "/Drafts" :key ?d)))))
+ message-send-mail-function 'smtpmail-send-it
+ message-citation-line-format "Quoth %f :\n"
+ smtpmail-default-smtp-server "mail.earman.xyz"
+ smtpmail-smtp-server "mail.earman.xyz"
+ smtpmail-smtp-service 587
+ smtpmail-stream-type 'starttls
+ smtpmail-local-domain "earman.xyz"
+ smtpmail-queue-mail nil
+ smtpmail-queue-dir "~/mail/Outbox/cur"
+ user-mail-address "iv@earman.xyz"
+ user-full-name "Rush N. Earman IV"
+ message-signature "Rush Earman IV, PE"
+ message-kill-buffer-on-exit t
+ mu4e-get-mail-command "mbsync -a"
+ mu4e-update-interval (* 10 60)
+ mu4e-change-filenames-when-moving t
+ mu4e-use-fancy-chars t
+ mu4e-attachment-dir "~/downloads"
+ mu4e-compose-reply-to-address "iv@earman.xyz"
+ mu4e-maildir "~/mail"
+ mu4e-drafts-folder "/Drafts"
+ mu4e-sent-folder "/Sent"
+ mu4e-trash-folder "/Trash"
+ mu4e-maildir-shortcuts '((:maildir "/Inbox" :key ?i)
+ (:maildir "/Sent" :key ?s)
+ (:maildir "/Trash" :key ?t)
+ (:maildir "/Drafts" :key ?d)))))
#+END_SRC
* Editing
** UNIX/vi-like bindings
=C-h=, =C-w=, =C-u=, et. al to work as I expect. Some functions get re-bound when these take over a default.
#+BEGIN_SRC emacs-lisp
- (defun re/open-line-below (n)
- "Creates a new empty line below the current line and moves to it."
- (interactive "*p")
- (end-of-line)
- (open-line n)
- (next-line 1)
- (indent-for-tab-command))
-
- (keymap-global-set "C-o" #'re/open-line-below)
-
- (defun re/open-line-above (n)
- "Creates a new empty line above the current line."
- (interactive "*p")
- (beginning-of-line)
- (open-line n)
- (indent-for-tab-command))
-
- (keymap-global-set "M-o" #'re/open-line-above)
-
- (defun re/kill-bword-or-region (&optional arg)
- "Kill region if active, otherwise kill back one word."
- (interactive "p")
- (if (use-region-p)
- (kill-region (region-beginning) (region-end))
- (backward-kill-word arg)))
-
- (keymap-global-set "C-w" #'re/kill-bword-or-region)
- (keymap-global-set "C-u" (lambda () (interactive) (kill-line 0))) ; kill-line backwards
- (keymap-global-set "C-S-U" #'universal-argument)
- (keymap-set key-translation-map "C-h" "<DEL>") ; Rather F1 for help, also C-S-H works
- (keymap-global-set "M-j" (lambda () (interactive) (join-line 0))) ; join-line other way
+(defun re/open-line-below (n)
+ "Creates a new empty line below the current line and moves to it."
+ (interactive "*p")
+ (end-of-line)
+ (open-line n)
+ (next-line 1)
+ (indent-for-tab-command))
+
+(keymap-global-set "C-o" #'re/open-line-below)
+
+(defun re/open-line-above (n)
+ "Creates a new empty line above the current line."
+ (interactive "*p")
+ (beginning-of-line)
+ (open-line n)
+ (indent-for-tab-command))
+
+(keymap-global-set "M-o" #'re/open-line-above)
+
+(defun re/kill-bword-or-region (&optional arg)
+ "Kill region if active, otherwise kill back one word."
+ (interactive "p")
+ (if (use-region-p)
+ (kill-region (region-beginning) (region-end))
+ (backward-kill-word arg)))
+
+(keymap-global-set "C-w" #'re/kill-bword-or-region)
+(keymap-global-set "C-u" (lambda () (interactive) (kill-line 0))) ; kill-line backwards
+(keymap-global-set "C-S-U" #'universal-argument)
+(keymap-set key-translation-map "C-h" "<DEL>") ; Rather F1 for help, also C-S-H works
+(keymap-global-set "M-j" (lambda () (interactive) (join-line 0))) ; join-line other way
#+END_SRC
** Commenting and defun-level bindings
#+BEGIN_SRC emacs-lisp
- (defun re/comment-dwim (&optional arg)
- "Comment region if active, otherwise comment line.
+(defun re/comment-dwim (&optional arg)
+ "Comment region if active, otherwise comment line.
Stolen from https://depp.brause.cc/dotemacs"
- (interactive "P")
- (if (use-region-p)
- (comment-or-uncomment-region (region-beginning) (region-end))
- (comment-line arg)))
+ (interactive "P")
+ (if (use-region-p)
+ (comment-or-uncomment-region (region-beginning) (region-end))
+ (comment-line arg)))
- (keymap-global-set "M-;" #'re/comment-dwim)
+(keymap-global-set "M-;" #'re/comment-dwim)
- (defun re/comment-defun (&optional arg)
- "Mark a defun and comment it out.
+(defun re/comment-defun (&optional arg)
+ "Mark a defun and comment it out.
Return to initial position after. Arg works on `mark-defun'."
- (interactive "P")
- (save-excursion (mark-defun arg)
- (comment-region (region-beginning) (region-end))))
+ (interactive "P")
+ (save-excursion (mark-defun arg)
+ (comment-region (region-beginning) (region-end))))
- (keymap-global-set "C-M-;" #'re/comment-defun)
+(keymap-global-set "C-M-;" #'re/comment-defun)
- (defun re/kill-defun (&optional arg)
- "Mark a defun and kill it.
+(defun re/kill-defun (&optional arg)
+ "Mark a defun and kill it.
Arg works on `mark-defun'."
- (interactive "P")
- (mark-defun arg)
- (kill-region (region-beginning) (region-end)))
+ (interactive "P")
+ (mark-defun arg)
+ (kill-region (region-beginning) (region-end)))
- (keymap-global-set "C-M-S-K" #'re/kill-defun)
+(keymap-global-set "C-M-S-K" #'re/kill-defun)
#+END_SRC
** Misc QOL bindings
#+BEGIN_SRC emacs-lisp
;; Tabs
(setq-default indent-tabs-mode t
- tab-width 8
- backward-delete-char-untabify-method nil)
+ tab-width 8
+ backward-delete-char-untabify-method nil)
(advice-add 'indent-to :around
- (lambda (orig-fun column &rest args)
- (when indent-tabs-mode
- (setq column (* tab-width (round column tab-width))))
- (apply orig-fun column args)))
+ (lambda (orig-fun column &rest args)
+ (when indent-tabs-mode
+ (setq column (* tab-width (round column tab-width))))
+ (apply orig-fun column args)))
(dolist (indent-level '(c-basic-offset cperl-indent-level LaTeX-indent-level))
(defvaralias indent-level 'tab-width))
#+BEGIN_SRC emacs-lisp
;; Buffer dealiŋ
(setq-default indicate-empty-lines t
- truncate-lines t
- fill-column 78)
+ truncate-lines t
+ fill-column 78)
(dolist (hook '(text-mode-hook LaTeX-mode-hook))
(add-hook hook #'visual-line-mode))
(interactive "^")
(let ((oldpos (point)))
(if (equal major-mode 'org-mode)
- (org-beginning-of-line)
+ (org-beginning-of-line)
(progn
- (when visual-line-mode (beginning-of-visual-line 1))
- (skip-syntax-forward " " (line-end-position))
- (backward-prefix-chars)))
+ (when visual-line-mode (beginning-of-visual-line 1))
+ (skip-syntax-forward " " (line-end-position))
+ (backward-prefix-chars)))
(and (= oldpos (point))
- (let ((newpos (point)))
- (back-to-indentation)
- (and (= newpos (point)) (beginning-of-line))))))
+ (let ((newpos (point)))
+ (back-to-indentation)
+ (and (= newpos (point)) (beginning-of-line))))))
(keymap-global-set "<remap> <move-beginning-of-line>" #'re/smart-beginning-of-line)
(keymap-set visual-line-mode-map "C-a" #'re/smart-beginning-of-line)
(interactive "^")
(let ((oldpos (point)))
(if (equal major-mode 'org-mode)
- (org-end-of-line)
+ (org-end-of-line)
(when visual-line-mode
- (end-of-visual-line 1)))
+ (end-of-visual-line 1)))
(and (= oldpos (point)) (move-end-of-line nil))))
(keymap-global-set "<remap> <move-end-of-line>" #'re/smart-end-of-line)
(defun re/add-region-to-search-ring ()
(when (use-region-p)
(add-to-history 'search-ring
- (buffer-substring (region-beginning) (region-end)))
+ (buffer-substring (region-beginning) (region-end)))
(deactivate-mark)))
(defun re/isearch-forward-use-region ()
Stolen from https://www.masteringemacs.org/article/fixing-mark-commands-transient-mark-mode"
(interactive "P")
(exchange-point-and-mark (if (and transient-mark-mode (not mark-active))
- (not arg)
- arg)))
+ (not arg)
+ arg)))
(keymap-global-set "<remap> <exchange-point-and-mark>" #'re/exchange-point-and-mark-maybe-activate)
(midnight-mode t)
(setq clean-buffer-list-delay-general 1)
(dolist (never-re '("\\` \\*tramp/.*\\'"
- "\\` \\*eshell.*\\'"))
+ "\\` \\*eshell.*\\'"))
(add-to-list 'clean-buffer-list-kill-never-regexps never-re))
(save-place-mode 1)
(recentf-mode 1)
"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" #'re/rename-current-buffer-file)
(defun re/get-file-modified-time (filepath)
(interactive)
(format-time-string "%Y-%m-%d-%H%M"
- (file-attribute-modification-time (file-attributes filepath))))
+ (file-attribute-modification-time (file-attributes filepath))))
(defun re/filename-inject-mod-time (filepath)
(interactive)
(concat (file-name-sans-extension filepath)
- "_"
- (re/get-file-modified-time filepath)
- (file-name-extension filepath t)))
+ "_"
+ (re/get-file-modified-time filepath)
+ (file-name-extension filepath t)))
(defun re/copy-with-mod-time (&optional filepath)
(interactive)
(let ((filepath (if (eq major-mode 'dired-mode)
- (dired-get-filename t)
- (when (null filepath)
- (read-file-name "File to copy with datestring: "
- default-directory
- nil
- t
- nil)))))
+ (dired-get-filename t)
+ (when (null filepath)
+ (read-file-name "File to copy with datestring: "
+ default-directory
+ nil
+ t
+ nil)))))
(copy-file filepath (re/filename-inject-mod-time filepath ) nil t t t)))
#+END_SRC
* Dired
"In dired mode, visit the file at the cursor in the right/below/left/above window."
(interactive)
(let* ((file-or-dir (dired-get-file-for-visit)) ;; get the file at cursor
- (buffer (find-file-noselect file-or-dir))) ;; load the file into a buffer
+ (buffer (find-file-noselect file-or-dir))) ;; load the file into a buffer
(let ((window ;; figure out the window to use
- (cond ((get-buffer-window buffer (selected-frame)))
- ((window-in-direction 'right)) ;; try window in each direction
- ((window-in-direction 'below)) ;; and default to right
- ((window-in-direction 'left)) ;; if no window found.
- ((window-in-direction 'above))
- (t (split-window-sensibly (selected-window))))))
+ (cond ((get-buffer-window buffer (selected-frame)))
+ ((window-in-direction 'right)) ;; try window in each direction
+ ((window-in-direction 'below)) ;; and default to right
+ ((window-in-direction 'left)) ;; if no window found.
+ ((window-in-direction 'above))
+ (t (split-window-sensibly (selected-window))))))
(window--display-buffer buffer window 'window nil)
window)))
"Open dired in a new frame."
(interactive)
(re/open-with-new-frame "DIRED"
- #'(lambda () (interactive) (dired default-directory))))
+ #'(lambda () (interactive) (dired default-directory))))
(keymap-global-set "<f8>" #'re/dired-new-frame)
"Change sort order of dired dir."
(interactive)
(let ((smenu '(("name" . "-Ahl")
- ("mdate" . "-Ahlt")
- ("adate" . "-Ahltu")
- ("size" . "-AhlS")
- ("dir" . "-Ahl --group-directories-first")))
- ssortBy)
+ ("mdate" . "-Ahlt")
+ ("adate" . "-Ahltu")
+ ("size" . "-AhlS")
+ ("dir" . "-Ahl --group-directories-first")))
+ ssortBy)
(setq ssortBy (completing-read "Sort by (default name):"
- smenu
- nil
- t
- nil
- nil
- (caar smenu)))
+ smenu
+ nil
+ t
+ nil
+ nil
+ (caar smenu)))
(dired-sort-other (cdr (assoc ssortBy smenu)))))
(defun re/open-file-external (file)
(interactive)
(let ((process-connection-type nil))
(cond ((eq system-type 'windows-nt)
- (w32-shell-execute "open"
- (replace-regexp-in-string "/" "\\\\" file t t)))
- ((eq system-type 'gnu/linux)
- (start-process "" nil "xdg-open" file))
- (t (error "Unable to automatically open this file")))))
+ (w32-shell-execute "open"
+ (replace-regexp-in-string "/" "\\\\" file t t)))
+ ((eq system-type 'gnu/linux)
+ (start-process "" nil "xdg-open" file))
+ (t (error "Unable to automatically open this file")))))
(defun re/dired-open-externally ()
"Open the file at point in an external program."
dired-kill-when-opening-new-dired-buffer t)
(add-hook 'dired-mode-hook
- (lambda ()
- (progn
- (keymap-set dired-mode-map
- "o"
- #'re/dired-display-direction)
- ;; Rename r,R+M(mv), chmod M>c, compress-to c>z
- (keymap-set dired-mode-map
- "z"
- #'dired-do-compress-to)
- (keymap-set dired-mode-map
- "c"
- #'dired-do-chmod)
- (keymap-set dired-mode-map
- "r"
- #'dired-do-rename)
- (keymap-set dired-mode-map
- "M"
- #'dired-do-rename)
- ;; My add-on defuns
- (keymap-set dired-mode-map
- "s"
- #'re/dired-sort)
- (keymap-set dired-mode-map
- "F"
- #'re/dired-find-marked-files)
- (keymap-set dired-mode-map
- "M-C"
- #'re/copy-with-mod-time)
- (keymap-set dired-mode-map
- "b"
- #'re/dired-open-externally)
- (keymap-set dired-mode-map
- "B"
- #'re/dired-open-marked-externally)
- (dired-hide-details-mode t)
- (hl-line-mode))))
+ (lambda ()
+ (progn
+ (keymap-set dired-mode-map
+ "o"
+ #'re/dired-display-direction)
+ ;; Rename r,R+M(mv), chmod M>c, compress-to c>z
+ (keymap-set dired-mode-map
+ "z"
+ #'dired-do-compress-to)
+ (keymap-set dired-mode-map
+ "c"
+ #'dired-do-chmod)
+ (keymap-set dired-mode-map
+ "r"
+ #'dired-do-rename)
+ (keymap-set dired-mode-map
+ "M"
+ #'dired-do-rename)
+ ;; My add-on defuns
+ (keymap-set dired-mode-map
+ "s"
+ #'re/dired-sort)
+ (keymap-set dired-mode-map
+ "F"
+ #'re/dired-find-marked-files)
+ (keymap-set dired-mode-map
+ "M-C"
+ #'re/copy-with-mod-time)
+ (keymap-set dired-mode-map
+ "b"
+ #'re/dired-open-externally)
+ (keymap-set dired-mode-map
+ "B"
+ #'re/dired-open-marked-externally)
+ (dired-hide-details-mode t)
+ (hl-line-mode))))
#+END_SRC
* Bookmarks
#+BEGIN_SRC emacs-lisp
-;; Bookmarks
(setq bookmark-save-flag 1)
(keymap-global-set "<f7>" #'recentf-open-files)
(keymap-global-set "C-x r B" #'bookmark-jump-other-window)
#+END_SRC
* GUI
#+BEGIN_SRC emacs-lisp
-;; GUI Settings
(load-theme 'eng-paper t)
(menu-bar-mode -1)
(tool-bar-mode -1)
mouse-autoselect-window -0.25)
(setq-default cursor-type 'hbar
- cursor-in-non-selected-windows nil
- mode-line-format
- '("%e"
- (:eval (propertize " "
- 'face
- (when (buffer-modified-p)
- 'mode-line-highlight)))
- " "
- (:propertize (buffer-file-name "%f" "%b")
- face
- mode-line)
- (vc-mode vc-mode)
- mode-line-format-right-align
- (:eval (number-to-string (line-number-at-pos (point-max))))
- "L @ %I%n %l,%C "))
+ cursor-in-non-selected-windows nil
+ mode-line-format
+ '("%e"
+ (:eval (propertize " "
+ 'face
+ (when (buffer-modified-p)
+ 'mode-line-highlight)))
+ " "
+ (:propertize (buffer-file-name "%f" "%b")
+ face
+ mode-line)
+ (vc-mode vc-mode)
+ mode-line-format-right-align
+ (:eval (number-to-string (line-number-at-pos (point-max))))
+ "L @ %I%n %l,%C "))
(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
* Parens
+Must be set after loading any theme
#+BEGIN_SRC emacs-lisp
-;; Parens (must be after loading the theme)
(setq show-paren-delay 0
show-paren-style 'expression)
(setq electric-pair-pairs '((?\" . ?\")
- (?\‘ . ?\’)
- (?\“ . ?\”)
- (?\{ . ?\})
- (?\< . ?\>)))
+ (?\‘ . ?\’)
+ (?\“ . ?\”)
+ (?\{ . ?\})
+ (?\< . ?\>)))
#+END_SRC
* Help
#+BEGIN_SRC emacs-lisp
-;; Help
(setq apropos-do-all t)
#+END_SRC
* UTF-8
#+BEGIN_SRC emacs-lisp
-;; UTF-8
(set-charset-priority 'unicode)
(prefer-coding-system 'utf-8-unix)
(set-language-environment 'utf-8)
"Change all groups of blank lines to 1 blank line."
(interactive)
(save-excursion (mark-whole-buffer)
- (replace-regexp "^\n+"
- "\n"
- nil
- (region-beginning)
- (region-end))))
+ (replace-regexp "^\n+"
+ "\n"
+ nil
+ (region-beginning)
+ (region-end))))
(setq require-final-newline t)
(add-hook 'before-save-hook #'re/flush-extra-lines)
"Select a single character at random to be used in a password.
If `no-special-chars' is t, use only alpha-numeric characters."
(let ((selected-charset (append *alphanumerics*
- (when (null no-special-chars)
- *special-characters*))))
+ (when (null no-special-chars)
+ *special-characters*))))
(elt selected-charset (random (length selected-charset)))))
(defun pw-get-chars (password-length &optional no-special-chars)
"Generate a list of characters as strings to be made into a password.
If `no-special-chars' is t, use only alpha-numeric characters."
(append (list (pw-get-char no-special-chars))
- (when (> password-length 1)
- (pw-get-chars (- password-length 1) no-special-chars))))
+ (when (> password-length 1)
+ (pw-get-chars (- password-length 1) no-special-chars))))
(defun generate-password (password-length &optional no-special-chars)
"Combine a list of randomly-selected characters into a single string of length given.
Negative password-length (or negative arg) sets `no-special-chars' for `generate-password'."
(interactive "p")
(let ((len (if (or (null password-length) (= 1 (abs password-length)))
- 16
- (abs password-length)))
- (no-special-p (and (numberp password-length) (< password-length 0))))
+ 16
+ (abs password-length)))
+ (no-special-p (and (numberp password-length) (< password-length 0))))
(insert (generate-password len no-special-p))))
#+END_SRC
** Get a password from a pass(1) entry
(with-temp-buffer
(insert-file-contents file-path)
(if (< line-number 0)
- (progn
- (goto-char (point-max))
- (forward-line line-number))
+ (progn
+ (goto-char (point-max))
+ (forward-line line-number))
(progn
- (goto-char (point-min))
- (forward-line (1- line-number))))
+ (goto-char (point-min))
+ (forward-line (1- line-number))))
(buffer-substring-no-properties (line-beginning-position) (line-end-position))))
(defun get-password (&optional filename)
(defun totp--hex-decode-string (string)
"Hex-decode STRING and return the result as a unibyte string."
(apply #'unibyte-string
- (seq-map (lambda (s) (hexl-htoi (aref s 0) (aref s 1)))
- (seq-partition string 2))))
+ (seq-map (lambda (s) (hexl-htoi (aref s 0) (aref s 1)))
+ (seq-partition string 2))))
(defun totp (string &optional time digits)
"Return a TOTP token using the secret hex STRING and current time.
TIME is used as counter value instead of current time, if non-nil.
DIGITS is the number of pin digits and defaults to 6."
(let* ((key-bytes (totp--hex-decode-string (upcase string)))
- (counter (truncate (/ (or time (time-to-seconds)) 30)))
- (digits (or digits 6))
- (format-string (format "%%0%dd" digits))
- ;; we have to manually split the 64 bit number (u64 not supported in Emacs 27.2)
- (counter-bytes (bindat-pack '((:high u32) (:low u32))
- `((:high . ,(ash counter -32)) (:low . ,(logand counter #xffffffff)))))
- (mac (gnutls-hash-mac 'SHA1 key-bytes counter-bytes))
- (offset (logand (bindat-get-field (bindat-unpack '((:offset u8)) mac 19) :offset) #xf)))
+ (counter (truncate (/ (or time (time-to-seconds)) 30)))
+ (digits (or digits 6))
+ (format-string (format "%%0%dd" digits))
+ ;; we have to manually split the 64 bit number (u64 not supported in Emacs 27.2)
+ (counter-bytes (bindat-pack '((:high u32) (:low u32))
+ `((:high . ,(ash counter -32)) (:low . ,(logand counter #xffffffff)))))
+ (mac (gnutls-hash-mac 'SHA1 key-bytes counter-bytes))
+ (offset (logand (bindat-get-field (bindat-unpack '((:offset u8)) mac 19) :offset) #xf)))
(format format-string
- (mod
- (logand (bindat-get-field (bindat-unpack '((:totp-pin u32)) mac offset) :totp-pin)
- #x7fffffff)
- (expt 10 digits)))))
+ (mod
+ (logand (bindat-get-field (bindat-unpack '((:totp-pin u32)) mac offset) :totp-pin)
+ #x7fffffff)
+ (expt 10 digits)))))
(defconst base32-alphabet
(let ((tbl (make-char-table nil)))
(dolist (mapping '(("A" . 0) ("B" . 1) ("C" . 2) ("D" . 3)
- ("E" . 4) ("F" . 5) ("G" . 6)
- ("H" . 7) ("I" . 8) ("J" . 9) ("K" . 10)
- ("L" . 11) ("M" . 12) ("N" . 13)
- ("O" . 14) ("P" . 15) ("Q" . 16) ("R" . 17)
- ("S" . 18) ("T" . 19) ("U" . 20)
- ("V" . 21) ("W" . 22) ("X" . 23) ("Y" . 24)
- ("Z" . 25) ("2" . 26) ("3" . 27)
- ("4" . 28) ("5" . 29) ("6" . 30) ("7" . 31)))
+ ("E" . 4) ("F" . 5) ("G" . 6)
+ ("H" . 7) ("I" . 8) ("J" . 9) ("K" . 10)
+ ("L" . 11) ("M" . 12) ("N" . 13)
+ ("O" . 14) ("P" . 15) ("Q" . 16) ("R" . 17)
+ ("S" . 18) ("T" . 19) ("U" . 20)
+ ("V" . 21) ("W" . 22) ("X" . 23) ("Y" . 24)
+ ("Z" . 25) ("2" . 26) ("3" . 27)
+ ("4" . 28) ("5" . 29) ("6" . 30) ("7" . 31)))
(aset tbl (string-to-char (car mapping)) (cdr mapping)))
tbl)
"Base-32 mapping table, as defined in RFC 4648.")
(setq string (upcase string))
(let ((trimmed-array (append (string-trim-right string "=+") nil)))
(format "%X" (seq-reduce
- (lambda (acc char) (+ (ash acc 5) (aref base32-alphabet char)))
- trimmed-array 0))))
+ (lambda (acc char) (+ (ash acc 5) (aref base32-alphabet char)))
+ trimmed-array 0))))
(defun keyfile-string (filename)
"Return a string which is the filepath to a `pass(1)' file."
(let ((directory "~/.password-store/"))
(if (null filename)
- (read-file-name "Select a password: " directory nil t nil)
+ (read-file-name "Select a password: " directory nil t nil)
(concat directory
- (if (stringp filename)
- filename
- (symbol-name filename))
- ".gpg"))))
+ (if (stringp filename)
+ filename
+ (symbol-name filename))
+ ".gpg"))))
(defun get-totp (&optional filename)
"Generate a totp code given a file with the secret hex string.
* Control
#+BEGIN_SRC emacs-lisp
-;; Control
(defun re/kill-emacs ()
"Save all open files and kill emacs."
(interactive)
(interactive)
(if (active-minibuffer-window)
(if (minibufferp)
- (minibuffer-keyboard-quit)
- (abort-recursive-edit))
+ (minibuffer-keyboard-quit)
+ (abort-recursive-edit))
(keyboard-quit)))
(keymap-global-set "<remap> <keyboard-quit>" #'re/keyboard-quit) ; Make C-g better
#+END_SRC
* Version-control mode
#+BEGIN_SRC emacs-lisp
-;; Versioning and Backups
(defun re/vc-clone ()
"Interactively clone with vc-mode.
Prompt for url and local dir."
(interactive)
(let* ((url (read-string "Repository URL: "))
- (dir (read-string "Local Dir: " (file-name-base url))))
+ (dir (read-string "Local Dir: " (file-name-base url))))
(vc-git-clone url dir nil)))
(keymap-global-set "C-x v C" #'re/vc-clone)
Remotes as well when arg."
(interactive "P")
(let ((default-directory (if (boundp 'vc-dir-directory)
- vc-dir-directory
- default-directory)))
+ vc-dir-directory
+ default-directory)))
(vc-git-command "*git-branches*"
- nil
- nil
- "branch"
- "--verbose"
- (when arg "--remotes"))
+ nil
+ nil
+ "branch"
+ "--verbose"
+ (when arg "--remotes"))
(pop-to-buffer "*git-branches*")
(goto-char (point-min))
(special-mode)))
With arg, ask for remote, otherwise fetch all."
(interactive "P")
(let* ((default-directory (if (boundp 'vc-dir-directory)
- vc-dir-directory
- default-directory)))
+ vc-dir-directory
+ default-directory)))
(vc-git-command "*vc-fetch*"
- nil
- nil
- "fetch"
- (if arg
- (read-string "Fetch From: " "origin")
- "--all")
- "--verbose")
+ nil
+ nil
+ "fetch"
+ (if arg
+ (read-string "Fetch From: " "origin")
+ "--all")
+ "--verbose")
(pop-to-buffer "*vc-fetch*")
(goto-char (point-min))
(special-mode)))
(keymap-global-set "C-x v f" #'re/vc-fetch)
(add-hook 'vc-dir-mode-hook
- (lambda ()
- (keymap-set vc-dir-mode-map "b b" #'re/vc-show-branches)
- (keymap-set vc-dir-mode-map "f" #'re/vc-fetch)
- (keymap-set vc-dir-mode-map "k" #'vc-revert)))
+ (lambda ()
+ (keymap-set vc-dir-mode-map "b b" #'re/vc-show-branches)
+ (keymap-set vc-dir-mode-map "f" #'re/vc-fetch)
+ (keymap-set vc-dir-mode-map "k" #'vc-revert)))
(setq vc-make-backup-files nil
vc-handled-backends '(Git)
#+END_SRC
* Backups
#+BEGIN_SRC emacs-lisp
-
(setq backup-directory-alist `((".*" . "~/emacs-backups/"))
backup-by-copying t
delete-old-versions t
#+END_SRC
* Any Lisp Repl
#+BEGIN_SRC emacs-lisp
-;; Any Lisp Repl
(defmacro re/send-on-close-paren (executor)
"Generalizes sending an execute on close paren.
Interactively call `executor'. For `executor', use whatever
Either delete, move forward, or add as many ')' as needed."
(let ((distance (re/sexp-unbalanced-count)))
(cond ((re/sexp-need-paren-p)
- (if (looking-at ")")
- (progn
- (forward-char)
- (re/balance-sexp))
- (insert-char 41 distance)))
- ((re/sexp-drop-paren-p)
- (backward-delete-char distance)))))
+ (if (looking-at ")")
+ (progn
+ (forward-char)
+ (re/balance-sexp))
+ (insert-char 41 distance)))
+ ((re/sexp-drop-paren-p)
+ (backward-delete-char distance)))))
(defmacro re/balance-and-eval-sexp (executor)
"Balance the sexp before point, then call `executor'.
(dolist (hook *re/lisp-mode-hooks*)
(add-hook hook
- (lambda ()
- (when (bound-and-true-p acme-mouse-mode) (acme-mouse-mode -1))
- (sedit-mouse-mode 1)
- (keymap-set lisp-mode-shared-map "C-M-z" #'eval-region)
- (keymap-set lisp-mode-shared-map
- "C-M-S-q"
- #'sedit-auto-prettify-sexp)
- (keymap-set lisp-mode-shared-map
- "]"
- (re/balance-and-eval-sexp #'sedit-auto-prettify-sexp))
- (keymap-set lisp-interaction-mode-map
- "]"
- (re/balance-and-eval-sexp #'eval-print-last-sexp)))))
+ (lambda ()
+ (when (bound-and-true-p acme-mouse-mode) (acme-mouse-mode -1))
+ (sedit-mouse-mode 1)
+ (keymap-set lisp-mode-shared-map "C-M-z" #'eval-region)
+ (keymap-set lisp-mode-shared-map
+ "C-M-S-q"
+ #'sedit-auto-prettify-sexp)
+ (keymap-set lisp-mode-shared-map
+ "]"
+ (re/balance-and-eval-sexp #'sedit-auto-prettify-sexp))
+ (keymap-set lisp-interaction-mode-map
+ "]"
+ (re/balance-and-eval-sexp #'eval-print-last-sexp)))))
#+END_SRC
* IELM
Rarely used, but nice to have when I want it.
#+BEGIN_SRC emacs-lisp
-;; IELM
(add-hook 'ielm-mode-hook
- (lambda ()
- (keymap-set inferior-emacs-lisp-mode-map
- "C-l"
- #'comint-clear-buffer)
- (let ((eval-function #'ielm-send-input))
- (keymap-set inferior-emacs-lisp-mode-map
- ")"
- (re/send-on-close-paren eval-function))
- (keymap-set inferior-emacs-lisp-mode-map
- "]"
- (re/balance-and-eval-sexp eval-function)))))
+ (lambda ()
+ (keymap-set inferior-emacs-lisp-mode-map
+ "C-l"
+ #'comint-clear-buffer)
+ (let ((eval-function #'ielm-send-input))
+ (keymap-set inferior-emacs-lisp-mode-map
+ ")"
+ (re/send-on-close-paren eval-function))
+ (keymap-set inferior-emacs-lisp-mode-map
+ "]"
+ (re/balance-and-eval-sexp eval-function)))))
#+END_SRC
* Eshell
#+BEGIN_SRC emacs-lisp
-;; Eshell
(keymap-global-set "C-c e" #'eshell)
(defun eshell-quit-or-delete-char (arg)
(delete-char arg)))
(add-hook 'eshell-mode-hook
- (lambda ()
- (keymap-set eshell-mode-map "C-d" #'eshell-quit-or-delete-char)
- (let ((eval-function #'eshell-send-input))
- (keymap-set eshell-mode-map
- ")"
- (re/send-on-close-paren eval-function))
- (keymap-set eshell-mode-map
- "]"
- (re/balance-and-eval-sexp eval-function)))))
+ (lambda ()
+ (keymap-set eshell-mode-map "C-d" #'eshell-quit-or-delete-char)
+ (let ((eval-function #'eshell-send-input))
+ (keymap-set eshell-mode-map
+ ")"
+ (re/send-on-close-paren eval-function))
+ (keymap-set eshell-mode-map
+ "]"
+ (re/balance-and-eval-sexp eval-function)))))
#+END_SRC
* C-mode
#+BEGIN_SRC emacs-lisp
-;;; C-mode
(dolist (mode-maps '(("\\.keymap\\'" . c-mode) ("\\.dtsi\\'" . c-mode)))
(add-to-list 'auto-mode-alist mode-maps t))
"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 ()
- (c-add-style "linux-tabs-only"
- '("linux" (c-offsets-alist
- (arglist-cont-nonempty
- c-lineup-gcc-asm-reg
- re/c-lineup-arglist-tabs-only))))))
+ (lambda ()
+ (c-add-style "linux-tabs-only"
+ '("linux" (c-offsets-alist
+ (arglist-cont-nonempty
+ c-lineup-gcc-asm-reg
+ re/c-lineup-arglist-tabs-only))))))
(add-hook 'c-mode-hook
- (lambda ()
- (setq c-backspace-function 'backward-delete-char)
- (c-set-style "linux-tabs-only")))
+ (lambda ()
+ (setq c-backspace-function 'backward-delete-char)
+ (c-set-style "linux-tabs-only")))
#+END_SRC
* Auto-Revert
#+BEGIN_SRC emacs-lisp
-;; Auto-Revert
(global-auto-revert-mode t)
(setq global-auto-revert-non-file-buffers nil)
#+END_SRC
* Crash Handliŋ
#+BEGIN_SRC emacs-lisp
-;; Crash handliŋ
(setq attempt-stack-overflow-recovery nil
attempt-orderly-shutdown-on-fatal-signal nil)
#+END_SRC
* Abbrev-mode and skeletons
#+BEGIN_SRC emacs-lisp
-;; Abbrev-mode and Skeletons
(define-skeleton workorder-link
"part of a link to a workorder, just enter the number."
""