From: Alex S. <al...@em...> - 2002-10-06 17:05:36
|
Ville Skytt=E4 <vil...@xe...> writes: > Yes, it's there. Be aware though that there are substantial differences > between XEmacs' easy-mmode.el and the GNU Emacs one. Hm, being an Emacs person, I have difficulties finding it... Looking at how I installed my XEmacs in /usr/local, I cannot find the right one. /usr/local $ ls /usr/local/src/xem* /usr/local/src/xemacs-21.4.6.tar.gz /usr/local/src/xemacs-sumo-2002-01-19.tar.gz /usr/local $ find . -name easy-mmode.el ./stow/emacs/share/emacs/21.2.90/lisp/emacs-lisp/easy-mmode.el ./stow/xemacs-packages/lib/xemacs/xemacs-packages/lisp/pcl-cvs/easy-mmode.el /usr/local $ ls /usr/local/lib/xemacs-21.4.6/lisp/easy* /usr/local/lib/xemacs-21.4.6/lisp/easymenu.el /usr/local/lib/xemacs-21.4.6/lisp/easymenu.elc /usr/local $ ls /usr/local/lib/xemacs/xemacs-packages/lisp/xemacs-base/easy* /usr/local/lib/xemacs/xemacs-packages/lisp/xemacs-base/easy*: No such file = or directory Note that the one easy-mmode file I found has a function called easy-mmode-define-minor-mode, but nothing called define-minor-mode. I just found that Emacs has an alias for that: ;;;###autoload (defalias 'easy-mmode-define-minor-mode 'define-minor-mode) But since the argument list does not match, we are out of luck. > A sync of this mode would be welcome. Can we (you) just replace the XEmacs definition with the Emacs version? Here is from GNU Emacs 21.2.90.1 easy-mmode.el: ;;;###autoload (defmacro define-minor-mode (mode doc &optional init-value lighter keymap &= rest body) "Define a new minor mode MODE. This function defines the associated control variable MODE, keymap MODE-map, toggle command MODE, and hook MODE-hook. DOC is the documentation for the mode toggle command. Optional INIT-VALUE is the initial value of the mode's variable. Optional LIGHTER is displayed in the modeline when the mode is on. Optional KEYMAP is the default (defvar) keymap bound to the mode keymap. If it is a list, it is passed to `easy-mmode-define-keymap' in order to build a valid keymap. It's generally better to use a separate MODE-map variable than to use this argument. The above three arguments can be skipped if keyword arguments are used (see below). BODY contains code that will be executed each time the mode is (dis)activat= ed. It will be executed after any toggling but before running the hooks. BODY can start with a list of CL-style keys specifying additional argumen= ts. The following keyword arguments are supported: :group Followed by the group name to use for any generated `defcustom'. :global If non-nil specifies that the minor mode is not meant to be buffer-local. By default, the variable is made buffer-local. :init-value Same as the INIT-VALUE argument. :lighter Same as the LIGHTER argument." ;; Allow skipping the first three args. (cond ((keywordp init-value) (setq body (list* init-value lighter keymap body) init-value nil lighter nil keymap nil)) ((keywordp lighter) (setq body (list* lighter keymap body) lighter nil keymap nil)) ((keywordp keymap) (push keymap body) (setq keymap nil))) (let* ((mode-name (symbol-name mode)) (pretty-name (easy-mmode-pretty-mode-name mode lighter)) (globalp nil) (togglep t) ;why would you ever want to toggle? (group nil) (extra-args nil) (keymap-sym (if (and keymap (symbolp keymap)) keymap (intern (concat mode-name "-map")))) (hook (intern (concat mode-name "-hook"))) (hook-on (intern (concat mode-name "-on-hook"))) (hook-off (intern (concat mode-name "-off-hook")))) ;; Check keys. (while (keywordp (car body)) (case (pop body) (:init-value (setq init-value (pop body))) (:lighter (setq lighter (pop body))) (:global (setq globalp (pop body))) (:extra-args (setq extra-args (pop body))) (:group (setq group (nconc group (list :group (pop body))))) (t (pop body)))) (unless group ;; We might as well provide a best-guess default group. (setq group `(:group ',(intern (replace-regexp-in-string "-mode\\'" "" mode-name))))) ;; Add default properties to LIGHTER. (unless (or (not (stringp lighter)) (get-text-property 0 'local-map lig= hter) (get-text-property 0 'keymap lighter)) (setq lighter (propertize lighter 'local-map mode-line-minor-mode-keymap 'help-echo "mouse-3: minor mode menu"))) `(progn ;; Define the variable to enable or disable the mode. ,(if (not globalp) `(progn (defvar ,mode ,init-value ,(format "Non-nil if %s is enabled. Use the command `%s' to change this variable." pretty-name mode)) (make-variable-buffer-local ',mode)) (let ((curfile (or (and (boundp 'byte-compile-current-file) byte-compile-current-file) load-file-name))) `(defcustom ,mode ,init-value ,(format "Non-nil if %s is enabled. See the command `%s' for a description of this minor-mode. Setting this variable directly does not take effect; use either \\[customize] or the function `%s'." pretty-name mode mode) :set (lambda (symbol value) (funcall symbol (or value 0))) :initialize 'custom-initialize-default ,@group :type 'boolean ,@(when curfile (list :require (list 'quote (intern (file-name-nondirectory (file-name-sans-extension curfile))))))))) ;; The actual function. (defun ,mode (&optional arg ,@extra-args) ,(or doc (format (concat "Toggle %s on or off. Interactively, with no prefix argument, toggle the mode. With universal prefix ARG " (unless togglep "(or if ARG is nil) ") "turn mo= de on. With zero or negative ARG turn mode off. \\{%s}") pretty-name keymap-sym)) ;; Make no arg by default in an interactive call, ;; so that repeating the command toggles again. (interactive) (setq ,mode (if arg (> (prefix-numeric-value arg) 0) ,(if togglep `(not ,mode) t))) ,@body ;; The on/off hooks are here for backward compatibility only. (run-hooks ',hook (if ,mode ',hook-on ',hook-off)) ;; Return the new setting. (if (interactive-p) (message ,(format "%s %%sabled" pretty-name) (if ,mode "en" "dis"))) (force-mode-line-update) ,mode) ;; Autoloading an easy-mmode-define-minor-mode autoloads ;; everything up-to-here. :autoload-end ;; The toggle's hook. (defcustom ,hook nil ,(format "Hook run at the end of function `%s'." mode-name) :group ,(cadr group) :type 'hook) ;; Define the minor-mode keymap. ,(unless (symbolp keymap) ;nil is also a symbol. `(defvar ,keymap-sym (let ((m ,keymap)) (cond ((keymapp m) m) ((listp m) (easy-mmode-define-keymap m)) (t (error "Invalid keymap %S" ,keymap)))) ,(format "Keymap for `%s'." mode-name))) (add-minor-mode ',mode ',lighter ,(if keymap keymap-sym `(if (boundp ',keymap-sym) (symbol-value ',keymap-sym)))) =20=20=20=20=20=20=20 ;; If the mode is global, call the function according to the default. ,(if globalp `(if (and load-file-name ,mode) (eval-after-load load-file-name '(,mode 1))))))) Alex. |