1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-01-04 11:00:45 -08:00

(easy-mmode-define-global-mode): Autoload.

Use find-file-hooks in the minor-mode function.
Be careful not to loop indefinitely in the post-command-hook function.
This commit is contained in:
Stefan Monnier 2000-06-05 06:06:30 +00:00
parent 02b420eb35
commit d5b037c5bf
2 changed files with 56 additions and 39 deletions

View file

@ -1,23 +1,44 @@
2000-06-05 Stefan Monnier <monnier@cs.yale.edu>
* emacs-lisp/easy-mmode.el (easy-mmode-define-global-mode): Autoload.
Use find-file-hooks in the minor-mode function.
Be careful not to loop indefinitely in the post-command-hook function.
2000-06-05 Michael Kifer <kifer@cs.sunysb.edu> 2000-06-05 Michael Kifer <kifer@cs.sunysb.edu>
* ediff-init.el (ediff-has-face-support-p): make it paint faces on * ediff-init.el (ediff-has-face-support-p): make it paint faces on
tty's. tty's.
* ediff-diff.el (ediff-exec-process): use --binary for fine * ediff-diff.el (ediff-exec-process): use --binary for fine
differences whenever apropriate. differences whenever appropriate.
* viper-cmd.el (viper-smart-suffix-list): rearranged list members. * viper-cmd.el (viper-smart-suffix-list): rearranged list members.
* viper.el (find-file,find-file-other-window): get viper to do * viper.el (find-file, find-file-other-window): get viper to do
wildcards. wildcards.
2000-06-04 Stefan Monnier <monnier@cs.yale.edu> 2000-06-04 Stefan Monnier <monnier@cs.yale.edu>
* emacs-lisp/easy-mmode.el (easy-mmode-define-toggle): * jit-lock.el (jit-lock-saved-fontify-buffer-function): New var.
Remove (inline into define-minor-mode). (jit-lock-fontify-buffer): New function for JIT refontification.
(jit-lock-mode): Fix docstring.
Use jit-lock-fontify-buffer for font-lock-fontify-buffer-function.
Remove jit-lock-after-change from the _local_ hook.
(jit-lock-function-1): Fix docstring.
* info.el (Info-on-current-buffer): Initialize info.
* newcomment.el (comment-indent): Ignore comment-indent-hook.
* progmodes/tcl.el (tcl-indent-for-comment):
Ignore comment-indent-hook.
* emacs-lisp/easy-mmode.el: Require CL during compilation.
(easy-mmode-define-toggle): Remove (inline into define-minor-mode).
(easy-mmode-pretty-mode-name): Rename from easy-mmode-derive-name (easy-mmode-pretty-mode-name): Rename from easy-mmode-derive-name
and improve to use the lighter to guess the capitalization. and improve to use the lighter to guess the capitalization.
(define-minor-mode): Inline code from easy-mmode-define-toggle. (define-minor-mode): Inline code from easy-mmode-define-toggle.
Add keyword arguments to specify global-ness or the custom group. Add keyword arguments to specify global-ness or the custom group.
Add local-map and help-echo properties to the lighter. Add local-map and help-echo properties to the lighter.
(easy-mmode-define-navigation): Add the errors to debug-ignored-errors. (easy-mmode-define-navigation): Add the errors to debug-ignored-errors.
(easy-mmode-define-global-mode): New macro.
2000-06-02 Dave Love <fx@gnu.org> 2000-06-02 Dave Love <fx@gnu.org>

View file

