From: Rüdiger Sonderfeld Date: Thu, 4 Dec 2014 06:08:18 +0000 (+0100) Subject: lisp/autoinsert.el: Change default of auto-insert-alist. X-Git-Tag: emacs-25.0.90~2635^2~209 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=a0363ffa9931cf751a92577ab1b0a7acbae4c4e7;p=emacs.git lisp/autoinsert.el: Change default of auto-insert-alist. * lisp/autoinsert.el (auto-insert-alist): Update C/C++ header and program support to match more extensions. Replace non-alnum characters when generating include guards (headers) and check for more extensions when generating includes (programs) (bug#19254). --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 2ff0a2d8d16..819e0d0a1b2 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,12 @@ +2014-12-04 Rupert Swarbrick (tiny change) + Rüdiger Sonderfeld + + * autoinsert.el (auto-insert-alist): Update C/C++ header and + program support to match more extensions. Replace non-alnum + characters when generating include guards (headers) and check for + more extensions when generating includes (programs) + (bug#19254). + 2014-12-03 Eric S. Raymond * files.el (file-tree-walk): Fix docstring. diff --git a/lisp/autoinsert.el b/lisp/autoinsert.el index 5eb51707883..a6104cc597a 100644 --- a/lisp/autoinsert.el +++ b/lisp/autoinsert.el @@ -91,23 +91,24 @@ If this contains a %s, that will be replaced by the matching rule." (defcustom auto-insert-alist - '((("\\.\\([Hh]\\|hh\\|hpp\\)\\'" . "C / C++ header") - (upcase (concat (file-name-nondirectory - (file-name-sans-extension buffer-file-name)) - "_" - (file-name-extension buffer-file-name))) + '((("\\.\\([Hh]\\|hh\\|hpp\\|hxx\\|h\\+\\+\\)\\'" . "C / C++ header") + (replace-regexp-in-string + "[^A-Z0-9]" "_" + (replace-regexp-in-string + "\\+" "P" + (upcase (file-name-nondirectory buffer-file-name)))) "#ifndef " str \n "#define " str "\n\n" _ "\n\n#endif") - (("\\.\\([Cc]\\|cc\\|cpp\\)\\'" . "C / C++ program") + (("\\.\\([Cc]\\|cc\\|cpp\\|cxx\\|c\\+\\+\\)\\'" . "C / C++ program") nil "#include \"" - (let ((stem (file-name-sans-extension buffer-file-name))) - (cond ((file-exists-p (concat stem ".h")) - (file-name-nondirectory (concat stem ".h"))) - ((file-exists-p (concat stem ".hh")) - (file-name-nondirectory (concat stem ".hh"))))) + (let ((stem (file-name-sans-extension buffer-file-name)) + ret) + (dolist (ext '("H" "h" "hh" "hpp" "hxx" "h++") ret) + (when (file-exists-p (concat stem "." ext)) + (setq ret (file-name-nondirectory (concat stem "." ext)))))) & ?\" | -10) (("[Mm]akefile\\'" . "Makefile") . "makefile.inc") @@ -305,6 +306,7 @@ file-name or one relative to `auto-insert-directory' or a function to call. ACTION may also be a vector containing several successive single actions as described above, e.g. [\"header.insert\" date-and-author-update]." :type 'sexp + :version "25.1" :group 'auto-insert)