[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: insert-header-preprocessor-definition

From: Emanuel Berg
Subject: Re: insert-header-preprocessor-definition
Date: Thu, 12 Apr 2018 00:07:49 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux)

Ben Bacarisse wrote:

>> So for color.c, color.h should have
> That is safe, yes. Doing it by hand, I think
> most people write H_COLOR but you can't even
> be sure there will be a .h in the name!

(defun insert-header-preprocessor-definition ()
  (let*((filename (buffer-name))
        (label (upcase (replace-regexp-in-string "\\." "_" filename)))
        (safe-label (concat "H_" label))
        (beg-string (concat
                     "#ifndef " safe-label "\n"
                     "#define " safe-label "\n\n"))
        (end-string "\n#endif") )
      (goto-char (point-min))
      (insert beg-string)

      (goto-char (point-max))
      (insert end-string) )
(defalias 'hep #'insert-header-preprocessor-definition)

underground experts united

reply via email to

[Prev in Thread] Current Thread [Next in Thread]