[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 9f6141f 345/399: counsel.el (counsel--browse-history): All
From: |
Oleh Krehel |
Subject: |
[elpa] master 9f6141f 345/399: counsel.el (counsel--browse-history): Allow to remove elements with "C-k" |
Date: |
Sat, 20 Jul 2019 14:57:54 -0400 (EDT) |
branch: master
commit 9f6141f13b51e409548acfe7efb23cad2199b685
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>
counsel.el (counsel--browse-history): Allow to remove elements with "C-k"
* ivy.el (ivy-history-contents):
(ivy-reverse-i-search-kill): Extend to rings.
* counsel.el (counsel--browse-history): Set :keymap and use
`ivy-history-contents'.
---
counsel.el | 15 ++++++---------
ivy.el | 34 ++++++++++++++++++++++------------
2 files changed, 28 insertions(+), 21 deletions(-)
diff --git a/counsel.el b/counsel.el
index 3e6f795..368f8c4 100644
--- a/counsel.el
+++ b/counsel.el
@@ -4181,17 +4181,14 @@ An extra action allows to switch to the process buffer."
:caller 'counsel-minibuffer-history)))
;;** `counsel-esh-history'
-(defun counsel--browse-history (elements)
- "Use Ivy to navigate through ELEMENTS."
+(defun counsel--browse-history (ring)
+ "Use Ivy to navigate through RING."
(setq ivy-completion-beg (point))
(setq ivy-completion-end (point))
- (let ((cands
- (delete-dups
- (when (> (ring-size elements) 0)
- (ring-elements elements)))))
- (ivy-read "Symbol name: " cands
- :action #'ivy-completion-in-region-action
- :caller 'counsel-shell-history)))
+ (ivy-read "Symbol name: " (ivy-history-contents ring)
+ :keymap ivy-reverse-i-search-map
+ :action #'ivy-completion-in-region-action
+ :caller 'counsel-shell-history))
(defvar eshell-history-ring)
diff --git a/ivy.el b/ivy.el
index cec9da2..0bc863b 100644
--- a/ivy.el
+++ b/ivy.el
@@ -42,6 +42,7 @@
(require 'ffap)
(require 'ivy-overlay)
(require 'colir)
+(require 'ring)
;;* Customization
(defgroup ivy nil
@@ -4333,11 +4334,14 @@ This list can be rotated with
`ivy-rotate-preferred-builders'."
(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)))
+ (let ((current (ivy-state-current ivy-last)))
+ (if (symbolp ivy--reverse-i-search-symbol)
+ (set
+ ivy--reverse-i-search-symbol
+ (delete current (symbol-value ivy--reverse-i-search-symbol)))
+ (ring-remove
+ ivy--reverse-i-search-symbol
+ (ring-member ivy--reverse-i-search-symbol (ivy-state-current
ivy-last)))))
(ivy--kill-current-candidate)))
(defvar ivy-reverse-i-search-map
@@ -4345,14 +4349,20 @@ This list can be rotated with
`ivy-rotate-preferred-builders'."
(define-key map (kbd "C-k") 'ivy-reverse-i-search-kill)
map))
-(defun ivy-history-contents (history-variable)
- "Copy contents of HISTORY-VARIABLE.
+(defun ivy-history-contents (sym-or-ring)
+ "Copy contents of SYM-OR-RING.
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)))))
+Also set `ivy--reverse-i-search-symbol' to SYM-OR-RING."
+ (setq ivy--reverse-i-search-symbol sym-or-ring)
+ (cond ((symbolp sym-or-ring)
+ (delete-dups
+ (copy-sequence (symbol-value sym-or-ring))))
+ ((ring-p sym-or-ring)
+ (delete-dups
+ (when (> (ring-size sym-or-ring) 0)
+ (ring-elements sym-or-ring))))
+ (t
+ (error "Expected a symbol or a ring: %S" sym-or-ring))))
(defun ivy-reverse-i-search ()
"Enter a recursive `ivy-read' session using the current history.
- [elpa] master cfb8d49 335/399: counsel.el (counsel-find-file-ignore-regexp): Add lockfiles to dotfiles, (continued)
- [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, 2019/07/20
- [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 <=
- [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
- [elpa] master 8fc254f 341/399: counsel.el (counsel--setq-doconst): Fix compiler warning, Oleh Krehel, 2019/07/20
- [elpa] master 1c436f6 347/399: ivy.el (ivy-reverse-i-search): Don't call another ivy-reverse-i-search, Oleh Krehel, 2019/07/20
- [elpa] master 975c2af 348/399: ivy.el (ivy-reverse-i-search): Error when called from top-level, Oleh Krehel, 2019/07/20
- [elpa] master 888b417 350/399: ivy.el (ivy--recompute-index-inhibit): Add, Oleh Krehel, 2019/07/20
- [elpa] master 4c9c14a 356/399: ivy.el (ivy--minibuffer-cleanup): Rename from ivy--cleanup, Oleh Krehel, 2019/07/20