Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (defun delete-region-before-insert (orig-fun &rest args) (cl-letf (((symbol-function 'insert) (lambda (arg) (if (region-active-p) (delete-region (region-beginning) (region-end))) (insert arg)))) (apply orig-fun args)))
- (advice-add 'helm-copy-to-buffer :around #'delete-region-before-insert)
- (defun helm-copy-to-buffer ()
- "Copy selection or marked candidates to `helm-current-buffer'.
- Note that the real values of candidates are copied and not the
- display values."
- (interactive)
- (with-helm-alive-p
- (helm-run-after-exit
- (lambda (cands)
- (with-helm-current-buffer
- (if (region-active-p) (delete-region (region-beginning) (region-end))) ; added to delete region if any.
- (insert (mapconcat (lambda (c)
- (format "%s" c))
- cands "n"))))
- (helm-marked-candidates))))
Add Comment
Please, Sign In to add comment