branch: master commit 022e65818607af5f8eeb0a9d39ee5957c0c9a9f2 Author: Oleh Krehel <ohwoeo...@gmail.com> Commit: Oleh Krehel <ohwoeo...@gmail.com>
When in prog-mode, "M-n" should wrap input with "\b" When searching for occurrences of a symbol, it's useful to omit the cases where the symbol is a part of a larger word. "M-n" will insert the symbol, then if the mode is derived from `prog-mode', wrap this symbol with \b - the regex notation for word boundary. This wrapping can be undone with `undo'. --- ivy.el | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/ivy.el b/ivy.el index 3d844d3..b144182 100644 --- a/ivy.el +++ b/ivy.el @@ -851,7 +851,17 @@ Call the permanent action if possible." (defun ivy-next-history-element (arg) "Forward to `next-history-element' with ARG." (interactive "p") - (next-history-element arg) + (if (= minibuffer-history-position 0) + (progn + (insert ivy--default) + (when (and (with-ivy-window (derived-mode-p 'prog-mode)) + (> (point) (minibuffer-prompt-end))) + (undo-boundary) + (insert "\\b") + (goto-char (minibuffer-prompt-end)) + (insert "\\b") + (forward-char (+ 2 (length ivy--default))))) + (next-history-element arg)) (ivy--cd-maybe) (move-end-of-line 1) (ivy--maybe-scroll-history))