all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Michael Heerdegen <noreply@nospam.dev.null>
To: help-gnu-emacs@gnu.org
Subject: Re: Advising appt-mode
Date: Sun, 15 Nov 2009 20:06:48 +0100	[thread overview]
Message-ID: <vs7ws1rboaf.fsf@ppc201.mirz.uni-jena.de> (raw)
In-Reply-To: 878wea5zpd.wl%richard.lewis@gold.ac.uk

Your defadvice is syntactically correct (and will be used if you didn't
forget to activate it.) But it won't work. Let's have a look at the
altered symbol-function of appt-check:


(lambda
  (&optional force)
  #("Advice doc string" 0 17
    (ad-advice-info appt-check))
  (interactive "P")
  (let
      (ad-return-value)
    (setq ad-return-value
	  (ad-Orig-appt-check force))
    (when
	(and appt-issue-message appt-time-msg-list)
      (when
	  (and
	   (<= min-to-app appt-message-warning-time)
	   (>= min-to-app 0))
	(rjl/notify
	 (format "%s <b>in %d minutes</b>"
		 (cadr
		  (car appt-time-msg-list))
		 min-to-app)
	 "Appointment")))
    ad-return-value))

You see that there is a reference to `min-to-app' in your code, a
variable which is only visible _inside_ `ad-Orig-appt-check'
(`ad-Orig-appt-check' holds the original symbol-function of
`appt-check'). Note that `appt-check' checks for all appointments at
once in a while loop, so `min-to-app' may change its value several times
each call.

I think you can do what you want with an advice of
`appt-display-message'. If you really want to change `appt-check' in
such a way, you will will have to redefine it with `defun'.


Michael.


  reply	other threads:[~2009-11-15 19:06 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-13 13:19 Advising appt-mode Richard Lewis
2009-11-15 19:06 ` Michael Heerdegen [this message]
2009-11-17  4:51 ` Glenn Morris
2009-11-17  6:08   ` Richard Riley
     [not found]   ` <mailman.10870.1258438170.2239.help-gnu-emacs@gnu.org>
2009-11-17 10:18     ` Fabrice Niessen
2009-11-18 12:27   ` Richard Lewis

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

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

  git send-email \
    --in-reply-to=vs7ws1rboaf.fsf@ppc201.mirz.uni-jena.de \
    --to=noreply@nospam.dev.null \
    --cc=help-gnu-emacs@gnu.org \
    /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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.