all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Ihor Radchenko <yantar92@posteo.net>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: emacs-orgmode@gnu.org
Subject: Re: Saving some kitten, plus some questions along the way
Date: Sun, 19 May 2024 14:45:53 +0000	[thread overview]
Message-ID: <87a5klsvvi.fsf@localhost> (raw)
In-Reply-To: <jwvv839khrq.fsf-monnier+emacs@gnu.org>

Stefan Monnier <monnier@iro.umontreal.ca> writes:

>>> -	    (org-eval-in-calendar '(setq cursor-type nil) t)
>>> +	    ;; FIXME: Could we use `with-current-buffer' or do we really
>>> +	    ;; need the `move-overlay' that's in `org-funcall-in-calendar'?
>>> +	    (org-funcall-in-calendar (lambda () (setq cursor-type nil)) t)
>>
>> `move-overlay' is important - this is additional decoration that Org
>> mode uses to indicate "current" date in the calendar while the focus is
>> on other window and the cursor may not be clearly visible.
>
> I understand it's important in general, but the question is for this
> specific use of `org-funcall-in-calendar` where all we do (apparently)
> is to set `cursor-type` which shouldn't require any change to the
> overlay (nor does it require to `select-window`), or should it?

No, it should not, and it does not require `select-window'.

> Along the same lines, maybe:
>
> 	(progn
> 	  (calendar-forward-day (- (time-to-days org-def)
> 				   (calendar-absolute-from-gregorian
> 				    (calendar-current-date))))
> 	  (org-funcall-in-calendar #'ignore t)
> 	  (let* ((old-map (current-local-map))
> 		 (map (copy-keymap calendar-mode-map))
> 		 (minibuffer-local-map
>
> should turn into something like:
>
> 	(let ((days (- (time-to-days org-def)
> 				   (calendar-absolute-from-gregorian
> 				    (calendar-current-date)))))
> 	  (org-funcall-in-calendar #'calendar-forward-day t days)
> 	  (let* ((old-map (current-local-map))
> 		 (map (copy-keymap calendar-mode-map))
> 		 (minibuffer-local-map
>
> so it's clear why we need to use `org-funcall-in-calendar`?

Yes. Looks reasonable.

>>> -(defun org-eval-in-calendar (form &optional keepdate)
>>> -  "Eval FORM in the calendar window and return to current window.
>>> +(defun org-funcall-in-calendar (func &optional keepdate &rest args)
>>> +  "Call FUNC in the calendar window and return to current window.
>> Why not a macro?  Having to write lambda may be awkward.
>
> [ Hmm... in my book, writing `lambda` should not be considered awkward.  ]
>
> So far there are only two uses of `org-funcall-in-calendar` which go
> through `lambda`, one of them is quoted and discussed above and the
> other is the backward compatibility wrapper `org-eval-in-calendar`, so
> I'm not sure it's worth the trouble.  But if you want, I can include
> a macro for it, of course.

Not necessary. Lambda is also ok, I just slightly prefer macro.
The only reason why I call lambda "awkward" is because it is more
typing.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


  reply	other threads:[~2024-05-19 14:44 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-18 15:22 Saving some kitten, plus some questions along the way Stefan Monnier
2024-05-19 11:56 ` Ihor Radchenko
2024-05-19 14:40   ` Stefan Monnier
2024-05-19 14:45     ` Ihor Radchenko [this message]
2024-05-19 21:24       ` Stefan Monnier
2024-05-20 11:10         ` Ihor Radchenko
2024-06-15 14:32           ` Ihor Radchenko
2024-05-21 10:55         ` Max Nikulin

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=87a5klsvvi.fsf@localhost \
    --to=yantar92@posteo.net \
    --cc=emacs-orgmode@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 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.