@ -120,32 +120,21 @@ BODY contains code that will be executed each time the mode is (dis)activated.
`(progn `(progn
;; Define the variable to enable or disable the mode. ;; Define the variable to enable or disable the mode.
,(if globalp ,(if (not globalp)
;; BEWARE! autoload.el depends on this `defcustom' coming `(progn
;; as the first element after progn. (defvar ,mode ,init-value ,(format "Non-nil if %s is enabled.
`(defcustom ,mode ,init-value Use the function `%s' to change this variable." pretty-name mode))
,(format "Toggle %s. (make-variable-buffer-local ',mode))
`(defcustom ,mode ,init-value
,(format "Toggle %s.
Setting this variable directly does not take effect; Setting this variable directly does not take effect;
use either \\[customize] or the function `%s'." use either \\[customize] or the function `%s'."
pretty-name mode) pretty-name mode)
:set (lambda (symbol value) (funcall symbol (or value 0))) :set (lambda (symbol value) (funcall symbol (or value 0)))
:initialize 'custom-initialize-default :initialize 'custom-initialize-default
:group ,group :group ,group
:type 'boolean) :type 'boolean))
`(progn
(defvar ,mode ,init-value ,(format "Non-nil if %s is enabled.
Use the function `%s' to change this variable." pretty-name mode))
(make-variable-buffer-local ',mode)))
;; Define the minor-mode keymap.
,(when keymap
`(defvar ,keymap-sym
(cond ((and ,keymap (keymapp ,keymap))
,keymap)
((listp ,keymap)
(easy-mmode-define-keymap ,keymap))
(t (error "Invalid keymap %S" ,keymap)))
,(format "Keymap for `%s'." mode-name)))
;; The toggle's hook. ;; The toggle's hook.
(defcustom ,hook nil (defcustom ,hook nil
@ -174,6 +163,14 @@ With zero or negative ARG turn mode off.
(if ,mode "en" "dis"))) (if ,mode "en" "dis")))
,mode) ,mode)
;; Define the minor-mode keymap.
,(when keymap
`(defvar ,keymap-sym
(cond ((keymapp ,keymap) ,keymap)
((listp ,keymap) (easy-mmode-define-keymap ,keymap))
(t (error "Invalid keymap %S" ,keymap)))
,(format "Keymap for `%s'." mode-name)))
(add-minor-mode ',mode ',lighter (add-minor-mode ',mode ',lighter
(if (boundp ',keymap-sym) (symbol-value ',keymap-sym))) (if (boundp ',keymap-sym) (symbol-value ',keymap-sym)))
@ -184,6 +181,7 @@ With zero or negative ARG turn mode off.
;;; make global minor mode ;;; make global minor mode
;;; ;;;
;;;###autoload
(defmacro easy-mmode-define-global-mode (global-mode mode turn-on (defmacro easy-mmode-define-global-mode (global-mode mode turn-on
&rest keys) &rest keys)
"Make GLOBAL-MODE out of the MODE buffer-local minor mode. "Make GLOBAL-MODE out of the MODE buffer-local minor mode.
@ -209,9 +207,6 @@ KEYS is a list of CL-style keyword arguments:
(t (setq keys (cdr keys))))) (t (setq keys (cdr keys)))))
`(progn `(progn
;; BEWARE! autoload.el depends on `define-minor-mode' coming
;; as the first element after progn.
;; The actual global minor-mode ;; The actual global minor-mode
(define-minor-mode ,global-mode (define-minor-mode ,global-mode
,(format "Toggle %s in every buffer. ,(format "Toggle %s in every buffer.
@ -223,7 +218,10 @@ in which `%s' turns it on."
;; Setup hook to handle future mode changes and new buffers. ;; Setup hook to handle future mode changes and new buffers.
(if ,global-mode (if ,global-mode
(add-hook 'change-major-mode-hook ',cmmh) (progn
(add-hook 'find-file-hooks ',buffers)
(add-hook 'change-major-mode-hook ',cmmh))
(remove-hook 'find-file-hooks ',buffers)
(remove-hook 'change-major-mode-hook ',cmmh)) (remove-hook 'change-major-mode-hook ',cmmh))
;; Go through existing buffers. ;; Go through existing buffers.
@ -236,18 +234,16 @@ in which `%s' turns it on."
;; The function that calls TURN-ON in each buffer. ;; The function that calls TURN-ON in each buffer.
(defun ,buffers () (defun ,buffers ()
(while ,buffers
(when (buffer-name (car ,buffers))
(with-current-buffer (pop ,buffers)
(,turn-on))))
(remove-hook 'post-command-hook ',buffers) (remove-hook 'post-command-hook ',buffers)
(remove-hook 'after-find-file ',buffers)) (while ,buffers
(let ((buf (pop ,buffers)))
(when (buffer-live-p buf)
(with-current-buffer buf (,turn-on))))))
;; The function that catches kill-all-local-variables. ;; The function that catches kill-all-local-variables.
(defun ,cmmh () (defun ,cmmh ()
(add-to-list ',buffers (current-buffer)) (add-to-list ',buffers (current-buffer))
(add-hook 'post-command-hook ',buffers) (add-hook 'post-command-hook ',buffers)))))
(add-hook 'after-find-file ',buffers)))))
;;; ;;;
;;; easy-mmode-defmap ;;; easy-mmode-defmap