unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Stephen Berman <stephen.berman@gmx.net>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: emacs-devel@gnu.org
Subject: Re: New version of todo-mode.el (announcement + user guide)
Date: Fri, 14 Jun 2013 23:37:25 +0200	[thread overview]
Message-ID: <87obb874ru.fsf@rosalinde.fritz.box> (raw)
In-Reply-To: <jwvzjuteecb.fsf-monnier+emacs@gnu.org> (Stefan Monnier's message of "Thu, 13 Jun 2013 20:21:01 -0400")

On Thu, 13 Jun 2013 20:21:01 -0400 Stefan Monnier <monnier@iro.umontreal.ca> 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



  reply	other threads:[~2013-06-14 21:37 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-09 23:31 New version of todo-mode.el (announcement + user guide) Stephen Berman
2013-06-10 13:24 ` Bastien
2013-06-10 14:35   ` Stephen Berman
2013-06-10 14:49     ` Bastien
2013-06-10 20:51       ` New version of todo-mode.el (code) Stephen Berman
2013-08-30 18:31         ` Jambunathan K
2013-09-08 21:09           ` Stephen Berman
2013-06-10 14:52     ` New version of todo-mode.el (announcement + user guide) Óscar Fuentes
2013-06-10 20:52       ` Stephen Berman
2013-06-11  0:20         ` Stefan Monnier
2013-06-11 18:36           ` Stephen Berman
2013-06-11 21:48             ` Stefan Monnier
2013-06-12 21:37               ` Stephen Berman
2013-06-13  1:06                 ` Stefan Monnier
2013-06-13 20:53                   ` Stephen Berman
2013-06-12 17:28             ` Glenn Morris
2013-06-12 21:26               ` Stefan Monnier
2013-06-12 21:37               ` Stephen Berman
2013-06-13  1:18                 ` Stefan Monnier
2013-06-13 20:53                   ` Stephen Berman
2013-06-14  0:21                     ` Stefan Monnier
2013-06-14 21:37                       ` Stephen Berman [this message]
2013-06-15  0:40                         ` Glenn Morris
2013-06-15  1:49                         ` Stefan Monnier
2013-06-15 12:52                           ` Stephen Berman
2013-06-16  0:44                             ` Stefan Monnier
2013-06-16 22:52                               ` Stephen Berman
2013-06-17  0:37                                 ` Stefan Monnier
2013-06-17 19:50                                 ` Glenn Morris
2013-06-17 22:33                                   ` Stephen Berman
2013-06-12 18:30             ` Wolfgang Jenkner
2013-06-12 21:38               ` Stephen Berman
2013-06-13  1:24                 ` Wolfgang Jenkner
2013-06-13 20:54                   ` Stephen Berman
2013-06-13 10:59 ` Vitalie Spinu
2013-06-13 20:54   ` Stephen Berman
2013-08-31  3:55 ` Jambunathan K

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87obb874ru.fsf@rosalinde.fritz.box \
    --to=stephen.berman@gmx.net \
    --cc=emacs-devel@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).