* Advising appt-mode
@ 2009-11-13 13:19 Richard Lewis
2009-11-15 19:06 ` Michael Heerdegen
2009-11-17 4:51 ` Glenn Morris
0 siblings, 2 replies; 6+ messages in thread
From: Richard Lewis @ 2009-11-13 13:19 UTC (permalink / raw)
To: help-gnu-emacs
Hi there,
I'm trying to make appt-mode display popup messages on my desktop
(using a small wrapper function for libnotify) by advising the
appt-check function like this:
(defadvice appt-check (after appt-notify)
(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"))))
I've not tried using defadvice before and this attempt isn't
working. It doesn't even work if I remove both the (when) conditions
and leave just the (rjl/notify) call. (BTW, (rjl/notify) works fine in
all other contexts.)
Any ideas?
--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Richard Lewis
ISMS, Computing
Goldsmiths, University of London
JID: ironchicken@jabber.earth.li
http://www.richard-lewis.me.uk/
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
+-------------------------------------------------------+
|Please avoid sending me Word or PowerPoint attachments.|
|http://www.gnu.org/philosophy/no-word-attachments.html |
+-------------------------------------------------------+
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Advising appt-mode
2009-11-13 13:19 Advising appt-mode Richard Lewis
@ 2009-11-15 19:06 ` Michael Heerdegen
2009-11-17 4:51 ` Glenn Morris
1 sibling, 0 replies; 6+ messages in thread
From: Michael Heerdegen @ 2009-11-15 19:06 UTC (permalink / raw)
To: help-gnu-emacs
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.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Advising appt-mode
2009-11-13 13:19 Advising appt-mode Richard Lewis
2009-11-15 19:06 ` Michael Heerdegen
@ 2009-11-17 4:51 ` Glenn Morris
2009-11-17 6:08 ` Richard Riley
` (2 more replies)
1 sibling, 3 replies; 6+ messages in thread
From: Glenn Morris @ 2009-11-17 4:51 UTC (permalink / raw)
To: help-gnu-emacs
Richard Lewis wrote:
> I'm trying to make appt-mode display popup messages on my desktop
> (using a small wrapper function for libnotify) by advising the
> appt-check function like this:
No need to advise anything. Customize appt-disp-window-function (the
name is a little misleading) to a function of your choice.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Advising appt-mode
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-18 12:27 ` Richard Lewis
2 siblings, 0 replies; 6+ messages in thread
From: Richard Riley @ 2009-11-17 6:08 UTC (permalink / raw)
To: help-gnu-emacs
Glenn Morris <rgm+news@stanford.edu> writes:
> Richard Lewis wrote:
>
>> I'm trying to make appt-mode display popup messages on my desktop
>> (using a small wrapper function for libnotify) by advising the
>> appt-check function like this:
>
> No need to advise anything. Customize appt-disp-window-function (the
> name is a little misleading) to a function of your choice.
>
I dont know if this still works but it might help:-
http://www.emacswiki.org/emacs-en/OrgMode-OSD
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Advising appt-mode
[not found] ` <mailman.10870.1258438170.2239.help-gnu-emacs@gnu.org>
@ 2009-11-17 10:18 ` Fabrice Niessen
0 siblings, 0 replies; 6+ messages in thread
From: Fabrice Niessen @ 2009-11-17 10:18 UTC (permalink / raw)
To: help-gnu-emacs-mXXj517/zsQ
Hi Richard,
Richard Riley wrote:
> Glenn Morris <rgm+news-FGKo4X94FMn2fBVCVOL8/A@public.gmane.org> writes:
>
>> Richard Lewis wrote:
>>
>>> I'm trying to make appt-mode display popup messages on my desktop
>>> (using a small wrapper function for libnotify) by advising the
>>> appt-check function like this:
>>
>> No need to advise anything. Customize appt-disp-window-function (the
>> name is a little misleading) to a function of your choice.
>>
>
> I dont know if this still works but it might help:-
>
> http://www.emacswiki.org/emacs-en/OrgMode-OSD
The following works perfectly for me...
--8<---------------cut here---------------start------------->8---
(when window-system
(setq appt-display-format 'window)
;; FIXME Check `notify-send' (in `libnotify-bin' Ubuntu package) is installed
(defun rgr/org-display (min-to-app new-time msg)
(shell-command
(concat "notify-send "
"-i /usr/share/icons/gnome/32x32/status/appointment-soon.png "
"'Appointment' "
"'" msg "'")))
;; TODO For Windows users: use todochicku.el and the snarl notifier
(setq appt-disp-window-function (function rgr/org-display)))
--8<---------------cut here---------------end--------------->8---
Best regards,
Fabrice
--
Fabrice Niessen
Search the Web with "My Google Search Tools" on http://www.MyGooglest.com
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Advising appt-mode
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-18 12:27 ` Richard Lewis
2 siblings, 0 replies; 6+ messages in thread
From: Richard Lewis @ 2009-11-18 12:27 UTC (permalink / raw)
To: help-gnu-emacs
At Mon, 16 Nov 2009 20:51:15 -0800,
Glenn Morris wrote:
>
> Richard Lewis wrote:
>
> > I'm trying to make appt-mode display popup messages on my desktop
> > (using a small wrapper function for libnotify) by advising the
> > appt-check function like this:
>
> No need to advise anything. Customize appt-disp-window-function (the
> name is a little misleading) to a function of your choice.
>
Ah, cool. Thanks very much.
--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Richard Lewis
ISMS, Computing
Goldsmiths, University of London
Tel: +44 (0)20 7078 5134
Skype: richardjlewis
JID: ironchicken@jabber.earth.li
http://www.richard-lewis.me.uk/
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
+----------------------------------------------+
| Support open access to scholarship |
| http://freeculture.org/ http://www.doaj.org/ |
+----------------------------------------------+
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2009-11-18 12:27 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-11-13 13:19 Advising appt-mode Richard Lewis
2009-11-15 19:06 ` Michael Heerdegen
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
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).