Guest User

Untitled

a guest
Nov 19th, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. (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)))
  2. (advice-add 'helm-copy-to-buffer :around #'delete-region-before-insert)
  3.  
  4. (defun helm-copy-to-buffer ()
  5. "Copy selection or marked candidates to `helm-current-buffer'.
  6. Note that the real values of candidates are copied and not the
  7. display values."
  8. (interactive)
  9. (with-helm-alive-p
  10. (helm-run-after-exit
  11. (lambda (cands)
  12. (with-helm-current-buffer
  13. (if (region-active-p) (delete-region (region-beginning) (region-end))) ; added to delete region if any.
  14. (insert (mapconcat (lambda (c)
  15. (format "%s" c))
  16. cands "n"))))
  17. (helm-marked-candidates))))
Add Comment
Please, Sign In to add comment