[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master a18de2f 269/399: counsel.el (counsel-register): Add
From: |
Oleh Krehel |
Subject: |
[elpa] master a18de2f 269/399: counsel.el (counsel-register): Add |
Date: |
Sat, 20 Jul 2019 14:57:38 -0400 (EDT) |
branch: master
commit a18de2fe56429a61b19ecd8fbc1448f625bfe32f
Author: Matthew Sojourner Newton <address@hidden>
Commit: Oleh Krehel <address@hidden>
counsel.el (counsel-register): Add
Fixes #2056
---
counsel.el | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 51 insertions(+)
diff --git a/counsel.el b/counsel.el
index 3e5de37..3bb2b7c 100644
--- a/counsel.el
+++ b/counsel.el
@@ -3896,6 +3896,57 @@ Note: Duplicate elements of `kill-ring' are always
deleted."
'(("d" counsel-yank-pop-action-remove "delete")
("r" counsel-yank-pop-action-rotate "rotate")))
+;;** `counsel-register'
+(defvar counsel-register-actions
+ '(("\\`buffer position" . jump-to-register)
+ ("\\`text" . insert-register)
+ ("\\`rectangle" . insert-register)
+ ("\\`window configuration" . jump-to-register)
+ ("\\`frame configuration" . jump-to-register)
+ ("\\`[-+]?[0-9]+\\(?:\\.[0-9]\\)?\\'" . insert-register)
+ ("\\`the file" . jump-to-register)
+ ("\\`keyboard macro" . jump-to-register)
+ ("\\`file-query" . jump-to-register))
+ "Alist of (REGEXP . FUNCTION) pairs for `counsel-register'.
+Selecting a register whose description matches REGEXP specifies
+FUNCTION as the action to take on the register.")
+
+(defvar counsel-register-history nil
+ "History for `counsel-register'.")
+
+(defun counsel-register-action (register)
+ "Default action for `counsel-register'.
+
+Call a function on REGISTER. The function is determined by
+matching the register's value description against a regexp in
+`counsel-register-actions'."
+ (let* ((val (get-text-property 0 'register register))
+ (desc (register-describe-oneline val))
+ (action (cdr (cl-assoc-if (lambda (re) (string-match-p re desc))
+ counsel-register-actions))))
+ (if action
+ (funcall action val)
+ (error "No action was found for register %c" val))))
+
+;;;###autoload
+(defun counsel-register ()
+ "Interactively choose a register."
+ (interactive)
+ (ivy-read "Register: "
+ (cl-mapcan
+ (lambda (reg)
+ (let ((s (funcall register-preview-function reg)))
+ (setq s (substring s 0 (string-match-p "[ \t\n\r]+\\'" s)))
+ (unless (string= s "")
+ (put-text-property 0 1 'register (car reg) s)
+ (list s))))
+ register-alist)
+ :require-match t
+ :sort t
+ :history 'counsel-register-history
+ :action #'counsel-register-action
+ :caller 'counsel-register))
+
;;** `counsel-evil-registers'
(make-obsolete-variable
'counsel-evil-registers-height
- [elpa] master 9a9e3e4 251/399: ivy-test.el (swiper--isearch-format): Add test, (continued)
- [elpa] master 9a9e3e4 251/399: ivy-test.el (swiper--isearch-format): Add test, Oleh Krehel, 2019/07/20
- [elpa] master 76ef143 258/399: swiper.el (swiper-isearch): Fix ivy-occur, Oleh Krehel, 2019/07/20
- [elpa] master c6977eb 266/399: ivy.el (ivy-read): Add :multi-action arg, Oleh Krehel, 2019/07/20
- [elpa] master df0d980 267/399: Modify counsel-unicode-char's copy action to use actual result, Oleh Krehel, 2019/07/20
- [elpa] master 19ff7cf 270/399: counsel.el (counsel-register-action): Tweak error, Oleh Krehel, 2019/07/20
- [elpa] master 4898a5e 272/399: counsel.el (counsel-compile): better handling for counsel--get-build-subdirs, Oleh Krehel, 2019/07/20
- [elpa] master e95a16b 275/399: Shrink ivy window after read action., Oleh Krehel, 2019/07/20
- [elpa] master 226171b 268/399: ivy.el (ivy--occur-insert-lines): Don't highlight the file name part, Oleh Krehel, 2019/07/20
- [elpa] master e8f9370 273/399: counsel.el (counsel-compile): nreverse recent history, Oleh Krehel, 2019/07/20
- [elpa] master b65cdb5 274/399: counsel.el (counsel-compile): track build dir for the benefit of M-i, Oleh Krehel, 2019/07/20
- [elpa] master a18de2f 269/399: counsel.el (counsel-register): Add,
Oleh Krehel <=
- [elpa] master fbf654c 276/399: counsel.el (counsel-company): Rely on company-prefix if company-common is nil, Oleh Krehel, 2019/07/20
- [elpa] master 2410219 284/399: swiper.el (swiper-isearch-highlight-delay): New defcustom, Oleh Krehel, 2019/07/20
- [elpa] master bc2dcbe 279/399: counsel.el (counsel--find-build-subdir): Simplify, Oleh Krehel, 2019/07/20
- [elpa] master 13da38a 287/399: ivy.el (ivy-help): Hide Org markup buffer-locally, Oleh Krehel, 2019/07/20
- [elpa] master 0134255 281/399: ivy.el (ivy--highlight-default): Use single face for adjacent groups, Oleh Krehel, 2019/07/20
- [elpa] master b7e9dfd 277/399: counsel.el: Fix a couple of typos, Oleh Krehel, 2019/07/20
- [elpa] master 92d5335 291/399: Add counsel-up-level command, Oleh Krehel, 2019/07/20
- [elpa] master 7e8622f 286/399: ivy.el (ivy-read-action): Fix, Oleh Krehel, 2019/07/20
- [elpa] master 0a26144 280/399: ivy.el (ivy--highlight-default): Handle unmatched groups, Oleh Krehel, 2019/07/20
- [elpa] master 8905b8b 278/399: counsel.el: Pacify byte-compiler, Oleh Krehel, 2019/07/20