diff options
Diffstat (limited to 'lisp')
-rw-r--r-- | lisp/+browse-url.el | 6 | ||||
-rw-r--r-- | lisp/+consult.el | 2 | ||||
-rw-r--r-- | lisp/+dired.el | 23 | ||||
-rw-r--r-- | lisp/+init.el | 9 | ||||
-rw-r--r-- | lisp/+jabber.el | 12 | ||||
-rw-r--r-- | lisp/+key.el | 6 | ||||
-rw-r--r-- | lisp/+org.el | 13 | ||||
-rw-r--r-- | lisp/+setup.el | 80 | ||||
-rw-r--r-- | lisp/+straight.el | 1 | ||||
-rw-r--r-- | lisp/acdw.el | 23 | ||||
-rw-r--r-- | lisp/find-script.el | 36 |
11 files changed, 122 insertions, 89 deletions
diff --git a/lisp/+browse-url.el b/lisp/+browse-url.el index dbbfef2..fc479e4 100644 --- a/lisp/+browse-url.el +++ b/lisp/+browse-url.el | |||
@@ -120,9 +120,9 @@ ARGS are ignored here, but passed on for later processing." | |||
120 | ;; along with the rest of the args, in a list to the original caller (probably | 120 | ;; along with the rest of the args, in a list to the original caller (probably |
121 | ;; `browse-url'.) | 121 | ;; `browse-url'.) |
122 | (apply 'list | 122 | (apply 'list |
123 | (cl-loop with url = (substring-no-properties | 123 | (cl-loop with url = (substring-no-properties |
124 | (if (consp url) (car url) url)) | 124 | (if (consp url) (car url) url)) |
125 | for (regex . transformation) in +browse-url-transformations | 125 | for (regex . transformation) in +browse-url-transformations |
126 | if (string-match regex url) | 126 | if (string-match regex url) |
127 | return (replace-match transformation nil nil url) | 127 | return (replace-match transformation nil nil url) |
128 | ;; else | 128 | ;; else |
diff --git a/lisp/+consult.el b/lisp/+consult.el index dc06ad5..21c2565 100644 --- a/lisp/+consult.el +++ b/lisp/+consult.el | |||
@@ -5,7 +5,7 @@ | |||
5 | (defun +consult-project-root () | 5 | (defun +consult-project-root () |
6 | "Return either the current project, or the VC root, of current file." | 6 | "Return either the current project, or the VC root, of current file." |
7 | (if (and (functionp 'project-current) | 7 | (if (and (functionp 'project-current) |
8 | (project-current)) | 8 | (project-current)) |
9 | (car (project-roots (project-current))) | 9 | (car (project-roots (project-current))) |
10 | (vc-root-dir))) | 10 | (vc-root-dir))) |
11 | 11 | ||
diff --git a/lisp/+dired.el b/lisp/+dired.el index 9a2e01a..2e42c19 100644 --- a/lisp/+dired.el +++ b/lisp/+dired.el | |||
@@ -2,18 +2,17 @@ | |||
2 | 2 | ||
3 | ;;; Code: | 3 | ;;; Code: |
4 | 4 | ||
5 | (require 'vertico) | 5 | (with-eval-after-load 'vertico |
6 | 6 | (defun +dired-goto-file (file) | |
7 | (defun +dired-goto-file (file) | 7 | "ADVICE for `dired-goto-file' to make RET call `vertico-exit'." |
8 | "ADVICE for `dired-goto-file' to make RET call `vertico-exit'." | 8 | (interactive ; stolen from `dired-goto-file' |
9 | (interactive ; stolen from `dired-goto-file' | 9 | (prog1 |
10 | (prog1 | 10 | (list (dlet ((vertico-map (copy-keymap vertico-map))) |
11 | (list (dlet ((vertico-map (copy-keymap vertico-map))) | 11 | (define-key vertico-map (kbd "RET") #'vertico-exit) |
12 | (define-key vertico-map (kbd "RET") #'vertico-exit) | 12 | (expand-file-name (read-file-name "Goto file: " |
13 | (expand-file-name (read-file-name "Goto file: " | 13 | (dired-current-directory))))) |
14 | (dired-current-directory))))) | 14 | (push-mark))) |
15 | (push-mark))) | 15 | (dired-goto-file file))) |
16 | (dired-goto-file file)) | ||
17 | 16 | ||
18 | ;;; [[https://www.reddit.com/r/emacs/comments/u2lf9t/weekly_tips_tricks_c_thread/i4n9aoa/?context=3][Dim files in .gitignore]] | 17 | ;;; [[https://www.reddit.com/r/emacs/comments/u2lf9t/weekly_tips_tricks_c_thread/i4n9aoa/?context=3][Dim files in .gitignore]] |
19 | 18 | ||
diff --git a/lisp/+init.el b/lisp/+init.el index 8f999f9..a3f680b 100644 --- a/lisp/+init.el +++ b/lisp/+init.el | |||
@@ -72,11 +72,10 @@ are sorted lexigraphically." | |||
72 | ;; otherwise, sort lexigraphically | 72 | ;; otherwise, sort lexigraphically |
73 | (t (string< s1 s2))))))))) | 73 | (t (string< s1 s2))))))))) |
74 | ;; Return to original point relative to the defun we were in | 74 | ;; Return to original point relative to the defun we were in |
75 | (goto-char (point-min)) | 75 | (ignore-errors (goto-char (point-min)) |
76 | (re-search-forward current-defun-re) | 76 | (re-search-forward current-defun-re) |
77 | (beginning-of-defun) | 77 | (beginning-of-defun) |
78 | (goto-char (+ (point) defun-point)) | 78 | (goto-char (+ (point) defun-point))))) |
79 | )) | ||
80 | 79 | ||
81 | (defun +init-sort-then-save () | 80 | (defun +init-sort-then-save () |
82 | "Sort init.el, then save it." | 81 | "Sort init.el, then save it." |
diff --git a/lisp/+jabber.el b/lisp/+jabber.el index c5d568c..e018b0c 100644 --- a/lisp/+jabber.el +++ b/lisp/+jabber.el | |||
@@ -10,6 +10,18 @@ | |||
10 | (require 'jabber) | 10 | (require 'jabber) |
11 | (require 'tracking) | 11 | (require 'tracking) |
12 | 12 | ||
13 | (defgroup +jabber nil | ||
14 | "Extra jabber.el customizations." | ||
15 | :group 'jabber) | ||
16 | |||
17 | (defcustom +jabber-ws-prefix 0 | ||
18 | "Width to pad left side of chats." | ||
19 | :type 'string) | ||
20 | |||
21 | (defcustom +jabber-pre-prompt "\n" | ||
22 | "String to put before the prompt." | ||
23 | :type 'string) | ||
24 | |||
13 | (defvar +jabber-tracking-show-p #'jabber-activity-show-p-default | 25 | (defvar +jabber-tracking-show-p #'jabber-activity-show-p-default |
14 | "Function that checks if the given JID should be shown in the mode line. | 26 | "Function that checks if the given JID should be shown in the mode line. |
15 | This does the same as `jabber-activity-show-p', but for the | 27 | This does the same as `jabber-activity-show-p', but for the |
diff --git a/lisp/+key.el b/lisp/+key.el index ad3b215..a217dad 100644 --- a/lisp/+key.el +++ b/lisp/+key.el | |||
@@ -19,9 +19,9 @@ | |||
19 | 19 | ||
20 | ;; I need to define this map before the proper mode map. | 20 | ;; I need to define this map before the proper mode map. |
21 | (defvar +key-leader-map (let ((map (make-sparse-keymap)) | 21 | (defvar +key-leader-map (let ((map (make-sparse-keymap)) |
22 | (c-z (global-key-binding "\C-z"))) | 22 | (c-z (global-key-binding "\C-z"))) |
23 | (define-key map "\C-z" c-z) | 23 | ;;(define-key map "\C-z" c-z) |
24 | map) | 24 | map) |
25 | "A leader keymap under the \"C-z\" bind.") | 25 | "A leader keymap under the \"C-z\" bind.") |
26 | 26 | ||
27 | ;; http://xahlee.info/emacs/emacs/emacs_menu_app_keys.html and | 27 | ;; http://xahlee.info/emacs/emacs/emacs_menu_app_keys.html and |
diff --git a/lisp/+org.el b/lisp/+org.el index 252ee55..6075b60 100644 --- a/lisp/+org.el +++ b/lisp/+org.el | |||
@@ -588,19 +588,6 @@ and POST-PROCESS are passed to `org-export-to-file'." | |||
588 | ("—" "---")))) | 588 | ("—" "---")))) |
589 | (replace-match replace nil nil))))) | 589 | (replace-match replace nil nil))))) |
590 | 590 | ||
591 | ;;; Toggle org-hide-emphasis-markers | ||
592 | |||
593 | (define-minor-mode +org-show-mode | ||
594 | "Show emphasis markers and full links in `org-mode'." | ||
595 | :lighter "/*/" | ||
596 | (setq org-hide-emphasis-markers (not +org-show-mode) | ||
597 | org-link-descriptive (not +org-show-mode)) | ||
598 | (funcall (if +org-show-mode | ||
599 | #'remove-from-invisibility-spec | ||
600 | #'add-to-invisibility-spec) | ||
601 | '(org-link)) | ||
602 | (font-lock-update)) | ||
603 | |||
604 | ;;; go forward and backward in the tree, ~ cleanly ~ | 591 | ;;; go forward and backward in the tree, ~ cleanly ~ |
605 | ;; https://stackoverflow.com/a/25201697/10756297 | 592 | ;; https://stackoverflow.com/a/25201697/10756297 |
606 | 593 | ||
diff --git a/lisp/+setup.el b/lisp/+setup.el index db59223..919e312 100644 --- a/lisp/+setup.el +++ b/lisp/+setup.el | |||
@@ -29,23 +29,37 @@ | |||
29 | "Warn the user that something bad happened in `setup'." | 29 | "Warn the user that something bad happened in `setup'." |
30 | (display-warning 'setup (format message args))) | 30 | (display-warning 'setup (format message args))) |
31 | 31 | ||
32 | (defun +setup-wrap-to-demote-errors (body name) | ||
33 | "Wrap BODY in a `with-demoted-errors' block. | ||
34 | This behavior is prevented if `setup-attributes' contains the | ||
35 | symbol `without-error-demotion'. | ||
36 | |||
37 | This function differs from `setup-wrap-to-demote-errors' in that | ||
38 | it includes the NAME of the setup form in the warning output." | ||
39 | (if (memq 'without-error-demotion setup-attributes) | ||
40 | body | ||
41 | `(with-demoted-errors ,(format "Error in setup form on line %d (%s): %%S" | ||
42 | (line-number-at-pos) | ||
43 | name) | ||
44 | ,body))) | ||
45 | |||
32 | (setup-define :quit | 46 | (setup-define :quit |
33 | 'setup-quit | 47 | 'setup-quit |
34 | :documentation "Quit the current `setup' form. | 48 | :documentation "Quit the current `setup' form. |
35 | Good for commenting.") | 49 | Good for commenting.") |
36 | 50 | ||
37 | (setup-define :face | 51 | (setup-define :face |
38 | (lambda (face spec) | 52 | (lambda (face spec) |
39 | `(custom-set-faces (list ,face ,spec 'now "Customized by `setup'."))) | 53 | `(custom-set-faces (list ,face ,spec 'now "Customized by `setup'."))) |
40 | :documentation "Customize FACE with SPEC using `custom-set-faces'." | 54 | :documentation "Customize FACE with SPEC using `custom-set-faces'." |
41 | :repeatable t) | 55 | :repeatable t) |
42 | 56 | ||
43 | (setup-define :load-after | 57 | (setup-define :load-after |
44 | (lambda (&rest features) | 58 | (lambda (&rest features) |
45 | (let ((body `(require ',(setup-get 'feature)))) | 59 | (let ((body `(require ',(setup-get 'feature)))) |
46 | (dolist (feature (nreverse features)) | 60 | (dolist (feature (nreverse features)) |
47 | (setq body `(with-eval-after-load ',feature ,body))) | 61 | (setq body `(with-eval-after-load ',feature ,body))) |
48 | body)) | 62 | body)) |
49 | :documentation "Load the current feature after FEATURES.") | 63 | :documentation "Load the current feature after FEATURES.") |
50 | 64 | ||
51 | (setup-define :load-from | 65 | (setup-define :load-from |
@@ -88,50 +102,7 @@ If PATH does not exist, abort the evaluation." | |||
88 | ',recipe) | 102 | ',recipe) |
89 | ,(setup-quit)) | 103 | ,(setup-quit)) |
90 | (:success t))) | 104 | (:success t))) |
91 | (defun setup--straight-handle-arg (arg var) | 105 | ,(setup-quit)))) |
92 | (cond | ||
93 | ((and (boundp var) (symbol-value var)) t) | ||
94 | ((keywordp arg) (set var t)) | ||
95 | ((functionp arg) (set var nil) (funcall arg)) | ||
96 | ((listp arg) (set var nil) (eval arg :lexical)))) | ||
97 | |||
98 | (setup-define :straight | ||
99 | (lambda (recipe &rest predicates) | ||
100 | (let* ((skp (make-symbol "straight-keyword-p")) | ||
101 | (straight-use-p | ||
102 | (cl-every (lambda (f) (setup--straight-handle-arg f skp)) | ||
103 | predicates)) | ||
104 | (form `(unless (and ,straight-use-p | ||
105 | (condition-case e | ||
106 | (straight-use-package ',recipe) | ||
107 | (error | ||
108 | (+setup-warn ":straight error: %S" | ||
109 | ',recipe) | ||
110 | ,(setup-quit)) | ||
111 | (:success t))) | ||
112 | ,(setup-quit)))) | ||
113 | ;; Keyword arguments --- :quit is special and should short-circuit | ||
114 | (if (memq :quit predicates) | ||
115 | (setq form `,(setup-quit)) | ||
116 | ;; Otherwise, handle the rest of them ... | ||
117 | (when-let ((after (cadr (memq :after predicates)))) | ||
118 | (setq form `(with-eval-after-load ,(if (eq after t) | ||
119 | (setup-get 'feature) | ||
120 | after) | ||
121 | ,form)))) | ||
122 | ;; Finally ... | ||
123 | form)) | ||
124 | :documentation "Install RECIPE with `straight-use-package'. | ||
125 | If PREDICATES are given, only install RECIPE if all of them return non-nil. | ||
126 | The following keyword arguments are also recognized: | ||
127 | - :quit --- immediately stop evaluating. Good for commenting. | ||
128 | - :after FEATURE --- only install RECIPE after FEATURE is loaded. | ||
129 | If FEATURE is t, install RECIPE after the current feature." | ||
130 | :repeatable nil | ||
131 | :indent 1 | ||
132 | :shorthand (lambda (sexp) | ||
133 | (let ((recipe (cadr sexp))) | ||
134 | (or (car-safe recipe) recipe)))) ,(setup-quit)))) | ||
135 | ;; Keyword arguments --- :quit is special and should short-circuit | 106 | ;; Keyword arguments --- :quit is special and should short-circuit |
136 | (if (memq :quit predicates) | 107 | (if (memq :quit predicates) |
137 | (setq form `,(setup-quit)) | 108 | (setq form `,(setup-quit)) |
@@ -155,6 +126,13 @@ The following keyword arguments are also recognized: | |||
155 | (let ((recipe (cadr sexp))) | 126 | (let ((recipe (cadr sexp))) |
156 | (or (car-safe recipe) recipe))))) | 127 | (or (car-safe recipe) recipe))))) |
157 | 128 | ||
129 | (setup-define :needs | ||
130 | (lambda (executable) | ||
131 | `(unless (executable-find ,executable) | ||
132 | ,(setup-quit))) | ||
133 | :documentation "If EXECUTABLE is not in the path, stop here." | ||
134 | :repeatable 1) | ||
135 | |||
158 | 136 | ||
159 | ;;; Redefines of `setup' forms | 137 | ;;; Redefines of `setup' forms |
160 | 138 | ||
diff --git a/lisp/+straight.el b/lisp/+straight.el index d00ad9a..cba6c96 100644 --- a/lisp/+straight.el +++ b/lisp/+straight.el | |||
@@ -34,6 +34,7 @@ all of them, for reasons that should be obvious. | |||
34 | 34 | ||
35 | With a prefix argument, it also pulls the packages FROM-UPSTREAM." | 35 | With a prefix argument, it also pulls the packages FROM-UPSTREAM." |
36 | (interactive "P") | 36 | (interactive "P") |
37 | (straight-pull-recipe-repositories) | ||
37 | (straight-pull-all from-upstream) | 38 | (straight-pull-all from-upstream) |
38 | (straight-rebuild-all)) | 39 | (straight-rebuild-all)) |
39 | 40 | ||
diff --git a/lisp/acdw.el b/lisp/acdw.el index 7ef745d..6707e76 100644 --- a/lisp/acdw.el +++ b/lisp/acdw.el | |||
@@ -138,6 +138,10 @@ active, or else the entire buffer." | |||
138 | (= (line-beginning-position) (line-end-position))) | 138 | (= (line-beginning-position) (line-end-position))) |
139 | (insert "\n"))))) | 139 | (insert "\n"))))) |
140 | 140 | ||
141 | (defcustom +open-paragraph-ignore-modes '(special-mode lui-mode comint-mode) | ||
142 | "Modes in which `+open-paragraph' makes no sense." | ||
143 | :type '(repeat function)) | ||
144 | |||
141 | (defun +open-paragraph (&optional arg) | 145 | (defun +open-paragraph (&optional arg) |
142 | "Open a paragraph after paragraph at point. | 146 | "Open a paragraph after paragraph at point. |
143 | A paragraph is defined as continguous non-empty lines of text | 147 | A paragraph is defined as continguous non-empty lines of text |
@@ -148,7 +152,7 @@ Called with prefix ARG, open a paragraph before point." | |||
148 | ;; TODO: Take an integer as ARG, allowing for skipping paragraphs up and down. | 152 | ;; TODO: Take an integer as ARG, allowing for skipping paragraphs up and down. |
149 | (interactive "*P") | 153 | (interactive "*P") |
150 | ;; TODO: add `+open-paragraph-ignore-modes' | 154 | ;; TODO: add `+open-paragraph-ignore-modes' |
151 | (unless (derived-mode-p 'special-mode 'lui-mode 'comint-mode) | 155 | (unless (apply #'derived-mode-p +open-paragraph-ignore-modes) |
152 | ;; Go to next blank line. This /isn't/ `end-of-paragraph-text' because | 156 | ;; Go to next blank line. This /isn't/ `end-of-paragraph-text' because |
153 | ;; that's weird with org, and I'm guessing other modes too. | 157 | ;; that's weird with org, and I'm guessing other modes too. |
154 | (unless (looking-at "^$") (forward-line (if arg -1 +1))) | 158 | (unless (looking-at "^$") (forward-line (if arg -1 +1))) |
@@ -426,5 +430,22 @@ This calls `indent-rigidly' and passes ARG to it." | |||
426 | (goto-char (line-end-position))) | 430 | (goto-char (line-end-position))) |
427 | (call-interactively #'indent-rigidly)) | 431 | (call-interactively #'indent-rigidly)) |
428 | 432 | ||
433 | (defun +sort-lines (reverse beg end) | ||
434 | "Sort lines in region, ignoring leading whitespace. | ||
435 | REVERSE non-nil means descending order; interactively, REVERSE is | ||
436 | the prefix argument, and BEG and END are the region. The | ||
437 | variable `sort-fold-case' determines whether case affects the | ||
438 | sort order." | ||
439 | (interactive "P\nr") | ||
440 | (save-excursion | ||
441 | (save-restriction | ||
442 | (narrow-to-region beg end) | ||
443 | (goto-char (point-min)) | ||
444 | (let ((inhibit-field-text-motion t)) | ||
445 | (sort-subr reverse | ||
446 | #'forward-line | ||
447 | #'end-of-line | ||
448 | #'beginning-of-line-text))))) | ||
449 | |||
429 | (provide 'acdw) | 450 | (provide 'acdw) |
430 | ;;; acdw.el ends here | 451 | ;;; acdw.el ends here |
diff --git a/lisp/find-script.el b/lisp/find-script.el new file mode 100644 index 0000000..9e3633a --- /dev/null +++ b/lisp/find-script.el | |||
@@ -0,0 +1,36 @@ | |||
1 | ;;; find-script.el --- Find a script in $PATH -*- lexical-binding: t; -*- | ||
2 | |||
3 | ;;; Commentary: | ||
4 | |||
5 | ;; This package makes it easier to find a script to edit in $PATH. The initial | ||
6 | ;; `rehash-exes' is slow, but it's stored in `*exes*' as a caching mechanism. | ||
7 | ;; However, I'm sure it could be improved. | ||
8 | |||
9 | ;; In addition, `*exes*' currently contains /all/ executables in $PATH, which | ||
10 | ;; ... maybe only the ones stored in some text format should be shown. | ||
11 | |||
12 | ;;; Code: | ||
13 | |||
14 | (defvar *exes* nil | ||
15 | "All the exectuables in $PATH. | ||
16 | Run `rehash-exes' to refresh this variable.") | ||
17 | |||
18 | (defun rehash-exes () | ||
19 | "List all the executables in $PATH. | ||
20 | Also sets `*exes*' parameter." | ||
21 | (setq *exes* | ||
22 | (cl-loop for dir in exec-path | ||
23 | append (file-expand-wildcards (concat dir "*")) | ||
24 | into exes | ||
25 | finally return exes))) | ||
26 | |||
27 | ;;;###autoload | ||
28 | (defun find-script (script) | ||
29 | "Find a file in $PATH." | ||
30 | (interactive | ||
31 | (list (let ((exes (or *exes* (rehash-exes)))) | ||
32 | (completing-read "Script> " exes nil t)))) | ||
33 | (find-file script)) | ||
34 | |||
35 | (provide 'find-script) | ||
36 | ;;; find-script.el ends here | ||