Org-mode mailing list
 help / color / mirror / Atom feed
* viewing appointments while scheduling event
@ 2021-06-04  9:26 Victor A. Stoichita
  2021-06-04 16:25 ` Victor A. Stoichita
  0 siblings, 1 reply; 2+ messages in thread
From: Victor A. Stoichita @ 2021-06-04  9:26 UTC (permalink / raw)
  To: emacs-orgmode

When scheduling an event with C-c C-s (org-schedule) a calendar pops up.
While navigating that calendar to choose a date, is it possible to view
the events already scheduled in the agenda for that date?

I found this answer to a similar question: https://emacs.stackexchange.com/questions/30512/show-tasks-during-orgmode-scheduling

It says that pressing "!" should pop to the diary file. I don’t use
the diary file, all my appointments are in org-mode files.

The answer mentions adding the following line to the diary file:
%%(org-diary :timestamp :sexp)

In my init file I have set:
(setq diary-file "~/calendriers/diary")
(setq calendar-mark-diary-entries-flag t)

And in ~/calendriers/diary I have just the following line:
%%(org-diary :timestamp :sexp)

This does work. When trying to schedule an event the calendar is not
opened any more, I just get a message "End of buffer". I suppose that
it’s not the correct way to write the diary file, but I’m unfamiliar
with the diary syntax and could find no documentation for the particular
feature which %%(org-diary :timestamp :sexp) might provide.

Does anyone have a working setup for this?

Regards,
Victor


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: viewing appointments while scheduling event
  2021-06-04  9:26 viewing appointments while scheduling event Victor A. Stoichita
@ 2021-06-04 16:25 ` Victor A. Stoichita
  0 siblings, 0 replies; 2+ messages in thread
From: Victor A. Stoichita @ 2021-06-04 16:25 UTC (permalink / raw)
  To: emacs-orgmode

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



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-06-04 17:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-04  9:26 viewing appointments while scheduling event Victor A. Stoichita
2021-06-04 16:25 ` Victor A. Stoichita

Org-mode mailing list

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://orgmode.org/list/0 list/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 list list/ https://orgmode.org/list \
		emacs-orgmode@gnu.org
	public-inbox-index list

Example config snippet for mirrors.
Newsgroups are available over NNTP:
	nntp://news.yhetil.org/yhetil.emacs.orgmode
	nntp://news.gmane.io/gmane.emacs.orgmode


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git