2

@lawlist asked for more details so I am re-writing the question:

My goal is to treat ^X and ^K as two different ways to cut text into a SINGLE logical clipboard that can be pasted using ^V in emacs or in any other app.

Suppose there are two lines in the emacs buffer: I am line one I am line two

and I press ^K on the first line, then the kill ring AND the OS-level clipboard BOTH now have 'I am line one' by pressing ^K two more time, then the OS-level clipboard will be updated again to have "I am line one\nI am line two"

Pressing ^V in emacs or in other applications will cause that text to be pasted into them. (^Y can continue to have its original behavior, or not, I don't care)

Right now, ^K is bound to org-kill-line or just kill-line depending on which edit mode I am in.

I don't think there is an existing emacs command to do this, but if only I knew the functions to call, I bet it is trivial to simply update the OS clipboard after every ^K.

Any help would be great.

thanks, dan

Dan Oblinger
  • 489
  • 3
  • 15
  • What happens now when you press `Control-K` in Aquamacs, and how is that different than what you want to achieve? It will also be helpful to include the name of the specific function that is called -- e.g., `kill-line`. In Emacs, the name of the function can be obtained by typing `Control-h k` and then pressing whichever keyboard shortcut after that. Most of the forum participants will have easy access to the generic Emacs, but not Aquamacs. If the function is common to the generic Emacs, then your odds of getting an answer increase substantially. – lawlist Jun 07 '15 at 15:34
  • @lawlist I rewrote my question to be much more precise. let me know if there is more info you need. p.s. I expect the answer that works for emacs will also work for Aquamac, I was just being complete. Thanks! – Dan Oblinger Jun 07 '15 at 22:05
  • The doc-string for `kill-line` states in part: *If you want to append the killed line to the last killed text, use `append-next-kill` before `kill-line`.* Does that get you any closer to where you want to be? The default behavior is to add the killed data to both the Emacs kill-ring and the OSX kill-ring. Here is a link to the manual regarding `append-next-kill`: http://www.gnu.org/software/emacs/manual/html_node/emacs/Appending-Kills.html The doc-string can be viewed within Emacs by calling `C-h f` or `M-x describe-function`. – lawlist Jun 08 '15 at 02:29
  • Thanks @lawlist, the kill-line function right now does not affect the OS level clipboard at all... it actually already has the semantics I hope for, but it is a SEPARATE clipboard. (this is silly) so I dream of a function that basically is something like: (defun merged_kill() (kill-line) (setq clipboard (current-kill-buffer)) but I don't know the commands. so appending or not, is not the issue, the issue is, it does not update the OS level clipboard – Dan Oblinger Jun 08 '15 at 05:22
  • In the generic version of Emacs, `kill-line` invokes `kill-region`, which invokes `kill-new` *unless* `(eq last-command 'kill-region)` -- `kill-new` contains the `interprogram-...` stuff responsible for pushing to the OSX clipboard. Perhaps the author of Aquamacs has modified `kill-line` and/or its underlying functions to isolate the OSX clipboard -- you can use `M-x find-function` to locate `kill-line` and the other functions too. `M-x find-variable` is used for variables. I try to avoid installing Aquamacs because it adds folders and files in places I don't like. – lawlist Jun 08 '15 at 05:57

1 Answers1

1

I think you are looking for save-interprogram-paste-before-kill. Try adding this

(setq save-interprogram-paste-before-kill t)

to your init.el

PuercoPop
  • 6,707
  • 4
  • 30
  • 40
  • Thanks for the attempt. this seems to save the contents of the clipboard into the kill ring. my goal is the reverse, to save the contents from a ^K (currently in the kill ring) to the clipboard. If I knew how to get the contents of the current kill ring entry into a elisp variable, I think I could write the function. unfortunately the value returned to me, is not a simple string when I attempt this. What a byzantine mess! – Dan Oblinger Jun 09 '15 at 16:23
  • I no longer have a mac to test it out, but when I did the integration went both ways. Although I used vanilla GNU/Emacs, not Aquamacs. weird. – PuercoPop Jun 09 '15 at 22:11
  • I will try this out in vanilla emacs. The guy managing Aqua does a better job of fixing OSX specific bugs.... so I had troubles w. vanilla emacs years ago.... maybe they will be fixed now. – Dan Oblinger Jun 10 '15 at 20:24