GNU bug report logs - #68547
[PATCH] ; Fix 'mode-line-format-right-align' with ElDoc

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Severity: minor; Reported by: Eshel Yaron <me@HIDDEN>; Keywords: patch; dated Wed, 17 Jan 2024 19:45:02 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.
Severity set to 'minor' from 'normal' Request was from Stefan Kangas <stefankangas@HIDDEN> to control <at> debbugs.gnu.org. Full text available.

Message received at 68547 <at> debbugs.gnu.org:


Received: (at 68547) by debbugs.gnu.org; 6 Mar 2025 03:31:14 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Mar 05 22:31:14 2025
Received: from localhost ([127.0.0.1]:40687 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tq1x4-0004n0-9l
	for submit <at> debbugs.gnu.org; Wed, 05 Mar 2025 22:31:14 -0500
Received: from mail-ed1-x536.google.com ([2a00:1450:4864:20::536]:61635)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.84_2) (envelope-from <stefankangas@HIDDEN>)
 id 1tq1x1-0004ma-0h
 for 68547 <at> debbugs.gnu.org; Wed, 05 Mar 2025 22:31:11 -0500
Received: by mail-ed1-x536.google.com with SMTP id
 4fb4d7f45d1cf-5e52c1c3599so200484a12.2
 for <68547 <at> debbugs.gnu.org>; Wed, 05 Mar 2025 19:31:10 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1741231863; x=1741836663; darn=debbugs.gnu.org;
 h=content-transfer-encoding:cc:to:subject:message-id:date
 :mime-version:references:in-reply-to:from:from:to:cc:subject:date
 :message-id:reply-to;
 bh=KD5XI1DvkGNW/R/kqS6iaN8RPfUR0VFpbO57IpAG8TA=;
 b=H7X3WOmw34zuDIIpm1ab5PVcamovkMCWEPbjd1SAsz6Ot7Bu5GTIkBsNFXRDIRfMiu
 akX2mwZRq0+oQWT+ub7ZU/e4onJEGFJf7ikXHRg/tc0Q/cphNtTmHEtmIrBHvJn3no5l
 wHQaTwNCG2R8U6/YQFG38nnQvXaPB81tJ3gUmwVGV96EugT85TlcSESsEXA7yATUB2L6
 lnoqFGdJQukpoPyoTw8a/q//ivIqU3mnGyJi9dpANsPBm8ACF2noIfMOEFKgtURvtI8D
 21z/boEkumHGoQ1LuYwYpcjnkblAWowP/X1Hz4meLcu5PDgJ57CnD4uHplju2mXbGn4g
 b45g==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1741231863; x=1741836663;
 h=content-transfer-encoding:cc:to:subject:message-id:date
 :mime-version:references:in-reply-to:from:x-gm-message-state:from:to
 :cc:subject:date:message-id:reply-to;
 bh=KD5XI1DvkGNW/R/kqS6iaN8RPfUR0VFpbO57IpAG8TA=;
 b=w47AbV4uLBgSPgnHx3qFOLGfJiG+Qz/sxK4O68HcTl6BfxpptcPSXTwYdeWe1+3SQX
 wMy6LlOJVTL/JRoUCkD4NhgaQEfs6AprDlFX64WRDzSL05x8QT400A2RSwF8ehpVV2y+
 p2EHV4Q8hmqy4qUIARTTdDTuQ/ij9Be4H+g2gfJk5e2HmVlKctevAa5ZNra0l3I/NmEq
 DXgbYukQIdGCoUeul0YhdBLYcpBDs4Xl2ENz91Y4U9J86q7DqM4kWzqZTCQvU1OEr61a
 XsWfg37SmA898JS5mRt7B4Qbi9bWCPQjcG8/R8sPF3pi9u6dXcebkfwdh5ekVpTtD9tp
 tyrA==
X-Forwarded-Encrypted: i=1;
 AJvYcCXRyUQqIcqw3dhP2dnfMw0brsEwMvCkZAZXxTjneNuHRdHASxu9MN6Gor2TUNohCawgJB4fPA==@debbugs.gnu.org
X-Gm-Message-State: AOJu0Yy9EtkQ5JZ7ZB3xPANYBKvC3vExa4sJoPmk7Bj7+NCtY907QsLm
 CZGLW2znF0tfLhVk8Zomsd8Y+ou1DOs1veg/k2CXsv7iAHFKVxHwNdGjVicsCqRb22CYf6DYhCj
 ZisYIIeDkOT5NHYHBDzFN8KVnXfo=
X-Gm-Gg: ASbGncuPN7BLNlZuE4TZWMf+0VblN/+8g5xqfMzs+/ij2xClImI6ueTD6HpoWUq6R18
 DhIfNo79XDMcz4lfyKcdBDHz9g+GiUmusjO8SFVnyvzq7JDHbmUhEtaXyxa9F4qpIg6uA4HT6J+
 09koT9N6evXNpcC+zmhfYldMdDoA==
X-Google-Smtp-Source: AGHT+IHXqFe5YCaIa0UQAHzZXsfiy1nSOvU1w0jQrI/nr/gk5yMdur/o4PyVI6MxkP8cTgm1mMo2cixVGnG6idOo3ow=
X-Received: by 2002:a05:6402:1e94:b0:5e0:52c5:cd6a with SMTP id
 4fb4d7f45d1cf-5e59f46fdddmr4940680a12.25.1741231862399; Wed, 05 Mar 2025
 19:31:02 -0800 (PST)
Received: from 753933720722 named unknown by gmailapi.google.com with
 HTTPREST; Wed, 5 Mar 2025 19:31:01 -0800
From: Stefan Kangas <stefankangas@HIDDEN>
In-Reply-To: <CALDnm50S6F3JkeAJUcrbL8X3BCUMC=5wCKTZ6vwmCuJgZ0P7oQ@HIDDEN>
References: <m14jfbg2yj.fsf@HIDDEN> <83cytwtjiw.fsf@HIDDEN>
 <CALDnm53Z4LppG7AUej2W5qrD_8MyA6YmYvZFFOpK5ULfv62j_w@HIDDEN>
 <m1edec9sq6.fsf@HIDDEN>
 <CALDnm50RA9ph-Dm8sWy7vzBm7y_0qqauM4AU6V7iB6FKgxeTXw@HIDDEN>
 <CALDnm50=ewmdLiScARL_akC57NZ9Y4qkSupE49fa9o3OqYCw+g@HIDDEN>
 <m1le8k58a7.fsf@HIDDEN>
 <CALDnm50S6F3JkeAJUcrbL8X3BCUMC=5wCKTZ6vwmCuJgZ0P7oQ@HIDDEN>
MIME-Version: 1.0
Date: Wed, 5 Mar 2025 19:31:01 -0800
X-Gm-Features: AQ5f1Jp24r1emjgu7u2pb8opzU3QxTq8xHi9Q928eydV8FfRet_uTBoJRDdVWxw
Message-ID: <CADwFkmkixeYX89uifxYe8eupRO-BQnaZ_tibMv6Rj32UBrYa7A@HIDDEN>
Subject: Re: bug#68547: [PATCH] ; Fix 'mode-line-format-right-align' with ElDoc
To: =?UTF-8?B?Sm/Do28gVMOhdm9yYQ==?= <joaotavora@HIDDEN>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 68547
Cc: Eli Zaretskii <eliz@HIDDEN>, Eshel Yaron <me@HIDDEN>,
 68547 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Jo=C3=A3o T=C3=A1vora <joaotavora@HIDDEN> writes:

