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: Richard Riley
Subject: Re: FSF like smart header
Date: Tue, 03 Aug 2010 18:22:48 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux)

Andrea Crotti <andrea.crotti.0@gmail.com> writes:

> I head another idea to make it more general:
>
>
> ;; (mode . (regexp snippet)
> (setq auto-snips
>              '((c-mode . '('h' "once"))
>                (python-mode . (t "!"))))
>
> (defun smart-snips()
>   (let
>       ((found (assoc major-mode auto-snips)))
>     (if (and
>          found
>          (string-match (nth 0 found) major-mode)
>          (yes-or-no-p "insert the header?"))
>         (progn
>           (insert (nth 1 found))
>           (yas/expand)))))
>
>
>
> In this way we define for every language (and possibly extension) what
> snippet we want to expand when we create a file.
>
> Then adding smart-snips to "find-file-hook" would do the rest of the magic.
>
> It doesn't work yet because I guess c-mode is a symbol and string-match
> doesn't like it.
> Don't know if I should just use the string representation or if there's
> a smarter way...
>
>
>
>

FYI - Whats does this provide that other existing packages to auto
create headers for certain file types do not?

http://www.emacswiki.org/emacs/AutomaticFileHeaders

It's maintained by Drew and seems pretty comprehensive.









reply via email to

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