diff options
-rw-r--r-- | init.el | 133 | ||||
-rw-r--r-- | lisp/+browse-url.el | 117 | ||||
-rw-r--r-- | lisp/+elfeed.el | 24 | ||||
-rw-r--r-- | lisp/+emacs.el | 1 | ||||
-rw-r--r-- | lisp/+key.el | 14 | ||||
-rw-r--r-- | lisp/+modeline.el | 8 | ||||
-rw-r--r-- | lisp/+org.el | 55 | ||||
-rw-r--r-- | lisp/+util.el | 8 |
8 files changed, 332 insertions, 28 deletions
diff --git a/init.el b/init.el index e0cf8ae..5d756cd 100644 --- a/init.el +++ b/init.el | |||
@@ -25,8 +25,7 @@ | |||
25 | ;; necessary for good functioning. In this block, I add extra | 25 | ;; necessary for good functioning. In this block, I add extra |
26 | ;; things or more "experimental" ones that might not belong in a | 26 | ;; things or more "experimental" ones that might not belong in a |
27 | ;; separate file. | 27 | ;; separate file. |
28 | (:global "M-o" 'other-buffer | 28 | (:global "C-x C-k" 'kill-this-buffer) |
29 | "C-x C-k" 'kill-this-buffer) | ||
30 | ;; C-h deletes backward - see https://idiomdrottning.org/bad-emacs-defaults | 29 | ;; C-h deletes backward - see https://idiomdrottning.org/bad-emacs-defaults |
31 | (global-set-key (kbd "C-h") 'delete-backward-char) | 30 | (global-set-key (kbd "C-h") 'delete-backward-char) |
32 | (keyboard-translate ?\C-h ?\C-?)) | 31 | (keyboard-translate ?\C-h ?\C-?)) |
@@ -39,7 +38,7 @@ | |||
39 | (:hook '+init-add-setup-to-imenu)) | 38 | (:hook '+init-add-setup-to-imenu)) |
40 | 39 | ||
41 | (setup (:require +key) | 40 | (setup (:require +key) |
42 | (+key-global-mode +1)) | 41 | (+key-setup)) |
43 | 42 | ||
44 | (setup (:require auth-source) | 43 | (setup (:require auth-source) |
45 | (:option auth-sources (list (private/ "authinfo") | 44 | (:option auth-sources (list (private/ "authinfo") |
@@ -51,7 +50,8 @@ | |||
51 | (:also-load +pulse) | 50 | (:also-load +pulse) |
52 | (:option pulse-flag nil | 51 | (:option pulse-flag nil |
53 | pulse-delay 0.5 | 52 | pulse-delay 0.5 |
54 | pulse-iterations 1) | 53 | pulse-iterations 1 |
54 | (append +pulse-location-commands) 'lui-track-jump-to-indicator) | ||
55 | (+pulse-location-mode +1)) | 55 | (+pulse-location-mode +1)) |
56 | 56 | ||
57 | (setup calendar | 57 | (setup calendar |
@@ -168,7 +168,7 @@ | |||
168 | (setup (:straight anzu) | 168 | (setup (:straight anzu) |
169 | (:option anzu-cons-mode-line-p nil) | 169 | (:option anzu-cons-mode-line-p nil) |
170 | (:+key [remap query-replace] 'anzu-query-replace-regexp | 170 | (:+key [remap query-replace] 'anzu-query-replace-regexp |
171 | [remap query-replace-regexp] 'anzu-query-replace-regexp) | 171 | [remap query-replace-regexp] 'anzu-query-replace-regexp) |
172 | (global-anzu-mode +1) | 172 | (global-anzu-mode +1) |
173 | (:bind-into isearch | 173 | (:bind-into isearch |
174 | [remap isearch-query-replace] | 174 | [remap isearch-query-replace] |
@@ -206,8 +206,8 @@ | |||
206 | (circadian-setup)) | 206 | (circadian-setup)) |
207 | 207 | ||
208 | (setup (:straight circe) | 208 | (setup (:straight circe) |
209 | (:require _circe) | 209 | (:require _circe |
210 | (:require +circe) | 210 | +circe) |
211 | (autoload '+irc "+circe" "Connect to IRC." t) | 211 | (autoload '+irc "+circe" "Connect to IRC." t) |
212 | 212 | ||
213 | ;; Formatting options | 213 | ;; Formatting options |
@@ -315,7 +315,7 @@ | |||
315 | ("C-M-#" . consult-register) | 315 | ("C-M-#" . consult-register) |
316 | ;; Other custom bindings | 316 | ;; Other custom bindings |
317 | ("M-y" . consult-yank-pop) | 317 | ("M-y" . consult-yank-pop) |
318 | ("<help> a" . consult-apropos) | 318 | ("<f1> a" . consult-apropos) |
319 | ;; M-g bindings (goto-map) | 319 | ;; M-g bindings (goto-map) |
320 | ("M-g e" . consult-compile-error) | 320 | ("M-g e" . consult-compile-error) |
321 | ("M-g f" . consult-flymake) ; or consult-flycheck | 321 | ("M-g f" . consult-flymake) ; or consult-flycheck |
@@ -339,7 +339,7 @@ | |||
339 | ("M-s u" . consult-focus-lines) | 339 | ("M-s u" . consult-focus-lines) |
340 | ;; Isearch integration | 340 | ;; Isearch integration |
341 | ("M-s e" . consult-isearch-history))) | 341 | ("M-s e" . consult-isearch-history))) |
342 | (global-set-key (kbd (car binding)) (cdr binding))) | 342 | (define-key +key-mode-map (kbd (car binding)) (cdr binding))) |
343 | (with-eval-after-load 'isearch-mode | 343 | (with-eval-after-load 'isearch-mode |
344 | (dolist (binding '(("M-e" . consult-isearch-history) | 344 | (dolist (binding '(("M-e" . consult-isearch-history) |
345 | ("M-s e" . consult-isearch-history) | 345 | ("M-s e" . consult-isearch-history) |
@@ -370,8 +370,8 @@ | |||
370 | 370 | ||
371 | (setup (:straight crux) | 371 | (setup (:straight crux) |
372 | (:+key "C-o" 'crux-smart-open-line | 372 | (:+key "C-o" 'crux-smart-open-line |
373 | "M-o" 'crux-other-window-or-switch-buffer | 373 | "M-o" 'crux-other-window-or-switch-buffer |
374 | "C-x 4 t" 'crux-transpose-windows) | 374 | "C-x 4 t" 'crux-transpose-windows) |
375 | 375 | ||
376 | (el-patch-feature crux) | 376 | (el-patch-feature crux) |
377 | (with-eval-after-load 'crux | 377 | (with-eval-after-load 'crux |
@@ -419,8 +419,8 @@ See also `crux-reopen-as-root-mode'." | |||
419 | (setup (:straight embark) | 419 | (setup (:straight embark) |
420 | (:option prefix-help-command 'embark-prefix-help-command) | 420 | (:option prefix-help-command 'embark-prefix-help-command) |
421 | (:+key "C-." 'embark-act | 421 | (:+key "C-." 'embark-act |
422 | "M-." 'embark-dwim | 422 | "M-." 'embark-dwim |
423 | "<help> B" 'embark-bindings)) | 423 | "<f1> B" 'embark-bindings)) |
424 | 424 | ||
425 | (setup (:straight embark-consult) | 425 | (setup (:straight embark-consult) |
426 | (:load-after consult embark) | 426 | (:load-after consult embark) |
@@ -461,10 +461,12 @@ See also `crux-reopen-as-root-mode'." | |||
461 | (gcmh-mode +1)) | 461 | (gcmh-mode +1)) |
462 | 462 | ||
463 | (setup (:straight helpful) | 463 | (setup (:straight helpful) |
464 | (:+key "<help> f" 'helpful-callable | 464 | (run-with-idle-timer 0.5 nil |
465 | "<help> v" 'helpful-variable | 465 | 'require 'helpful) |
466 | "<help> k" 'helpful-key | 466 | (:+key "<f1> f" 'helpful-callable |
467 | "C-c C-d" 'helpful-at-point)) | 467 | "<f1> v" 'helpful-variable |
468 | "<f1> k" 'helpful-key | ||
469 | "C-c C-d" 'helpful-at-point)) | ||
468 | 470 | ||
469 | (setup (:straight (hippie-completing-read | 471 | (setup (:straight (hippie-completing-read |
470 | :host github | 472 | :host github |
@@ -531,7 +533,7 @@ See also `crux-reopen-as-root-mode'." | |||
531 | 533 | ||
532 | (setup (:straight mwim) | 534 | (setup (:straight mwim) |
533 | (:+key "C-a" #'mwim-beginning | 535 | (:+key "C-a" #'mwim-beginning |
534 | "C-e" #'mwim-end)) | 536 | "C-e" #'mwim-end)) |
535 | 537 | ||
536 | (setup (:straight orderless) | 538 | (setup (:straight orderless) |
537 | (:option completion-styles '(orderless))) | 539 | (:option completion-styles '(orderless))) |
@@ -589,6 +591,7 @@ See also `crux-reopen-as-root-mode'." | |||
589 | org-log-into-drawer t | 591 | org-log-into-drawer t |
590 | org-outline-path-complete-in-steps nil | 592 | org-outline-path-complete-in-steps nil |
591 | org-pretty-entities t | 593 | org-pretty-entities t |
594 | org-pretty-entities-include-sub-superscripts nil | ||
592 | org-refile-use-outline-path 'file | 595 | org-refile-use-outline-path 'file |
593 | org-special-ctrl-a/e t | 596 | org-special-ctrl-a/e t |
594 | org-special-ctrl-k t | 597 | org-special-ctrl-k t |
@@ -666,6 +669,7 @@ See also `crux-reopen-as-root-mode'." | |||
666 | +modeline-vc | 669 | +modeline-vc |
667 | simple-modeline-segment-misc-info | 670 | simple-modeline-segment-misc-info |
668 | simple-modeline-segment-process | 671 | simple-modeline-segment-process |
672 | +modeline-text-scale | ||
669 | +modeline-narrowed | 673 | +modeline-narrowed |
670 | +modeline-minions | 674 | +modeline-minions |
671 | +modeline-major-mode))) | 675 | +modeline-major-mode))) |
@@ -719,7 +723,7 @@ See also `crux-reopen-as-root-mode'." | |||
719 | 723 | ||
720 | (setup (:straight undo-fu) | 724 | (setup (:straight undo-fu) |
721 | (:+key "C-/" #'undo-fu-only-undo | 725 | (:+key "C-/" #'undo-fu-only-undo |
722 | "C-?" #'undo-fu-only-redo)) | 726 | "C-?" #'undo-fu-only-redo)) |
723 | 727 | ||
724 | (setup (:straight undo-fu-session) | 728 | (setup (:straight undo-fu-session) |
725 | (:option undo-fu-session-incompatible-files '("/COMMIT_EDITMSG\\'" | 729 | (:option undo-fu-session-incompatible-files '("/COMMIT_EDITMSG\\'" |
@@ -730,7 +734,8 @@ See also `crux-reopen-as-root-mode'." | |||
730 | 734 | ||
731 | (setup (:straight (unfill :host github :repo "purcell/unfill" | 735 | (setup (:straight (unfill :host github :repo "purcell/unfill" |
732 | :fork (:host github :repo "duckwork/unfill"))) | 736 | :fork (:host github :repo "duckwork/unfill"))) |
733 | (:+key "M-q" #'unfill-toggle)) | 737 | (:bind-into text-mode |
738 | "M-q" #'unfill-toggle)) | ||
734 | 739 | ||
735 | (setup (:straight (vertico | 740 | (setup (:straight (vertico |
736 | :host github | 741 | :host github |
@@ -765,7 +770,87 @@ See also `crux-reopen-as-root-mode'." | |||
765 | 770 | ||
766 | (setup (:straight zzz-to-char) | 771 | (setup (:straight zzz-to-char) |
767 | (:+key "M-z" (lambda (prefix) | 772 | (:+key "M-z" (lambda (prefix) |
768 | "Call `zzz-to-char' or `zzz-up-to-char' with PREFIX arg." | 773 | "Call `zzz-to-char' or `zzz-up-to-char' with PREFIX arg." |
769 | (interactive "P") | 774 | (interactive "P") |
770 | (call-interactively | 775 | (call-interactively |
771 | (if prefix #'zzz-up-to-char #'zzz-to-char))))) | 776 | (if prefix #'zzz-up-to-char #'zzz-to-char))))) |
777 | |||
778 | (setup (:straight elfeed) | ||
779 | (:also-load +elfeed) | ||
780 | (:option elfeed-use-curl t | ||
781 | elfeed-curl-extra-arguments '("--insecure") | ||
782 | elfeed-show-unique-buffers t | ||
783 | elfeed-db-directory (sync/ "elfeed/db/" t)) | ||
784 | (:with-mode elfeed-show-mode | ||
785 | (:bind "SPC" '+elfeed-scroll-up-command | ||
786 | "S-SPC" '+elfeed-scroll-down-command))) | ||
787 | |||
788 | (setup (:straight elfeed-org) | ||
789 | (:option rmh-elfeed-org-files (list (sync/ "elfeed/elfeed.org" t))) | ||
790 | (elfeed-org)) | ||
791 | |||
792 | (setup (:straight (lin :host gitlab :repo "protesilaos/lin")) | ||
793 | (require 'lin) | ||
794 | (:hook-into dired-mode | ||
795 | elfeed-search-mode | ||
796 | git-rebase-mode | ||
797 | ibuffer-mode | ||
798 | ledger-report-mode | ||
799 | log-view-mode | ||
800 | magit-log-mode | ||
801 | notmuch-search-mode | ||
802 | notmuch-tree-mode | ||
803 | org-agenda-mode | ||
804 | tabulated-list-mode)) | ||
805 | |||
806 | |||
807 | (setup browse-url | ||
808 | (:also-load +browse-url) | ||
809 | (:option browse-url-secondary-browser-function (if (executable-find "firefox") | ||
810 | 'browse-url-firefox | ||
811 | 'browse-url-default-browser) | ||
812 | browse-url-new-window-flag nil | ||
813 | browse-url-firefox-arguments '("--new-tab") | ||
814 | browse-url-firefox-new-window-is-tab t) | ||
815 | ;; Set up URL handlers. | ||
816 | (+browse-url-set-handlers | ||
817 | (list | ||
818 | (cons (rx ; images | ||
819 | "." (or "jpeg" "jpg" "png") eos) | ||
820 | (lambda (&rest args) | ||
821 | (apply | ||
822 | (cond ((executable-find "feh") '+browse-url-with-feh) | ||
823 | ((executable-find "mpv") '+browse-image-with-mpv) | ||
824 | (t 'eww-browse-url)) | ||
825 | args))) | ||
826 | (cons (rx ; videos | ||
827 | (or "youtube.com" "youtu.be" "yewtu.be" | ||
828 | (seq "." (or "mp4" "gif" "mov" "MOV") eos))) | ||
829 | (lambda (&rest args) | ||
830 | (apply (if (executable-find "mpv") | ||
831 | 'browse-url-mpv | ||
832 | browse-url-secondary-browser-function) | ||
833 | args))) | ||
834 | (cons (rx ; non-eww-friendly websites | ||
835 | (or | ||
836 | "github.com" | ||
837 | "gitlab.com" | ||
838 | "google.com" | ||
839 | "imgur.com" | ||
840 | "pixelfed" | ||
841 | "reddit.com" | ||
842 | "taskiq" | ||
843 | "twitter.com" | ||
844 | )) | ||
845 | browse-url-secondary-browser-function) | ||
846 | (cons "." ; everything else | ||
847 | 'eww-browse-url))) | ||
848 | ;; Transform URLs before passing to `browse-url' | ||
849 | (:option +browse-url-transformations `((,(rx "//" (or "youtube.com" | ||
850 | "youtu.be")) | ||
851 | . "//yewtu.be"))) | ||
852 | (+browse-url-transform-url-global-mode +1)) | ||
853 | |||
854 | (setup (:straight-when pdf-tools | ||
855 | (eq system-type 'gnu/linux)) | ||
856 | (pdf-tools-install)) | ||
diff --git a/lisp/+browse-url.el b/lisp/+browse-url.el new file mode 100644 index 0000000..fad0826 --- /dev/null +++ b/lisp/+browse-url.el | |||
@@ -0,0 +1,117 @@ | |||
1 | ;;; +browse-url.el -*- lexical-binding: t; -*- | ||
2 | |||
3 | ;;; Code: | ||
4 | |||
5 | (require 'cl-lib) | ||
6 | |||
7 | (defgroup +browse-url nil | ||
8 | "Group for my `browse-url' extras." | ||
9 | :group 'browse-url) | ||
10 | |||
11 | ;;; URL Handlers | ||
12 | |||
13 | (defun +browse-url-set-handlers (handlers) | ||
14 | "Set handlers for `browse-url'. | ||
15 | Set `browse-url-handlers', if they exist; else | ||
16 | `browse-url-browser-function'. The reason for this switch is | ||
17 | that the latter is deprecated in Emacs 28+." | ||
18 | (set-default (if (boundp 'browse-url-handlers) | ||
19 | 'browse-url-handlers | ||
20 | 'browse-url-browser-function) | ||
21 | handlers)) | ||
22 | |||
23 | (cl-defmacro +browse-url-make-external-viewer-handler | ||
24 | (viewer default-args &optional (prompt "URL: ") | ||
25 | &key | ||
26 | (custom-group '+browse-url) | ||
27 | (name (format "+browse-url-with-%s" viewer))) | ||
28 | "Create a `browse-url' handler function that calls VIEWER on the url. | ||
29 | Also create a `customize' setting in CUSTOM-GROUP for VIEWER's | ||
30 | arguments. DEFAULT-ARGS specifies the default arguments that | ||
31 | setting should have. PROMPT will be shown to user in the | ||
32 | function's `interactive' spec, as an argument to | ||
33 | `browse-url-interactive-arg'. The resulting function will be | ||
34 | named NAME, defaulting to \"+browse-url-with-VIEWER\", and the variable | ||
35 | \"NAME-args\"." | ||
36 | (declare (indent 1)) | ||
37 | `(progn | ||
38 | (defcustom ,(intern (format "%s-args" name)) | ||
39 | ,default-args | ||
40 | ,(format "Arguments to pass to %s in `%s'." viewer name) | ||
41 | :type '(repeat :tag "Command-line argument" string) | ||
42 | :group ',custom-group) | ||
43 | (defun ,(intern name) (url &optional _new-window) | ||
44 | ,(format "Open URL in %s." viewer) | ||
45 | (interactive (browse-url-interactive-arg ,prompt)) | ||
46 | (let* ((url (browse-url-encode-url url)) | ||
47 | (process-environment (browse-url-process-environment))) | ||
48 | (message ,(format "Opening %%s in %s..." viewer) url) | ||
49 | (apply #'start-process | ||
50 | (concat ,viewer " " url) nil | ||
51 | ,viewer | ||
52 | (append ,(intern (format "%s-args" name)) (list url))))))) | ||
53 | |||
54 | ;; Reference implementation: mpv | ||
55 | (+browse-url-make-external-viewer-handler "mpv" nil "Video URL: ") | ||
56 | ;; And feh too | ||
57 | (+browse-url-make-external-viewer-handler "feh" '("--auto-zoom" | ||
58 | "--geometry" "800x600")) | ||
59 | ;; And ... mpv, but for images | ||
60 | (+browse-url-make-external-viewer-handler "mpv" | ||
61 | '("--image-display-duration=inf") | ||
62 | "Image URL: " | ||
63 | :name "+browse-image-with-mpv") | ||
64 | |||
65 | ;;; URL Transformation Functions | ||
66 | ;; There's a lot of bad websites out there. Luckily we can easily redirect | ||
67 | ;; requests to more privacy-respecting, or just less javascript-ridden, sites | ||
68 | ;; using some basic regex magic. Inspired by add-ons like | ||
69 | ;; https://einaregilsson.com/redirector/. | ||
70 | |||
71 | (defcustom +browse-url-transformations nil | ||
72 | "Transformation rules for various URLs. | ||
73 | This is an alist, the keys of which are regexen to match URLs | ||
74 | against, and the values are how to transform them. Match capture | ||
75 | data will be used in the transformations." | ||
76 | :type | ||
77 | '(alist :key-type (string :tag "URL regex match") | ||
78 | :value-type (string :tag "URL regex transformation")) | ||
79 | :group '+browse-url) | ||
80 | |||
81 | (defun +browse-url-transform-advice (url &rest args) | ||
82 | "ADVICE to transform URL for later opening by `browse-url'. | ||
83 | ARGS are ignored here, but passed on for later processing." | ||
84 | ;; Basically, loop through `+browse-url-transformations' until finding a CAR | ||
85 | ;; that matches the URL. If one is found, transform it using `replace-match' | ||
86 | ;; with the CDR of that cell, or if one isn't, just pass the URL unchanged, | ||
87 | ;; along with the rest of the args, in a list to the original caller (probably | ||
88 | ;; `browse-url'.) | ||
89 | (apply 'list | ||
90 | (cl-loop with url = (substring-no-properties | ||
91 | (if (consp url) (car url) url)) | ||
92 | for (regex . transformation) in +browse-url-transformations | ||
93 | if (string-match regex url) | ||
94 | return (replace-match transformation nil nil url) | ||
95 | ;; else | ||
96 | finally return url) | ||
97 | args)) | ||
98 | |||
99 | (define-minor-mode +browse-url-transform-url-mode | ||
100 | "Minor mode to transform a URL before passing it to `browse-url'. | ||
101 | This can be used to \"redirect\" URLs, for example from an | ||
102 | information silo to a more privacy-respecting one (e.g., | ||
103 | \"twitter.com\" -> \"nitter.com\"), by adding advice to `browse-url'. | ||
104 | |||
105 | When using this mode, ensure that the transformed URL is also in | ||
106 | `browse-url-handlers', since that's what `browse-url' will see." | ||
107 | :lighter " Xurl" | ||
108 | :keymap nil | ||
109 | (if +browse-url-transform-url-mode | ||
110 | (advice-add 'browse-url :filter-args '+browse-url-transform-advice) | ||
111 | (advice-remove 'browse-url '+browse-url-transform-advice))) | ||
112 | |||
113 | (define-global-minor-mode +browse-url-transform-url-global-mode | ||
114 | +browse-url-transform-url-mode +browse-url-transform-url-mode) | ||
115 | |||
116 | (provide '+browse-url) | ||
117 | ;;; +browse-url.el ends here | ||
diff --git a/lisp/+elfeed.el b/lisp/+elfeed.el new file mode 100644 index 0000000..823902b --- /dev/null +++ b/lisp/+elfeed.el | |||
@@ -0,0 +1,24 @@ | |||
1 | ;;; +elfeed.el -*- lexical-binding: t; -*- | ||
2 | |||
3 | ;;; Code: | ||
4 | |||
5 | (require 'elfeed) | ||
6 | |||
7 | (defun +elfeed-scroll-up-command (&optional arg) | ||
8 | "Scroll up or go to next feed item in Elfeed" | ||
9 | (interactive "^P") | ||
10 | (let ((scroll-error-top-bottom nil)) | ||
11 | (condition-case-unless-debug nil | ||
12 | (scroll-up-command arg) | ||
13 | (error (elfeed-show-next))))) | ||
14 | |||
15 | (defun +elfeed-scroll-down-command (&optional arg) | ||
16 | "Scroll up or go to next feed item in Elfeed" | ||
17 | (interactive "^P") | ||
18 | (let ((scroll-error-top-bottom nil)) | ||
19 | (condition-case-unless-debug nil | ||
20 | (scroll-down-command arg) | ||
21 | (error (elfeed-show-prev))))) | ||
22 | |||
23 | (provide '+elfeed) | ||
24 | ;;; +elfeed.el ends here | ||
diff --git a/lisp/+emacs.el b/lisp/+emacs.el index 147bb76..a858cf6 100644 --- a/lisp/+emacs.el +++ b/lisp/+emacs.el | |||
@@ -69,7 +69,6 @@ Do this only if the buffer is not visiting a file." | |||
69 | kill-do-not-save-duplicates t | 69 | kill-do-not-save-duplicates t |
70 | kill-read-only-ok t | 70 | kill-read-only-ok t |
71 | kill-ring-max 500 | 71 | kill-ring-max 500 |
72 | kill-whole-line t | ||
73 | kmacro-ring-max 20 | 72 | kmacro-ring-max 20 |
74 | load-prefer-newer t | 73 | load-prefer-newer t |
75 | major-mode '+set-major-mode-from-buffer-name | 74 | major-mode '+set-major-mode-from-buffer-name |
diff --git a/lisp/+key.el b/lisp/+key.el index 5b4f467..7a51be1 100644 --- a/lisp/+key.el +++ b/lisp/+key.el | |||
@@ -14,6 +14,9 @@ | |||
14 | 14 | ||
15 | ;;; Code: | 15 | ;;; Code: |
16 | 16 | ||
17 | (require 'easy-mmode) | ||
18 | (require 'setup nil t) | ||
19 | |||
17 | ;; I need to define this map before the proper mode map. | 20 | ;; I need to define this map before the proper mode map. |
18 | (defvar +key-leader-map (let ((map (make-sparse-keymap)) | 21 | (defvar +key-leader-map (let ((map (make-sparse-keymap)) |
19 | (c-z (global-key-binding "\C-z"))) | 22 | (c-z (global-key-binding "\C-z"))) |
@@ -30,13 +33,18 @@ | |||
30 | (define-minor-mode +key-mode | 33 | (define-minor-mode +key-mode |
31 | "A minor mode with keybindings that will override every other mode." | 34 | "A minor mode with keybindings that will override every other mode." |
32 | :init-value t | 35 | :init-value t |
33 | :lighter " +" | 36 | :lighter " +") |
34 | :keymap +key-mode-map) | 37 | (add-to-list 'emulation-mode-map-alists `((+key-mode . ,+key-mode-map))) |
35 | 38 | ||
36 | ;;;###autoload | 39 | ;;;###autoload |
37 | (define-globalized-minor-mode +key-global-mode +key-mode +key-mode) | 40 | (define-globalized-minor-mode +key-global-mode +key-mode +key-mode) |
38 | 41 | ||
39 | (add-to-list 'emulation-mode-map-alists `((+key-mode . ,+key-mode-map))) | 42 | ;;;###autoload |
43 | (defun +key-setup () | ||
44 | "Setup `+key-mode' after everything else." | ||
45 | (if after-init-time | ||
46 | (+key-global-mode +1) | ||
47 | (add-hook 'after-init-hook '+key-global-mode))) | ||
40 | 48 | ||
41 | (defun turn-off-+key-mode () | 49 | (defun turn-off-+key-mode () |
42 | "Turn off `+key-mode'." | 50 | "Turn off `+key-mode'." |
diff --git a/lisp/+modeline.el b/lisp/+modeline.el index 0dc34c7..7c74f76 100644 --- a/lisp/+modeline.el +++ b/lisp/+modeline.el | |||
@@ -153,5 +153,13 @@ The order of elements matters: whichever one matches first is applied." | |||
153 | "Display `anzu--update-mode-line'." | 153 | "Display `anzu--update-mode-line'." |
154 | (concat " " (anzu--update-mode-line))) | 154 | (concat " " (anzu--update-mode-line))) |
155 | 155 | ||
156 | (defun +modeline-text-scale () | ||
157 | "Display text scaling level." | ||
158 | ;; adapted from https://github.com/seagle0128/doom-modeline | ||
159 | (when (and (boundp 'text-scale-mode-amount) | ||
160 | (/= text-scale-mode-amount 0)) | ||
161 | (format (if (> text-scale-mode-amount 0) " (%+d)" " (%-d)") | ||
162 | text-scale-mode-amount))) | ||
163 | |||
156 | (provide '+modeline) | 164 | (provide '+modeline) |
157 | ;;; +modeline.el ends here | 165 | ;;; +modeline.el ends here |
diff --git a/lisp/+org.el b/lisp/+org.el index a4ce230..9a91ef1 100644 --- a/lisp/+org.el +++ b/lisp/+org.el | |||
@@ -337,5 +337,60 @@ the deletion might narrow the column." | |||
337 | (backward-delete-char-untabify N) | 337 | (backward-delete-char-untabify N) |
338 | (org-fix-tags-on-the-fly)))) | 338 | (org-fix-tags-on-the-fly)))) |
339 | 339 | ||
340 | ;;; Smarter {super,sub}scripts | ||
341 | ;; https://old.reddit.com/r/emacs/comments/qzlzm0/what_are_your_top_key_bindings_rebindings_minor/hmwyhm3/ | ||
342 | ;; I don't use this currently because I found out about | ||
343 | ;; `org-pretty-entities-include-sub-superscripts', which really does exactly | ||
344 | ;; what I wanted. | ||
345 | |||
346 | (defface +org-script-markers '((t :inherit shadow)) | ||
347 | "Face to be used for sub/superscripts markers i.e., ^, _, {, }.") | ||
348 | |||
349 | ;; Hiding the super and subscript markers is extremely annoying | ||
350 | ;; since any remotely complex equation becomes a chore. And leaving | ||
351 | ;; it not raised is jarring to the eye. So this fontifies the | ||
352 | ;; buffer just like how auctex does -- use a muted colour to | ||
353 | ;; highlight the markup and raise the script. | ||
354 | (defun +org-raise-scripts (limit) | ||
355 | "Differences from `org-raise-scripts' are: | ||
356 | |||
357 | - It doesn't actually hide the markup used for super and subscript. | ||
358 | - It uses a custom face to highlight the markup: +org-script-markers. | ||
359 | - It doesn't require `org-pretty-entities' to be t." | ||
360 | (when (and org-pretty-entities-include-sub-superscripts | ||
361 | (re-search-forward | ||
362 | (if (eq org-use-sub-superscripts t) | ||
363 | org-match-substring-regexp | ||
364 | org-match-substring-with-braces-regexp) | ||
365 | limit t)) | ||
366 | (let* ((pos (point)) table-p comment-p | ||
367 | (mpos (match-beginning 3)) | ||
368 | (emph-p (get-text-property mpos 'org-emphasis)) | ||
369 | (link-p (get-text-property mpos 'mouse-face)) | ||
370 | (keyw-p (eq 'org-special-keyword (get-text-property mpos 'face)))) | ||
371 | (goto-char (point-at-bol)) | ||
372 | (setq table-p (looking-at-p org-table-dataline-regexp) | ||
373 | comment-p (looking-at-p "^[ \t]*#[ +]")) | ||
374 | (goto-char pos) | ||
375 | ;; Handle a_b^c | ||
376 | (when (member (char-after) '(?_ ?^)) (goto-char (1- pos))) | ||
377 | (unless (or comment-p emph-p link-p keyw-p) | ||
378 | (put-text-property (match-beginning 3) (match-end 0) | ||
379 | 'display | ||
380 | (if (equal (char-after (match-beginning 2)) ?^) | ||
381 | ;; (nth (if table-p 3 1) org-script-display) | ||
382 | (nth 3 org-script-display) | ||
383 | ;; (nth (if table-p 2 0) org-script-display) | ||
384 | (nth 2 org-script-display))) | ||
385 | (put-text-property (match-beginning 2) (match-end 2) | ||
386 | 'face 'vz/org-script-markers) | ||
387 | (when (and (eq (char-after (match-beginning 3)) ?{) | ||
388 | (eq (char-before (match-end 3)) ?})) | ||
389 | (put-text-property (match-beginning 3) (1+ (match-beginning 3)) | ||
390 | 'face '+org-script-markers) | ||
391 | (put-text-property (1- (match-end 3)) (match-end 3) | ||
392 | 'face '+org-script-markers))) | ||
393 | t))) | ||
394 | |||
340 | (provide '+org) | 395 | (provide '+org) |
341 | ;;; +org.el ends here | 396 | ;;; +org.el ends here |
diff --git a/lisp/+util.el b/lisp/+util.el index 0184a48..fb77278 100644 --- a/lisp/+util.el +++ b/lisp/+util.el | |||
@@ -79,6 +79,14 @@ ALIGNMENT can be one of these: | |||
79 | 79 | ||
80 | ;;; COMMANDS | 80 | ;;; COMMANDS |
81 | 81 | ||
82 | (defun +dos2unix (buffer) | ||
83 | "Replace \r\n with \n in BUFFER." | ||
84 | (interactive "*b") | ||
85 | (save-excursion | ||
86 | (with-current-buffer buffer | ||
87 | (goto-char (point-min)) | ||
88 | (while (search-forward (string ?\C-m ?\C-j) nil t) | ||
89 | (replace-match (string ?\C-j) nil t))))) | ||
82 | 90 | ||
83 | (provide '+util) | 91 | (provide '+util) |
84 | ;;; +util.el ends here | 92 | ;;; +util.el ends here |