[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master f164cfe 33/54: counsel.el (counsel-yank-pop): New command
From: |
Oleh Krehel |
Subject: |
[elpa] master f164cfe 33/54: counsel.el (counsel-yank-pop): New command |
Date: |
Tue, 29 Sep 2015 14:09:58 +0000 |
branch: master
commit f164cfebbe132e2d86a47e44b31dc318c2db4bc1
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>
counsel.el (counsel-yank-pop): New command
* counsel.el (counsel-yank-pop-truncate): New defcustom. Choose whether
to truncate strings over 4 lines.
(counsel-yank-pop-action): New defun.
Fixes #218
---
counsel.el | 46 ++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 46 insertions(+), 0 deletions(-)
diff --git a/counsel.el b/counsel.el
index 7d2745a..fa1475d 100644
--- a/counsel.el
+++ b/counsel.el
@@ -1034,6 +1034,52 @@ INITIAL-INPUT can be given as the initial minibuffer
input."
(unless (string-match "pdf$" x)
(swiper ivy-text)))))))
+(defcustom counsel-yank-pop-truncate nil
+ "When non-nil, truncate the display of long strings.")
+
+(defun counsel-yank-pop ()
+ "Ivy replacement for `yank-pop'."
+ (interactive)
+ (if (eq last-command 'yank)
+ (progn
+ (setq counsel-completion-end (point))
+ (setq counsel-completion-beg
+ (save-excursion
+ (search-backward (car kill-ring))
+ (point))))
+ (setq counsel-completion-beg (point))
+ (setq counsel-completion-end (point)))
+ (let ((candidates (cl-remove-if
+ (lambda (s)
+ (or (< (length s) 3)
+ (string-match "\\`[\n[:blank:]]+\\'" s)))
+ (delete-dups kill-ring))))
+ (when counsel-yank-pop-truncate
+ (setq candidates
+ (mapcar (lambda (s)
+ (if (string-match "\\`\\(.*\n.*\n.*\n.*\\)\n" s)
+ (progn
+ (let ((s (copy-sequence s)))
+ (put-text-property
+ (match-end 1)
+ (length s)
+ 'display
+ " [...]"
+ s)
+ s))
+ s))
+ candidates)))
+ (ivy-read "kill-ring: " candidates
+ :action 'counsel-yank-pop-action)))
+
+(defun counsel-yank-pop-action (s)
+ "Insert S into the buffer, overwriting the previous yank."
+ (with-ivy-window
+ (delete-region counsel-completion-beg
+ counsel-completion-end)
+ (insert (substring-no-properties s))
+ (setq counsel-completion-end (point))))
+
(provide 'counsel)
;;; counsel.el ends here
- [elpa] master d8d7ed4 42/54: Fix minibuffer collapses to one line, (continued)
- [elpa] master d8d7ed4 42/54: Fix minibuffer collapses to one line, Oleh Krehel, 2015/10/07
- [elpa] master db8fb1b 39/54: Make "<left>" and "<right>" behave as in fundamental-mode, Oleh Krehel, 2015/10/07
- [elpa] master 8b73497 54/54: Merge commit 'ba49407c5b4c719dd5dcc298c260513abf0c70df' from swiper, Oleh Krehel, 2015/10/07
- [elpa] master 9413acb 52/54: counsel.el (counsel--find-symbol): Allow to jump back with pop-tag-mark, Oleh Krehel, 2015/10/07
- [elpa] master aa3e1dd 51/54: swiper.el (swiper-font-lock-ensure): Add mu4e, Oleh Krehel, 2015/10/07
- [elpa] master 680f6e2 44/54: swiper.el (swiper--ivy): Use minibuffer-allow-text-properties, Oleh Krehel, 2015/10/07
- [elpa] master 5fef653 08/54: ivy.el (ivy-completing-read): Fix up last commit, Oleh Krehel, 2015/10/07
- [elpa] master 1f93f40 16/54: counsel.el (counsel-cl): New command, Oleh Krehel, 2015/10/07
- [elpa] master 67cd682 06/54: Fix #126 again., Oleh Krehel, 2015/10/07
- [elpa] master 1f64cb8 11/54: ivy: enlarge the minibuffer window if the candiate list doesn't fit, Oleh Krehel, 2015/10/07
- [elpa] master f164cfe 33/54: counsel.el (counsel-yank-pop): New command,
Oleh Krehel <=
- [elpa] master 03d93f7 40/54: ivy.el (ivy-switch-buffer): Make "M-o r" rename buffer, Oleh Krehel, 2015/10/07
- [elpa] master 8d754de 17/54: ivy.el (ivy-display-style): New defcustom, Oleh Krehel, 2015/10/07
- [elpa] master efd1f09 48/54: Make ivy-display-style more compatible with 24.3, Oleh Krehel, 2015/10/07
- [elpa] master b45d10c 43/54: Revert multiple frames workaround, Oleh Krehel, 2015/10/07
- [elpa] master 3ce7df8 49/54: Truncate minibuffer prompts longer than window-width, Oleh Krehel, 2015/10/07
- [elpa] master 78499dd 22/54: Add default values for minibuffer faces, Oleh Krehel, 2015/10/07
- [elpa] master dad8183 23/54: Make the minibuffer faces look nicer, Oleh Krehel, 2015/10/07
- [elpa] master 4b17d9a 27/54: Fix up the "foo ! bar" matching and highlighting, Oleh Krehel, 2015/10/07
- [elpa] master d3f1f2c 18/54: Add extra faces for minibuffer highlighting, Oleh Krehel, 2015/10/07
- [elpa] master 1bf45be 21/54: ivy.el (ivy--format-minibuffer-line): Fix nil regexp, Oleh Krehel, 2015/10/07