summaryrefslogtreecommitdiff
path: root/lisp/autoinsert.el
diff options
context:
space:
mode:
authorStefan Monnier <monnier@iro.umontreal.ca>2000-09-29 22:14:58 +0000
committerStefan Monnier <monnier@iro.umontreal.ca>2000-09-29 22:14:58 +0000
commitbff6da3dcea94d04e1147d5988d6b76242fc695e (patch)
treeae53f48ce311d47eeabb6eb471bb2962a486e79f /lisp/autoinsert.el
parent264f0aa7ed3df3e078f077e23765bbf71a8a5faf (diff)
downloademacs-bff6da3dcea94d04e1147d5988d6b76242fc695e.tar.gz
(auto-insert-mode): Use define-minor-mode.
Diffstat (limited to 'lisp/autoinsert.el')
-rw-r--r--lisp/autoinsert.el30
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 @@
:group 'convenience)
-(defcustom auto-insert-mode nil
- "Toggle Auto-insert mode.
-Setting this variable directly does not take effect;
-use either \\[customize] or the function `auto-insert-mode'."
- :set (lambda (symbol value)
- (auto-insert-mode (or value 0)))
- :initialize 'custom-initialize-default
- :type 'boolean
- :group 'auto-insert
- :require 'autoinsert)
-
(defcustom auto-insert 'not-modified
"*Controls automatic insertion into newly found empty files.
Possible values:
@@ -293,26 +282,17 @@ or if CONDITION had no actions, after all other CONDITIONs."
auto-insert-alist))))))
;;;###autoload
-(defun auto-insert-mode (&optional arg)
+(define-minor-mode auto-insert-mode
"Toggle Auto-insert mode.
With prefix ARG, turn Auto-insert mode on if and only if ARG is positive.
Returns the new status of Auto-insert mode (non-nil means on).
When Auto-insert mode is enabled, when new files are created you can
insert a template for the file depending on the mode of the buffer."
- (interactive "P")
- (let ((on-p (if arg
- (> (prefix-numeric-value arg) 0)
- (not auto-insert-mode))))
- (if on-p
- (add-hook 'find-file-hooks 'auto-insert)
- (remove-hook 'find-file-hooks 'auto-insert))
- (if (interactive-p)
- (message "Auto-insert now %s." (if on-p "on" "off")))
- (setq auto-insert-mode on-p)))
-
-(if auto-insert-mode
- (auto-insert-mode 1))
+ nil nil nil :global t :group 'auto-insert
+ (if auto-insert-mode
+ (add-hook 'find-file-hooks 'auto-insert)
+ (remove-hook 'find-file-hooks 'auto-insert)))
(provide 'autoinsert)