[Top][All Lists]

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

Is there a code better than the other?

From: Sebastien Vauban
Subject: Is there a code better than the other?
Date: Thu, 04 Jul 2013 17:07:17 +0200
User-agent: Gnus/5.130006 (Ma Gnus v0.6) Emacs/24.3.50 (windows-nt)


When searching for info on the web, I found the following chunks of code to
automatically reload snippets after saving.

--8<---------------cut here---------------start------------->8---

  (eval-after-load "yasnippet"
       (add-hook 'snippet-mode-hook
                 (lambda ()
                   (setq require-final-newline nil)
                   (add-hook 'after-save-hook 'yas-recompile-all 'append 
                   (add-hook 'after-save-hook 'yas-reload-all 'append 
--8<---------------cut here---------------end--------------->8---


--8<---------------cut here---------------start------------->8---

  ;; automatically reload snippets after saving:
  (defun reload-snippets ()

  (defun snippet-mode-before-save ()
    (when (eq major-mode 'snippet-mode) (reload-snippets)))

  (add-hook 'after-save-hook 'snippet-mode-before-save)
--8<---------------cut here---------------end--------------->8---

Except the small differences (2 x reload and 2 x recompile, or the "don't
require final newline"), is there one better than the other?  There are
differences on the "make it local" hook "after-save". Is there a writing that
will be more portable (during time) than the other?

Best regards,

Sebastien Vauban

reply via email to

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