From 2243b1e4effdeda0cec9cde4a49fd9ac8a5f9271 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Sun, 16 Jan 2022 23:13:11 -0600 Subject: Dammit, lots of changes --- lisp/+mwim.el | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 lisp/+mwim.el (limited to 'lisp/+mwim.el') 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 @@ +;;; +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")) + (funcall (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")) + (funcall (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 -- cgit 1.4.1-21-gabe81