From: "Victor A. Stoichita" <victor@svictor.net>
To: emacs-orgmode <emacs-orgmode@gnu.org>
Subject: Re: viewing appointments while scheduling event
Date: Fri, 04 Jun 2021 18:25:56 +0200 [thread overview]
Message-ID: <871r9h7qzh.fsf@svictor.net> (raw)
In-Reply-To: <87o8cm6kw0.fsf@svictor.net>
I found something that seems to work. I’m posting it here in case
anyone is interested or has better suggestions.
First, I understood that my diary file should read:
&%%(org-diary) ~/calendriers/victor.org
This was clearly explained in the docstring of org-diary (if it was
also in the org-mode manual, then I missed it there).
With this set, one can hit "!" from the minibuffer while scheduling an
event to view the diary for the corresponding date.
I found it a bit cumbersome though to hit "!" after each move in the
calendar. So I ended up with the following code. Pressing "!" now
toggles following the diary when the cursor moves in the calendar.
#+begin_src emacs-lisp
;;;;; Follow diary from calendar when scheduling events
(defvar-local vic/org-read-date-diary t
"Whether to display diary for current calendar date when scheduling an event from org-mode")
(defun vic/org-read-date-calendar-display-diary (&rest arg)
"Used as advice after `org-eval-in-calendar'. Display diary for that day if `vic/org-read-date-diary' is non nil."
(when (and vic/org-read-date-diary
;; Check that the cursor was actually moved
;; Otherwise too many calls
(member arg '(((calendar-goto-today))
((calendar-backward-day 1))
((calendar-forward-day 1))
((calendar-backward-week 1))
((calendar-forward-week 1))
((calendar-backward-month 1))
((calendar-forward-month 1))
((calendar-backward-year 1))
((calendar-forward-year 1)))))
(org-eval-in-calendar '(diary-view-entries))
(message "")))
(advice-add 'org-eval-in-calendar :after 'vic/org-read-date-calendar-display-diary)
(defun vic/org-read-date-toggle-diary ()
"Toggle following diary from calendar when scheduling events."
(interactive)
(if vic/org-read-date-diary
(setq vic/org-read-date-diary nil)
(setq vic/org-read-date-diary t)))
(define-key org-read-date-minibuffer-local-map
(kbd "!") 'vic/org-read-date-toggle-diary)
#+end_src
It’s a bit hackish I suppose, partly because I could not find an easy
way to advise the functions in org-read-date-minibuffer-local-map
which are all lambdas. But it seems to work.
I’m still interested in learning from more advanced setups that people
might have for the same purpose (which is: display existing events for
the date that is currently selected in the org-schedule
minibuffer/calendar).
Cheers
Victor
prev parent reply other threads:[~2021-06-04 17:06 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-04 9:26 viewing appointments while scheduling event Victor A. Stoichita
2021-06-04 16:25 ` Victor A. Stoichita [this message]
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.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=871r9h7qzh.fsf@svictor.net \
--to=victor@svictor.net \
--cc=emacs-orgmode@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 public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.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).