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

[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)

Hello,

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---
;; 
https://github.com/vderyagin/dotemacs/blob/master/conf/yasnippet-configuration.el

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

and

--8<---------------cut here---------------start------------->8---
;; 
https://earthserver.com/Setting_up_a_C%2B%2B11_development_environment_on_Linux_with_Clang_and_Emacs

  ;; automatically reload snippets after saving:
  (defun reload-snippets ()
    (interactive)
    (yas-reload-all)
    (yas-recompile-all)
    (yas-reload-all)
    (yas-recompile-all))

  (defun snippet-mode-before-save ()
    (interactive)
    (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,
  Seb

-- 
Sebastien Vauban


reply via email to

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