: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:
(latex-mode
;; should try to offer completing read for these
"options, RET: "
- "\\documentstyle[" str & ?\] | -1
+ "\\documentclass[" str & ?\] | -1
?{ (read-string "class: ") "}\n"
("package, %s: "
"\\usepackage[" (read-string "options, RET: ") & ?\] | -1 ?{ str "}\n")
"Short description: "
";;; " (file-name-nondirectory (buffer-file-name)) " --- " str "
-;; Copyright (C) " (substring (current-time-string) -4) " "
+;; Copyright (C) " (substring (current-time-string) -4) " "
(getenv "ORGANIZATION") | "Free Software Foundation, Inc." "
;; Author: " (user-full-name)
-;;; " (file-name-nondirectory (buffer-file-name)) " ends here"))
+\(provide '"
+ (file-name-sans-extension (file-name-nondirectory (buffer-file-name)))
+ ")
+;;; " (file-name-nondirectory (buffer-file-name)) " ends here\n"))
"A list specifying text to insert by default into a new file.
Elements look like (CONDITION . ACTION) or ((CONDITION . DESCRIPTION) . ACTION).
CONDITION maybe a regexp that must match the new file's name, or it may be
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))
+ :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)