diff options
Diffstat (limited to 'lisp/+mwim.el')
-rw-r--r-- | lisp/+mwim.el | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/lisp/+mwim.el b/lisp/+mwim.el new file mode 100644 index 0000000..1c8ef5c --- /dev/null +++ b/lisp/+mwim.el | |||
@@ -0,0 +1,42 @@ | |||
1 | ;;; +mwim.el --- Extras -*- lexical-binding: t; -*- | ||
2 | |||
3 | ;;; Commentary: | ||
4 | |||
5 | ;;; Code: | ||
6 | |||
7 | (require 'seq) | ||
8 | |||
9 | (defgroup +mwim nil | ||
10 | "Extra `mwim' customizations." | ||
11 | :group 'mwim) | ||
12 | |||
13 | (defcustom +mwim-passthrough-modes nil | ||
14 | "Modes to not move-where-I-mean." | ||
15 | :type '(repeat function)) | ||
16 | |||
17 | (defun +mwim-beginning-maybe (&optional arg) | ||
18 | "Perform `mwim-beginning', maybe. | ||
19 | Will just do \\[beginning-of-line] in one of | ||
20 | `+mwim-passthrough-modes'." | ||
21 | (interactive) | ||
22 | (if (apply #'derived-mode-p +mwim-passthrough-modes) | ||
23 | (let ((this-mode-map (symbol-value (intern (format "%s-map" major-mode)))) | ||
24 | (key "C-a")) | ||
25 | (funcall (or (keymap-lookup this-mode-map key t t) | ||
26 | (keymap-lookup (current-global-map) key t t)))) | ||
27 | (call-interactively #'mwim-beginning))) | ||
28 | |||
29 | (defun +mwim-end-maybe (&optional arg) | ||
30 | "Perform `mwim-beginning', maybe. | ||
31 | Will just do \\[end-of-line] in one of | ||
32 | `+mwim-passthrough-modes'." | ||
33 | (interactive) | ||
34 | (if (apply #'derived-mode-p +mwim-passthrough-modes) | ||
35 | (let ((this-mode-map (symbol-value (intern (format "%s-map" major-mode)))) | ||
36 | (key "C-e")) | ||
37 | (funcall (or (keymap-lookup this-mode-map key t t) | ||
38 | (keymap-lookup (current-global-map) key t t)))) | ||
39 | (call-interactively #'mwim-end))) | ||
40 | |||
41 | (provide '+mwim) | ||
42 | ;;; +mwim.el ends here | ||