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

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

Re: Is there a code better than the other?


From: Sebastien Vauban
Subject: Re: Is there a code better than the other?
Date: Fri, 05 Jul 2013 10:46:16 +0200
User-agent: Gnus/5.130006 (Ma Gnus v0.6) Emacs/24.3.50 (windows-nt)

Hello Pascal,

"Pascal J. Bourguignon" wrote:
> "Sebastien Vauban" <sva-news@mygooglest.com> writes:
>
>> ;; 
>> 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)))))
>>
>> and
>>
>> ;; 
>> 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)
>>
>> 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?
>
> The later is better than the former, because it allow you to redefine
> snippet-mode-before-save and have the new definition used in the hook
> right away.  With the former,  you would have to search in the hook the
> lambda, remove it, and add the new hook…

Good argument... Thanks for your answer!

Best regards,
  Seb

-- 
Sebastien Vauban


reply via email to

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