> On Sat, Jan 20, 2024 at 3:33=E2=80=AFPM Eshel Yaron <me@HIDDEN> w=
rote:
>
>> Then I tried the following (somewhat pathological) use case:
>>
>> 0. Setup: (keymap-global-set "C-x w a" #'windmove-swap-states-left)
>> 1. Open two buffers in two windows side by side.
>> 2. Say `M-: (car `, to show info in the mode line of the left window.
>> 3. Without quitting the minibuffer, use `C-x o` to switch to the right
>>    window, followed by `C-x w a` to switch the buffers in the left and
>>    right windows.
>> 4. Return to the minibuffer and type `nil) RET` or something like that
>>    to exit the minibuffer.
>> 5. The `mode-line-format` of the left buffer is becomes nil, i.e. no mod=
e line.
>>
>> Shuffling `mode-line-format` around is really tricky :(
>
> Indeed.  Your case is pathological, but not particularly hard to
> trigger.  Given the consequences are somewhat dire (vanished mode-line)
> , it should most definitely be handled.
>
> Try this version, please.  Only difference is it uses a setq-local
> for eldoc--saved-mlf instead of a setq.
>
> Please give it as much testing as you can.
>
> Jo=C3=A3o

Was this installed?  If not, should it be?

> diff --git a/lisp/emacs-lisp/eldoc.el b/lisp/emacs-lisp/eldoc.el
> index 912a7357ca7..1ba4e6a006f 100644
> --- a/lisp/emacs-lisp/eldoc.el
> +++ b/lisp/emacs-lisp/eldoc.el
> @@ -182,7 +182,7 @@ eldoc-current-idle-delay
>    "Idle time delay currently in use by timer.
>  This is used to determine if `eldoc-idle-delay' is changed by the user."=
)
>
> -(defvar eldoc-message-function #'eldoc-minibuffer-message
> +(defvar eldoc-message-function #'eldoc--minibuffer-message
>    "The function used by `eldoc--message' to display messages.
>  It should receive the same arguments as `message'.")
>
> @@ -292,43 +292,42 @@ eldoc-schedule-timer
>           (setq eldoc-current-idle-delay eldoc-idle-delay)
>           (timer-set-idle-time eldoc-timer eldoc-idle-delay t))))
>
> -(defvar eldoc-mode-line-string nil)
> -(put 'eldoc-mode-line-string 'risky-local-variable t)
> -
> -(defun eldoc-minibuffer-message (format-string &rest args)
> +(defvar eldoc--saved-mlf nil
> +  "Saved `mode-line-format' used in `eldoc--minibuffer-message'.")
> +(defun eldoc--minibuffer-message (format-string &rest args)
>    "Display message specified by FORMAT-STRING and ARGS on the
> mode-line as needed.
>  This function displays the message produced by formatting ARGS
>  with FORMAT-STRING on the mode line when the current buffer is a minibuf=
fer.
>  Otherwise, it displays the message like `message' would."
> -  (if (or (bound-and-true-p edebug-mode) (minibufferp))
> -      (progn
> -        (add-hook 'post-command-hook #'eldoc-minibuffer--cleanup)
> - (with-current-buffer
> -     (window-buffer
> -      (or (window-in-direction 'above (minibuffer-window))
> - (minibuffer-selected-window)
> - (get-largest-window)))
> -          (when (and mode-line-format
> -                     (not (and (listp mode-line-format)
> -                               (assq 'eldoc-mode-line-string
> mode-line-format))))
> -     (setq mode-line-format
> -                  (funcall
> -                   (if (listp mode-line-format) #'append #'list)
> -                   (list "" '(eldoc-mode-line-string
> -       (" " eldoc-mode-line-string " ")))
> -                   mode-line-format)))
> -          (setq eldoc-mode-line-string
> -                (when (stringp format-string)
> -                  (apply #'format-message format-string args)))
> -          (force-mode-line-update)))
> -    (apply #'message format-string args)))
> -
> -(defun eldoc-minibuffer--cleanup ()
> -  (unless (or (bound-and-true-p edebug-mode) (minibufferp))
> -    (setq eldoc-mode-line-string nil
> -          ;; https://debbugs.gnu.org/16920
> -          eldoc-last-message nil)
> -    (remove-hook 'post-command-hook #'eldoc-minibuffer--cleanup)))
> +  (cond ((bound-and-true-p edebug-mode)
> +         (eldoc--message-in-mode-line 'edebug-mode-hook format-string ar=
gs))
> +        ((minibufferp)
> +         (eldoc--message-in-mode-line 'minibuffer-exit-hook
> format-string args))
> +        (t
> +         (apply #'message format-string args))))
> +
> +(defun eldoc--message-in-mode-line (hook format-string args)
> +  (with-current-buffer
> +      (window-buffer
> +       (or (window-in-direction 'above (minibuffer-window))
> +           (minibuffer-selected-window)
> +           (get-largest-window)))
> +    (let ((buf (current-buffer)))
> +      (cl-labels ((cleanup ()
> +                    (with-current-buffer buf
> +                      (remove-hook hook #'cleanup)
> +                      (setq mode-line-format eldoc--saved-mlf
> +                            eldoc--saved-mlf nil))))
> +        (add-hook hook #'cleanup)
> +        (setq-local eldoc--saved-mlf (or eldoc--saved-mlf mode-line-form=
at))
> +        (when format-string
> +          (setq-local
> +           mode-line-format
> +           (funcall (if (listp eldoc--saved-mlf) #'cons #'list)
> +                    (and format-string
> +                         (apply #'format-message format-string args))
> +                    eldoc--saved-mlf)))
> +        (force-mode-line-update)))))
>
>  (make-obsolete
>   'eldoc-message "use `eldoc-documentation-functions' instead." "eldoc-1.=
1.0")




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#68547; Package emacs. Full text available.

Message received at 68547 <at> debbugs.gnu.org:


Received: (at 68547) by debbugs.gnu.org; 21 Jan 2024 13:20:36 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Jan 21 08:20:36 2024
Received: from localhost ([127.0.0.1]:36740 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rRXkZ-0001QX-Uv
	for submit <at> debbugs.gnu.org; Sun, 21 Jan 2024 08:20:36 -0500
Received: from mail.eshelyaron.com ([107.175.124.16]:45768 helo=eshelyaron.com)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <me@HIDDEN>) id 1rRXkU-0001QL-R3
 for 68547 <at> debbugs.gnu.org; Sun, 21 Jan 2024 08:20:34 -0500
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=eshelyaron.com;
 s=mail; t=1705843226;
 bh=SF2AUYxAo/Rit8Pps1FtT3vPdQTuS1sK7jqAIK3Uzag=;
 h=From:To:Cc:Subject:In-Reply-To:References:Date:From;
 b=FWC2/XdLck7d3Lqb3hikuRIHJ+xIX4Sbb9F4PjPZuEEaYwSzZbD8LJ5ZbYa+hONWY
 vCIeBEm3TDHMPujpzg17Z4x7g/TChRiAVvbH60v0rkIH1MaxVAsxXH+6rW9X74kM0g
 22dMdby2O/IZUVeRQHwEs+/FAO5DUWH87hnZ+LuBKIkfpk7pdKEJviqeGFIl+RnhQB
 /vliHylX7t2SKA/Au78zTYuU4SPWnkk6JOObK92HKgr319mppVOrxsnKKcWBuxh5Qb
 1oNXnghODDpaf2DQkserpDAyUAdLcAOOWYecUZxwOyvJRrCTltReF5cmwzJr9feqlP
 MO+FkFmI3H3LQ==
From: Eshel Yaron <me@HIDDEN>
To: =?utf-8?B?Sm/Do28gVMOhdm9yYQ==?= <joaotavora@HIDDEN>
Subject: Re: bug#68547: [PATCH] ; Fix 'mode-line-format-right-align' with ElDoc
In-Reply-To: <CALDnm52KpypEO-gh4rE8ncmdO9==jSa3f1fFw_Lo1zwZNdhUYg@HIDDEN>
 (=?utf-8?Q?=22Jo=C3=A3o_T=C3=A1vora=22's?= message of "Sun, 21 Jan
 2024 08:52:33 +0000")
References: <m14jfbg2yj.fsf@HIDDEN> <83cytwtjiw.fsf@HIDDEN>
 <CALDnm53Z4LppG7AUej2W5qrD_8MyA6YmYvZFFOpK5ULfv62j_w@HIDDEN>
 <m1edec9sq6.fsf@HIDDEN>
 <CALDnm50RA9ph-Dm8sWy7vzBm7y_0qqauM4AU6V7iB6FKgxeTXw@HIDDEN>
 <CALDnm50=ewmdLiScARL_akC57NZ9Y4qkSupE49fa9o3OqYCw+g@HIDDEN>
 <m1le8k58a7.fsf@HIDDEN>
 <CALDnm50S6F3JkeAJUcrbL8X3BCUMC=5wCKTZ6vwmCuJgZ0P7oQ@HIDDEN>
 <83plxvsweh.fsf@HIDDEN>
 <CALDnm51n=XFAmcFfzmSrbS5SbP=_Wsbh9SYL62KyPBhW_7wOtw@HIDDEN>
 <m1y1cj5bl4.fsf@HIDDEN>
 <CALDnm52KpypEO-gh4rE8ncmdO9==jSa3f1fFw_Lo1zwZNdhUYg@HIDDEN>
Date: Sun, 21 Jan 2024 14:20:24 +0100
Message-ID: <m17ck26cx3.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: 68547
Cc: Eli Zaretskii <eliz@HIDDEN>, 68547 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Jo=C3=A3o T=C3=A1vora <joaotavora@HIDDEN> writes:

> On Sun, Jan 21, 2024 at 8:34=E2=80=AFAM Eshel Yaron <me@HIDDEN> w=
rote:
>
>> I tried your new patch, and it works well, AFAICT.  Two suggestions:
>>
>> 1. This patch omits a space that would appear before the info on the
>>    mode line.  I like that bit of padding, so I suggest restoring it :)
>
> OK.
>
>> 2. In `eldoc--message-in-mode-line`, `add-hook` and `remove-hook` can be
>>    called with non-nil LOCAL argument to further localize the effect,
>>    although I'm not sure that makes a real difference in practice.
>
> I tend to think it would break your pathological use cases of
> shuffling buffers above the minibuffer while it is ongoing, no?
> Two or more separate transient cleanup lambdas can appear
> in those cases, no?

Yes, you're right.  My suggestion was based on a wrong assumption that
these calls take place with the minibuffer as the current buffer.

If I say something like `(with-current-buffer minibuf ...)` around the
`add-hook` and `remove-hook` calls, and make these calls change the
local value of `minibuffer-exit-hook`, that seems to work nicely.  In
particular, this avoids calling the cleanup lambda when you exit a
nested minibuffer (e.g. `M-: (foo bar) M-x baz RET RET`).  WDYT?




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#68547; Package emacs. Full text available.

Message received at 68547 <at> debbugs.gnu.org:


Received: (at 68547) by debbugs.gnu.org; 21 Jan 2024 08:52:55 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Jan 21 03:52:55 2024
Received: from localhost ([127.0.0.1]:36578 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rRTZW-00089p-Pz
	for submit <at> debbugs.gnu.org; Sun, 21 Jan 2024 03:52:55 -0500
Received: from mail-lf1-x12c.google.com ([2a00:1450:4864:20::12c]:46426)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <joaotavora@HIDDEN>) id 1rRTZU-00089b-Hn
 for 68547 <at> debbugs.gnu.org; Sun, 21 Jan 2024 03:52:53 -0500
Received: by mail-lf1-x12c.google.com with SMTP id
 2adb3069b0e04-50ea98440a7so2072303e87.1
 for <68547 <at> debbugs.gnu.org>; Sun, 21 Jan 2024 00:52:49 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1705827163; x=1706431963; darn=debbugs.gnu.org;
 h=content-transfer-encoding:cc:to:subject:message-id:date:from
 :in-reply-to:references:mime-version:from:to:cc:subject:date
 :message-id:reply-to;
 bh=70e0O0FF09pUvoIAEz+iZYkRj9+32lmiiUH2mYupxjU=;
 b=lPFkBGsDi16xSGiVyalw83kxt3QscN7JHACWhReTfPwSM7HVomAJwM4eG3+u6pBFkd
 9XuRL5uo5/Ajd3ljqZMpvACDlJazpq5YJwYH/r40U8n7tlAl1Nda+dCqUIKEIHS3fKYT
 zogXdRI8Pe6mrzZmcgCKs0mF55/LaMg4L+cddhIRScazdx/DS7VTKg/aOMZjAGySJdWO
 XbnnHXhjxnL4crrrGdpEqRAXlqRCssI3iChRajsXZy5HTPAp27wE1zR4qyouCUjMgnNe
 MfhEuWAiPpPyg/JLBvV8/1ty3rhy5OWFTu0ClvkXOMM/UyywJKqpC42yYfBmXNX+pNNN
 72mg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1705827163; x=1706431963;
 h=content-transfer-encoding:cc:to:subject:message-id:date:from
 :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc
 :subject:date:message-id:reply-to;
 bh=70e0O0FF09pUvoIAEz+iZYkRj9+32lmiiUH2mYupxjU=;
 b=NcdwiYYNZ3HXXJbmOyWdxqDICvZtvSDnOy+Y5Jx07/5xGx7xLrDaEDKjLfAg548YvQ
 6UH9wbJ2C/W8VuA8Az4l9m0GTYlvjL3h2tvXpejLhgEWX4RDDcwI8ktGIluFfJPqk6T1
 KOZCpi2Drof49VnjZL/7aQ2fbRgXqiubXLjU5zB6L3kuym/hY72lwAeuV661kzMxxUkV
 rvZTQkVKK0isRXKYJclvdkYk9wT3VeVfW6rTqfqcs8xdvc5p8VijBK47auJK7vMIi9nx
 tdPGD5rWyeZLSakoYQSg0AH0Cg4kP3yT2uFUfe/sGTJdMZ6qeAJeIeirE1rctRir1mBr
 qmGQ==
X-Gm-Message-State: AOJu0YwyQVmazLbYQix810SMoNncjAyNHYniyLta3W1zkKLMdbiHtVZy
 mTuu5WmBCG7YGN7cQqr51DAoryzKdjk6VPlOh/krrfxRWEihO/dCCc0qwEfyExkrDTiltW1Wfyu
 aPJ32NaxyhskxakeTi9JfWwsc7T8=
X-Google-Smtp-Source: AGHT+IGXB84ZTWvVBOmONcQlP0r1LrVZujsiqEtSxR3K4GVSdNGjTDy5HI/BmkisOhQsTFkUcrVXRZDdo45VOkCrXU8=
X-Received: by 2002:a05:6512:3c8d:b0:50e:80fe:add8 with SMTP id
 h13-20020a0565123c8d00b0050e80feadd8mr689470lfv.41.1705827163044; Sun, 21 Jan
 2024 00:52:43 -0800 (PST)
MIME-Version: 1.0
References: <m14jfbg2yj.fsf@HIDDEN> <83cytwtjiw.fsf@HIDDEN>
 <CALDnm53Z4LppG7AUej2W5qrD_8MyA6YmYvZFFOpK5ULfv62j_w@HIDDEN>
 <m1edec9sq6.fsf@HIDDEN>
 <CALDnm50RA9ph-Dm8sWy7vzBm7y_0qqauM4AU6V7iB6FKgxeTXw@HIDDEN>
 <CALDnm50=ewmdLiScARL_akC57NZ9Y4qkSupE49fa9o3OqYCw+g@HIDDEN>
 <m1le8k58a7.fsf@HIDDEN>
 <CALDnm50S6F3JkeAJUcrbL8X3BCUMC=5wCKTZ6vwmCuJgZ0P7oQ@HIDDEN>
 <83plxvsweh.fsf@HIDDEN>
 <CALDnm51n=XFAmcFfzmSrbS5SbP=_Wsbh9SYL62KyPBhW_7wOtw@HIDDEN>
 <m1y1cj5bl4.fsf@HIDDEN>
In-Reply-To: <m1y1cj5bl4.fsf@HIDDEN>
From: =?UTF-8?B?Sm/Do28gVMOhdm9yYQ==?= <joaotavora@HIDDEN>
Date: Sun, 21 Jan 2024 08:52:33 +0000
Message-ID: <CALDnm52KpypEO-gh4rE8ncmdO9==jSa3f1fFw_Lo1zwZNdhUYg@HIDDEN>
Subject: Re: bug#68547: [PATCH] ; Fix 'mode-line-format-right-align' with ElDoc
To: Eshel Yaron <me@HIDDEN>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: 68547
Cc: Eli Zaretskii <eliz@HIDDEN>, 68547 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

On Sun, Jan 21, 2024 at 8:34=E2=80=AFAM Eshel Yaron <me@HIDDEN> wro=
te:

> I tried your new patch, and it works well, AFAICT.  Two suggestions:
>
> 1. This patch omits a space that would appear before the info on the
>    mode line.  I like that bit of padding, so I suggest restoring it :)

OK.

> 2. In `eldoc--message-in-mode-line`, `add-hook` and `remove-hook` can be
>    called with non-nil LOCAL argument to further localize the effect,
>    although I'm not sure that makes a real difference in practice.

I tend to think it would break your pathological use cases of
shuffling buffers above the minibuffer while it is ongoing, no?
Two or more separate transient cleanup lambdas can appear
in those cases, no?

Jo=C3=A3o




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#68547; Package emacs. Full text available.

Message received at 68547 <at> debbugs.gnu.org:


Received: (at 68547) by debbugs.gnu.org; 21 Jan 2024 08:34:42 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Jan 21 03:34:42 2024
Received: from localhost ([127.0.0.1]:36544 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rRTHu-0007el-2Q
	for submit <at> debbugs.gnu.org; Sun, 21 Jan 2024 03:34:42 -0500
Received: from mail.eshelyaron.com ([107.175.124.16]:42388 helo=eshelyaron.com)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <me@HIDDEN>) id 1rRTHq-0007ea-7j
 for 68547 <at> debbugs.gnu.org; Sun, 21 Jan 2024 03:34:40 -0500
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=eshelyaron.com;
 s=mail; t=1705826074;
 bh=k1HPUAxIBZLMe7zft++K4e5E6OYxKBF5r6t2MjN0kYA=;
 h=From:To:Cc:Subject:In-Reply-To:References:Date:From;
 b=K5NCwMNm16ARiMoLoH0J6dd9G/SE/99mPklJzrYicD6EZkPv70YBTTDJF7KPU7kS4
 9Bj4TTqw01SBttASmY2OmpgJ5ohJMNn1Hj9Bhv0wP3qbB8X9lQ3oWKENvmR8q9fTGK
 FgCMVUxRrxeaxfRgf13/61DPQdRQ7F3/AZCQ6IZ2EZxeHYA7xlvNxVXavBIfgYCBt2
 v+LSciaeX9QjKMX09wS8mpQY1vtSHA2O4DDGn/N+BnvT3T8qMXBbRQXfBupbfHkKEe
 7RRv7AcAJlo8N6wAk3N5ybs+wEZSrxCRa02vdxNE3qd9lPMaiy1avMCq7wN2IfZ4XD
 XcDkgFAigpaZA==
From: Eshel Yaron <me@HIDDEN>
To: =?utf-8?B?Sm/Do28gVMOhdm9yYQ==?= <joaotavora@HIDDEN>
Subject: Re: bug#68547: [PATCH] ; Fix 'mode-line-format-right-align' with ElDoc
In-Reply-To: <CALDnm51n=XFAmcFfzmSrbS5SbP=_Wsbh9SYL62KyPBhW_7wOtw@HIDDEN>
 (=?utf-8?Q?=22Jo=C3=A3o_T=C3=A1vora=22's?= message of "Sat, 20 Jan
 2024 21:12:22 +0000")
References: <m14jfbg2yj.fsf@HIDDEN> <83cytwtjiw.fsf@HIDDEN>
 <CALDnm53Z4LppG7AUej2W5qrD_8MyA6YmYvZFFOpK5ULfv62j_w@HIDDEN>
 <m1edec9sq6.fsf@HIDDEN>
 <CALDnm50RA9ph-Dm8sWy7vzBm7y_0qqauM4AU6V7iB6FKgxeTXw@HIDDEN>
 <CALDnm50=ewmdLiScARL_akC57NZ9Y4qkSupE49fa9o3OqYCw+g@HIDDEN>
 <m1le8k58a7.fsf@HIDDEN>
 <CALDnm50S6F3JkeAJUcrbL8X3BCUMC=5wCKTZ6vwmCuJgZ0P7oQ@HIDDEN>
 <83plxvsweh.fsf@HIDDEN>
 <CALDnm51n=XFAmcFfzmSrbS5SbP=_Wsbh9SYL62KyPBhW_7wOtw@HIDDEN>
Date: Sun, 21 Jan 2024 09:34:31 +0100
Message-ID: <m1y1cj5bl4.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: 68547
Cc: Eli Zaretskii <eliz@HIDDEN>, 68547 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Hi,

Jo=C3=A3o T=C3=A1vora <joaotavora@HIDDEN> writes:

> So Eshel, if you try my patch...

I tried your new patch, and it works well, AFAICT.  Two suggestions:

1. This patch omits a space that would appear before the info on the
   mode line.  I like that bit of padding, so I suggest restoring it :)

2. In `eldoc--message-in-mode-line`, `add-hook` and `remove-hook` can be
   called with non-nil LOCAL argument to further localize the effect,
   although I'm not sure that makes a real difference in practice.


Best,

Eshel




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#68547; Package emacs. Full text available.

Message received at 68547 <at> debbugs.gnu.org:


Received: (at 68547) by debbugs.gnu.org; 21 Jan 2024 05:19:30 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Jan 21 00:19:30 2024
Received: from localhost ([127.0.0.1]:36372 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rRQEz-0001xN-Rr
	for submit <at> debbugs.gnu.org; Sun, 21 Jan 2024 00:19:30 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10]:39578)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1rRQEv-0001x7-56
 for 68547 <at> debbugs.gnu.org; Sun, 21 Jan 2024 00:19:28 -0500
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1rRQEm-0004eC-D1; Sun, 21 Jan 2024 00:19:16 -0500
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From:
 Date; bh=26wjgiezBXGYKAmDjDveJ2+t0E/rfi/YdF34FPmnKIg=; b=D09peztU5vHeXo9pBi/X
 aKp0JTZIoj/JhSdUWNYneGxcTtXiddhgrZPsiuXBSRwrydE7knzrjjmYGH/SYvl36DRlYudj6p9lD
 nVjK9H9Bi/9V95R5W8J2JwTn2m8lTSgbtEiiE2VYzKre7zRqFvTorqW0+ouzuPM1jymgy2OkAXusj
 Saruj1uyqRZqIaFSxwiVOXhk0Bar5fFncIwaPG63S9BBIK3ekMv+S0J2TqDCkeV9nWWdx3Z+U+OY+
 oNbseaZa9TlZ4a5mnlmdsSqbKB7FSyOGfFxZ3VyomVy5lAWWz9/N83nAE8YOaVHYRqCb2US/ORjor
 8bt6hNE86N2Nag==;
Date: Sun, 21 Jan 2024 07:18:59 +0200
Message-Id: <83h6j7s1q4.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: =?utf-8?B?Sm/Do28gVMOhdm9yYQ==?= <joaotavora@HIDDEN>
In-Reply-To: <CALDnm51n=XFAmcFfzmSrbS5SbP=_Wsbh9SYL62KyPBhW_7wOtw@HIDDEN>
 (message from =?utf-8?B?Sm/Do28gVMOhdm9yYQ==?= on Sat, 20 Jan 2024 21:12:22
 +0000)
Subject: Re: bug#68547: [PATCH] ; Fix 'mode-line-format-right-align' with ElDoc
References: <m14jfbg2yj.fsf@HIDDEN> <83cytwtjiw.fsf@HIDDEN>
 <CALDnm53Z4LppG7AUej2W5qrD_8MyA6YmYvZFFOpK5ULfv62j_w@HIDDEN>
 <m1edec9sq6.fsf@HIDDEN>
 <CALDnm50RA9ph-Dm8sWy7vzBm7y_0qqauM4AU6V7iB6FKgxeTXw@HIDDEN>
 <CALDnm50=ewmdLiScARL_akC57NZ9Y4qkSupE49fa9o3OqYCw+g@HIDDEN>
 <m1le8k58a7.fsf@HIDDEN>
 <CALDnm50S6F3JkeAJUcrbL8X3BCUMC=5wCKTZ6vwmCuJgZ0P7oQ@HIDDEN>
 <83plxvsweh.fsf@HIDDEN>
 <CALDnm51n=XFAmcFfzmSrbS5SbP=_Wsbh9SYL62KyPBhW_7wOtw@HIDDEN>
MIME-version: 1.0
Content-type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: 68547
Cc: me@HIDDEN, 68547 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> From: João Távora <joaotavora@HIDDEN>
> Date: Sat, 20 Jan 2024 21:12:22 +0000
> Cc: me@HIDDEN, 68547 <at> debbugs.gnu.org
> 
> > Does this remove a function that existed before?  If so, please don't,
> > since that function's name didn't include "--", so it was not an
> > internal function.
> 
> The function eglot-minibuffer-message is a value for
> eldoc-message-function and it's "external" indeed.  But not by
> design rather by "status quo" -- i.e. because at the time it was
> introduced, the '-- 'convention was not always observed.
> 
> The correct way to customize ElDoc's messaging outlet is to
> set 'eldoc-message-function', the variable. That doesn't
> require referencing the should-have-been-internal symbol.

It does, if some Lisp program wants to reset the value back for some
reason.

> > (I also find the tendency of using internal functions as values of
> > variables that are clearly meant to be customized by modes to be
> > undesirable.  They are not really internal functions.)
> 
> I see nothing wrong with it.

What is wrong with it is that it's a possible value of a public
variable, so the value is basically public by definition.

> But as you noted, because of this design mistake, I've noticed
> a small number of modes do set it via 'setq'.  The correct way
> would be to create an obsolete alias.  But if you don't want
> to I won't insist, and we let this dirt persist.  There's
> certainly much worse.

Thanks, I prefer not to rename it.  Who knows what code out there
relies on it being available.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#68547; Package emacs. Full text available.

Message received at 68547 <at> debbugs.gnu.org:


Received: (at 68547) by debbugs.gnu.org; 20 Jan 2024 21:12:45 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Jan 20 16:12:45 2024
Received: from localhost ([127.0.0.1]:35964 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rRIdx-00084I-2x
	for submit <at> debbugs.gnu.org; Sat, 20 Jan 2024 16:12:45 -0500
Received: from mail-lf1-x134.google.com ([2a00:1450:4864:20::134]:47289)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <joaotavora@HIDDEN>) id 1rRIdv-000844-Du
 for 68547 <at> debbugs.gnu.org; Sat, 20 Jan 2024 16:12:44 -0500
Received: by mail-lf1-x134.google.com with SMTP id
 2adb3069b0e04-50e72e3d435so1798505e87.2
 for <68547 <at> debbugs.gnu.org>; Sat, 20 Jan 2024 13:12:40 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1705785154; x=1706389954; darn=debbugs.gnu.org;
 h=content-transfer-encoding:cc:to:subject:message-id:date:from
 :in-reply-to:references:mime-version:from:to:cc:subject:date
 :message-id:reply-to;
 bh=JVYBCZVDUKZdRU/BnCNn9e0CN9Qy04SgO9zYqZm51Bs=;
 b=d+U5HtSFBEr8HKh6jPyb9G/pqh3gNsATv5ScD9WMNyEI7Tm9RaFafy5Zx7Vk/tpxhh
 CbFVNAhcN/2ZZjoqKCvG3J7TVRIqnlB/KJPkPpWIzq9Zb0lnuguJjVIm1HiLYhqPgnLz
 O/lUhwQSP0xAJ/fXswx7FJsYUPO9Ph6S7QVpZeubY+n5BMn9R4hUJmn49Bw0xaNGlcpN
 gLF2q2cEwNnDkbDQdfd0w3ie9YW0YnZa3mEN87Jq8DhuP3V1EdnuNXz9SOiaz0mynJ8q
 qjE8eQml2/a6PEieDvYYDdg8NzuZfmdpYruo8pu+VBiXR0h79tZZj1qLCA3dUfFIQHkD
 reOQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1705785154; x=1706389954;
 h=content-transfer-encoding:cc:to:subject:message-id:date:from
 :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc
 :subject:date:message-id:reply-to;
 bh=JVYBCZVDUKZdRU/BnCNn9e0CN9Qy04SgO9zYqZm51Bs=;
 b=u1ErajIha/hsmHn5byoSlsTY3b0rzpytcsEBtU6dbYfzkcgQ4NfOxC9DDVSsrsGtvO
 5+qcjhixVay22YCZhmMr6Ja/PvGFROp29OWXUVpMX9U2I7xjwr1I3fuDxyYNvloczp7q
 A3Ez0euZTsfclcyONbhOegU1NSVq3tS+MpZQZdiZdO4XggDb8v2ihQIOxBmhT82FCwVg
 d8q5KivCt3f6Yq3/4+3sRpNJqWtouEYb3QUfeIO8I74tjkji37PRUmBPFmNn9QoIXxuG
 xnSmPtzT3SaDf7/Wbd3IZVV8I/Qy+Ekxa2tB/P084+R9NQl3X1Ev0Nkk+Pvp9gi6cdGG
 lGLA==
X-Gm-Message-State: AOJu0YzKSe5Br+qGtrzGbHHREPC2pVrv7uK83OBfyp5xCrKK1S5rKqfR
 SilDMvEQZoHQjeQYJ3q+BfoYvt/yWF70T5Uc0D/NVTlQknoDGZSm0/yyaeH+el6DZAvH2z2KWxg
 YRCIWVh5xp6+VjSHgxhrva9JjO88=
X-Google-Smtp-Source: AGHT+IH6hX5emSyYMUfKDiAoN6qPFgBGfaTzNBWf76aYe73/6BZFNyjXe+bCmy4w55VTdGP64uMKDjz4h/w+7lJZaxw=
X-Received: by 2002:a05:6512:1295:b0:50e:ca83:887e with SMTP id
 u21-20020a056512129500b0050eca83887emr499226lfs.34.1705785154091; Sat, 20 Jan
 2024 13:12:34 -0800 (PST)
MIME-Version: 1.0
References: <m14jfbg2yj.fsf@HIDDEN> <83cytwtjiw.fsf@HIDDEN>
 <CALDnm53Z4LppG7AUej2W5qrD_8MyA6YmYvZFFOpK5ULfv62j_w@HIDDEN>
 <m1edec9sq6.fsf@HIDDEN>
 <CALDnm50RA9ph-Dm8sWy7vzBm7y_0qqauM4AU6V7iB6FKgxeTXw@HIDDEN>
 <CALDnm50=ewmdLiScARL_akC57NZ9Y4qkSupE49fa9o3OqYCw+g@HIDDEN>
 <m1le8k58a7.fsf@HIDDEN>
 <CALDnm50S6F3JkeAJUcrbL8X3BCUMC=5wCKTZ6vwmCuJgZ0P7oQ@HIDDEN>
 <83plxvsweh.fsf@HIDDEN>
In-Reply-To: <83plxvsweh.fsf@HIDDEN>
From: =?UTF-8?B?Sm/Do28gVMOhdm9yYQ==?= <joaotavora@HIDDEN>
Date: Sat, 20 Jan 2024 21:12:22 +0000
Message-ID: <CALDnm51n=XFAmcFfzmSrbS5SbP=_Wsbh9SYL62KyPBhW_7wOtw@HIDDEN>
Subject: Re: bug#68547: [PATCH] ; Fix 'mode-line-format-right-align' with ElDoc
To: Eli Zaretskii <eliz@HIDDEN>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: 68547
Cc: me@HIDDEN, 68547 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

On Sat, Jan 20, 2024 at 6:16=E2=80=AFPM Eli Zaretskii <eliz@HIDDEN> wrote:
>
> > From: Jo=C3=A3o T=C3=A1vora <joaotavora@HIDDEN>
> > Date: Sat, 20 Jan 2024 18:08:35 +0000
> > Cc: Eli Zaretskii <eliz@HIDDEN>, 68547 <at> debbugs.gnu.org
> >
> > -(defun eldoc-minibuffer-message (format-string &rest args)
> > +(defvar eldoc--saved-mlf nil
> > +  "Saved `mode-line-format' used in `eldoc--minibuffer-message'.")
> > +(defun eldoc--minibuffer-message (format-string &rest args)
> >    "Display message specified by FORMAT-STRING and ARGS on the
> > mode-line as needed.
>
> Does this remove a function that existed before?  If so, please don't,
> since that function's name didn't include "--", so it was not an
> internal function.

The function eglot-minibuffer-message is a value for
eldoc-message-function and it's "external" indeed.  But not by
design rather by "status quo" -- i.e. because at the time it was
introduced, the '-- 'convention was not always observed.

The correct way to customize ElDoc's messaging outlet is to
set 'eldoc-message-function', the variable. That doesn't
require referencing the should-have-been-internal symbol.

> (I also find the tendency of using internal functions as values of
> variables that are clearly meant to be customized by modes to be
> undesirable.  They are not really internal functions.)

I see nothing wrong with it.

An internal symbol that designates a function means that:

1) you shouldn't call it, it's probably a bug if you do, and it
   unnecessarily constrains the development of the library.

2) you needn't refer to its value function value via (function <symbol>)
   or equivalent.

'eglot-minibuffer-message' verifies both.

1) The function is an alias to message except in certain situations
   where it will use the mode-line of a certain buffer chosen
   heuristically.  It is also a misnomer and the docstring

