Path: utzoo!utgpu!utstat!jarvis.csri.toronto.edu!mailrus!bbn!bbn.com!mesard From: mesard@bbn.com (Wayne Mesard) Newsgroups: comp.emacs Subject: Re: Copy From Above? Message-ID: <36077@bbn.COM> Date: 16 Feb 89 14:39:04 GMT References: <690026@hpsemc.HP.COM> Sender: news@bbn.COM Reply-To: mesard@BBN.COM (Wayne Mesard) Organization: Bolt Beranek and Newman Inc., Cambridge MA Lines: 45 In article <690026@hpsemc.HP.COM> gph@hpsemc.HP.COM (Old run-down actor) writes: >Can anyone tell me how I can get gnuemacs to (with one keystroke) copy >the character on the line above the cursor to the current cursor >position? > If I repeat it multiple times or use cntl-u (say 5) and then the >keystroke, you should see: > [deleted] For simple things like this, all you need is keyboard macros. Read about them in the manual (section 28.3 of the fifth edition), and look at the documentation for the function start-kbd-macro [which is generally bound to Ctrl-X ( ]. In your case you would type the following: Ctrl-X ( ; Start the macro. Ctrl-P ; Move up a line. Ctrl-U 1 Ctrl-D ; Delete one char and put it on the kill-ring. Ctrl-Y ; Yank it back. Ctrl-N ; Move back to original line. Ctrl-Y ; Put a copy of the killed char here. Ctrl-X ) ; Done defining macro. Now your command can be executed by Ctrl-X E (call-last-kbd-macro). And Ctrl-U Ctrl-X E will do the right thing, too. To bind it to another key, you must first name it with M-x name-last-kbd-macro. After naming it you can insert it in, e.g., your ~/.emacs file, so it will be available in later Emacs sessions. To do this use insert-kbd-macro. Gosh, and you didn't have to type a single lisp expression. Whattaneditor! [[Hypothesis of the day: It is possible to build an arbitrarily complex Turing machine using Emacs keyboard macros :-) ]] [[Followups refuting the previous sentence (after all its got a net.insurance.policy (i.e. a smiley)), or showing a way to do the macro in only six keystrokes to /dev/null.]] -- unsigned *Wayne_Mesard(); MESARD@BBN.COM BBN, Cambridge, MA