From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Pascal J. Bourguignon" Newsgroups: gmane.emacs.help Subject: Re: Is there a code better than the other? Date: Thu, 04 Jul 2013 20:48:19 +0200 Organization: Informatimago Message-ID: <8738ruyxe4.fsf@informatimago.com> References: <861u7euzx6.fsf@somewhere.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1372963843 2623 80.91.229.3 (4 Jul 2013 18:50:43 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 4 Jul 2013 18:50:43 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Jul 04 20:50:46 2013 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Uuobh-00055y-O3 for geh-help-gnu-emacs@m.gmane.org; Thu, 04 Jul 2013 20:50:17 +0200 Original-Received: from localhost ([::1]:52190 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uuobh-0005vA-Dr for geh-help-gnu-emacs@m.gmane.org; Thu, 04 Jul 2013 14:50:17 -0400 Original-Path: usenet.stanford.edu!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 50 Original-X-Trace: individual.net kuvKXWydgQBVMA1BLK5SQwzTj7qWlUuzJ3UNtI5g1PqsEpl09U Cancel-Lock: sha1:ODY0MDFiMjFmMzg5YWMyMGJkYjMyNGFjOTJjYmNiMmFhNjc4ZjgyMw== sha1:QzRL1nj7pAKFH/Kc26SXY5jiTNQ= Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwAQMAAABtzGvEAAAABlBMVEUAAAD///+l2Z/dAAAA oElEQVR4nK3OsRHCMAwF0O8YQufUNIQRGIAja9CxSA55AxZgFO4coMgYrEDDQZWPIlNAjwq9 033pbOBPtbXuB6PKNBn5gZkhGa86Z4x2wE67O+06WxGD/HCOGR0deY3f9Ijwwt7rNGNf6Oac l/GuZTF1wFGKiYYHKSFAkjIo1b6sCYS1sVmFhhhahKQssRjRT90ITWUk6vvK3RsPGs+M1RuR mV+hO/VvFAAAAABJRU5ErkJggg== X-Accept-Language: fr, es, en User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2 (gnu/linux) Original-Xref: usenet.stanford.edu gnu.emacs.help:199678 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:91945 Archived-At: "Sebastien Vauban" writes: > Hello, > > When searching for info on the web, I found the following chunks of code to > automatically reload snippets after saving. > > ;; 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… -- __Pascal Bourguignon__ http://www.informatimago.com/ A bad day in () is better than a good day in {}. You know you've been lisping too long when you see a recent picture of George Lucas and think "Wait, I thought John McCarthy was dead!" -- Dalek_Baldwin