43 lines
1.3 KiB
EmacsLisp
43 lines
1.3 KiB
EmacsLisp
;;; +mwim.el --- Extras -*- lexical-binding: t; -*-
|
|
|
|
;;; Commentary:
|
|
|
|
;;; Code:
|
|
|
|
(require 'seq)
|
|
|
|
(defgroup +mwim nil
|
|
"Extra `mwim' customizations."
|
|
:group 'mwim)
|
|
|
|
(defcustom +mwim-passthrough-modes nil
|
|
"Modes to not move-where-I-mean."
|
|
:type '(repeat function))
|
|
|
|
(defun +mwim-beginning-maybe (&optional arg)
|
|
"Perform `mwim-beginning', maybe.
|
|
Will just do \\[beginning-of-line] in one of
|
|
`+mwim-passthrough-modes'."
|
|
(interactive)
|
|
(if (apply #'derived-mode-p +mwim-passthrough-modes)
|
|
(let ((this-mode-map (symbol-value (intern (format "%s-map" major-mode))))
|
|
(key "C-a"))
|
|
(call-interactively (or (keymap-lookup this-mode-map key t t)
|
|
(keymap-lookup (current-global-map) key t t))))
|
|
(call-interactively #'mwim-beginning)))
|
|
|
|
(defun +mwim-end-maybe (&optional arg)
|
|
"Perform `mwim-beginning', maybe.
|
|
Will just do \\[end-of-line] in one of
|
|
`+mwim-passthrough-modes'."
|
|
(interactive)
|
|
(if (apply #'derived-mode-p +mwim-passthrough-modes)
|
|
(let ((this-mode-map (symbol-value (intern (format "%s-map" major-mode))))
|
|
(key "C-e"))
|
|
(call-interactively (or (keymap-lookup this-mode-map key t t)
|
|
(keymap-lookup (current-global-map) key t t))))
|
|
(call-interactively #'mwim-end)))
|
|
|
|
(provide '+mwim)
|
|
;;; +mwim.el ends here
|