I wrote a hydra today (I think my very first one) - I always do
Meta-| pbcopy after doing a
C-x h, so why not let hydra help out:
(global-set-key (kbd "C-x h") (defhydra hydra-my-mark-whole-buffer (:body-pre (mark-whole-buffer)) "hydra-my-mark-whole-buffer" ("h" mark-whole-buffer "this was not needed") ("p" my-pbcopy "Meta-| pbcopy"))) ;; https://emacs.stackexchange.com/a/13177 (defun my-pbcopy (beg end) (interactive "r") (message (if (zerop (shell-command-on-region beg end "pbcopy")) "copied" "copy failed")))
(btw I'm always in
emacsclient -nw mode)
Anyway, I'd like two more things:
- not lose the point/position
- if a region was marked before calling the hydra, if should stay that way after
pbcopyhas been done.
How can I tweak my code to do that?