help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: FSF like smart header


From: Andrea Crotti
Subject: Re: FSF like smart header
Date: Tue, 03 Aug 2010 17:15:01 +0200
User-agent: Gnus/5.110011 (No Gnus v0.11) Emacs/23.2 (darwin)

"Drew Adams" <address@hidden> writes:

> More generally (includes info about the previous feature):
> http://www.emacswiki.org/emacs/AutomaticFileHeaders

Given that I didn't like that too much and I prefer using yasnippet I
did this simple thing for header files (but can be adapted to anything)

--8<---------------cut here---------------start------------->8---
(defun is-header (file)
  "Check if file is an header"
  (equal "h" (file-name-extension file)))
      

(defun my-h-header ()
  "try to insert the header smartly"
  (if
      (is-header buffer-file-name)
      (progn 
        (insert "once")
        (yas/expand))))

(add-hook 'c-mode-hook 'my-h-header)
--8<---------------cut here---------------end--------------->8---

Which is pretty nice :)




reply via email to

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