all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Ignacio Casso <ignaciocasso@hotmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: Lars Ingebrigtsen <larsi@gnus.org>, 54371@debbugs.gnu.org
Subject: bug#54371: 29.0.50; read-char does not reset idle timer in some cases
Date: Sun, 13 Mar 2022 18:45:33 +0100	[thread overview]
Message-ID: <PAXPR06MB7760E20F16BB6428F82D3C6FC60E9@PAXPR06MB7760.eurprd06.prod.outlook.com> (raw)
In-Reply-To: <83pmmpls5g.fsf@gnu.org>


> I think we should first understand the use case better.  For starters,
> I don't think I understand why an idle timer function should want to
> call read-char with a time-out.  It is a strange thing to do, IMO.

The function in question is org-resolve-clocks-if-idle. It runs with a
normal timer (not idle) every 60 seconds, and resolves the running org
clock if (current-idle-time) is greater than the time specified by the
variable org-clock-idle-time. To do so, it prompts the user for a
character that indicates which action to take, with a prompt text that
indicates the current idle time: "Clocked in & idle for X mins
[jkKtTgGSscCiq]? ". To provide a relatively up-to-date current idle time
in the prompt text, it reads the char with a timeout in the following
loop:

  (while (or (null char-pressed)
	     (and (not (memq char-pressed
			     '(?k ?K ?g ?G ?s ?S ?C
				  ?j ?J ?i ?q ?t ?T)))
		  (or (ding) t)))
    (setq char-pressed
	  (read-char (concat (funcall prompt-fn clock)
			     " [jkKtTgGSscCiq]? ")
		     nil 45)))


Since the idle time is not reset after the character is read, this
produces the bug I explained in
https://lists.gnu.org/archive/html/emacs-orgmode/2022-03/msg00127.html,
but otherwise I find it to be reasonable code.

> Doesn't seem to be anything reachable from Lisp land.  Adding a subr
> that just calls timer_start_idle would be trivial, though.

I think that particular bug with org-clock can be fixed with other
workarounds that do not involve resetting the idle timer. No need to
expose that code only for that if it isn't already exposed.

> However, it sounds like we do this on purpose, to avoid problems with
> idle timers that call sit-for.  See the discussion that started here:
>
>   https://lists.gnu.org/archive/html/emacs-devel/2006-08/msg00395.html
>
> The change installed at that time made read_char avoid restarting idle
> timers when it is called with a non-nil END_TIME argument.

However, I still think that if not a bug, this is at least inconsistent
and probably deserving a footnote in the relevant section of the Emacs
Lisp manual
(https://www.gnu.org/software/emacs/manual/html_node/elisp/Idle-Timers.html).





  reply	other threads:[~2022-03-13 17:45 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-12 23:27 bug#54371: 29.0.50; read-char does not reset idle timer in some cases Ignacio Casso
2022-03-13 10:08 ` Eli Zaretskii
2022-03-13 10:48   ` Ignacio Casso
2022-03-13 15:02     ` Lars Ingebrigtsen
2022-03-13 16:43       ` Eli Zaretskii
2022-03-13 17:45         ` Ignacio Casso [this message]
2022-03-13 19:34           ` Eli Zaretskii
2022-03-13 21:58             ` Ignacio Casso
2022-04-01 18:22               ` Ignacio Casso
2022-04-01 19:36                 ` Eli Zaretskii
2022-04-07 11:42                   ` Ignacio Casso
2022-04-08  6:50                     ` Eli Zaretskii
2022-04-11  6:42                       ` Ignacio Casso
2022-04-11 11:17                         ` Eli Zaretskii

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=PAXPR06MB7760E20F16BB6428F82D3C6FC60E9@PAXPR06MB7760.eurprd06.prod.outlook.com \
    --to=ignaciocasso@hotmail.com \
    --cc=54371@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=larsi@gnus.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.