diff options
| author | Stefan Monnier | 2000-09-29 22:14:58 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2000-09-29 22:14:58 +0000 |
| commit | bff6da3dcea94d04e1147d5988d6b76242fc695e (patch) | |
| tree | ae53f48ce311d47eeabb6eb471bb2962a486e79f | |
| parent | 264f0aa7ed3df3e078f077e23765bbf71a8a5faf (diff) | |
| download | emacs-bff6da3dcea94d04e1147d5988d6b76242fc695e.tar.gz emacs-bff6da3dcea94d04e1147d5988d6b76242fc695e.zip | |
(auto-insert-mode): Use define-minor-mode.
| -rw-r--r-- | lisp/autoinsert.el | 30 |
1 files changed, 5 insertions, 25 deletions
diff --git a/lisp/autoinsert.el b/lisp/autoinsert.el index 59430cafdd4..9ba77ad9cb4 100644 --- a/lisp/autoinsert.el +++ b/lisp/autoinsert.el | |||
| @@ -57,17 +57,6 @@ | |||
| 57 | :group 'convenience) | 57 | :group 'convenience) |
| 58 | 58 | ||
| 59 | 59 | ||
| 60 | (defcustom auto-insert-mode nil | ||
| 61 | "Toggle Auto-insert mode. | ||
| 62 | Setting this variable directly does not take effect; | ||
| 63 | use either \\[customize] or the function `auto-insert-mode'." | ||
| 64 | :set (lambda (symbol value) | ||
| 65 | (auto-insert-mode (or value 0))) | ||
| 66 | :initialize 'custom-initialize-default | ||
| 67 | :type 'boolean | ||
| 68 | :group 'auto-insert | ||
| 69 | :require 'autoinsert) | ||
| 70 | |||
| 71 | (defcustom auto-insert 'not-modified | 60 | (defcustom auto-insert 'not-modified |
| 72 | "*Controls automatic insertion into newly found empty files. | 61 | "*Controls automatic insertion into newly found empty files. |
| 73 | Possible values: | 62 | Possible values: |
| @@ -293,26 +282,17 @@ or if CONDITION had no actions, after all other CONDITIONs." | |||
| 293 | auto-insert-alist)))))) | 282 | auto-insert-alist)))))) |
| 294 | 283 | ||
| 295 | ;;;###autoload | 284 | ;;;###autoload |
| 296 | (defun auto-insert-mode (&optional arg) | 285 | (define-minor-mode auto-insert-mode |
| 297 | "Toggle Auto-insert mode. | 286 | "Toggle Auto-insert mode. |
| 298 | With prefix ARG, turn Auto-insert mode on if and only if ARG is positive. | 287 | With prefix ARG, turn Auto-insert mode on if and only if ARG is positive. |
| 299 | Returns the new status of Auto-insert mode (non-nil means on). | 288 | Returns the new status of Auto-insert mode (non-nil means on). |
| 300 | 289 | ||
| 301 | When Auto-insert mode is enabled, when new files are created you can | 290 | When Auto-insert mode is enabled, when new files are created you can |
| 302 | insert a template for the file depending on the mode of the buffer." | 291 | insert a template for the file depending on the mode of the buffer." |
| 303 | (interactive "P") | 292 | nil nil nil :global t :group 'auto-insert |
| 304 | (let ((on-p (if arg | 293 | (if auto-insert-mode |
| 305 | (> (prefix-numeric-value arg) 0) | 294 | (add-hook 'find-file-hooks 'auto-insert) |
| 306 | (not auto-insert-mode)))) | 295 | (remove-hook 'find-file-hooks 'auto-insert))) |
| 307 | (if on-p | ||
| 308 | (add-hook 'find-file-hooks 'auto-insert) | ||
| 309 | (remove-hook 'find-file-hooks 'auto-insert)) | ||
| 310 | (if (interactive-p) | ||
| 311 | (message "Auto-insert now %s." (if on-p "on" "off"))) | ||
| 312 | (setq auto-insert-mode on-p))) | ||
| 313 | |||
| 314 | (if auto-insert-mode | ||
| 315 | (auto-insert-mode 1)) | ||
| 316 | 296 | ||
| 317 | (provide 'autoinsert) | 297 | (provide 'autoinsert) |
| 318 | 298 | ||