[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 4de54f1 340/399: ivy.el (ivy-reverse-i-search-kill): Add a
From: |
Oleh Krehel |
Subject: |
[elpa] master 4de54f1 340/399: ivy.el (ivy-reverse-i-search-kill): Add and bind to "C-k" |
Date: |
Sat, 20 Jul 2019 14:57:53 -0400 (EDT) |
branch: master
commit 4de54f1162b248d12e22daf20283fa5133cae6fc
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>
ivy.el (ivy-reverse-i-search-kill): Add and bind to "C-k"
You can now remove history elements after you press "C-r" in Ivy.
Just press "C-k" from end-of-line.
---
counsel.el | 5 ++---
ivy.el | 48 +++++++++++++++++++++++++++++++++++++++++-------
2 files changed, 43 insertions(+), 10 deletions(-)
diff --git a/counsel.el b/counsel.el
index 0b97f03..49a86dc 100644
--- a/counsel.el
+++ b/counsel.el
@@ -4175,9 +4175,8 @@ An extra action allows to switch to the process buffer."
"Browse minibuffer history."
(interactive)
(let ((enable-recursive-minibuffers t))
- (ivy-read "History: "
- (delete-dups (copy-sequence
- (symbol-value minibuffer-history-variable)))
+ (ivy-read "History: " (ivy-history-contents minibuffer-history-variable)
+ :keymap ivy-reverse-i-search-map
:action #'insert
:caller 'counsel-minibuffer-history)))
diff --git a/ivy.el b/ivy.el
index c1a8f5a..37e388e 100644
--- a/ivy.el
+++ b/ivy.el
@@ -4049,16 +4049,19 @@ BUFFER may be a string or nil."
(cdr (assoc buffer ivy--virtual-buffers))
recentf-list))))
+(defun ivy--kill-current-candidate ()
+ (setf (ivy-state-preselect ivy-last) ivy--index)
+ (setq ivy--old-re nil)
+ (setq ivy--all-candidates (delete (ivy-state-current ivy-last)
ivy--all-candidates))
+ (ivy--exhibit))
+
(defun ivy--kill-buffer-action (buffer)
"Kill BUFFER."
(ivy--kill-buffer-or-virtual buffer)
(unless (buffer-live-p (ivy-state-buffer ivy-last))
(setf (ivy-state-buffer ivy-last)
(with-ivy-window (current-buffer))))
- (setf (ivy-state-preselect ivy-last) ivy--index)
- (setq ivy--old-re nil)
- (setq ivy--all-candidates (delete buffer ivy--all-candidates))
- (ivy--exhibit))
+ (ivy--kill-current-candidate))
(defvar ivy-switch-buffer-map
(let ((map (make-sparse-keymap)))
@@ -4321,15 +4324,46 @@ This list can be rotated with
`ivy-rotate-preferred-builders'."
(setq ivy--regex-function 'ivy--regex-plus)
(setq ivy--regex-function 'ivy--regex-fuzzy)))
+(defvar ivy--reverse-i-search-symbol nil
+ "Store the history symbol.")
+
+(defun ivy-reverse-i-search-kill ()
+ "Remove the current item from history"
+ (interactive)
+ (if (not (eolp))
+ (ivy-kill-line)
+ (set
+ ivy--reverse-i-search-symbol
+ (delete
+ (ivy-state-current ivy-last)
+ (symbol-value ivy--reverse-i-search-symbol)))
+ (ivy--kill-current-candidate)))
+
+(defvar ivy-reverse-i-search-map
+ (let ((map (make-sparse-keymap)))
+ (define-key map (kbd "C-k") 'ivy-reverse-i-search-kill)
+ map))
+
+(defun ivy-history-contents (history-variable)
+ "Copy contents of HISTORY-VARIABLE.
+A copy is necessary so that we don't clobber any string attributes.
+Also set `ivy--reverse-i-search-symbol' to HISTORY-VARIABLE."
+ (delete-dups
+ (copy-sequence
+ (symbol-value
+ (setq ivy--reverse-i-search-symbol history-variable)))))
+
(defun ivy-reverse-i-search ()
"Enter a recursive `ivy-read' session using the current history.
-The selected history element will be inserted into the minibuffer."
+The selected history element will be inserted into the minibuffer.
+\\<ivy-reverse-i-search-map>
+You can also delete an emement from history with
\\[ivy-reverse-i-search-kill]."
(interactive)
(let ((enable-recursive-minibuffers t)
- (history (symbol-value (ivy-state-history ivy-last)))
(old-last ivy-last))
(ivy-read "Reverse-i-search: "
- (delete-dups (copy-sequence history))
+ (ivy-history-contents (ivy-state-history ivy-last))
+ :keymap ivy-reverse-i-search-map
:action (lambda (x)
(ivy--reset-state
(setq ivy-last old-last))
- [elpa] master 704b1de 328/399: ivy.el (ivy-avy): Allow to scroll with "C-v" and "M-v", (continued)
- [elpa] master 704b1de 328/399: ivy.el (ivy-avy): Allow to scroll with "C-v" and "M-v", Oleh Krehel, 2019/07/20
- [elpa] master 7183491 332/399: ivy.el (ivy--minibuffer-setup): Avoid extra call to ivy--exhibit, Oleh Krehel, 2019/07/20
- [elpa] master a249d15 329/399: ivy-test.el (ivy-avy): Only run if avy is installed, Oleh Krehel, 2019/07/20
- [elpa] master 15f8e10 330/399: .travis.yml: Add emacs-25.3 and emacs-26.2, Oleh Krehel, 2019/07/20
- [elpa] master d752db5 333/399: counsel.el (counsel-find-file-extern-extensions): New defcustom, Oleh Krehel, 2019/07/20
- [elpa] master cfb8d49 335/399: counsel.el (counsel-find-file-ignore-regexp): Add lockfiles to dotfiles, Oleh Krehel, 2019/07/20
- [elpa] master 011626a 343/399: ivy.el (ivy-occur-press): Improve when window config changed, Oleh Krehel, 2019/07/20
- [elpa] master 8db9cc1 349/399: swiper.el (swiper--add-cursor-overlay): Avoid a very wide cursor on tab chars, Oleh Krehel, 2019/07/20
- [elpa] master 40d8114 338/399: counsel.el (counsel-shell-command-history): Remove obsolete command, Oleh Krehel, 2019/07/20
- [elpa] master f0a2341 337/399: counsel.el (counsel-rhythmbox): Add :require-match, Oleh Krehel, 2019/07/20
- [elpa] master 4de54f1 340/399: ivy.el (ivy-reverse-i-search-kill): Add and bind to "C-k",
Oleh Krehel <=
- [elpa] master 7201c0f 334/399: ivy-hydra.el (ivy-dispatching-done-hydra-exit-keys): Extract, Oleh Krehel, 2019/07/20
- [elpa] master 935603e 310/399: ivy.el (ivy--done): Press "RET" or "C-m" to create a directory, Oleh Krehel, 2019/07/20
- [elpa] master a20c196 336/399: counsel.el (counsel-set-variable): Better annotations for options, Oleh Krehel, 2019/07/20
- [elpa] master cea24b7 339/399: counsel.el (counsel-expression-history): Remove obsolete command, Oleh Krehel, 2019/07/20
- [elpa] master 9f6141f 345/399: counsel.el (counsel--browse-history): Allow to remove elements with "C-k", Oleh Krehel, 2019/07/20
- [elpa] master 673c45e 342/399: ivy.el (ivy--minibuffer-setup): Set line-spacing to nil in the minibuffer, Oleh Krehel, 2019/07/20
- [elpa] master 8d7578f 346/399: counsel.el (counsel--browse-history): Better prompt, Oleh Krehel, 2019/07/20
- [elpa] master f9e8116 344/399: swiper.el (swiper-isearch-action): Fix outlines getting over-revealed, Oleh Krehel, 2019/07/20
- [elpa] master f29207f 324/399: Add ability to resume dynamic collections, Oleh Krehel, 2019/07/20
- [elpa] master 3b1a25b 331/399: ivy-test.el (counsel-find-file-with-dotfiles): Fix, Oleh Krehel, 2019/07/20