branch: master commit 9d3d7defe669b08d2c316ddf9c1133467e6c29af Author: Brian Leung <bkleun...@gmail.com> Commit: Oleh Krehel <ohwoeo...@gmail.com>
counsel.el (counsel-slime-repl-history): Add. ivy.el (ivy-history-contents): Accommodate sequences. --- counsel.el | 9 +++++++++ ivy.el | 23 +++++++++++++---------- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/counsel.el b/counsel.el index dbf0470..be433ef 100644 --- a/counsel.el +++ b/counsel.el @@ -4394,6 +4394,15 @@ An extra action allows to switch to the process buffer." (require 'comint) (counsel--browse-history comint-input-ring)) +(defvar slime-repl-input-history) + +;;;###autoload +(defun counsel-slime-repl-history () + "Browse Slime REPL history." + (interactive) + (require 'slime-repl) + (counsel--browse-history slime-repl-input-history)) + ;;** `counsel-hydra-heads' (defvar hydra-curr-body-fn) (declare-function hydra-keyboard-quit "ext:hydra") diff --git a/ivy.el b/ivy.el index 14b1002..c241b80 100644 --- a/ivy.el +++ b/ivy.el @@ -4503,20 +4503,23 @@ 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 (sym-or-ring) - "Copy contents of SYM-OR-RING. +(defun ivy-history-contents (history) + "Copy contents of HISTORY. A copy is necessary so that we don't clobber any string attributes. -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) +Also set `ivy--reverse-i-search-symbol' to HISTORY." + (setq ivy--reverse-i-search-symbol history) + (cond ((symbolp history) (delete-dups - (copy-sequence (symbol-value sym-or-ring)))) - ((ring-p sym-or-ring) + (copy-sequence (symbol-value history)))) + ((ring-p history) (delete-dups - (when (> (ring-size sym-or-ring) 0) - (ring-elements sym-or-ring)))) + (when (> (ring-size history) 0) + (ring-elements history)))) + ((sequencep history) + (delete-dups + (copy-sequence history))) (t - (error "Expected a symbol or a ring: %S" sym-or-ring)))) + (error "Expected a symbol, ring, or sequence: %S" history)))) (defun ivy-reverse-i-search () "Enter a recursive `ivy-read' session using the current history.