about summary refs log tree commit diff stats
path: root/.emacs.d
diff options
context:
space:
mode:
authorDavid Morgan <djm_uk@protonmail.com>2024-09-06 14:15:44 +0100
committerDavid Morgan <djm_uk@protonmail.com>2024-09-06 14:15:44 +0100
commitc133e2f3fe774dfecd9afe79d368c911c5386828 (patch)
treeea928ad4d21bfa0e5886dff348152cd213c427f9 /.emacs.d
parent84ef0059794fee46932a0099bc771db76aa6919d (diff)
downloaddotfiles-c133e2f3fe774dfecd9afe79d368c911c5386828.tar.gz
Add +become-consult-line function that removes the leading hash
Diffstat (limited to '.emacs.d')
-rw-r--r--.emacs.d/lisp/init-minibuffer.el23
1 files changed, 21 insertions, 2 deletions
diff --git a/.emacs.d/lisp/init-minibuffer.el b/.emacs.d/lisp/init-minibuffer.el
index 9d0b4c6..2949528 100644
--- a/.emacs.d/lisp/init-minibuffer.el
+++ b/.emacs.d/lisp/init-minibuffer.el
@@ -242,7 +242,8 @@ DEFS is a plist associating completion categories to commands."
                ("C-S-p" . vertico-previous)
                ("C-S-n" . vertico-next)
                ;; Toggle preview on/off without changing preview-key
-               ("M-P" . consult-toggle-preview)))
+               ("M-P" . consult-toggle-preview)
+               ("C-x C-M-x" . remove-leading-hash)))
 
   :config
 
@@ -398,6 +399,17 @@ DEFS is a plist associating completion categories to commands."
                                          (format  "fd --color never -t f -0 . %s" root))
                                         "\0" t))))))))
 
+  (defun remove-leading-hash ()
+    "Remove a # character from the beginning of the current line.
+
+Designed to be used for consult commands that automatically add a # at the beginning of the minibuffer.
+See `+become-consult-line'."
+    (interactive)
+    (save-excursion
+      (beginning-of-line)
+      (when (= ?# (char-after))
+        (delete-forward-char 1))))
+
   (defun consult-project-buffer ()
     (interactive)
     (let ((consult-buffer-sources '(consult--project-source-project-buffer
@@ -467,9 +479,16 @@ DEFS is a plist associating completion categories to commands."
   ;; demand, combined with after means that this will load after embark and consult
   ;; See https://github.com/oantolin/embark/commit/47daded610b245caf01a97d74c940aff91fe14e2#r46010972
   :demand t
+  :config
+  (defun +become-consult-line ()
+    "TODO."
+    (interactive)
+    (progn
+      (setq unread-command-events (listify-key-sequence "\C-x\C-\M-x"))
+      (consult-line)))
   :bind
   (:map embark-consult-async-search-map
-        ("l" . consult-line) ;; TODO how to delete the #
+        ("l" . +become-consult-line)
         ("^" . consult-ripgrep-parent)
         ("R" . consult-ripgrep-unrestricted))
   :hook