summaryrefslogtreecommitdiff
path: root/helm-ring.el
diff options
context:
space:
mode:
authorThierry Volpiatto <thierry.volpiatto@gmail.com>2017-12-21 09:10:11 +0100
committerThierry Volpiatto <thierry.volpiatto@gmail.com>2017-12-21 09:16:00 +0100
commitf1878e94353e1f1595db91e7c6b88c0a910b9835 (patch)
treeabb56bfe23942c03e613cff93b87e27eb7498a30 /helm-ring.el
parent48fa38c576bd05e268ba9a54f8ed4e3d9476690e (diff)
Allow using marked in default kill-ring action (#1934)
Append action have been removed * helm-ring.el (helm-kill-ring-actions): Remove append. (helm-kill-ring-map): Same. (helm-kill-ring-action-yank): Handle marked. (helm-kill-ring-action-yank-1): Same as before but renamed to be used internally, now specify prefix arg to '(4) to be sure mark and point are not reversed when using separator prompt.
Diffstat (limited to 'helm-ring.el')
-rw-r--r--helm-ring.el37
1 files changed, 18 insertions, 19 deletions
diff --git a/helm-ring.el b/helm-ring.el
index 6973c8b4..c9fac52e 100644
--- a/helm-ring.el
+++ b/helm-ring.el
@@ -52,9 +52,8 @@ will not have anymore separators between candidates."
:type 'integer)
(defcustom helm-kill-ring-actions
- '(("Yank" . helm-kill-ring-action-yank)
- ("Delete" . helm-kill-ring-action-delete)
- ("Append" . helm-kill-ring-append))
+ '(("Yank marked" . helm-kill-ring-action-yank)
+ ("Delete marked" . helm-kill-ring-action-delete))
"List of actions for kill ring source."
:group 'helm-ring
:type '(alist :key-type string :value-type function))
@@ -69,7 +68,6 @@ will not have anymore separators between candidates."
(define-key map (kbd "M-y") 'helm-next-line)
(define-key map (kbd "M-u") 'helm-previous-line)
(define-key map (kbd "M-D") 'helm-kill-ring-delete)
- (define-key map (kbd "C-M-w") 'helm-kill-ring-run-append)
(define-key map (kbd "C-]") 'helm-kill-ring-toggle-truncated)
(define-key map (kbd "C-c C-k") 'helm-kill-ring-kill-selection)
map)
@@ -140,7 +138,21 @@ Same as `helm-kill-selection-and-quit' called with a prefix arg."
(cl-return)
(helm-next-line))))
-(defun helm-kill-ring-action-yank (str)
+(defun helm-kill-ring-action-yank (_str)
+ "Insert concatenated marked candidates in current-buffer.
+
+When two prefix args are given prompt to choose separator, otherwise
+a new line as default separator is used."
+ (let ((marked (helm-marked-candidates))
+ (sep (if (equal helm-current-prefix-arg '(16))
+ (read-string "Separator: ")
+ "\n")))
+ (helm-kill-ring-action-yank-1
+ (cl-loop for c in (butlast marked)
+ concat (concat c sep) into str
+ finally return (concat str (car (last marked)))))))
+
+(defun helm-kill-ring-action-yank-1 (str)
"Insert STR in `kill-ring' and set STR to the head.
When called with a prefix arg, point and mark are exchanged without
@@ -153,7 +165,7 @@ replace with STR as yanked string."
;; the yank command, if possible.
(when yank-pop
(set-window-start (selected-window) yank-window-start t))
- (when (or helm-current-prefix-arg before)
+ (when (or (equal helm-current-prefix-arg '(4)) before)
;; Same as exchange-point-and-mark but without
;; activating region.
(goto-char (prog1 (mark t)
@@ -206,19 +218,6 @@ This is a command for `helm-kill-ring-map'."
(with-helm-alive-p
(helm-exit-and-execute-action 'helm-kill-ring-action-delete)))
-(defun helm-kill-ring-append (_candidate)
- "Yank concatenated marked candidates."
- (let ((marked (helm-marked-candidates)))
- (helm-kill-ring-action-yank
- (cl-loop for cand in marked
- for sep = (if (string-match "\n\\'" cand) "" "\n")
- concat (concat cand sep)))))
-
-(defun helm-kill-ring-run-append ()
- "Yank concatenated marked candidates."
- (interactive)
- (with-helm-alive-p
- (helm-exit-and-execute-action 'helm-kill-ring-append)))
;;;; <Mark ring>
;; DO NOT use these sources with other sources use