Autocomplete compile comands based on compile-history #531
-
Hello, first of all I'm not sure if vertico is the correct place to ask, but if anyone I'm sure you would know how to direct me. What I want to do is to get auto-complete in the compile-command prompt that will auto-suggest entries from Any help would be greatly appreciated, thank you in advance |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 3 replies
-
To my absolute surprise I was able to do this myself after reading through vertico's readme and the linked emacs docs for completions.. I'll leave my solution here since I don't want this to be another "nvm I fixed it" post, and I'll leave the issue open in case you know of any better solutions, but feel free to just close. ;; compilation-read-command uses `read-shell-command` by default, which doesn't use
;; completion at all. So I overwrite it to use `completing-read` instead, which seems to work great.
(defun compilation-read-command (command)
(completing-read "Compile command: " compile-history
nil nil command
(if (equal (car compile-history) command)
'(compile-history . 1)
'compile-history))) |
Beta Was this translation helpful? Give feedback.
-
This is fun! Thank you for sharing. Here is a version that shows all candidates, like say (defun compilation-read-command (command)
(completing-read "Compile command: " compile-history
nil nil nil
(if (equal (car compile-history) command)
'(compile-history . 1)
'compile-history)
command)) |
Beta Was this translation helpful? Give feedback.
-
Note. It would perhaps be a good idea to contribute a patch to Emacs where the user could set the |
Beta Was this translation helpful? Give feedback.
-
And here is an
(defun my-compilation-read-command (command)
(completing-read "Compile command: " compile-history
nil nil nil
(if (equal (car compile-history) command)
'(compile-history . 1)
'compile-history)
command))
(advice-add #'compilation-read-command
:override
#'my-compilation-read-command) |
Beta Was this translation helpful? Give feedback.
To my absolute surprise I was able to do this myself after reading through vertico's readme and the linked emacs docs for completions.. I'll leave my solution here since I don't want this to be another "nvm I fixed it" post, and I'll leave the issue open in case you know of any better solutions, but feel free to just close.