[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Zmacs keystroke programming?

    Date: 6 Nov 87 11:21:00 EST
    From: "ARTIC::AREAPU" <areapu%artic.decnet@ari-hq1.arpa>

    Does anyone know a way to define a macro in ZMACS
    via the usual keystrokes, then capture that into
    a file for adding to an init file? Figuring the macro
    while defining it in a lisp form in the init file is
    so difficult with complex macros; know you know why
    HP and other calculator folks did it the way they did.

    Many thanks.


An example from Lisp Lore:

     (zwei:define-keyboard-macro change-form-style-to-bold (nil)
       #\c-Space #\c-m-B #\c-x #\c-X #\c-X #\c-J #\B #\Return)

     (zwei:command-store (zwei:make-macro-command

However, I assume you want something which will help you automate this
process, right?  Here is a hack:

     (defcom com-insert-kbd-macro-into-buffer
	     "Inserts keyboard macro into buffer at point." ()
       (unless (memq :macro-previous-array (send standard-input :which-operations))
	 (barf "This stream does not support macros."))
       (let ((array (send standard-input :macro-previous-array))
	     (gensym ':|<Name>|))
	   (insert (point)(format nil "(~S ~A (NIL) ~%  ~{~@C~^ ~})~2%#|~%~S~%|#~%"
				  'define-keyboard-macro gensym (cl:coerce array 'list)
				  `(command-store (zwei:make-macro-command ,gensym)
						  |<Character>| |<Comtab>|)))))

When run, this produces something like this:

    #\f #\o #\o)

	ZWEI:|<Character>| ZWEI:|<Comtab>|) 

which you can edit into whatever form you like.  In the form I have it
here, you need to type "c-m-X Insert ...".  You can say:

     (set-comtab *standard-comtab* nil
	(make-command-alist '(com-insert-kbd-macro-into-buffer)))

to make it more easily accessible, but presumably you won't be using it
that much.