Making Aquamacs kill and yank work with the clipboard
239
post-template-default,single,single-post,postid-239,single-format-standard,bridge-core-3.0.1,qodef-qi--no-touch,qi-addons-for-elementor-1.5.3,qode-page-transition-enabled,ajax_updown,page_not_loaded,,vertical_menu_enabled,side_area_uncovered_from_content,qode-theme-ver-28.7,qode-theme-bridge,disabled_footer_top,qode_header_in_grid,wpb-js-composer js-comp-ver-6.8.0,vc_responsive,elementor-default,elementor-kit-6

Making Aquamacs kill and yank work with the clipboard

Making Aquamacs kill and yank work with the clipboard

My favorite editor on the Mac is Aquamacs (me and Emacs go waaay back) and something that has long been a productivity killer for me was the different actions of C-y and CMD-V.

This is due to there being two clipboards, the one belonging to the Mac and the one in Emacs (the kill ring).

Often I would use one or the other and get the wrong pasted contents. Then I’d have to stop, back up, and find the original contents and do it again. Worse, sometimes the contents would be cut or killed, meaning that I would have to undo the cut/kill, redo the cut/kill, then yank/paste.

Well, I finally had enough and looked for ways to harmonize the two clipboards via the .emacs file. Here is what I came up with:


(defun swap-and-kill ()
"Swap point and mark, then clipboard kill region"
(interactive)
(exchange-point-and-mark)
(clipboard-kill-region (region-beginning) (region-end))
(deactivate-mark)
)
(global-set-key "\C-w" 'swap-and-kill)
(global-set-key "\M-w" 'clipboard-kill-ring-save)
(global-set-key "\C-y" 'clipboard-yank)

Now everything goes to the Mac clipboard, even if I use my beloved mark and point with C-w.

I found most of the clues for this solution here:

http://www.emacswiki.org/emacs/CopyAndPaste

Tags:


Mastodon