Hi, in etc/TODO we have:
,----[ etc/TODO ] | * Important features: | | [...] | | ** Add a command to make a "Local Variables" section in the current buffer | and/or add a variable to the list. `---- How about the following? Upto now, it only adds a new section, but extending the function to add a variable to an existing list can be done by using parts of `hack-local-variables', AFAICS. --8<---------------cut here---------------start------------->8--- (defun insert-local-variables (&optional formfeed mode coding variables) "Add a \"Local Variables\" section in the current buffer. If FORMFEED, insert ^L before the \"Local Variables\" section. If MODE, insert \"mode:\", if CODING, add \"coding:\". VARIABLES is a list of variables. For all variables, the values in the current buffer are used." (interactive (list (y-or-n-p "Insert page marker (formfeed)? ") (y-or-n-p "Insert mode? ") (y-or-n-p "Insert coding? ") (let ((var t) (lst nil)) (while var (if (string= "" (setq var (completing-read "Variable: " obarray 'boundp t nil nil nil))) (setq var nil) (add-to-list 'lst (intern var)))) lst))) (save-excursion (goto-char (point-max)) (if (search-backward "Local Variables:" (search-backward "\n\^L" (max (- (point-max) 3000) (point-min)) t) t) (error "Buffer already has a \"Local Variables:\" list") (goto-char (point-max))) (when formfeed (insert "\n\f\n")) (set-mark (point)) (insert "Local Variables:\n") (when mode (insert (format "mode: %s\n" (replace-regexp-in-string "-mode$" "" (symbol-name major-mode))))) (when coding (insert (format "coding: %s\n" (symbol-name buffer-file-coding-system)))) (dolist (v variables) (insert (format "%s: %S\n" (symbol-name v) (symbol-value v)))) (insert "End:\n") (comment-region (mark) (point)))) --8<---------------cut here---------------end--------------->8--- Bye, Reiner. -- ,,, (o o) ---ooO-(_)-Ooo--- | PGP key available | http://rsteib.home.pages.de/ _______________________________________________ Emacs-devel mailing list Emacs-devel@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-devel