[Top][All Lists]

[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:40:33 +0200
User-agent: Gnus/5.110011 (No Gnus v0.11) Emacs/23.2 (darwin)

I head another idea to make it more general:
--8<---------------cut here---------------start------------->8---
;; (mode . (regexp snippet)
(setq auto-snips
             '((c-mode . '('h' "once"))
               (python-mode . (t "!"))))

(defun smart-snips()
      ((found (assoc major-mode auto-snips)))
    (if (and
         (string-match (nth 0 found) major-mode)
         (yes-or-no-p "insert the header?"))
          (insert (nth 1 found))
--8<---------------cut here---------------end--------------->8---

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...

reply via email to

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