From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1.migadu.com ([2001:41d0:403:58f0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms13.migadu.com with LMTPS id IFvhKkGkXmfx5AAA62LTzQ:P1 (envelope-from ) for ; Sun, 15 Dec 2024 09:41:21 +0000 Received: from aspmx1.migadu.com ([2001:41d0:403:58f0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1.migadu.com with LMTPS id IFvhKkGkXmfx5AAA62LTzQ (envelope-from ) for ; Sun, 15 Dec 2024 10:41:21 +0100 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=pengjiz.com header.s=fm2 header.b="KDX/IjcE"; dkim=fail ("body hash did not verify") header.d=messagingengine.com header.s=fm1 header.b="F1/lvd6K"; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 2a01:4f9:c011:7a79::1 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1734255681; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-owner:list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=zxva+VP5AfRBpSjApXscfVzE8HuiR64iTDDvSRPQTT0=; b=K7ttJgMDIfxSYjfxYQpzDndcEHQRL8uu8g5+YMo6nnobM4Ptm0mrFQxlrsU3oMmYNMpch5 0DT1t3Dx4aBXkc2zQguBQvvlmPalUKQh9Da8pAcEbufhZTcaSFrSuLmkUnrYTllktd855+ M+6ttnghrEABHoCCz9/ZJO5ru0YjnVgunRU0oyDpVDxWTO7ZqYU2dubXJaYAPCq1/K6ALn ZPJ4FTSBM1QTsg4E6l43ZjquUqfkfX+k0hOnK53aIiXNZZxOR9B63QNnzvtL2afTlGozk5 lm6Zib4Bl9qfZWxTk687a2mTSrZUAZRbYRPgSGDaBxM72g7lIxM1ruk+nkNzDw== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1734255681; a=rsa-sha256; cv=none; b=fdfX+iQoOcaudx1YWawOinMvv878mN0O70BogS5MwoWatQlSrBEBA0gLQhbM8R0+h2XGTk i7tv3XP94ekZSyFVC29cvO1AhA7ixmsCZARi59NIcqiboRjQcfsGXnGESR6pGe0wuPlfPD 5ncDILgUmaEcADVji1sajkA30VUh44NyVkJ34UPEE5LXCviXYFSMxvrBE8TLaH4Tcr5KYY +QD5ha37CSxhpyD4thSEn9xJMP1VbWj+vDXiunyN1dcH+YDLJ/Ky+R0sjBt5BIKeyj25Qy 6HaP6TlZehD8l8u9FGOG0lBA7rBhKDCAp7Z7062DcrLsHghKU1T+4Tbtz02vEg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=pengjiz.com header.s=fm2 header.b="KDX/IjcE"; dkim=fail ("body hash did not verify") header.d=messagingengine.com header.s=fm1 header.b="F1/lvd6K"; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 2a01:4f9:c011:7a79::1 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org; dmarc=none Received: from mail.notmuchmail.org (yantan.tethera.net [IPv6:2a01:4f9:c011:7a79::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 64F1347FF8 for ; Sun, 15 Dec 2024 10:41:20 +0100 (CET) Received: from yantan.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id B8DD95E28D; Sun, 15 Dec 2024 09:41:16 +0000 (UTC) X-Greylist: delayed 462 seconds by postgrey-1.36 at yantan; Sun, 15 Dec 2024 09:41:13 UTC Received: from fout-b3-smtp.messagingengine.com (fout-b3-smtp.messagingengine.com [202.12.124.146]) by mail.notmuchmail.org (Postfix) with ESMTPS id 9CEF45E01A for ; Sun, 15 Dec 2024 09:41:13 +0000 (UTC) Received: from phl-compute-03.internal (phl-compute-03.phl.internal [10.202.2.43]) by mailfout.stl.internal (Postfix) with ESMTP id C8B621140100; Sun, 15 Dec 2024 04:33:29 -0500 (EST) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-03.internal (MEProxy); Sun, 15 Dec 2024 04:33:29 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pengjiz.com; h= cc:cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm2; t=1734255209; x=1734341609; bh=kUnuB2bQLy BQUJuadIImCfJHuwHm8tqWhYfohJ44wB0=; b=KDX/IjcEXTfzBANrUUA//9jy4j mHkJEQ13XIvCtsMbaGQ/52nmpSdOFwBy9iMZXTvPVvpkACTmLi+vWW6K1AtEo5dM bnHA/bRqHCNSNVyNlawSHZr5OrFVh6GZwxm1hV9L61mpFzFVcDgRr7w/MimicdjQ AelzFcLN2Y8IJVOljeQktMtA3G6uAm6Mgzf0DPgye7PEOuO0R2LStfUxD6v43MfB eYMOK5Z7EJrb8/ILRPZbxGeDKG8zSXYbOtlmpG6lOAM2JXQ4WyBlLUCuEBrG+l/B QvMaq8uy2h9eIaUMLOi87CR/8eNQ6lvzlDUflDQz7YjCv4ElPxig/jsHVzTg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t= 1734255209; x=1734341609; bh=kUnuB2bQLyBQUJuadIImCfJHuwHm8tqWhYf ohJ44wB0=; b=F1/lvd6KgK5OluXmndDE61qFk3+gdSUWPQy2WkkYG7RdZ/mxCkW je/bfA/kHP+NOyDsL9Mg5msiRNd3sLcyDRjThG5gscikOvpYJ3DRrWaulkWmGCD6 qlaP6Te7hRaKmcz8zOH3D75Zxy3fRVHaS174m9AtBiH5n210IlbaGSiJBJ9Y2HCF qyDEJ5Lk2Bg3CoU7i/D8AtInfaQCsI4KS/zuCEjBZNXBxlni+niU1uwyk8NjZtHd L9+qgEfJXR2jxU3U/h2Xh5gN0s+d3UjG9deLpToWhUnTAXgi/i0sYE/dIPlAogdZ 9VlArPUHeuEfuylBtrGwNWQ06mCU8MxAYCg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefuddrledugddtgecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdpuffr tefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnth hsucdlqddutddtmdenucfjughrpefhvfevufgjfhffkfggtgesthdtredttddttdenucfh rhhomheprfgvnhhgjhhiucgkhhgrnhhguceomhgvsehpvghnghhjihiirdgtohhmqeenuc ggtffrrghtthgvrhhnpeegfeeiiedvudekiedtgedufedtvedtueetieffhfdvhefftefg ieejieelleehgeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfh hrohhmpehmvgesphgvnhhgjhhiiidrtghomhdpnhgspghrtghpthhtohepvddpmhhouggv pehsmhhtphhouhhtpdhrtghpthhtohepnhhothhmuhgthhesnhhothhmuhgthhhmrghilh drohhrghdprhgtphhtthhopegurghmihgvnhestggrshhsohhurdhmvg X-ME-Proxy: Feedback-ID: i16614472:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 15 Dec 2024 04:33:28 -0500 (EST) From: Pengji Zhang To: notmuch@notmuchmail.org Subject: Re: [PATCH] emacs/show: Only recenter interactively In-Reply-To: <20241123151601.16201-2-damien@cassou.me> References: <20241123151601.16201-2-damien@cassou.me> Date: Sun, 15 Dec 2024 17:33:25 +0800 Message-ID: <87o71dguje.fsf@pengjiz.com> MIME-Version: 1.0 Message-ID-Hash: 5GDQSBLRIH4EABIUMXVPMMNZ3IQRTSTB X-Message-ID-Hash: 5GDQSBLRIH4EABIUMXVPMMNZ3IQRTSTB X-MailFrom: me@pengjiz.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-notmuch.notmuchmail.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Damien Cassou X-Mailman-Version: 3.3.3 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_IN X-Migadu-Country: DE X-Migadu-Spam-Score: 2.76 X-Spam-Score: 2.76 X-Migadu-Queue-Id: 64F1347FF8 X-Migadu-Scanner: mx11.migadu.com X-TUID: CjpG1rstrf0P Damien Cassou writes: > Several notmuch-show commands recenter the window by calling > `notmuch-show-message-adjust`. This is fine when these commands are > called interactively but not when used inside non-interactive > functions. An example of the problem is when `which-func-mode` is > activated: each time the user moves the point to a different line, the > window is recentered. This happens because `which-func-mode` calls > `imenu` which calls `notmuch-show-imenu-prev-index-position-function` > which calls `notmuch-show-previous-message` which recenters the > window. > > This patch makes sure that commands only invoke > `notmuch-show-message-adjust` when they have been called > interactively. I think this is a reasonable change. Thanks! I am not a maintainer, but here is my review of your patch. > --- > emacs/notmuch-show.el | 14 +++++++------- > 1 file changed, 7 insertions(+), 7 deletions(-) > > diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el > index 14e3c698..c08375b8 100644 > --- a/emacs/notmuch-show.el > +++ b/emacs/notmuch-show.el > @@ -1535,7 +1535,7 @@ (defun notmuch-show-goto-message (msg-id) > until (not (notmuch-show-goto-message-next))) > (goto-char (point-min)) > (message "Message-id not found.")) > - (notmuch-show-message-adjust)) > + (when (interactive-p) (notmuch-show-message-adjust))) 'notmuch-show-goto-message' is not a command. So it is always called non-interactively. > (defun notmuch-show-apply-state (state) > "Apply STATE to the current buffer. > @@ -2052,7 +2052,7 @@ (defun notmuch-show-rewind () > (when (<= (count-screen-lines (window-start) start-of-message) > next-screen-context-lines) > (goto-char (notmuch-show-message-top)) > - (notmuch-show-message-adjust)) > + (when (interactive-p) (notmuch-show-message-adjust))) > ;; Move to the top left of the window. > (goto-char (window-start))) > (t > @@ -2109,7 +2109,7 @@ (defun notmuch-show-next-message (&optional pop-at-end) > thread, navigate to the next thread in the parent search buffer." > (interactive "P") > (if (notmuch-show-goto-message-next) > - (notmuch-show-message-adjust) > + (when (interactive-p) (notmuch-show-message-adjust)) > (if pop-at-end > (notmuch-show-next-thread) > (goto-char (point-max))))) > @@ -2120,7 +2120,7 @@ (defun notmuch-show-previous-message () > (if (= (point) (notmuch-show-message-top)) > (notmuch-show-goto-message-previous) > (notmuch-show-move-to-message-top)) > - (notmuch-show-message-adjust)) > + (when (interactive-p) (notmuch-show-message-adjust))) > > (defun notmuch-show-next-open-message (&optional pop-at-end) > "Show the next open message. > @@ -2134,7 +2134,7 @@ (defun notmuch-show-next-open-message (&optional pop-at-end) > (while (and (setq r (notmuch-show-goto-message-next)) > (not (notmuch-show-message-visible-p)))) > (if r > - (notmuch-show-message-adjust) > + (when (interactive-p) (notmuch-show-message-adjust)) > (if pop-at-end > (notmuch-show-next-thread) > (goto-char (point-max)))) > @@ -2147,7 +2147,7 @@ (defun notmuch-show-next-matching-message () > (while (and (setq r (notmuch-show-goto-message-next)) > (not (notmuch-show-get-prop :match)))) > (if r > - (notmuch-show-message-adjust) > + (when (interactive-p) (notmuch-show-message-adjust)) > (goto-char (point-max))))) > > (defun notmuch-show-open-if-matched () > @@ -2176,7 +2176,7 @@ (defun notmuch-show-previous-open-message () > (notmuch-show-goto-message-previous) > (notmuch-show-move-to-message-top)) > (not (notmuch-show-message-visible-p)))) > - (notmuch-show-message-adjust)) > + (when (interactive-p) (notmuch-show-message-adjust))) > > (defun notmuch-show-view-raw-message () > "View the original source of the current message." 'interactive-p' is a long obsolete function. I think we should at least use 'called-interactively-p'. Even better, as suggested in the documentation of 'called-interactively-p', we may add an optional argument and make use of the interactive form. E.g., --8<---------------cut here---------------start------------->8--- -(defun notmuch-show-previous-open-message () +(defun notmuch-show-previous-open-message (&optional adjust) "Show the previous open message." - (interactive) + (interactive (list t)) (while (and (if (= (point) (notmuch-show-message-top)) (notmuch-show-goto-message-previous) (notmuch-show-move-to-message-top)) (not (notmuch-show-message-visible-p)))) - (notmuch-show-message-adjust)) + (when adjust (notmuch-show-message-adjust))) --8<---------------cut here---------------end--------------->8--- Best, Pengji