Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!rutgers!ames!ucbcad!ucbvax!ALEXANDER.BBN.COM!jr From: jr@ALEXANDER.BBN.COM (John Robinson) Newsgroups: comp.emacs Subject: Re: GNU Emacs Query Message-ID: <8701151449.AA20121@ucbvax.Berkeley.EDU> Date: Thu, 15-Jan-87 09:50:10 EST Article-I.D.: ucbvax.8701151449.AA20121 Posted: Thu Jan 15 09:50:10 1987 Date-Received: Fri, 16-Jan-87 01:04:16 EST References: <361@cfa.cfa.harvard.EDU> Sender: daemon@ucbvax.BERKELEY.EDU Organization: The ARPA Internet Lines: 41 Here's a definition that works: (defun append-to-killring () " Append mark-point region to the last entry on the kill ring." (interactive) (setq last-command 'kill-region) (kill-region (point) (mark)) (message "Appended.") ) The problem has to do with the semantics of (append-next-kill), and the variables this-command and last-command. (append-next-kill) sets the variable "this-command" to 'kill-region. When the command interpreter returns to the top level (read more keyboard input, I assume), it copies this-command to last-command. (kill-region) then notices whether last-command was 'kill-region, and does the append if so. This is why ^K^K appends the two kills. Since your function calls kill-region before it returns, setting this-command isn't good enough; last-command needs to be set when kill-region is called; hence the change I made. (I also bummed the message line, though I guess you'll pull that out). Look in lisp/simple.el for more. You could probably open-code the whole function without having to call kill-region at all by seeing how it works. A similar thing happens with (yank) and (yank-pop). Lesson 1: (append-next-kill) can never be called from inside an interactive (or any other for that matter) function unless you want the next *interactive* function to do the append iff it is or calls (kill-region). Lesson 2: look at the sources. That's why you have them. I won't comment on the correctness of this design, but there it is. /jr jr@bbn.com or jr@bbnccv.uucp Without life, there wouldn't be chemical companies.