From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0.migadu.com ([2001:41d0:303:e16b::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms13.migadu.com with LMTPS id 6MKJET/1QWch3QAAqHPOHw:P1 (envelope-from ) for ; Sat, 23 Nov 2024 15:31:11 +0000 Received: from aspmx1.migadu.com ([2001:41d0:303:e16b::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0.migadu.com with LMTPS id 6MKJET/1QWch3QAAqHPOHw (envelope-from ) for ; Sat, 23 Nov 2024 16:31:11 +0100 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=cassou.me header.s=dkim header.b="cQdtM/QM"; dmarc=fail reason="SPF not aligned (relaxed)" header.from=cassou.me (policy=none); spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 135.181.149.255 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org ARC-Seal: i=1; s=key1; d=yhetil.org; t=1732375871; a=rsa-sha256; cv=none; b=FmYvxQ8gk2Ohstg+X6GsZPu++T0s7TR0d3I4iJPGmmaqUwgXvluy5PYaAljl7nfjBSSjCE cWS3P7puVCrAjQCiKj/exiz8pr1ZbMFGNLmSriNHx2gK6Rka2zvY4krWW/7yzvxa5Vq8r3 IVhyiV0jjccmxjJ5fyhjWkqDL+/ndeScho9FIqoCrlKgcTojANaFRjCgzV8q9bIj1zRyhn yRtEfNVHQWgIhzgdLufwp+JvLKEHiQ0Y5r3f5AMmlxj1GOcBIM2o2HrxMiKFFsltnwGlTG C2GO1dWrcYfoo0MiX56lSiDy3TnH+XSzVDQYotbIraexewGMT4ZXO9ZKlm6TDw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=cassou.me header.s=dkim header.b="cQdtM/QM"; dmarc=fail reason="SPF not aligned (relaxed)" header.from=cassou.me (policy=none); spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 135.181.149.255 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1732375871; 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:list-id:list-help: list-owner:list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=skCl1dr9uqupHojuNsQYRPL1oGCjGEIpmfWa9PsYWik=; b=Vy0Aq9ZCnKGBIh21iFnlTmYK4Xt7j8OMRgj/EtcHY3SYMNDrwOX1GUQeFL8ZO1rmv0XgkH YJWkgZdaAuj2wlZROrVYIuIfwoV0i4kDeGRnhz+Sbye6tQ60MzWw9CcsCcNmnVP3bMw/Er jdK9ox6uLLhl2LyxFu1mEXf00LbxRIjgPWDNeVi4L7jjl1mfzfu4cl7Eaw5d8wjwwamu5B MaU4F1auPq8VUStZvDQYRoc22nYyWou0xen1DpOG+WfvaMZd9p8r08uxsXFFI7y3MzW21j jEWbhQLvflEi+wLs0bz5Yz9YpezEQizy3tMibYEPdzeFovkZTXqZDx2Ewl4btg== Received: from mail.notmuchmail.org (yantan.tethera.net [135.181.149.255]) (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 0F1D583FAF for ; Sat, 23 Nov 2024 16:31:10 +0100 (CET) Received: from yantan.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id 59C9F5F832; Sat, 23 Nov 2024 15:22:46 +0000 (UTC) X-Greylist: delayed 344 seconds by postgrey-1.36 at yantan; Sat, 23 Nov 2024 15:22:42 UTC Received: from mail.reprendre.net (mail.reprendre.net [IPv6:2001:910:1410:501::1]) by mail.notmuchmail.org (Postfix) with ESMTPS id E443E5F6B6 for ; Sat, 23 Nov 2024 15:22:42 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 9E31B2CA1E9; Sat, 23 Nov 2024 16:16:55 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cassou.me; s=dkim; t=1732375016; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=P7jUMLyjpXm4Bwz25AcrDqzOKQz1WZQFEJR4sIME6hg=; b=cQdtM/QML3Q+yTR47wu5NgrCoA7yVGvD4Mp0BgT9K4PsW0KgEkVpl/7hRHUVkeL92asFyR 1IB6GrP2Q4Pe91IQbZtmS10CzzRKIOIcnEFVv8nlRxJ9RngFjfYT9XxUTDmMP/PFTiAixX 0HhDs8t0qLjuTT4X4rsx8q5rc+75gpeZ/5gQAacJHvLLbO8KQwrx0km1Jx3sMVuYpNz9LZ 6tttFmKFfenVHtB8ERx0JZst47PkA1Ib1H0alRrD2Cg/fw+FG91oo/wJBweGVtfL78M7m+ MZ6YrZHTdIxvApa993/vH9pWTW/kfrW9wHp0yEQk5dm5547A8XZato3kZZlE8g== From: Damien Cassou To: notmuch@notmuchmail.org Subject: [PATCH] emacs/show: Only recenter interactively Date: Sat, 23 Nov 2024 16:16:02 +0100 Message-ID: <20241123151601.16201-2-damien@cassou.me> X-Mailer: git-send-email 2.47.0 MIME-Version: 1.0 X-Last-TLS-Session-Version: TLSv1.3 Message-ID-Hash: 2KH2PJLAN6II2GZVCMG4SMNQDIXOMCMX X-Message-ID-Hash: 2KH2PJLAN6II2GZVCMG4SMNQDIXOMCMX X-MailFrom: damien@cassou.me X-Mailman-Rule-Hits: nonmember-moderation X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-notmuch.notmuchmail.org-0 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-Queue-Id: 0F1D583FAF X-Migadu-Scanner: mx13.migadu.com X-Migadu-Spam-Score: 2.05 X-Spam-Score: 2.05 X-TUID: Ogy4x40X6PEl 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. --- 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))) (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." -- 2.47.0