[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.

    PANgaro
    ------

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
     		      :change-form-style-to-bold)
     		    #\c-m-sh-J
     		    zwei:*zmacs-comtab*)

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>|))
	 (move-bp
	   (point)
	   (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>|)))))
       dis-text)

When run, this produces something like this:

  (ZWEI:DEFINE-KEYBOARD-MACRO <Name> (NIL) 
    #\f #\o #\o)

  #|
  (ZWEI:COMMAND-STORE (ZWEI:MAKE-MACRO-COMMAND :|<Name>|) 
	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.