From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: New version of todo-mode.el (announcement + user guide) Date: Thu, 13 Jun 2013 20:21:01 -0400 Message-ID: References: <87k3m2275u.fsf@rosalinde.fritz.box> <8761xmxfnx.fsf@bzg.ath.cx> <87txl6ghjq.fsf@rosalinde.fritz.box> <87a9myggr7.fsf@wanadoo.es> <87sj0p8z99.fsf@rosalinde.fritz.box> <87mwqwpk98.fsf@rosalinde.fritz.box> <6emwqvxmpo.fsf@fencepost.gnu.org> <8761xjdn7t.fsf@rosalinde.fritz.box> <87txl1bula.fsf@rosalinde.fritz.box> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1371169272 27602 80.91.229.3 (14 Jun 2013 00:21:12 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 14 Jun 2013 00:21:12 +0000 (UTC) Cc: emacs-devel@gnu.org To: Stephen Berman Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Jun 14 02:21:12 2013 Return-path: Envelope-to: ged-emacs-devel@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 1UnHlP-0000Hr-RS for ged-emacs-devel@m.gmane.org; Fri, 14 Jun 2013 02:21:11 +0200 Original-Received: from localhost ([::1]:40712 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UnHlP-00086B-AA for ged-emacs-devel@m.gmane.org; Thu, 13 Jun 2013 20:21:11 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:54701) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UnHlL-00083f-Rp for emacs-devel@gnu.org; Thu, 13 Jun 2013 20:21:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UnHlK-0007hm-NK for emacs-devel@gnu.org; Thu, 13 Jun 2013 20:21:07 -0400 Original-Received: from ironport2-out.teksavvy.com ([206.248.154.182]:25689) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UnHlK-0007hf-Ji; Thu, 13 Jun 2013 20:21:06 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Av4EABK/CFFFpZVy/2dsb2JhbABEvw4Xc4IeAQEEAVYjBQsLNBIUGA0kiB4GwS2RCgOSWpIggV6DEw X-IPAS-Result: Av4EABK/CFFFpZVy/2dsb2JhbABEvw4Xc4IeAQEEAVYjBQsLNBIUGA0kiB4GwS2RCgOSWpIggV6DEw X-IronPort-AV: E=Sophos;i="4.84,565,1355115600"; d="scan'208";a="16360969" Original-Received: from 69-165-149-114.dsl.teksavvy.com (HELO pastel.home) ([69.165.149.114]) by ironport2-out.teksavvy.com with ESMTP/TLS/ADH-AES256-SHA; 13 Jun 2013 20:21:00 -0400 Original-Received: by pastel.home (Postfix, from userid 20848) id CAE196793F; Thu, 13 Jun 2013 20:21:01 -0400 (EDT) In-Reply-To: <87txl1bula.fsf@rosalinde.fritz.box> (Stephen Berman's message of "Thu, 13 Jun 2013 22:53:53 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 206.248.154.182 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:160429 Archived-At: > Thank you for this excellent "advice" ;-). It works very nicely -- > except for one wrinkle: after loading todos.el (which requires > 'diary-lib) I have to eval diary-goto-entry (or load diary-lib) again in > order for the advice to take effect. Without doing that it's as if the > advice were not activated. But I see nothing about activating advice in > nadvice.el. Here's what I added to diary-lib.el: Contrary to advice, which has all kinds of subtle distinction between defining an advice, enabling an advice, and activating an advice, nadvice just has add-function (or advice-add) which works more like add-hook (i.e. kind of defines/enables/activates all at once). > (define-derived-mode todos-mode special-mode "Todos" > "Major mode for displaying, navigating and editing Todo lists. > \\{todos-mode-map}" > ;; other initializations ... > (add-function :around diary-goto-location-function > (lambda (orig-fun &rest args) > (when (derived-mode-p 'todos-mode) (widen)) > (apply orig-fun args) > (todos-diary-goto-entry)))) This doesn't make sense: you `add-function' to the global value of diary-goto-location-function, but you do it in the mode function, i.e. once per todo-mode buffer. Either do it locally (i.e. in the todo-mode function but with (add-function :around (local diary-goto-location-function) (lambda (orig-fun &rest args) (widen) (apply orig-fun args) (todos-diary-goto-entry))) Or do it globally, (i.e. at the top-level of todo-mode.el). Stefan