逃避。なんか,しょーもないのばっか書いてますわ,はい。 逃避してんのに,仕事に関係してるのが ちょっと悲しい。関数名,意味不明やし。
(defun TT:c-header-file-ifndef-capsulate () (let ((filename buffer-file-name) (commentform (if (eq major-mode 'c++-mode) " // %s " " /* %s */ ")) (identifier) (p)) (when (and (null (file-attributes filename)) ; new file (string-match "\.\(h\|hh\)$" filename)) (setq identifier (concat "_" (mapconcat 'upcase (split-string (file-name-nondirectory filename) "\.") "_"))) (insert "#ifndef " identifier " #define " identifier " ") (setq p (point)) (insert " #endif" (format commentform identifier)) (goto-char p)))) (add-hook 'c-mode-common-hook (function (lambda () (TT:c-header-file-ifndef-capsulate))))