diff options
author | Thierry Volpiatto <thierry.volpiatto@gmail.com> | 2017-08-16 17:36:11 +0200 |
---|---|---|
committer | Thierry Volpiatto <thierry.volpiatto@gmail.com> | 2017-08-16 17:36:11 +0200 |
commit | 2d50d4cc034c8a8fa769026722d2021a003021a5 (patch) | |
tree | 10ca51cee8e434628706cb1bdfddf5cb783d84b3 /helm-ring.el | |
parent | cd24f1d36f653b4359582ba3b6df4089bff06e1f (diff) |
Allow using a prefix arg when yanking.
* helm-ring.el (helm-kill-ring-action-yank): Do it.
Diffstat (limited to 'helm-ring.el')
-rw-r--r-- | helm-ring.el | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/helm-ring.el b/helm-ring.el index 1c196104..ee866222 100644 --- a/helm-ring.el +++ b/helm-ring.el @@ -142,6 +142,9 @@ Same as `helm-kill-selection-and-quit' called with a prefix arg." (defun helm-kill-ring-action-yank (str) "Insert STR in `kill-ring' and set STR to the head. + +When called with a prefix arg, point and mark are exchanged without +activating region. If this action is executed just after `yank', replace with STR as yanked string." (with-helm-current-buffer @@ -155,9 +158,22 @@ replace with STR as yanked string." (when (and (region-active-p) delete-selection-mode) (delete-region (region-beginning) (region-end))) (if (not (eq (helm-attr 'last-command helm-source-kill-ring) 'yank)) - ;; When yanking in a helm minibuffer we need a small - ;; delay to detect the mark in previous minibuffer. [1] - (run-with-timer 0.01 nil (lambda () (insert-for-yank str))) + (progn + ;; Ensure mark is at beginning of inserted text. + (push-mark) + ;; When yanking in a helm minibuffer we need a small + ;; delay to detect the mark in previous minibuffer. [1] + (run-with-timer + 0.01 nil + (lambda () + (insert-for-yank str) + (when helm-current-prefix-arg + ;; Same as exchange-point-and-mark but without + ;; activating region. + (goto-char (prog1 (mark t) + (set-marker (mark-marker) + (point) + helm-current-buffer))))))) ;; from `yank-pop' (let ((inhibit-read-only t) (before (< (point) (mark t)))) |