diff options
| author | Stefan Monnier | 2000-06-05 06:06:30 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2000-06-05 06:06:30 +0000 |
| commit | d5b037c5bf1da10b37f97ac7a07dd7331d230de2 (patch) | |
| tree | a0d83f0d6b2fbac6a4c499b0ae204d96e316c5c4 | |
| parent | 02b420eb35814cd05f36685b84f683ca699e2ed9 (diff) | |
| download | emacs-d5b037c5bf1da10b37f97ac7a07dd7331d230de2.tar.gz emacs-d5b037c5bf1da10b37f97ac7a07dd7331d230de2.zip | |
(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.
| -rw-r--r-- | lisp/ChangeLog | 29 | ||||
| -rw-r--r-- | lisp/emacs-lisp/easy-mmode.el | 66 |
2 files changed, 56 insertions, 39 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 90c447d803f..905c15ff523 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,23 +1,44 @@ | |||
| 1 | 2000-06-05 Stefan Monnier <monnier@cs.yale.edu> | ||
| 2 | |||
| 3 | * emacs-lisp/easy-mmode.el (easy-mmode-define-global-mode): Autoload. | ||
| 4 | Use find-file-hooks in the minor-mode function. | ||
| 5 | Be careful not to loop indefinitely in the post-command-hook function. | ||
| 6 | |||
| 1 | 2000-06-05 Michael Kifer <kifer@cs.sunysb.edu> | 7 | 2000-06-05 Michael Kifer <kifer@cs.sunysb.edu> |
| 2 | 8 | ||
| 3 | * ediff-init.el (ediff-has-face-support-p): make it paint faces on | 9 | * ediff-init.el (ediff-has-face-support-p): make it paint faces on |
| 4 | tty's. | 10 | tty's. |
| 5 | * ediff-diff.el (ediff-exec-process): use --binary for fine | 11 | * ediff-diff.el (ediff-exec-process): use --binary for fine |
| 6 | differences whenever apropriate. | 12 | differences whenever appropriate. |
| 7 | * viper-cmd.el (viper-smart-suffix-list): rearranged list members. | 13 | * viper-cmd.el (viper-smart-suffix-list): rearranged list members. |
| 8 | * viper.el (find-file,find-file-other-window): get viper to do | 14 | * viper.el (find-file, find-file-other-window): get viper to do |
| 9 | wildcards. | 15 | wildcards. |
| 10 | 16 | ||
| 11 | 2000-06-04 Stefan Monnier <monnier@cs.yale.edu> | 17 | 2000-06-04 Stefan Monnier <monnier@cs.yale.edu> |
| 12 | 18 | ||
| 13 | * emacs-lisp/easy-mmode.el (easy-mmode-define-toggle): | 19 | * jit-lock.el (jit-lock-saved-fontify-buffer-function): New var. |
| 14 | Remove (inline into define-minor-mode). | 20 | (jit-lock-fontify-buffer): New function for JIT refontification. |
| 21 | (jit-lock-mode): Fix docstring. | ||
| 22 | Use jit-lock-fontify-buffer for font-lock-fontify-buffer-function. | ||
| 23 | Remove jit-lock-after-change from the _local_ hook. | ||
| 24 | (jit-lock-function-1): Fix docstring. | ||
| 25 | |||
| 26 | * info.el (Info-on-current-buffer): Initialize info. | ||
| 27 | |||
| 28 | * newcomment.el (comment-indent): Ignore comment-indent-hook. | ||
| 29 | |||
| 30 | * progmodes/tcl.el (tcl-indent-for-comment): | ||
| 31 | Ignore comment-indent-hook. | ||
| 32 | |||
| 33 | * emacs-lisp/easy-mmode.el: Require CL during compilation. | ||
| 34 | (easy-mmode-define-toggle): Remove (inline into define-minor-mode). | ||
| 15 | (easy-mmode-pretty-mode-name): Rename from easy-mmode-derive-name | 35 | (easy-mmode-pretty-mode-name): Rename from easy-mmode-derive-name |
| 16 | and improve to use the lighter to guess the capitalization. | 36 | and improve to use the lighter to guess the capitalization. |
| 17 | (define-minor-mode): Inline code from easy-mmode-define-toggle. | 37 | (define-minor-mode): Inline code from easy-mmode-define-toggle. |
| 18 | Add keyword arguments to specify global-ness or the custom group. | 38 | Add keyword arguments to specify global-ness or the custom group. |
| 19 | Add local-map and help-echo properties to the lighter. | 39 | Add local-map and help-echo properties to the lighter. |
| 20 | (easy-mmode-define-navigation): Add the errors to debug-ignored-errors. | 40 | (easy-mmode-define-navigation): Add the errors to debug-ignored-errors. |
| 41 | (easy-mmode-define-global-mode): New macro. | ||
| 21 | 42 | ||
| 22 | 2000-06-02 Dave Love <fx@gnu.org> | 43 | 2000-06-02 Dave Love <fx@gnu.org> |
| 23 | 44 | ||
diff --git a/lisp/emacs-lisp/easy-mmode.el b/lisp/emacs-lisp/easy-mmode.el index 72b64a4a881..32ceecd2996 100644 --- a/lisp/emacs-lisp/easy-mmode.el +++ b/lisp/emacs-lisp/easy-mmode.el | |||
| @@ -120,32 +120,21 @@ BODY contains code that will be executed each time the mode is (dis)activated. | |||
| 120 | 120 | ||
| 121 | `(progn | 121 | `(progn |
| 122 | ;; Define the variable to enable or disable the mode. | 122 | ;; Define the variable to enable or disable the mode. |
| 123 | ,(if globalp | 123 | ,(if (not globalp) |
| 124 | ;; BEWARE! autoload.el depends on this `defcustom' coming | 124 | `(progn |
| 125 | ;; as the first element after progn. | 125 | (defvar ,mode ,init-value ,(format "Non-nil if %s is enabled. |
| 126 | `(defcustom ,mode ,init-value | ||
| 127 | ,(format "Toggle %s. | ||
| 128 | Setting this variable directly does not take effect; | ||
| 129 | use either \\[customize] or the function `%s'." | ||
| 130 | pretty-name mode) | ||
| 131 | :set (lambda (symbol value) (funcall symbol (or value 0))) | ||
| 132 | :initialize 'custom-initialize-default | ||
| 133 | :group ,group | ||
| 134 | :type 'boolean) | ||
| 135 | `(progn | ||
| 136 | (defvar ,mode ,init-value ,(format "Non-nil if %s is enabled. | ||
| 137 | Use the function `%s' to change this variable." pretty-name mode)) | 126 | Use the function `%s' to change this variable." pretty-name mode)) |
| 138 | (make-variable-buffer-local ',mode))) | 127 | (make-variable-buffer-local ',mode)) |
| 139 | 128 | ||
| 140 | ;; Define the minor-mode keymap. | 129 | `(defcustom ,mode ,init-value |
| 141 | ,(when keymap | 130 | ,(format "Toggle %s. |
| 142 | `(defvar ,keymap-sym | 131 | Setting this variable directly does not take effect; |
| 143 | (cond ((and ,keymap (keymapp ,keymap)) | 132 | use either \\[customize] or the function `%s'." |
| 144 | ,keymap) | 133 | pretty-name mode) |
| 145 | ((listp ,keymap) | 134 | :set (lambda (symbol value) (funcall symbol (or value 0))) |
| 146 | (easy-mmode-define-keymap ,keymap)) | 135 | :initialize 'custom-initialize-default |
| 147 | (t (error "Invalid keymap %S" ,keymap))) | 136 | :group ,group |
| 148 | ,(format "Keymap for `%s'." mode-name))) | 137 | :type 'boolean)) |
| 149 | 138 | ||
| 150 | ;; The toggle's hook. | 139 | ;; The toggle's hook. |
| 151 | (defcustom ,hook nil | 140 | (defcustom ,hook nil |
| @@ -174,6 +163,14 @@ With zero or negative ARG turn mode off. | |||
| 174 | (if ,mode "en" "dis"))) | 163 | (if ,mode "en" "dis"))) |
| 175 | ,mode) | 164 | ,mode) |
| 176 | 165 | ||
| 166 | ;; Define the minor-mode keymap. | ||
| 167 | ,(when keymap | ||
| 168 | `(defvar ,keymap-sym | ||
| 169 | (cond ((keymapp ,keymap) ,keymap) | ||
| 170 | ((listp ,keymap) (easy-mmode-define-keymap ,keymap)) | ||
| 171 | (t (error "Invalid keymap %S" ,keymap))) | ||
| 172 | ,(format "Keymap for `%s'." mode-name))) | ||
| 173 | |||
| 177 | (add-minor-mode ',mode ',lighter | 174 | (add-minor-mode ',mode ',lighter |
| 178 | (if (boundp ',keymap-sym) (symbol-value ',keymap-sym))) | 175 | (if (boundp ',keymap-sym) (symbol-value ',keymap-sym))) |
| 179 | 176 | ||
| @@ -184,6 +181,7 @@ With zero or negative ARG turn mode off. | |||
| 184 | ;;; make global minor mode | 181 | ;;; make global minor mode |
| 185 | ;;; | 182 | ;;; |
| 186 | 183 | ||
| 184 | ;;;###autoload | ||
| 187 | (defmacro easy-mmode-define-global-mode (global-mode mode turn-on | 185 | (defmacro easy-mmode-define-global-mode (global-mode mode turn-on |
| 188 | &rest keys) | 186 | &rest keys) |
| 189 | "Make GLOBAL-MODE out of the MODE buffer-local minor mode. | 187 | "Make GLOBAL-MODE out of the MODE buffer-local minor mode. |
| @@ -209,9 +207,6 @@ KEYS is a list of CL-style keyword arguments: | |||
| 209 | (t (setq keys (cdr keys))))) | 207 | (t (setq keys (cdr keys))))) |
| 210 | 208 | ||
| 211 | `(progn | 209 | `(progn |
| 212 | ;; BEWARE! autoload.el depends on `define-minor-mode' coming | ||
| 213 | ;; as the first element after progn. | ||
| 214 | |||
| 215 | ;; The actual global minor-mode | 210 | ;; The actual global minor-mode |
| 216 | (define-minor-mode ,global-mode | 211 | (define-minor-mode ,global-mode |
| 217 | ,(format "Toggle %s in every buffer. | 212 | ,(format "Toggle %s in every buffer. |
| @@ -223,7 +218,10 @@ in which `%s' turns it on." | |||
| 223 | 218 | ||
| 224 | ;; Setup hook to handle future mode changes and new buffers. | 219 | ;; Setup hook to handle future mode changes and new buffers. |
| 225 | (if ,global-mode | 220 | (if ,global-mode |
| 226 | (add-hook 'change-major-mode-hook ',cmmh) | 221 | (progn |
| 222 | (add-hook 'find-file-hooks ',buffers) | ||
| 223 | (add-hook 'change-major-mode-hook ',cmmh)) | ||
| 224 | (remove-hook 'find-file-hooks ',buffers) | ||
| 227 | (remove-hook 'change-major-mode-hook ',cmmh)) | 225 | (remove-hook 'change-major-mode-hook ',cmmh)) |
| 228 | 226 | ||
| 229 | ;; Go through existing buffers. | 227 | ;; Go through existing buffers. |
| @@ -236,18 +234,16 @@ in which `%s' turns it on." | |||
| 236 | 234 | ||
| 237 | ;; The function that calls TURN-ON in each buffer. | 235 | ;; The function that calls TURN-ON in each buffer. |
| 238 | (defun ,buffers () | 236 | (defun ,buffers () |
| 239 | (while ,buffers | ||
| 240 | (when (buffer-name (car ,buffers)) | ||
| 241 | (with-current-buffer (pop ,buffers) | ||
| 242 | (,turn-on)))) | ||
| 243 | (remove-hook 'post-command-hook ',buffers) | 237 | (remove-hook 'post-command-hook ',buffers) |
| 244 | (remove-hook 'after-find-file ',buffers)) | 238 | (while ,buffers |
| 239 | (let ((buf (pop ,buffers))) | ||
| 240 | (when (buffer-live-p buf) | ||
| 241 | (with-current-buffer buf (,turn-on)))))) | ||
| 245 | 242 | ||
| 246 | ;; The function that catches kill-all-local-variables. | 243 | ;; The function that catches kill-all-local-variables. |
| 247 | (defun ,cmmh () | 244 | (defun ,cmmh () |
| 248 | (add-to-list ',buffers (current-buffer)) | 245 | (add-to-list ',buffers (current-buffer)) |
| 249 | (add-hook 'post-command-hook ',buffers) | 246 | (add-hook 'post-command-hook ',buffers))))) |
| 250 | (add-hook 'after-find-file ',buffers))))) | ||
| 251 | 247 | ||
| 252 | ;;; | 248 | ;;; |
| 253 | ;;; easy-mmode-defmap | 249 | ;;; easy-mmode-defmap |