2) The recommended way to customize eldoc-message-function or
   other function-holding variables is not by 'setq' but rather
   'add-function'.  `setq` can be used if you intend to restore
   the old value.

But as you noted, because of this design mistake, I've noticed
a small number of modes do set it via 'setq'.  The correct way
would be to create an obsolete alias.  But if you don't want
to I won't insist, and we let this dirt persist.  There's
certainly much worse.

So Eshel, if you try my patch, remove the '--' from the
eldoc--minibuffer-message please.

Jo=C3=A3o




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#68547; Package emacs. Full text available.

Message received at 68547 <at> debbugs.gnu.org:


Received: (at 68547) by debbugs.gnu.org; 20 Jan 2024 18:16:54 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Jan 20 13:16:53 2024
Received: from localhost ([127.0.0.1]:35712 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rRFtl-0000I9-J1
	for submit <at> debbugs.gnu.org; Sat, 20 Jan 2024 13:16:53 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10]:48504)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1rRFth-0000Hp-IT
 for 68547 <at> debbugs.gnu.org; Sat, 20 Jan 2024 13:16:52 -0500
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1rRFtZ-0003oe-4R; Sat, 20 Jan 2024 13:16:41 -0500
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From:
 Date; bh=X86AIm6waHllmi4tGphKXoXDNW5rYNz/McTrHN89N8Q=; b=IG0F9nEgB53qLXxkgCYU
 Y/6iPUbr//gHw25Tjl3HGPIDgi0VUf2xjX2dcxIHtQghlu19erYArWpcSQDPJfGj2xYbHFgY9oWiJ
 qRszlYVHSgpRo02XHLkYsuJjpcNpbZG/1T2fjo3JyDtEnerklYsclCdAu9GVW0zae2KzU/xrWRqzB
 Afg/D/rpqH1L4ZGi68BT+yIcj9dhv4KpbhqBTRJrm2NWCspapxj3rvw6O9fYmEB8PnocL9yBAPxGf
 XFJoe1H0PSPhmIXgGU9UeLLPHFhYIeD1tS9iLf4cmQ4IOTCFEayhmjWypsT6LFLXKTnBXD1Crp+i5
 gPz+iSfsIJRtaA==;
