Compare commits

...

10 Commits

Author SHA1 Message Date
Case Duckworth 9b17702d3f Fix typo 2022-04-24 15:02:24 -05:00
Case Duckworth 47371e7484 Change prot's urls 2022-04-24 15:02:19 -05:00
Case Duckworth 0aab1430c8 Configure jabber 2022-04-24 15:02:12 -05:00
Case Duckworth 6d62265dd0 Add ement.el 2022-04-24 15:02:05 -05:00
Case Duckworth f2b652dabc Bleh 2022-04-24 15:01:58 -05:00
Case Duckworth 57b0d19290 Refactor 2022-04-24 15:01:25 -05:00
Case Duckworth 30a7f9651b Add commentary to user-save.el 2022-04-24 15:01:13 -05:00
Case Duckworth 86c2a140a5 Change `+org-before-save@prettify-buffer' 2022-04-24 15:00:58 -05:00
Case Duckworth d4c3d79770 Fix `+org-fix-blank-lines' 2022-04-24 15:00:41 -05:00
Case Duckworth 56b2c9fb54 Correct backward-kill-word behavior 2022-04-24 15:00:11 -05:00
6 changed files with 207 additions and 90 deletions

92
init.el
View File

@ -41,6 +41,7 @@
"C-x C-o" #'+open-paragraph
"C-w" #'+kill-word-backward-or-region
"C-x C-m" #'execute-extended-command ; original: coding systems
"C-<backspace>" #'+backward-kill-word
;; Alright, Yegge... NOPE! C-x t is tab prefix ... (maybe F6 or something?)
;; "C-x t" #'beginning-of-buffer
;; "C-x e" #'end-of-buffer
@ -118,7 +119,8 @@
pulse-iterations 1)
(dolist (command '(+ace-window-or-switch-buffer
pop-mark pop-global-mark
Info-history-back Info-history-forward))
Info-history-back Info-history-forward
))
(add-to-list '+pulse-location-commands command))
(+ensure-after-init #'+pulse-location-mode))
@ -128,6 +130,8 @@
(setup (:require user-save)
(add-hook 'user-save-hook #'+clean-empty-lines)
(add-hook 'user-save-hook (defun user-save@save-some-buffers ()
(save-some-buffers t t)))
(user-save-global-mode +1))
(setup (:require winner)
@ -622,6 +626,17 @@
("=" org-verbatim)
("~" org-code)
("+" org-strikethrough)))
;; (setq org-todo-keywords
;; '((sequence
;; "TODO(t)"
;; "NEXT(n!)" ; next action
;; "DONE(d)" ; done)
;; (sequence
;; "WAIT(w@)" ; waiting to be actionable again
;; "HOLD(h@/!)" ; actinable, but will do later
;; "IDEA(i)" ; maybe someday
;; "KILL(k@/!)" ; cancelled, aborted or is no longer applicable
;; ))))
(:bind "RET" #'+org-return-dwim
"<S-return>" #'+org-table-copy-down
"C-c C-l" #'+org-insert-link-dwim
@ -773,7 +788,14 @@
:unnarrowed t))
(+org-capture-sort))
(setup org-export
(setup org-id
(:load-after org)
;; https://helpdeskheadesk.net/2022-03-13/
(:option org-id-method 'ts
org-attach-id-to-path-function-list '(org-attach-id-ts-folder-format
org-attach-id-uuid-folder-format)))
(setup ox ; org-export
(:also-load ox-md)
(:option org-export-coding-system 'utf-8-unix
org-export-headline-levels 8
@ -783,14 +805,7 @@
org-export-with-sub-superscripts t
org-export-with-toc nil)
(with-eval-after-load 'user-save
(advice-add 'org-export-dispatch :before 'user-save-run-hooks)))
(setup org-id
(:load-after org)
;; https://helpdeskheadesk.net/2022-03-13/
(:option org-id-method 'ts
org-attach-id-to-path-function-list '(org-attach-id-ts-folder-format
org-attach-id-uuid-folder-format)))
(advice-add 'org-export-as :before #'user-save-run-hooks)))
(setup password-cache
(:option password-cache t
@ -1509,6 +1524,14 @@ See also `crux-reopen-as-root-mode'."
(setup (:straight embrace)
(:+key "C-," #'embrace-commander))
(setup (:straight (ement
:host github
:repo "alphapapa/ement.el")
;; `plz' is a requirement, but isn't on an elpa.
(setup (:straight (plz :host github
:repo "alphapapa/plz.el"))
t)))
(setup (:straight epithet)
(add-hook 'epithet-suggesters #'epithet-for-eww-url)
(dolist (hook '(Info-selection-hook
@ -1719,17 +1742,16 @@ See also `crux-reopen-as-root-mode'."
(define-key isearch-mb-minibuffer-map (kbd key) command)))))))
(isearch-mb-mode +1))
(setup (:straight (jabber :repo "https://tildegit.org/wgreenhouse/emacs-jabber"
(setup (:straight (jabber :repo "https://codeberg.org/emacs-jabber/emacs-jabber"
:host nil
:files ("*.el" "*.texi"
("jabber-fallback-lib"
"jabber-fallback-lib/hexrgb.el"
"jabber-fallback-lib/srv.el"
"jabber-fallback-lib/fsm.el")
"jabber-pkg.el")
:fork (:repo "https://tildegit.org/acdw/emacs-jabber"
:host nil)))
"jabber-pkg.el")))
(:also-load +jabber)
(defvar +jabber-ws-prefix 8 "Width to pad left side of chats.")
(:option jabber-account-list '(("acdw@hmm.st"))
jabber-groupchat-buffer-format "X:%n"
jabber-chat-buffer-format "X:%n"
@ -1737,13 +1759,37 @@ See also `crux-reopen-as-root-mode'."
jabber-activity-show-p #'ignore
jabber-muc-decorate-presence-patterns
'(("\\( enters the room ([^)]+)\\| has left the chatroom\\)$")
("." . jabber-muc-presence-dim)))
("." . jabber-muc-presence-dim))
jabber-muc-colorize-foreign t
jabber-chat-foreign-prompt-format (concat "[%t] %n:\n"
(make-string +jabber-ws-prefix
?\ ))
jabber-chat-local-prompt-format (concat "[%t] %n:\n"
(make-string +jabber-ws-prefix
?\ ))
jabber-groupchat-prompt-format (concat "[%t] %n:\n"
(make-string +jabber-ws-prefix
?\ ))
jabber-auto-reconnect t)
(add-hook 'modus-themes-after-load-theme-hook
(defun jabber-chat@after-modus-themes-load ()
(modus-themes-with-colors
(:face 'jabber-chat-prompt-foreign `((t (:foreground ,red)))
'jabber-chat-prompt-local `((t (:foreground ,blue)))
'jabber-chat-prompt-system `((t (:foreground ,green)))))))
(dolist (mode '(jabber-chat-mode
jabber-browse-mode
jabber-roster-mode
jabber-console-mode))
(add-hook (intern (format "%s-hook" mode)) #'visual-fill-column-mode))
(add-hook 'jabber-activity-mode-hook 'tracking-mode)
(add-hook 'jabber-activity-mode-hook #'tracking-mode)
(:with-mode jabber-chat-mode
(:local-set +modeline-position-function (lambda ()
(cond
((string-match-p "hmm@" (buffer-name))
"🤔 ")))
wrap-prefix (make-string +jabber-ws-prefix ?\ )
))
(:+leader "C-j" jabber-global-keymap)
(advice-add 'jabber-activity-add :after #'+jabber-tracking-add)
(advice-add 'jabber-activity-add-muc :after #'+jabber-tracking-add-muc))
@ -1762,7 +1808,9 @@ See also `crux-reopen-as-root-mode'."
(setf (alist-get 'lacarte-execute-menu-command vertico-multiform-commands)
'(buffer grid (vertico-sort-function . vertico-sort-length-alpha)))))
(setup (:straight (lin :host gitlab :repo "protesilaos/lin"))
(setup (:straight (lin :host nil
:repo "https://git.sr.ht/~protesilaos/lin"))
(:require)
(lin-global-mode +1))
(setup (:straight link-hint)
@ -1863,8 +1911,8 @@ See also `crux-reopen-as-root-mode'."
(mode-line-bell-mode +1))
(setup (:straight (modus-themes
:host gitlab
:repo "protesilaos/modus-themes"))
:host nil
:repo "https://git.sr.ht/~protesilaos/modus-themes"))
(require 'modus-themes (.etc "straight/build/modus-themes/modus-themes"))
(:option modus-themes-mixed-fonts t
modus-themes-bold-constructs t
@ -2028,8 +2076,9 @@ See also `crux-reopen-as-root-mode'."
(add-hook '+init-mode-hook #'flymake-mode-off))
(setup (:straight paredit)
(:also-load +paredit)
(:bind "DEL" #'paredit-backward-delete
"C-<backspace>" #'paredit-backward-kill-word
"C-<backspace>" #'+paredit-backward-kill-word
"C-w" (lambda (arg) (interactive "P")
(+kill-word-backward-or-region arg
#'paredit-backward-kill-word))
@ -2387,7 +2436,8 @@ See also `crux-reopen-as-root-mode'."
(setup (:straight zoom-frm)
(:+key "M-+" #'zoom-frm-in
"M-_" #'zoom-frm-out))
"M-_" #'zoom-frm-out)
(dolist (c '(zoom-frm-in zoom-frm-out))))
(setup (:straight zzz-to-char)
(:require +zzz-to-char)

View File

@ -244,6 +244,34 @@ backward. It defaults to `backward-kill-word'."
#'kill-region
(or backward-kill-word-fn #'backward-kill-word))))
(defun +backward-kill-word-wrapper (fn &optional arg)
"Kill backward using FN until the beginning of a word, smartly.
If point is on at the beginning of a line, kill the previous new
line. If the only thing before point on the current line is
whitespace, kill that whitespace.
With argument ARG: if ARG is a number, just call FN
ARG times. Otherwise, just call FN."
;; I want this to be a wrapper so that I can call other word-killing functions
;; with it. It's *NOT* advice because those functions probably use
;; `backward-kill-word' under the hood (looking at you, paredit), so advice
;; will make things weird.
(if (null arg)
(cond
((looking-back "^" 1)
(let ((delete-active-region nil))
(delete-backward-char 1)))
((looking-back "^[ ]*")
(delete-horizontal-space :backward-only))
(t (call-interactively fn)))
(funcall fn (if (listp arg) 1 arg))))
(defun +backward-kill-word (&optional arg)
"Kill word backward using `backward-kill-word'.
ARG is passed to `backward-kill-word'."
(interactive "P")
(+backward-kill-word-wrapper #'backward-kill-word arg))
;; ... and advice
;; Indent the region after a yank.

View File

@ -143,38 +143,41 @@ N is passed to the functions."
Optional PREFIX argument operates on the entire buffer.
Drawers are included with their headings."
(interactive "P")
(org-map-entries (lambda ()
(org-with-wide-buffer
;; `org-map-entries' narrows the buffer, which
;; prevents us from seeing newlines before the
;; current heading, so we do this part widened.
(while (not (looking-back "\n\n" nil))
;; Insert blank lines before heading.
(insert "\n")))
(let ((end (org-entry-end-position)))
;; Insert blank lines before entry content
(forward-line)
(while (and (org-at-planning-p)
(< (point) (point-max)))
;; Skip planning lines
(forward-line))
(while (re-search-forward
org-drawer-regexp end t)
;; Skip drawers. You might think that
;; `org-at-drawer-p' would suffice, but for
;; some reason it doesn't work correctly when
;; operating on hidden text. This works, taken
;; from `org-agenda-get-some-entry-text'.
(re-search-forward "^[ \t]*:END:.*\n?" end t)
(goto-char (match-end 0)))
(unless (or (= (point) (point-max))
(org-at-heading-p)
(looking-at-p "\n"))
(insert "\n"))))
t
(if prefix
nil
'tree)))
(let ((org-element-use-cache nil))
(org-map-entries (lambda ()
(let ((beg (org-entry-beginning-position))
(end (org-entry-end-position)))
(org-with-wide-buffer
;; `org-map-entries' narrows the buffer, which
;; prevents us from seeing newlines before the
;; current heading, so we do this part widened.
(while (not (looking-back "\n\n" nil))
;; Insert blank lines before heading.
(insert "\n")))
;; Insert blank lines before entry content
(forward-line)
(while (and (org-at-planning-p)
(< (point) (point-max)))
;; Skip planning lines
(forward-line))
(while (re-search-forward
org-drawer-regexp end t)
;; Skip drawers. You might think that
;; `org-at-drawer-p' would suffice, but for
;; some reason it doesn't work correctly when
;; operating on hidden text. This works, taken
;; from `org-agenda-get-some-entry-text'.
(re-search-forward "^[ \t]*:END:.*\n?" end t)
(goto-char (match-end 0)))
(unless (or (= (point) (point-max))
(org-at-heading-p)
(looking-at-p "\n"))
(insert "\n"))))
t
(if prefix
nil
'tree))))
;;; org-count-words
@ -336,11 +339,13 @@ Return as a list."
(defun +org-before-save@prettify-buffer ()
(when +org-before-save-prettify-buffer
(save-mark-and-excursion
(mark-whole-buffer)
;;(org-fill-paragraph nil t)
(+org-unsmartify)
(+org-fix-blank-lines t)
(org-align-tags t))))
(+org-unsmartify)
(+org-fix-blank-lines t)
(org-align-tags t)
(when (buffer-narrowed-p)
(goto-char (point-min))
(forward-line 1)
(org-narrow-to-subtree)))))
(defun +org-delete-backward-char (N)
"Keep tables aligned while deleting N characters backward.

26
lisp/+paredit.el Normal file
View File

@ -0,0 +1,26 @@
;;; +paredit.el --- bespoke paredit stuffs -*- lexical-binding: t; -*-
;;; Commentary:
;;; Code:
(require '+emacs) ; `+backward-kill-word-wrapper'
(defun +paredit--backward-kill-word (&optional n)
"Perform `paredit-backward-kill-word' N times."
(interactive "p")
(dotimes (_ (or n 1))
(paredit-backward-kill-word)))
(defun +paredit-backward-kill-word (&optional arg)
"Kill a word backward using `paredit-backward-kill-word'.
Wrapped in `+backward-kill-word-wrapper', which see.
Prefix ARG means to just call `paredit-backward-kill-word'."
;; Of course, `paredit-backward-kill-word' doesn't TAKE an argument ... :///
;; So I had to write the wrapper above.
(interactive)
(+backward-kill-word-wrapper #'+paredit--backward-kill-word arg))
(provide '+paredit)
;;; +paredit.el ends here

View File

@ -1,4 +1,12 @@
;;; user-save.el -*- lexical-binding: t; -*-
;;; user-save.el --- Do things when explicitly saving files -*- lexical-binding: t; -*-
;; Copyright (C) 2021--2022 Case Duckworth <acdw@acdw.net>
;; URL: ...
;; Version: 0.1.0
;; Package-Requires: ((emacs "24.3"))
;; Keywords: files
;;; Commentary:
;; Because `super-save-mode' automatically saves every time we move away from a
;; buffer, it tends to run a lot of `before-save-hook's that don't need to be
@ -83,7 +91,7 @@ whether the buffer needs to be saved."
:keymap user-save-mode-map)
;;;###autoload
(defun turn-off-user-save-mode ()
(defun user-save-mode-disable ()
"Turn off `user-save-mode' in the current buffer."
(user-save-mode -1))

View File

@ -7,34 +7,34 @@
(require 'acdw)
(require 'machine)
;; Other ideas: [[https://twitter.com/NPRougier/status/1488570192561160195][from Nic Rougier]]
(add-function :after machine-after-load-theme
(defun +bob-set-faces (&rest _)
(let ((base-face "IBM Plex Mono")
(base-size 105)
(italic-face nil)
;; (bold-face nil)
(mono-face nil)
(var-face "IBM Plex Serif")
(var-size 1.0))
(+set-faces
`((default
:family ,base-face
:height ,base-size
:weight normal)
;; (bold :family ,(or bold-face base-face)
;; :weight bold)
(italic :family ,(or italic-face base-face)
:weight normal
:slant italic)
(fixed-pitch :family ,(or mono-face base-face)
:height 1.0)
(variable-pitch
:family ,(or var-face base-face)
:height ,var-size)
(org-italic
:family ,(or var-face base-face)
:slant italic))))
))
(defun +bob-set-faces (&rest _)
(let ((base-face "IBM Plex Mono")
(base-size 105)
(italic-face nil)
;; (bold-face nil)
(mono-face nil)
(var-face "IBM Plex Serif")
(var-size 1.0))
(+set-faces
`((default
:family ,base-face
:height ,base-size
:weight normal)
;; (bold :family ,(or bold-face base-face)
;; :weight bold)
(italic :family ,(or italic-face base-face)
:weight normal
:slant italic)
(fixed-pitch :family ,(or mono-face base-face)
:height 1.0)
(variable-pitch
:family ,(or var-face base-face)
:height ,var-size)
(org-italic
:family ,(or var-face base-face)
:slant italic)))))
;; bob.el ends here
;; Other ideas: [[https://twitter.com/NPRougier/status/1488570192561160195][from Nic Rougier]]
(add-function :after machine-after-load-theme #'+bob-set-faces)
;; bob.el ends here (+bob-set-faces)