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).
This commit is contained in:
Rüdiger Sonderfeld 2014-12-04 07:08:18 +01:00
parent de90917939
commit a0363ffa99
2 changed files with 22 additions and 11 deletions

View file

@ -1,3 +1,12 @@
2014-12-04 Rupert Swarbrick <ruperts@broadcom.com> (tiny change)
Rüdiger Sonderfeld <ruediger@c-plusplus.net>
* 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 <esr@snark.thyrsus.com> 2014-12-03 Eric S. Raymond <esr@snark.thyrsus.com>
* files.el (file-tree-walk): Fix docstring. * files.el (file-tree-walk): Fix docstring.

View file

@ -91,23 +91,24 @@ If this contains a %s, that will be replaced by the matching rule."
(defcustom auto-insert-alist (defcustom auto-insert-alist
'((("\\.\\([Hh]\\|hh\\|hpp\\)\\'" . "C / C++ header") '((("\\.\\([Hh]\\|hh\\|hpp\\|hxx\\|h\\+\\+\\)\\'" . "C / C++ header")
(upcase (concat (file-name-nondirectory (replace-regexp-in-string
(file-name-sans-extension buffer-file-name)) "[^A-Z0-9]" "_"
"_" (replace-regexp-in-string
(file-name-extension buffer-file-name))) "\\+" "P"
(upcase (file-name-nondirectory buffer-file-name))))
"#ifndef " str \n "#ifndef " str \n
"#define " str "\n\n" "#define " str "\n\n"
_ "\n\n#endif") _ "\n\n#endif")
(("\\.\\([Cc]\\|cc\\|cpp\\)\\'" . "C / C++ program") (("\\.\\([Cc]\\|cc\\|cpp\\|cxx\\|c\\+\\+\\)\\'" . "C / C++ program")
nil nil
"#include \"" "#include \""
(let ((stem (file-name-sans-extension buffer-file-name))) (let ((stem (file-name-sans-extension buffer-file-name))
(cond ((file-exists-p (concat stem ".h")) ret)
(file-name-nondirectory (concat stem ".h"))) (dolist (ext '("H" "h" "hh" "hpp" "hxx" "h++") ret)
((file-exists-p (concat stem ".hh")) (when (file-exists-p (concat stem "." ext))
(file-name-nondirectory (concat stem ".hh"))))) (setq ret (file-name-nondirectory (concat stem "." ext))))))
& ?\" | -10) & ?\" | -10)
(("[Mm]akefile\\'" . "Makefile") . "makefile.inc") (("[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 ACTION may also be a vector containing several successive single actions as
described above, e.g. [\"header.insert\" date-and-author-update]." described above, e.g. [\"header.insert\" date-and-author-update]."
:type 'sexp :type 'sexp
:version "25.1"
:group 'auto-insert) :group 'auto-insert)