Skip to content

Instantly share code, notes, and snippets.

@ymmt2005
Created June 11, 2013 23:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ymmt2005/5761766 to your computer and use it in GitHub Desktop.
Save ymmt2005/5761766 to your computer and use it in GitHub Desktop.
Emacs skeleton for C++ header files.
(add-hook 'find-file-hook 'auto-insert)
(setq auto-insert-alist
'(("\\.hpp\\'"
nil
'(setq v1 (read-string "Namespace: " "cybozu"))
'(setq v2 (upcase (concat v1 "_"
(file-name-nondirectory
(file-name-sans-extension buffer-file-name))
"_" (file-name-extension buffer-file-name))))
"// " (file-name-nondirectory buffer-file-name) n
"// (C) " (format-time-string "%Y") " Cybozu." n n
"#ifndef " v2 n
"#define " v2 n n
"namespace " v1 " {" n n
_ n n
"} // namespace " v1 n n
"#endif // " v2)))
@ymmt2005
Copy link
Author

This will insert the following skeleton to empty C++ header files.

// FILENAME
// (C) YEAR Cybozu.

#ifndef NAMESPACE_FILENAME
#define NAMESPACE_FILENAME

namespace NAMESPACE {

} // namespace NAMESPACE

#endif // NAMESPACE_FILENAME

NAMESPACE is inputted from the mini buffer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment