From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stephen Berman Newsgroups: gmane.emacs.devel Subject: Re: New version of todo-mode.el (announcement + user guide) Date: Fri, 14 Jun 2013 23:37:25 +0200 Message-ID: <87obb874ru.fsf@rosalinde.fritz.box> 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 1371245867 20287 80.91.229.3 (14 Jun 2013 21:37:47 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 14 Jun 2013 21:37:47 +0000 (UTC) Cc: emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Jun 14 23:37:46 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 1Unbgk-0007D7-HX for ged-emacs-devel@m.gmane.org; Fri, 14 Jun 2013 23:37:42 +0200 Original-Received: from localhost ([::1]:33657 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Unbgk-0001U2-50 for ged-emacs-devel@m.gmane.org; Fri, 14 Jun 2013 17:37:42 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:57997) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Unbgd-0001Oc-IQ for emacs-devel@gnu.org; Fri, 14 Jun 2013 17:37:38 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UnbgZ-0004n7-7N for emacs-devel@gnu.org; Fri, 14 Jun 2013 17:37:35 -0400 Original-Received: from mout.gmx.net ([212.227.15.15]:51104) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UnbgY-0004ml-Kj for emacs-devel@gnu.org; Fri, 14 Jun 2013 17:37:31 -0400 Original-Received: from mailout-de.gmx.net ([10.1.76.35]) by mrigmx.server.lan (mrigmx002) with ESMTP (Nemesis) id 0Mg2Ch-1V1iBh361N-00NTO3 for ; Fri, 14 Jun 2013 23:37:28 +0200 Original-Received: (qmail invoked by alias); 14 Jun 2013 21:37:28 -0000 Original-Received: from i59F56F59.versanet.de (EHLO rosalinde.fritz.box) [89.245.111.89] by mail.gmx.net (mp035) with SMTP; 14 Jun 2013 23:37:28 +0200 X-Authenticated: #20778731 X-Provags-ID: V01U2FsdGVkX1/0ZIcm14n0EKLcF7DXrz7osKHOgZwYrIYaPd/tVK RLiffm04NYHoPH In-Reply-To: (Stefan Monnier's message of "Thu, 13 Jun 2013 20:21:01 -0400") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) X-Y-GMX-Trusted: 0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 212.227.15.15 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:160436 Archived-At: On Thu, 13 Jun 2013 20:21:01 -0400 Stefan Monnier wrote: >> 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). Ah, ok, thanks for clarifying. >> (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). Thanks. Doing it locally still doesn't work, I guess because the function is called from the Fancy Diary buffer, not from Todos mode. But it works when it's added at top-level. Moreover, it turns out that using :around isn't right, at least not without making it much more complicated AFAICT. It's much more straightforward to use :override. So I'd like to make the following change to diary-lib.el: *** /data/steve/bzr/emacs/trunk/lisp/calendar/diary-lib.el 2013-06-05 11:41:31.000000000 +0200 --- /data/steve/bzr/emacs/quickfixes/lisp/calendar/diary-lib.el 2013-06-14 23:34:12.000000000 +0200 *************** *** 1032,1038 **** (define-obsolete-function-alias 'simple-diary-display 'diary-simple-display "23.1") ! (define-button-type 'diary-entry 'action #'diary-goto-entry 'face 'diary-button 'help-echo "Find this diary entry" 'follow-link t) --- 1032,1045 ---- (define-obsolete-function-alias 'simple-diary-display 'diary-simple-display "23.1") ! (defvar diary-goto-entry-function 'diary-goto-entry ! "Function called to jump to a diary entry. ! Modes that require special handling of the included file ! containing the diary entry can assign a suitable function to this ! variable.") ! ! (define-button-type 'diary-entry ! 'action (lambda (button) (funcall diary-goto-entry-function button)) 'face 'diary-button 'help-echo "Find this diary entry" 'follow-link t) Any objections? Steve Berman