Date: Sat, 20 Jan 2024 20:16:22 +0200
Message-Id: <83plxvsweh.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: =?utf-8?B?Sm/Do28gVMOhdm9yYQ==?= <joaotavora@HIDDEN>
In-Reply-To: <CALDnm50S6F3JkeAJUcrbL8X3BCUMC=5wCKTZ6vwmCuJgZ0P7oQ@HIDDEN>
 (message from =?utf-8?B?Sm/Do28gVMOhdm9yYQ==?= on Sat, 20 Jan 2024 18:08:35
 +0000)
Subject: Re: bug#68547: [PATCH] ; Fix 'mode-line-format-right-align' with ElDoc
References: <m14jfbg2yj.fsf@HIDDEN> <83cytwtjiw.fsf@HIDDEN>
 <CALDnm53Z4LppG7AUej2W5qrD_8MyA6YmYvZFFOpK5ULfv62j_w@HIDDEN>
 <m1edec9sq6.fsf@HIDDEN>
 <CALDnm50RA9ph-Dm8sWy7vzBm7y_0qqauM4AU6V7iB6FKgxeTXw@HIDDEN>
 <CALDnm50=ewmdLiScARL_akC57NZ9Y4qkSupE49fa9o3OqYCw+g@HIDDEN>
 <m1le8k58a7.fsf@HIDDEN>
 <CALDnm50S6F3JkeAJUcrbL8X3BCUMC=5wCKTZ6vwmCuJgZ0P7oQ@HIDDEN>
