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

Re: adding command to dired comtab



In article <9104232242.AA15431@ceratiidae.cs.sandia.gov> drstrip@CS.SANDIA.GOV (David R Strip) writes:
>I want to add a command to dired. I know how to write the lisp code.
>I even know how to add it to the comtab if I redefine 
>(DEFMAJOR COM-DIRED-MODE ...
>where the comtab is.
>
>What I want to know is, is there some way to do a command-store
>to the mode comtab? How do I reference the mode comtab if I am 
>not currently in that mode?
>Thanks.
>strip
>drstrip@cs.sandia.gov


;;; DAVID
;;;
;;; The following is a bit of overkill.  I use this so that I can bash 
;;; DIRED in a way that lets me revert when done.  (BTW, this works
;;; generally for other modal comtabs, like edit-buffers.)
;;;
;;; The bit you're really interested in is MAJOR-MODE-SET-COMTAB.
;;;
;;; Hope it helps
;;; Nichael

;;; -*- Mode: LISP; Syntax: Zetalisp; Package: ZWEI; Base: 10 -*-

;;;********************************************************************************
;;; Various macros and functions of (possibly) general interest.
;;;********************************************************************************
(defmacro set!-major-mode-comtab-return-undo (MODE-KEYWORD SPECS)
  `(let ((*-*OLD-USER-FORMS*-* (send (major-mode-from-keyword ,MODE-KEYWORD) :user-mode-forms)))
     (major-mode-set-comtab ,MODE-KEYWORD ,SPECS)
     `(progn
	(setf (send (major-mode-from-keyword ,',MODE-KEYWORD) :user-mode-forms)
	      ,(and *-*OLD-USER-FORMS*-* `',*-*OLD-USER-FORMS*-*))))
  )

(defvar *NLCMACS-UNDO-DIRED-COMTAB-LIST* nil)

(eval-when (load)
  (setq *NLCMACS-UNDO-DIRED-COMTAB-LIST*
	(set!-major-mode-comtab-return-undo :dired
					    '(#\B COM-DIRED-COMPILE-FILE
					      #\b (0 #/B)
					      #\c-h COM-DIRED-AUTOMATIC-ALL-RATIONALLY
					      #\M COM-DIRED-MOVE-MARKED-FILES
					      #\m (0 #/M)
					      #\ABORT com-abort-at-top-level
					      #\Help  com-dired-nlcmacs-help
					      #\mouse-3-1 COM-DIRED-POINT-AND-EDIT-FILE))
	)
  )