• Skip to content

Menu 1

  • Zug
  • Blog
  • Local
  • Printed
  • Projects
  • Railroad
  • Podcasts
  • Newsletter

Thomas Beutel Art

Menu 1

  • Zug
  • Blog
  • Local
  • Printed
  • Projects
  • Railroad
  • Podcasts
  • Newsletter

Follow us

Follow us on TwitterFollow us on InstagramFollow us on PinterestSubscribe to our Channel on YouTubeFollow us on SoundCloud
AuthorPostedbyThomason October 14, 2011

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

♡

Posted in Apple Computer, ProgrammingTagged emacs

1 Comment

  1. Rick
    13 years ago Permalink

    You could also try:

    (setq x-select-enable-clipboard t)

Comments are closed.

Post navigation

Previous
Next

© 2025MINIMAL

Follow us

Follow us on TwitterFollow us on InstagramFollow us on PinterestSubscribe to our Channel on YouTubeFollow us on SoundCloud
x