Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watmath!clyde!rutgers!seismo!mcvax!diku!ambush!storm From: storm@ambush.UUCP Newsgroups: comp.emacs Subject: Re: User defined functions Message-ID: <455@ambush.UUCP> Date: Thu, 13-Aug-87 06:59:28 EDT Article-I.D.: ambush.455 Posted: Thu Aug 13 06:59:28 1987 Date-Received: Sat, 15-Aug-87 16:29:05 EDT References: <8708121417.AA19618@ucbvax.Berkeley.EDU> Distribution: world Organization: AmbraSoft A/S (Denmark) Lines: 36 In article <8708121417.AA19618@ucbvax.Berkeley.EDU> dsill@NSWC-OAS.ARPA (Dave Sill) writes: >I've been toying around with the idea of extending the macro concept. >What I envision is a facility whereby one could define a function in >the same manner as a macro. This function could be given an >associated name like any other Emacs command, e.g. daves-foo-command. >In addition, there should be a facility for saving these definitions >in a file. This is exactly what M-x name-last-kdb-macro and M-x insert-kbd-macro in GNU Emacs can do for you. The trick is that a string bound to a function name is interpreted as if the characters in the string were entered from the keyboard, e.g. (fset 'insert-hello-world-in-beginning-of-line "^AHello world ") However, there is a minor problem with this approach: If you use key bindings which are unique for the terminal on which the keyboard macro is defined, you will not be able to use them on another terminal. If you want to be able to move functions defined via keyboard macros between incompatible terminals, use only the standard bindings and call other functions via M-x or eval even when you have bound them to a key on YOUR keyboard. For example, (fset 'insert-hello-world-in-beginning-of-line "^[#Ghello world ") MIGHT do what was intended on the terminal it was defined on, but not on any other terminal! The following version is always protable: (fset 'insert-hello-world-in-beginning-of-line "^[xbeginning-of-line^Mhello world ") -- Kim F. Storm, storm@ambush.uucp (or ..!mcvax!diku!ambush!storm) AmbraSoft A/S, Rojelskaer 15, DK-2840 Holte, Denmark. tel: +45 2424 111