MIME-version: 1.0
Content-type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 68547
Cc: me@HIDDEN, 68547 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> From: João Távora <joaotavora@HIDDEN>
> Date: Sat, 20 Jan 2024 18:08:35 +0000
> Cc: Eli Zaretskii <eliz@HIDDEN>, 68547 <at> debbugs.gnu.org
> 
> -(defun eldoc-minibuffer-message (format-string &rest args)
> +(defvar eldoc--saved-mlf nil
> +  "Saved `mode-line-format' used in `eldoc--minibuffer-message'.")
> +(defun eldoc--minibuffer-message (format-string &rest args)
>    "Display message specified by FORMAT-STRING and ARGS on the
> mode-line as needed.

Does this remove a function that existed before?  If so, please don't,
since that function's name didn't include "--", so it was not an
internal function.

(I also find the tendency of using internal functions as values of
variables that are clearly meant to be customized by modes to be
undesirable.  They are not really internal functions.)




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#68547; Package emacs. Full text available.

Message received at 68547 <at> debbugs.gnu.org:


Received: (at 68547) by debbugs.gnu.org; 20 Jan 2024 18:08:59 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Jan 20 13:08:59 2024
Received: from localhost ([127.0.0.1]:35702 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rRFm6-0008W4-Qt
	for submit <at> debbugs.gnu.org; Sat, 20 Jan 2024 13:08:59 -0500
Received: from mail-lf1-x132.google.com ([2a00:1450:4864:20::132]:55738)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <joaotavora@HIDDEN>) id 1rRFm4-0008Vl-6D
 for 68547 <at> debbugs.gnu.org; Sat, 20 Jan 2024 13:08:58 -0500
Received: by mail-lf1-x132.google.com with SMTP id
 2adb3069b0e04-50e759ece35so1820696e87.3
 for <68547 <at> debbugs.gnu.org>; Sat, 20 Jan 2024 10:08:53 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1705774127; x=1706378927; darn=debbugs.gnu.org;
 h=content-transfer-encoding:cc:to:subject:message-id:date:from
 :in-reply-to:references:mime-version:from:to:cc:subject:date
 :message-id:reply-to;
 bh=06FA/1+vhip+odHmcGW8n6OMHtLqglxz53oEES5ejv8=;
 b=O7O4pcVqGI+HauE0xBSSWpX66AnuA8bMAqAAcYw4RVzY1TVa/LElHCnt2q5m/SpNBu
 0e3AdAU1ZYJs4R22tZiMZDfsWI5wFxuejj6ir/FnbOpXYV0tI5CHId31yjv2+NLiASLr
 EypXZ24zGUDY3q68Hb2HYCOjRXx8pce2jsX+m7RT58U+c7NUYon0XTlT8tPck+J/+5P5
 n6EQbmaZZ0tTH1Wdp+bnUyhnuvN1gRnuxbib6DPN0nVV64BduAOLUiOP1dgLyiwyD68O
 YGa1fT3rruRLKt/uw1tZMRMLornufOqHzMzIZkGkSfr08oaASmsICo3wndtsWeQWRzPu
 TbvA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1705774127; x=1706378927;
 h=content-transfer-encoding:cc:to:subject:message-id:date:from
 :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc
 :subject:date:message-id:reply-to;
 bh=06FA/1+vhip+odHmcGW8n6OMHtLqglxz53oEES5ejv8=;
 b=hnzZvXTiMnj3VfVOhqhrvHNBag9IeuPChxF/pe5KbsjVdGxX9zAuwhdlz6fVDw4Rro
 vUWLff7Wnf0BTSGzVTvI9/SkCA4QAzaNc9cvsGKGEAFCqmIaLWRh/PuIxq7nqjQKlZes
 1WXVp+nhh9P4E7HJpMHicPsM9cgUjzUp0TdWzadQBYDjHLCN78RHs7TqLYiAY/aku5Xj
 nUVwXOVoiPOlNZ+HkToVxR3ugOaMb/hINeqSYy5NSQtnnARtpdWJzsbO401w+MSy00c9
 5eKl2WMUAlNyZx/GdBKWmF+1rS57T+l3LOKci95Cz2XA1qEj3N3kExLy1UriK9rc/7R5
 orxA==
X-Gm-Message-State: AOJu0YxGEhoJ9l9GUXoUWABHMLYxzD+M43JhZbzCc5VmzWtm8czOaI3/
 3cMyBX8iT5f8N7MeJozy4Y81qsN/ui1nAEyNqXf+2gfe0Nscqk0l4z7mCs5xw2C3fljETtDoUN7
 aCbogCwFoBN7BoEy07RzwSlIxfko=
X-Google-Smtp-Source: AGHT+IFvdQ29CYUqXHF8WteS6K/ua5VbE+aHjhX1tvIiknphhabg0vds5NAWsX7n3B2pqkZE0p1j1Cfps4Cg1jFJyvc=
X-Received: by 2002:a05:6512:3592:b0:50e:6e41:2f2a with SMTP id
 m18-20020a056512359200b0050e6e412f2amr502488lfr.6.1705774126548; Sat, 20 Jan
 2024 10:08:46 -0800 (PST)
MIME-Version: 1.0
References: <m14jfbg2yj.fsf@HIDDEN> <83cytwtjiw.fsf@HIDDEN>
 <CALDnm53Z4LppG7AUej2W5qrD_8MyA6YmYvZFFOpK5ULfv62j_w@HIDDEN>
 <m1edec9sq6.fsf@HIDDEN>
 <CALDnm50RA9ph-Dm8sWy7vzBm7y_0qqauM4AU6V7iB6FKgxeTXw@HIDDEN>
 <CALDnm50=ewmdLiScARL_akC57NZ9Y4qkSupE49fa9o3OqYCw+g@HIDDEN>
 <m1le8k58a7.fsf@HIDDEN>
In-Reply-To: <m1le8k58a7.fsf@HIDDEN>
From: =?UTF-8?B?Sm/Do28gVMOhdm9yYQ==?= <joaotavora@HIDDEN>
Date: Sat, 20 Jan 2024 18:08:35 +0000
Message-ID: <CALDnm50S6F3JkeAJUcrbL8X3BCUMC=5wCKTZ6vwmCuJgZ0P7oQ@HIDDEN>
Subject: Re: bug#68547: [PATCH] ; Fix 'mode-line-format-right-align' with ElDoc
To: Eshel Yaron <me@HIDDEN>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: 68547
Cc: Eli Zaretskii <eliz@HIDDEN>, 68547 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

On Sat, Jan 20, 2024 at 3:33=E2=80=AFPM Eshel Yaron <me@HIDDEN> wro=
te:

> Then I tried the following (somewhat pathological) use case:
>
> 0. Setup: (keymap-global-set "C-x w a" #'windmove-swap-states-left)
> 1. Open two buffers in two windows side by side.
> 2. Say `M-: (car `, to show info in the mode line of the left window.
> 3. Without quitting the minibuffer, use `C-x o` to switch to the right
>    window, followed by `C-x w a` to switch the buffers in the left and
>    right windows.
> 4. Return to the minibuffer and type `nil) RET` or something like that
>    to exit the minibuffer.
> 5. The `mode-line-format` of the left buffer is becomes nil, i.e. no mode=
 line.
>
> Shuffling `mode-line-format` around is really tricky :(

Indeed.  Your case is pathological, but not particularly hard to
trigger.  Given the consequences are somewhat dire (vanished mode-line)
, it should most definitely be handled.

Try this version, please.  Only difference is it uses a setq-local
for eldoc--saved-mlf instead of a setq.

Please give it as much testing as you can.

Jo=C3=A3o

diff --git a/lisp/emacs-lisp/eldoc.el b/lisp/emacs-lisp/eldoc.el
index 912a7357ca7..1ba4e6a006f 100644
--- a/lisp/emacs-lisp/eldoc.el
+++ b/lisp/emacs-lisp/eldoc.el
@@ -182,7 +182,7 @@ eldoc-current-idle-delay
   "Idle time delay currently in use by timer.
 This is used to determine if `eldoc-idle-delay' is changed by the user.")

-(defvar eldoc-message-function #'eldoc-minibuffer-message
+(defvar eldoc-message-function #'eldoc--minibuffer-message
   "The function used by `eldoc--message' to display messages.
 It should receive the same arguments as `message'.")

@@ -292,43 +292,42 @@ eldoc-schedule-timer
          (setq eldoc-current-idle-delay eldoc-idle-delay)
          (timer-set-idle-time eldoc-timer eldoc-idle-delay t))))

-(defvar eldoc-mode-line-string nil)
-(put 'eldoc-mode-line-string 'risky-local-variable t)
-
-(defun eldoc-minibuffer-message (format-string &rest args)
+(defvar eldoc--saved-mlf nil
+  "Saved `mode-line-format' used in `eldoc--minibuffer-message'.")
+(defun eldoc--minibuffer-message (format-string &rest args)
   "Display message specified by FORMAT-STRING and ARGS on the
mode-line as needed.
 This function displays the message produced by formatting ARGS
 with FORMAT-STRING on the mode line when the current buffer is a minibuffe=
r.
 Otherwise, it displays the message like `message' would."
-  (if (or (bound-and-true-p edebug-mode) (minibufferp))
-      (progn
-        (add-hook 'post-command-hook #'eldoc-minibuffer--cleanup)
- (with-current-buffer
-     (window-buffer
-      (or (window-in-direction 'above (minibuffer-window))
- (minibuffer-selected-window)
- (get-largest-window)))
-          (when (and mode-line-format
-                     (not (and (listp mode-line-format)
-                               (assq 'eldoc-mode-line-string
mode-line-format))))
-     (setq mode-line-format
-                  (funcall
-                   (if (listp mode-line-format) #'append #'list)
-                   (list "" '(eldoc-mode-line-string
-       (" " eldoc-mode-line-string " ")))
-                   mode-line-format)))
-          (setq eldoc-mode-line-string
-                (when (stringp format-string)
-                  (apply #'format-message format-string args)))
-          (force-mode-line-update)))
-    (apply #'message format-string args)))
-
-(defun eldoc-minibuffer--cleanup ()
-  (unless (or (bound-and-true-p edebug-mode) (minibufferp))
-    (setq eldoc-mode-line-string nil
-          ;; https://debbugs.gnu.org/16920
-          eldoc-last-message nil)
-    (remove-hook 'post-command-hook #'eldoc-minibuffer--cleanup)))
+  (cond ((bound-and-true-p edebug-mode)
+         (eldoc--message-in-mode-line 'edebug-mode-hook format-string args=
))
+        ((minibufferp)
+         (eldoc--message-in-mode-line 'minibuffer-exit-hook
format-string args))
+        (t
+         (apply #'message format-string args))))
+
+(defun eldoc--message-in-mode-line (hook format-string args)
+  (with-current-buffer
+      (window-buffer
+       (or (window-in-direction 'above (minibuffer-window))
+           (minibuffer-selected-window)
+           (get-largest-window)))
+    (let ((buf (current-buffer)))
+      (cl-labels ((cleanup ()
+                    (with-current-buffer buf
+                      (remove-hook hook #'cleanup)
+                      (setq mode-line-format eldoc--saved-mlf
+                            eldoc--saved-mlf nil))))
+        (add-hook hook #'cleanup)
+        (setq-local eldoc--saved-mlf (or eldoc--saved-mlf mode-line-format=
))
+        (when format-string
+          (setq-local
+           mode-line-format
+           (funcall (if (listp eldoc--saved-mlf) #'cons #'list)
+                    (and format-string
+                         (apply #'format-message format-string args))
+                    eldoc--saved-mlf)))
+        (force-mode-line-update)))))

 (make-obsolete
  'eldoc-message "use `eldoc-documentation-functions' instead." "eldoc-1.1.=
0")



--=20
Jo=C3=A3o T=C3=A1vora




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#68547; Package emacs. Full text available.

Message received at 68547 <at> debbugs.gnu.org:


Received: (at 68547) by debbugs.gnu.org; 20 Jan 2024 15:33:45 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Jan 20 10:33:44 2024
Received: from localhost ([127.0.0.1]:35521 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rRDLs-0003qJ-JN
	for submit <at> debbugs.gnu.org; Sat, 20 Jan 2024 10:33:44 -0500
Received: from mail.eshelyaron.com ([107.175.124.16]:53438 helo=eshelyaron.com)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <me@HIDDEN>) id 1rRDLq-0003qB-CM
 for 68547 <at> debbugs.gnu.org; Sat, 20 Jan 2024 10:33:43 -0500
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=eshelyaron.com;
 s=mail; t=1705764818;
 bh=9aUYPqaL/7h5NNW3OQ17V3Zl8oo1jSgvC26t78ZefN4=;
 h=From:To:Cc:Subject:In-Reply-To:References:Date:From;
 b=Cxn50Y3gGQLYG8aFTq6GyAmiUDejA+mb6ysrSlWd4O3almN7SzeflUHo3iAAW6vy/
 gGpwMbd8oegDlyCFoiVcVL55WA6TcVqCEF46f59fnIZE8HwMwFKgkZQ9CafWChnhYz
 UPnW2kDUH0I7rap1fF/zR3v26Rj9x6LOw/M/5R5JzAkCZXGlS9Lyk1QiuaddBvwGPf
 tuCmAA4nLI6adlkNXrwh2Mv9zAKeg7yaznoAQzmEV7/KSD6xw2N8We5hJJi3Txa+u/
 FIwfKAP3p7dZ2z0ZDhvrWj6gi/qq0SsjcVVAEwgw2mNXVMB+0NY8bir3uMHB+nATto
 FumJoQQDiZI7Q==
From: Eshel Yaron <me@HIDDEN>
To: =?utf-8?B?Sm/Do28gVMOhdm9yYQ==?= <joaotavora@HIDDEN>
Subject: Re: bug#68547: [PATCH] ; Fix 'mode-line-format-right-align' with ElDoc
In-Reply-To: <CALDnm50=ewmdLiScARL_akC57NZ9Y4qkSupE49fa9o3OqYCw+g@HIDDEN>
 (=?utf-8?Q?=22Jo=C3=A3o_T=C3=A1vora=22's?= message of "Sat, 20 Jan
 2024 13:55:21 +0000")
References: <m14jfbg2yj.fsf@HIDDEN> <83cytwtjiw.fsf@HIDDEN>
 <CALDnm53Z4LppG7AUej2W5qrD_8MyA6YmYvZFFOpK5ULfv62j_w@HIDDEN>
 <m1edec9sq6.fsf@HIDDEN>
 <CALDnm50RA9ph-Dm8sWy7vzBm7y_0qqauM4AU6V7iB6FKgxeTXw@HIDDEN>
 <CALDnm50=ewmdLiScARL_akC57NZ9Y4qkSupE49fa9o3OqYCw+g@HIDDEN>
X-Hashcash: 1:20:240120:joaotavora@HIDDEN::Igss/w3eWI4HOqSR:1BBr
X-Hashcash: 1:20:240120:68547 <at> debbugs.gnu.org::o5X5YMKggfY5Nm1l:JEI
X-Hashcash: 1:20:240120:eliz@HIDDEN::TRFY1A1HwFtTisM9:9UQX
Date: Sat, 20 Jan 2024 16:33:36 +0100
Message-ID: <m1le8k58a7.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: 68547
Cc: Eli Zaretskii <eliz@HIDDEN>, 68547 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Hi Jo=C3=A3o,

Jo=C3=A3o T=C3=A1vora <joaotavora@HIDDEN> writes:

>> I'm going to look at this function though, since I don't I love the
>> logic of destroying any old buffer's mode-line-format and not
>> restoring after the minibuffer is exited.

Agreed.

> While we're on the subject, can you give this patch a try Eshel?

Sure.  At first glance this looks good, but I ran into some issues.
First of all, looks like some lines in the patch got wrapped, so I
needed to tweak the patch manually a bit in order to apply it.

Then I tried the following (somewhat pathological) use case:

0. Setup: (keymap-global-set "C-x w a" #'windmove-swap-states-left)
1. Open two buffers in two windows side by side.
2. Say `M-: (car `, to show info in the mode line of the left window.
3. Without quitting the minibuffer, use `C-x o` to switch to the right
   window, followed by `C-x w a` to switch the buffers in the left and
   right windows.
4. Return to the minibuffer and type `nil) RET` or something like that
   to exit the minibuffer.
5. The `mode-line-format` of the left buffer is becomes nil, i.e. no mode l=
ine.

Shuffling `mode-line-format` around is really tricky :(




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#68547; Package emacs. Full text available.

Message received at 68547 <at> debbugs.gnu.org:


Received: (at 68547) by debbugs.gnu.org; 20 Jan 2024 13:55:46 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Jan 20 08:55:46 2024
Received: from localhost ([127.0.0.1]:33172 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rRBp3-0000NB-Do
	for submit <at> debbugs.gnu.org; Sat, 20 Jan 2024 08:55:46 -0500
Received: from mail-lf1-x130.google.com ([2a00:1450:4864:20::130]:51589)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <joaotavora@HIDDEN>) id 1rRBp0-0000Mw-K0
 for 68547 <at> debbugs.gnu.org; Sat, 20 Jan 2024 08:55:44 -0500
Received: by mail-lf1-x130.google.com with SMTP id
 2adb3069b0e04-50edf4f478eso2186518e87.3
 for <68547 <at> debbugs.gnu.org>; Sat, 20 Jan 2024 05:55:39 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1705758933; x=1706363733; darn=debbugs.gnu.org;
 h=content-transfer-encoding:cc:to:subject:message-id:date:from
 :in-reply-to:references:mime-version:from:to:cc:subject:date
 :message-id:reply-to;
 bh=dEhFPJJ79ZXM19OXEbpqaZKeExp5lwhOcJCVua1ymw0=;
 b=SdnhAoE0GpS7AKwA9VPQuPY3LrwMuhjoXkhZZuqWr22a1b/kcnLHgxJPbQI7S/PQjm
 t6bX+uFdZ9/jMoruArTo+bh2+RCuNkr29k+m/YHXSJa91iH/A1ae9JOpK7h9xQue7065
 Am5SpDn7pWJa5H3e0ZXu8PoJ4ZWfILX2Hs21ScvQ7GcC3ujzfbGQfLL2FctP7gZhQN2K
 I964DZHcvBAyt6CJKmlf/CAsHqW+MftbKcKIaF/hPSSbthUDthRmHdhcFdIpbLzp1KYl
 W3DJExCt1Pxsi/BWwtd2HNvT7AZwaaC7je3Kz0u5UhzgUOJvWU1xL+PW3knYPxKFcKRD
 6w7w==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1705758933; x=1706363733;
 h=content-transfer-encoding:cc:to:subject:message-id:date:from
 :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc
 :subject:date:message-id:reply-to;
 bh=dEhFPJJ79ZXM19OXEbpqaZKeExp5lwhOcJCVua1ymw0=;
 b=LsYtLgUoGpTBVvRUP4LTKESMV+pJJDjQrVJePfbJ40uo5A/lS5DoayUHwoW8gkJ9wt
 19kKxhJJIo7FWsBYQOTyR5ARaINu32p1XfJgURbyWWKHclave7NHImyJ0gRLO3gbD5dS
 tPFoy6CcRHS0Py1KsOEhrE5Ggptxk9mLWrNiDFnGpSRNoBwvHYRcGNVSoK1YAruDVaYk
 z1jtqbAwHAsL6JgvPTsk/rVDMfAs/Rc2v4evuXXe2fgwicvq/bAkMPTyiwiQ91F7Q4jl
 9OuBUV1Ht8N1yNAnDJIQXNM8pnt3hjUGJ8UKQyPiJho+ll57k/l2wW00ss8MwSwMVUlZ
 7/Iw==
X-Gm-Message-State: AOJu0Yye+1dGrsa7540HuDFHn4uW6ZeiQADxM1o40nU4gE8CAwBYHCkS
 /b0zw9QwTXBQuXPgkJO93vGIS2IZTG+q5OATxX5QY4THCYfvcntzSifOpyFXLKKlIfJ+W76PsPV
 yNaU8XKLLl22G6V9l0vy6sTFHNbo=
X-Google-Smtp-Source: AGHT+IHO0jnnIunLnD7wwIJBaz0ts98ycKN2BanBeQgo52rS44s3m35yjUbJmfodjhhrB+VLVbtX7iB6GpKtbuoCGZg=
X-Received: by 2002:a05:6512:280f:b0:50e:7be0:3c38 with SMTP id
 cf15-20020a056512280f00b0050e7be03c38mr631970lfb.98.1705758932807; Sat, 20
 Jan 2024 05:55:32 -0800 (PST)
MIME-Version: 1.0
References: <m14jfbg2yj.fsf@HIDDEN> <83cytwtjiw.fsf@HIDDEN>
 <CALDnm53Z4LppG7AUej2W5qrD_8MyA6YmYvZFFOpK5ULfv62j_w@HIDDEN>
 <m1edec9sq6.fsf@HIDDEN>
 <CALDnm50RA9ph-Dm8sWy7vzBm7y_0qqauM4AU6V7iB6FKgxeTXw@HIDDEN>
In-Reply-To: <CALDnm50RA9ph-Dm8sWy7vzBm7y_0qqauM4AU6V7iB6FKgxeTXw@HIDDEN>
From: =?UTF-8?B?Sm/Do28gVMOhdm9yYQ==?= <joaotavora@HIDDEN>
Date: Sat, 20 Jan 2024 13:55:21 +0000
Message-ID: <CALDnm50=ewmdLiScARL_akC57NZ9Y4qkSupE49fa9o3OqYCw+g@HIDDEN>
Subject: Re: bug#68547: [PATCH] ; Fix 'mode-line-format-right-align' with ElDoc
To: Eshel Yaron <me@HIDDEN>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: 68547
Cc: Eli Zaretskii <eliz@HIDDEN>, 68547 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

On Sat, Jan 20, 2024 at 12:01=E2=80=AFPM Jo=C3=A3o T=C3=A1vora <joaotavora@=
gmail.com> wrote:
> Thanks.  I pushed it.  I'm going to look at this function though,
> since I don't I love the logic of destroying any old buffer's
> mode-line-format and not restoring after the minibuffer is
> exited.

While we're on the subject, can you give this patch a try Eshel?

diff --git a/lisp/emacs-lisp/eldoc.el b/lisp/emacs-lisp/eldoc.el
index 912a7357ca7..78ce7ecd123 100644
--- a/lisp/emacs-lisp/eldoc.el
+++ b/lisp/emacs-lisp/eldoc.el
@@ -182,7 +182,7 @@ eldoc-current-idle-delay
   "Idle time delay currently in use by timer.
 This is used to determine if `eldoc-idle-delay' is changed by the user.")

-(defvar eldoc-message-function #'eldoc-minibuffer-message
+(defvar eldoc-message-function #'eldoc--minibuffer-message
   "The function used by `eldoc--message' to display messages.
 It should receive the same arguments as `message'.")

@@ -292,43 +292,42 @@ eldoc-schedule-timer
          (setq eldoc-current-idle-delay eldoc-idle-delay)
          (timer-set-idle-time eldoc-timer eldoc-idle-delay t))))

-(defvar eldoc-mode-line-string nil)
-(put 'eldoc-mode-line-string 'risky-local-variable t)
-
-(defun eldoc-minibuffer-message (format-string &rest args)
+(defvar eldoc--saved-mlf nil
+  "Saved `mode-line-format' used in `eldoc--minibuffer-message'.")
+(defun eldoc--minibuffer-message (format-string &rest args)
   "Display message specified by FORMAT-STRING and ARGS on the
mode-line as needed.
 This function displays the message produced by formatting ARGS
 with FORMAT-STRING on the mode line when the current buffer is a minibuffe=
r.
 Otherwise, it displays the message like `message' would."
-  (if (or (bound-and-true-p edebug-mode) (minibufferp))
-      (progn
-        (add-hook 'post-command-hook #'eldoc-minibuffer--cleanup)
- (with-current-buffer
-     (window-buffer
-      (or (window-in-direction 'above (minibuffer-window))
- (minibuffer-selected-window)
- (get-largest-window)))
-          (when (and mode-line-format
-                     (not (and (listp mode-line-format)
-                               (assq 'eldoc-mode-line-string
mode-line-format))))
-     (setq mode-line-format
-                  (funcall
-                   (if (listp mode-line-format) #'append #'list)
-                   (list "" '(eldoc-mode-line-string
-       (" " eldoc-mode-line-string " ")))
-                   mode-line-format)))
-          (setq eldoc-mode-line-string
-                (when (stringp format-string)
-                  (apply #'format-message format-string args)))
-          (force-mode-line-update)))
-    (apply #'message format-string args)))
-
-(defun eldoc-minibuffer--cleanup ()
-  (unless (or (bound-and-true-p edebug-mode) (minibufferp))
-    (setq eldoc-mode-line-string nil
-          ;; https://debbugs.gnu.org/16920
-          eldoc-last-message nil)
-    (remove-hook 'post-command-hook #'eldoc-minibuffer--cleanup)))
+  (cond ((bound-and-true-p edebug-mode)
+         (eldoc--message-in-mode-line 'edebug-mode-hook format-string args=
))
+        ((minibufferp)
+         (eldoc--message-in-mode-line 'minibuffer-exit-hook
format-string args))
+        (t
+         (apply #'message format-string args))))
+
+(defun eldoc--message-in-mode-line (hook format-string args)
+  (with-current-buffer
+      (window-buffer
+       (or (window-in-direction 'above (minibuffer-window))
+           (minibuffer-selected-window)
+           (get-largest-window)))
+    (let ((buf (current-buffer)))
+      (cl-labels ((cleanup ()
+                    (with-current-buffer buf
+                      (remove-hook hook #'cleanup)
+                      (setq mode-line-format eldoc--saved-mlf
+                            eldoc--saved-mlf nil))))
+        (add-hook hook #'cleanup)
+        (setq eldoc--saved-mlf (or eldoc--saved-mlf mode-line-format))
+        (when format-string
+          (setq
+           mode-line-format
+           (funcall (if (listp eldoc--saved-mlf) #'cons #'list)
+                    (and format-string
+                         (apply #'format-message format-string args))
+                    eldoc--saved-mlf)))
+        (force-mode-line-update)))))

 (make-obsolete
  'eldoc-message "use `eldoc-documentation-functions' instead." "eldoc-1.1.=
0")



--=20
Jo=C3=A3o T=C3=A1vora




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#68547; Package emacs. Full text available.

Message received at 68547 <at> debbugs.gnu.org:


Received: (at 68547) by debbugs.gnu.org; 20 Jan 2024 12:02:10 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Jan 20 07:02:10 2024
Received: from localhost ([127.0.0.1]:33095 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rRA37-0007pR-8s
	for submit <at> debbugs.gnu.org; Sat, 20 Jan 2024 07:02:10 -0500
Received: from mail-lf1-x12c.google.com ([2a00:1450:4864:20::12c]:57606)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <joaotavora@HIDDEN>) id 1rRA35-0007kw-Ba
 for 68547 <at> debbugs.gnu.org; Sat, 20 Jan 2024 07:02:08 -0500
Received: by mail-lf1-x12c.google.com with SMTP id
 2adb3069b0e04-50e766937ddso1987944e87.3
 for <68547 <at> debbugs.gnu.org>; Sat, 20 Jan 2024 04:02:04 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1705752118; x=1706356918; darn=debbugs.gnu.org;
 h=content-transfer-encoding:cc:to:subject:message-id:date:from
 :in-reply-to:references:mime-version:from:to:cc:subject:date
 :message-id:reply-to;
 bh=W5tYt4hrprHvvuTKGDdRVFPW7TenRME8IJ23alEp2vM=;
 b=DY6rHwspDBzS/frsFiPGBAQWJQjzgDXMKvdqsBTzoLFSb40VdBVJbmokOFSOgdYhrQ
 /+kHys9zGnDAJ2kLbffigTdaltXeydryu5yh3EaTjSrnQn6YWu3f0foyQDoPVvUV8fqX
 UkjCgnFGHg1/zCk9WolRuKm001Lv6jH75rJIqvlQebL9pK9IgUqnFUiu5o1f92LUwXlk
 5QGuG9vBmkA49bzIEiIdfyE51+FXVrbyb3Bv78m/6ryvOf23aC3smbkzoL6mcVOVeCCS
 1hTVBg+HxQHnOdghAA7iJoDpKbvcOwp7V8Sagn/onuuYdWi3gW8sW3qkiM3DNEOTWLcb
 F9Kw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1705752118; x=1706356918;
 h=content-transfer-encoding:cc:to:subject:message-id:date:from
 :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc
 :subject:date:message-id:reply-to;
 bh=W5tYt4hrprHvvuTKGDdRVFPW7TenRME8IJ23alEp2vM=;
 b=msHnb5q2JGOfdR5NSpjp2I9d2on8unPbv1ETLGMRGpnpMIkgv1kWwj/Ub0i27SVzL0
 Pktuw6dyTXVhkpaW5PlgiAHHmBITKZNq7zO2YqgiB+bdoeZEn0sC6QPmkzU1JIlmsXl2
 eeekC/KTEbHVEO7ot/wYskTpKYqzeeShs/91NVvgvrL47VyGggnCC9V3MFZDkhl/mARd
 wj7CriAmknueAi5Vq5xk3XSpNBIv0uzpwzBm7eM9Z1pB1B3sLMRTgFRp702FhOLYbCoB
 4YL3roXbN1iqGe64GtjnwFbhD7QHoEhapVH1lysXJVl5UYeY7st8yiKd+GjB6WDAMyQP
 Z5qQ==
X-Gm-Message-State: AOJu0Yzswfk+oFAoHcl7FlTeDFoQHsm4WT5jJmfwJxHh18mQy7BoBF0S
 x/f4ML8nPMv7/3ODfCXTiTGHtnEnbvOTICrxURf1dYZgzv/xL7WXDBpyRa45nfdWGACm/7y3S9Q
 iLwaY9V34ld0jRVKcMzyBxVal3t8=
X-Google-Smtp-Source: AGHT+IE9po3C+sZEFkc/bkIuU5+YzjVc6zRcrEzFQAZfttMmgdzfPqocVRHrMzln2v3vze1iyxr23bSETDjIvAClja8=
X-Received: by 2002:a05:6512:550:b0:50e:4bf6:8848 with SMTP id
 h16-20020a056512055000b0050e4bf68848mr438879lfl.38.1705752118338; Sat, 20 Jan
 2024 04:01:58 -0800 (PST)
MIME-Version: 1.0
References: <m14jfbg2yj.fsf@HIDDEN> <83cytwtjiw.fsf@HIDDEN>
 <CALDnm53Z4LppG7AUej2W5qrD_8MyA6YmYvZFFOpK5ULfv62j_w@HIDDEN>
 <m1edec9sq6.fsf@HIDDEN>
In-Reply-To: <m1edec9sq6.fsf@HIDDEN>
From: =?UTF-8?B?Sm/Do28gVMOhdm9yYQ==?= <joaotavora@HIDDEN>
Date: Sat, 20 Jan 2024 12:01:46 +0000
Message-ID: <CALDnm50RA9ph-Dm8sWy7vzBm7y_0qqauM4AU6V7iB6FKgxeTXw@HIDDEN>
Subject: Re: bug#68547: [PATCH] ; Fix 'mode-line-format-right-align' with ElDoc
To: Eshel Yaron <me@HIDDEN>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: 68547
Cc: Eli Zaretskii <eliz@HIDDEN>, 68547 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

On Sat, Jan 20, 2024 at 10:58=E2=80=AFAM Eshel Yaron <me@HIDDEN> wr=
ote:
>
> Jo=C3=A3o T=C3=A1vora <joaotavora@HIDDEN> writes:
>
> > On Sat, Jan 20, 2024 at 9:57=E2=80=AFAM Eli Zaretskii <eliz@HIDDEN> wr=
ote:
> >>
> >> > Date: Wed, 17 Jan 2024 20:44:04 +0100
> >> > From:  Eshel Yaron via "Bug reports for GNU Emacs,
> >> >  the Swiss army knife of text editors" <bug-gnu-emacs@HIDDEN>
> >> >
> >> > Tags: patch
> >> >
> >> > The new mode line right alignment requires setting `mode-line-format=
` to
> >> > a list that contains (as in `memq`) the symbol
> >> > `mode-line-format-right-align`.  This is a bit brittle, and currentl=
y
> >> > `eldoc-minibuffer-message` modifies `mode-line-format` in a way that
> >> > happens to break `mode-line-format-right-align`.  To see that, set
> >> > `mode-line-format` to '("" mode-line-format-right-align "foo bar") a=
nd
> >> > then type `M-: (list`.  Now ElDoc info appears on the mode line, but
> >> > "bar" is no longer visible.
> >> >
> >> > This patch makes ElDoc modify `mode-line-format` in an equivalent wa=
y
> >> > that avoids messing with `mode-line-format-right-align`.
> >>
> >> Thanks.
> >>
> >> Jo=C3=A3o, any objections or comments?
> >
> > I think it looks good.  I just think the patch is a little
> > too newline friendly, i.e. the if can probably fit in a single
> > line without reaching 80 columns and it'll make it easier to
> > read.
>
> Yes, it fits nicely.  See updated patch below.

Thanks.  I pushed it.  I'm going to look at this function though,
since I don't I love the logic of destroying any old buffer's
mode-line-format and not restoring after the minibuffer is
exited.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#68547; Package emacs. Full text available.

Message received at 68547 <at> debbugs.gnu.org:


Received: (at 68547) by debbugs.gnu.org; 20 Jan 2024 10:58:33 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Jan 20 05:58:32 2024
Received: from localhost ([127.0.0.1]:32967 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rR93Y-0000fn-IU
	for submit <at> debbugs.gnu.org; Sat, 20 Jan 2024 05:58:32 -0500
Received: from mail.eshelyaron.com ([107.175.124.16]:58918 helo=eshelyaron.com)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <me@HIDDEN>) id 1rR93W-0000ff-M7
 for 68547 <at> debbugs.gnu.org; Sat, 20 Jan 2024 05:58:31 -0500
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=eshelyaron.com;
 s=mail; t=1705748307;
 bh=A8o4ROldKXjWXkKnkMWOs2gkqpCeOCpJc4W4YS0U8mY=;
 h=From:To:Cc:Subject:In-Reply-To:References:Date:From;
 b=QOGm1eoNzQe2MY4HJ4PyyqBKqwDurJxz1XBYFkt80FhqIAbO2pa6WUKerWFN9InVv
 e9kV6oe6VD69/ohfS/lxLym6+xgILBr60hlH/Zr3yo6/bQLFbN0TMBvBvwEti4UvyC
 A8uuvOtIqs2BPDFgXv2LvxTxc0PIEczEvqiDhvCL4zgf9DIqCHrRAeOnLOqJSfUQV/
 7UiSEh0892ySxrSnupMCC/o0CJP5RE/JCb7ibdx3lKcj6NfDp9YdYvT4s74g3jbiFh
 SyIaeIxmzdEL9toF9J7EqIiVmM0UFKCXSoBRjVEYz0kgNQtIrANmtsnQLp9QZBU5gB
 4Adi7AhvQ/QhA==
From: Eshel Yaron <me@HIDDEN>
To: =?utf-8?B?Sm/Do28gVMOhdm9yYQ==?= <joaotavora@HIDDEN>
Subject: Re: bug#68547: [PATCH] ; Fix 'mode-line-format-right-align' with ElDoc
In-Reply-To: <CALDnm53Z4LppG7AUej2W5qrD_8MyA6YmYvZFFOpK5ULfv62j_w@HIDDEN>
 (=?utf-8?Q?=22Jo=C3=A3o_T=C3=A1vora=22's?= message of "Sat, 20 Jan 2024
 10:20:39 +0000")
References: <m14jfbg2yj.fsf@HIDDEN> <83cytwtjiw.fsf@HIDDEN>
 <CALDnm53Z4LppG7AUej2W5qrD_8MyA6YmYvZFFOpK5ULfv62j_w@HIDDEN>
Date: Sat, 20 Jan 2024 11:58:25 +0100
Message-ID: <m1edec9sq6.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="=-=-="
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: 68547
Cc: Eli Zaretskii <eliz@HIDDEN>, 68547 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

--=-=-=
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable

Jo=C3=A3o T=C3=A1vora <joaotavora@HIDDEN> writes:

> On Sat, Jan 20, 2024 at 9:57=E2=80=AFAM Eli Zaretskii <eliz@HIDDEN> wrot=
e:
>>
>> > Date: Wed, 17 Jan 2024 20:44:04 +0100
>> > From:  Eshel Yaron via "Bug reports for GNU Emacs,
>> >  the Swiss army knife of text editors" <bug-gnu-emacs@HIDDEN>
>> >
>> > Tags: patch
>> >
>> > The new mode line right alignment requires setting `mode-line-format` =
to
>> > a list that contains (as in `memq`) the symbol
>> > `mode-line-format-right-align`.  This is a bit brittle, and currently
>> > `eldoc-minibuffer-message` modifies `mode-line-format` in a way that
>> > happens to break `mode-line-format-right-align`.  To see that, set
>> > `mode-line-format` to '("" mode-line-format-right-align "foo bar") and
>> > then type `M-: (list`.  Now ElDoc info appears on the mode line, but
>> > "bar" is no longer visible.
>> >
>> > This patch makes ElDoc modify `mode-line-format` in an equivalent way
>> > that avoids messing with `mode-line-format-right-align`.
>>
>> Thanks.
>>
>> Jo=C3=A3o, any objections or comments?
>
> I think it looks good.  I just think the patch is a little
> too newline friendly, i.e. the if can probably fit in a single
> line without reaching 80 columns and it'll make it easier to
> read.

Yes, it fits nicely.  See updated patch below.


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=v2-0001-Fix-mode-line-format-right-align-with-ElDoc-Bug-6.patch

From 9c69e20ed172a2bfa56056a62077ae1c68b9b979 Mon Sep 17 00:00:00 2001
From: Eshel Yaron <me@HIDDEN>
Date: Mon, 1 Jan 2024 22:14:59 +0100
Subject: [PATCH v2] ; Fix 'mode-line-format-right-align' with ElDoc
 (Bug#68547)

* lisp/emacs-lisp/eldoc.el (eldoc-minibuffer-message): Avoid nesting
'mode-line-format', since that breaks 'mode-line-format-right-align'.
---
 lisp/emacs-lisp/eldoc.el | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/lisp/emacs-lisp/eldoc.el b/lisp/emacs-lisp/eldoc.el
index 06970d40e8a..912a7357ca7 100644
--- a/lisp/emacs-lisp/eldoc.el
+++ b/lisp/emacs-lisp/eldoc.el
@@ -312,9 +312,11 @@ eldoc-minibuffer-message
                      (not (and (listp mode-line-format)
                                (assq 'eldoc-mode-line-string mode-line-format))))
 	    (setq mode-line-format
-		  (list "" '(eldoc-mode-line-string
-			     (" " eldoc-mode-line-string " "))
-			mode-line-format)))
+                  (funcall
+                   (if (listp mode-line-format) #'append #'list)
+                   (list "" '(eldoc-mode-line-string
+			      (" " eldoc-mode-line-string " ")))
+                   mode-line-format)))
           (setq eldoc-mode-line-string
                 (when (stringp format-string)
                   (apply #'format-message format-string args)))
-- 
2.42.0


--=-=-=--




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#68547; Package emacs. Full text available.

Message received at 68547 <at> debbugs.gnu.org:


Received: (at 68547) by debbugs.gnu.org; 20 Jan 2024 10:21:00 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Jan 20 05:21:00 2024
Received: from localhost ([127.0.0.1]:32931 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rR8TE-0002lH-Ak
	for submit <at> debbugs.gnu.org; Sat, 20 Jan 2024 05:21:00 -0500
Received: from mail-lf1-x134.google.com ([2a00:1450:4864:20::134]:51684)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <joaotavora@HIDDEN>) id 1rR8TD-0002l2-9d
 for 68547 <at> debbugs.gnu.org; Sat, 20 Jan 2024 05:20:59 -0500
Received: by mail-lf1-x134.google.com with SMTP id
 2adb3069b0e04-50edf4f478eso2090479e87.3
 for <68547 <at> debbugs.gnu.org>; Sat, 20 Jan 2024 02:20:56 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1705746050; x=1706350850; darn=debbugs.gnu.org;
 h=content-transfer-encoding:cc:to:subject:message-id:date:from
 :in-reply-to:references:mime-version:from:to:cc:subject:date
 :message-id:reply-to;
 bh=EfXe87u4YvlethQXMy5E48bGARbf4PNpxb0h87jmWvU=;
 b=mm6H4VLYg2uc29gyVSd2VEsb26iO1aWtYCIedfXPWMIsWeO57zeVLTTmuRsTX6e4rw
 DGYt1p2tnBxhdwQj95S9J6mSmsSQE71aRTET020xSlyOsVUUD2GLZ9P+8TmeKBvuQlIG
 FjSWBIt0tN/ZGG9kRM+s7ikod1uYjAiARwv4L7TgYPqdYAViicAMTdOO9z1afXBUONQ0
 g8ThWECcpLp59hPj3AHrlMRAPyee79i9gDzjrOL4uEeTSAf00ZuHyvinqnQz/THMtCxI
 xhUsdBXzgDKrvubOcrWVZj1xCbDIiqigXxpbXRFw27nbu/kxiRfFcYPYmnpKBw7b+rJq
 OBug==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1705746050; x=1706350850;
 h=content-transfer-encoding:cc:to:subject:message-id:date:from
 :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc
 :subject:date:message-id:reply-to;
 bh=EfXe87u4YvlethQXMy5E48bGARbf4PNpxb0h87jmWvU=;
 b=thXyhi3vzw57TAF2FGwORh4szDKzSkfhIZ1QPqFYqPQi/9f5eN+lj5GIi+uVf+miBB
 dfCc5Wwk2XPIKvkrJmsidh6QTdRE5yr41jjLDmIm3VWOfYgr8zhEVyYSbFkpFUWv8kn+
 eLTsZZN7OeueWFvm7D1kQUMjvZdWfDsRRlNikTVtv/gsfXx4+aUyLrUPIVZumHihk89f
 E8wGit15f9rR8hiWr6YP+UP84R9pEZpPbtI5zWDTIL8P7kc627xEEiLmDYsdxz7P9ypj
 aYvuK6rcxdim1flIGi1eBXDk4UbQh+oQ80t4GcyrcGTkKNo6oHtJvhola2CAFbNAWaGe
 rSTg==
X-Gm-Message-State: AOJu0YwcoPy1pZJ5jNQ/BVxJZISRHgdIS+oO9zQ2ZQhM0RGsOXYkbcnh
 ldfeo/VRiXwkYaOwKnWuJJgMF3eNrq5NXuVViv/e3Hau4D8o43k+vB7hew2cvoaPA1dEtfOIlI3
 e3wEUz+G2zzM0IdqdoOJgjFBXups=
X-Google-Smtp-Source: AGHT+IGvesOG6ydC+LkPu66rd6OeOA8PDhMV3voZZIvZ1MTHzD/NKZNKlszcsj0oMfwPSxRsx2dPkBgAw8Xk8PbFwHw=
X-Received: by 2002:a05:6512:554:b0:50e:42d7:21fa with SMTP id
 h20-20020a056512055400b0050e42d721famr461631lfl.107.1705746050363; Sat, 20
 Jan 2024 02:20:50 -0800 (PST)
MIME-Version: 1.0
References: <m14jfbg2yj.fsf@HIDDEN> <83cytwtjiw.fsf@HIDDEN>
In-Reply-To: <83cytwtjiw.fsf@HIDDEN>
From: =?UTF-8?B?Sm/Do28gVMOhdm9yYQ==?= <joaotavora@HIDDEN>
Date: Sat, 20 Jan 2024 10:20:39 +0000
Message-ID: <CALDnm53Z4LppG7AUej2W5qrD_8MyA6YmYvZFFOpK5ULfv62j_w@HIDDEN>
Subject: Re: bug#68547: [PATCH] ; Fix 'mode-line-format-right-align' with ElDoc
To: Eli Zaretskii <eliz@HIDDEN>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: 68547
Cc: Eshel Yaron <me@HIDDEN>, 68547 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

On Sat, Jan 20, 2024 at 9:57=E2=80=AFAM Eli Zaretskii <eliz@HIDDEN> wrote:
>
> > Date: Wed, 17 Jan 2024 20:44:04 +0100
> > From:  Eshel Yaron via "Bug reports for GNU Emacs,
> >  the Swiss army knife of text editors" <bug-gnu-emacs@HIDDEN>
> >
> > Tags: patch
> >
> > The new mode line right alignment requires setting `mode-line-format` t=
o
> > a list that contains (as in `memq`) the symbol
> > `mode-line-format-right-align`.  This is a bit brittle, and currently
> > `eldoc-minibuffer-message` modifies `mode-line-format` in a way that
> > happens to break `mode-line-format-right-align`.  To see that, set
> > `mode-line-format` to '("" mode-line-format-right-align "foo bar") and
> > then type `M-: (list`.  Now ElDoc info appears on the mode line, but
> > "bar" is no longer visible.
> >
> > This patch makes ElDoc modify `mode-line-format` in an equivalent way
> > that avoids messing with `mode-line-format-right-align`.
>
> Thanks.
>
> Jo=C3=A3o, any objections or comments?

I think it looks good.  I just think the patch is a little
too newline friendly, i.e. the if can probably fit in a single
line without reaching 80 columns and it'll make it easier to
read.

Jo=C3=A3o




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#68547; Package emacs. Full text available.

Message received at 68547 <at> debbugs.gnu.org:


Received: (at 68547) by debbugs.gnu.org; 20 Jan 2024 09:57:25 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Jan 20 04:57:25 2024
Received: from localhost ([127.0.0.1]:60900 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rR86P-0004z1-HQ
	for submit <at> debbugs.gnu.org; Sat, 20 Jan 2024 04:57:25 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10]:58976)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1rR86O-0004yo-GH
 for 68547 <at> debbugs.gnu.org; Sat, 20 Jan 2024 04:57:24 -0500
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1rR86G-0000TX-9C; Sat, 20 Jan 2024 04:57:16 -0500
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From:
 Date; bh=wOjj8QgOMz+KPzXIrhIEgU75ddZZYUKU/rZeNJRPXz0=; b=l7o+IUAUsH21xZKZP8lX
 8F4uFEqVKTU2qMDyo1+lhZvwpb4o2RbDtLzAaZITmXtcoj2qUqf9O7YLaaqYt7lxfJBM5s8F4L2Uk
 PkVc9BeMHkEbrU6LRFWQ6jZnS9xW9be80dYuKVBy2uN70wIxSp6iEErHhYchu28ZqNOSV4uRaJx1H
 41EZ3iqdabQJGqVN3TLPKdLnSTSHAc854QlQ98jqZzxO5Jtvt0lOv4VSqr/A2rRaEqwbUUCATruZ+
 w8kgbcR4XTN3EgUo05lbHl7ydS2OsQhBGWGstBuTnB5P5nkuwyNC+ymxbOc7Pbc7GXcXSpQIoHCk3
 MEWpK4ZmGm3bzg==;
Date: Sat, 20 Jan 2024 11:56:55 +0200
Message-Id: <83cytwtjiw.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Eshel Yaron <me@HIDDEN>, =?iso-8859-1?Q?Jo=E3o_T=E1vora?=
 <joaotavora@HIDDEN>
In-Reply-To: <m14jfbg2yj.fsf@HIDDEN> (bug-gnu-emacs@HIDDEN)
Subject: Re: bug#68547: [PATCH] ; Fix 'mode-line-format-right-align' with ElDoc
References: <m14jfbg2yj.fsf@HIDDEN>
MIME-version: 1.0
Content-type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 68547
Cc: 68547 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> Date: Wed, 17 Jan 2024 20:44:04 +0100
> From:  Eshel Yaron via "Bug reports for GNU Emacs,
>  the Swiss army knife of text editors" <bug-gnu-emacs@HIDDEN>
> 
> Tags: patch
> 
> The new mode line right alignment requires setting `mode-line-format` to
> a list that contains (as in `memq`) the symbol
> `mode-line-format-right-align`.  This is a bit brittle, and currently
> `eldoc-minibuffer-message` modifies `mode-line-format` in a way that
> happens to break `mode-line-format-right-align`.  To see that, set
> `mode-line-format` to '("" mode-line-format-right-align "foo bar") and
> then type `M-: (list`.  Now ElDoc info appears on the mode line, but
> "bar" is no longer visible.
> 
> This patch makes ElDoc modify `mode-line-format` in an equivalent way
> that avoids messing with `mode-line-format-right-align`.

Thanks.

João, any objections or comments?




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#68547; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 17 Jan 2024 19:44:18 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Jan 17 14:44:18 2024
Received: from localhost ([127.0.0.1]:53541 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rQBpi-0007Mr-1D
	for submit <at> debbugs.gnu.org; Wed, 17 Jan 2024 14:44:18 -0500
Received: from lists.gnu.org ([2001:470:142::17]:42716)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <me@HIDDEN>) id 1rQBpf-0007Mb-Oc
 for submit <at> debbugs.gnu.org; Wed, 17 Jan 2024 14:44:16 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10])
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <me@HIDDEN>) id 1rQBpY-0003Cc-MB
 for bug-gnu-emacs@HIDDEN; Wed, 17 Jan 2024 14:44:08 -0500
Received: from mail.eshelyaron.com ([107.175.124.16] helo=eshelyaron.com)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <me@HIDDEN>) id 1rQBpX-0004rP-3p
 for bug-gnu-emacs@HIDDEN; Wed, 17 Jan 2024 14:44:08 -0500
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=eshelyaron.com;
 s=mail; t=1705520646;
 bh=7Sfei4ztzVKngsz6oVkXcj/6/zIEMOe0uffJCIADVp4=;
 h=From:To:Subject:Date:From;
 b=mOOaYG0Wp/iFdOBe5wWE+iQSHsR7L4iwQg/OWoXrbYXAd7oWMP/YKAwP97wzVPaO/
 q8P8Iq2oAKwg/V0TIi7bk8Sjo4DHU8wHEWY9AacexBXyOZPBuG55VPFrFyJp7NltNo
 m2paJA2CNSN6yYxkGUlnvlAX5iTM/wVmlGwOWEsmP3s6sDUOz6f5ZPnixhLFHopFe1
 dC9oOZWDZQYB4Iu7RVgQ+UbiSsvXELbQtKZrw68eSQkFJ4EqSIIUG5lsc6Jwh/luWh
 zR9YeQYgSc9ucj8p88RIzkzWThJI6b8T31HlX/NVqzl4Sc0tjgFpjyMgOshufBEj0j
 ix4JfM/Gsdplw==
From: Eshel Yaron <me@HIDDEN>
To: bug-gnu-emacs@HIDDEN
Subject: [PATCH] ; Fix 'mode-line-format-right-align' with ElDoc
X-Hashcash: 1:20:240117:bug-gnu-emacs@HIDDEN::5LAWlTBilvOqUJ7p:05no
Date: Wed, 17 Jan 2024 20:44:04 +0100
Message-ID: <m14jfbg2yj.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="=-=-="
Received-SPF: pass client-ip=107.175.124.16; envelope-from=me@HIDDEN;
 helo=eshelyaron.com
X-Spam_score_int: -20
X-Spam_score: -2.1
X-Spam_bar: --
X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001,
 SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: 0.9 (/)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.1 (/)

--=-=-=
Content-Type: text/plain

Tags: patch

The new mode line right alignment requires setting `mode-line-format` to
a list that contains (as in `memq`) the symbol
`mode-line-format-right-align`.  This is a bit brittle, and currently
`eldoc-minibuffer-message` modifies `mode-line-format` in a way that
happens to break `mode-line-format-right-align`.  To see that, set
`mode-line-format` to '("" mode-line-format-right-align "foo bar") and
then type `M-: (list`.  Now ElDoc info appears on the mode line, but
"bar" is no longer visible.

This patch makes ElDoc modify `mode-line-format` in an equivalent way
that avoids messing with `mode-line-format-right-align`.


--=-=-=
Content-Type: text/patch
Content-Disposition: attachment;
 filename=0001-Fix-mode-line-format-right-align-with-ElDoc.patch

From 5d8568e00c2c36ce2fbc7554635868826ec5009a Mon Sep 17 00:00:00 2001
From: Eshel Yaron <me@HIDDEN>
Date: Mon, 1 Jan 2024 22:14:59 +0100
Subject: [PATCH] ; Fix 'mode-line-format-right-align' with ElDoc

* lisp/emacs-lisp/eldoc.el (eldoc-minibuffer-message): Avoid nesting
'mode-line-format', since that breaks 'mode-line-format-right-align'.
---
 lisp/emacs-lisp/eldoc.el | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/lisp/emacs-lisp/eldoc.el b/lisp/emacs-lisp/eldoc.el
index 4ee825136c9..a4faa25fd31 100644
--- a/lisp/emacs-lisp/eldoc.el
+++ b/lisp/emacs-lisp/eldoc.el
@@ -312,9 +312,13 @@ eldoc-minibuffer-message
                      (not (and (listp mode-line-format)
                                (assq 'eldoc-mode-line-string mode-line-format))))
 	    (setq mode-line-format
-		  (list "" '(eldoc-mode-line-string
-			     (" " eldoc-mode-line-string " "))
-			mode-line-format)))
+                  (funcall
+                   (if (listp mode-line-format)
+                       #'append
+                     #'list)
+                   (list "" '(eldoc-mode-line-string
+			      (" " eldoc-mode-line-string " ")))
+                   mode-line-format)))
           (setq eldoc-mode-line-string
                 (when (stringp format-string)
                   (apply #'format-message format-string args)))
-- 
2.42.0


--=-=-=--




Acknowledgement sent to Eshel Yaron <me@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#68547; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Thu, 6 Mar 2025 03:45:01 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.