;;; autoinsert.el --- automatic mode-dependent insertion of text into new files
-;; Copyright (C) 1985-1987, 1994-1995, 1998, 2000-2012
-;; Free Software Foundation, Inc.
+;; Copyright (C) 1985-1987, 1994-1995, 1998, 2000-2014 Free Software
+;; Foundation, Inc.
;; Author: Charlie Martin <crm@cs.duke.edu>
;; Adapted-By: Daniel Pfeiffer <occitan@esperanto.org>
;; Keywords: convenience
-;; Maintainer: FSF
+;; Maintainer: emacs-devel@gnu.org
;; This file is part of GNU Emacs.
;; setq auto-insert-directory to an appropriate slash-terminated value
;;
;; You can also customize the variable `auto-insert-mode' to load the
-;; package. Alternatively, add the following to your .emacs file:
+;; package. Alternatively, add the following to your init file:
;; (auto-insert-mode 1)
;;
;; Author: Charlie Martin
(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")
(("\\.el\\'" . "Emacs Lisp header")
"Short description: "
- ";;; " (file-name-nondirectory (buffer-file-name)) " --- " str "
+ ";;; " (file-name-nondirectory (buffer-file-name)) " --- " str
+ (make-string (max 2 (- 80 (current-column) 27)) ?\s)
+ "-*- lexical-binding: t; -*-" '(setq lexical-binding t)
+ "
;; Copyright (C) " (format-time-string "%Y") " "
(getenv "ORGANIZATION") | (progn user-full-name) "
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)