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

some useful zmacs keyboard macros



Here are some zmacs keyboard macros that I have found quite handy.
The first group makes it easy to comment source code, which is a great
benefit since hardly anybody puts adequate comments into their code.

The second group saves typing long, and frequently-used, commands
and helps you to move around in code a little better.  The code with
external zwei: headers was gotten from Kim Cook at Symbolics.

To use these, just put them into your lispm-init file, preferably inside
of a (login-forms ) form so that the next user is not victimized by 
your environment.
-------------------------------------------------------------------------

#||
*** comment macros for zmacs
||#
(zwei:define-keyboard-macro mmm-start-comment (nil)
  #\c-E #\LF #\# #\| #\| #\LF #\* #\* #\* #\SP)
(zwei:command-store (zwei:make-macro-command :mmm-start-comment)
		    #\S-LF zwei:*zmacs-comtab*)
(zwei:define-keyboard-macro mmm-mid-comment (nil)
  #\c-E #\LF #\* #\* #\* #\SP)
(zwei:command-store (zwei:make-macro-command :mmm-mid-comment)
		    #\C-LF zwei:*zmacs-comtab*)
(zwei:define-keyboard-macro mmm-end-comment (nil)
  #\c-E #\LF #\| #\| #\#)
(zwei:command-store (zwei:make-macro-command :mmm-end-comment)
		    #\H-LF zwei:*zmacs-comtab*)
(zwei:define-keyboard-macro mmm-two-comment (nil)
  #\c-E #\LF #/; #/; #\SP)
(zwei:command-store (zwei:make-macro-command :mmm-two-comment)
		    #\S-C zwei:*zmacs-comtab*)
(zwei:define-keyboard-macro mmm-three-comment (nil)
  #\c-E #\LF #/; #/; #/; #\SP)
(zwei:command-store (zwei:make-macro-command :mmm-three-comment)
		    #\H-C zwei:*zmacs-comtab*)

#||
*** other zmacs macros
||#
(zwei:define-keyboard-macro compile-changes (nil)
  #\m-X "Compile Changed Definitions Of Buffer")
(zwei:command-store (zwei:make-macro-command :compile-changes)
		    #\c-triangle zwei:*zmacs-comtab*)
(zwei:define-keyboard-macro add-patch-changes (nil)
  #\m-X "Add Patch Changed Definitions Of Buffer")
(zwei:command-store (zwei:make-macro-command :add-patch-changes)
		    #\m-triangle zwei:*zmacs-comtab*)

;;; M-Space will turn white space into one space
zwei:
(login-eval
  (set-comtab-return-undo *standard-comtab* '(#\m-space com-just-one-space)))

;;; To go to the beginning of the line after any white space, use Meta-Return.
;;; To go to the end of the line before any comments and before any white
;;; space, use Control-Return.
;;; 
zwei:
(defcom com-end-of-code-line
	"Goes to the end of the last /"real/" character on the line.
This provides a way to get positioned on a line so you can add to or modify
the code, not the comment.  A numeric argument specifies how many lines to
move.  " ()
  (let* ((the-line (bp-line
		     (forward-line (point)	;find the line wanted
				   (if *numeric-arg-p* *numeric-arg* 0))))
	 (index (find-comment-start the-line t)))	;index for comment
    (cond ((null index)				;no comment on line
	   (move-to-bp (end-line (create-bp the-line 0))))   ;so just go to end
	  (t
	   (move-to-bp (backward-over *blanks* (create-bp the-line index))))))
  dis-bps)

zwei:
(set-comtab *standard-comtab* '(#\Control-Return com-end-of-code-line))