aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/autoinsert.el
diff options
context:
space:
mode:
authorRĂ¼diger Sonderfeld2014-12-04 07:08:18 +0100
committerRĂ¼diger Sonderfeld2014-12-04 07:10:28 +0100
commita0363ffa9931cf751a92577ab1b0a7acbae4c4e7 (patch)
treeefec217c240966d95f63a8ff6c1b41ba61e292f7 /lisp/autoinsert.el
parentde909179393f2052eeb5dd0738bcdc582e654b14 (diff)
downloademacs-a0363ffa9931cf751a92577ab1b0a7acbae4c4e7.tar.gz
emacs-a0363ffa9931cf751a92577ab1b0a7acbae4c4e7.zip
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).
Diffstat (limited to 'lisp/autoinsert.el')
-rw-r--r--lisp/autoinsert.el24
1 files changed, 13 insertions, 11 deletions
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."
91 91
92 92
93(defcustom auto-insert-alist 93(defcustom auto-insert-alist
94 '((("\\.\\([Hh]\\|hh\\|hpp\\)\\'" . "C / C++ header") 94 '((("\\.\\([Hh]\\|hh\\|hpp\\|hxx\\|h\\+\\+\\)\\'" . "C / C++ header")
95 (upcase (concat (file-name-nondirectory 95 (replace-regexp-in-string
96 (file-name-sans-extension buffer-file-name)) 96 "[^A-Z0-9]" "_"
97 "_" 97 (replace-regexp-in-string
98 (file-name-extension buffer-file-name))) 98 "\\+" "P"
99 (upcase (file-name-nondirectory buffer-file-name))))
99 "#ifndef " str \n 100 "#ifndef " str \n
100 "#define " str "\n\n" 101 "#define " str "\n\n"
101 _ "\n\n#endif") 102 _ "\n\n#endif")
102 103
103 (("\\.\\([Cc]\\|cc\\|cpp\\)\\'" . "C / C++ program") 104 (("\\.\\([Cc]\\|cc\\|cpp\\|cxx\\|c\\+\\+\\)\\'" . "C / C++ program")
104 nil 105 nil
105 "#include \"" 106 "#include \""
106 (let ((stem (file-name-sans-extension buffer-file-name))) 107 (let ((stem (file-name-sans-extension buffer-file-name))
107 (cond ((file-exists-p (concat stem ".h")) 108 ret)
108 (file-name-nondirectory (concat stem ".h"))) 109 (dolist (ext '("H" "h" "hh" "hpp" "hxx" "h++") ret)
109 ((file-exists-p (concat stem ".hh")) 110 (when (file-exists-p (concat stem "." ext))
110 (file-name-nondirectory (concat stem ".hh"))))) 111 (setq ret (file-name-nondirectory (concat stem "." ext))))))
111 & ?\" | -10) 112 & ?\" | -10)
112 113
113 (("[Mm]akefile\\'" . "Makefile") . "makefile.inc") 114 (("[Mm]akefile\\'" . "Makefile") . "makefile.inc")
@@ -305,6 +306,7 @@ file-name or one relative to `auto-insert-directory' or a function to call.
305ACTION may also be a vector containing several successive single actions as 306ACTION may also be a vector containing several successive single actions as
306described above, e.g. [\"header.insert\" date-and-author-update]." 307described above, e.g. [\"header.insert\" date-and-author-update]."
307 :type 'sexp 308 :type 'sexp
309 :version "25.1"
308 :group 'auto-insert) 310 :group 'auto-insert)
309 311
310 312