GNU bug report logs - #11756
24.1.50; mode-line string and properties

Previous Next

Package: emacs;

Reported by: "Drew Adams" <drew.adams <at> oracle.com>

Date: Thu, 21 Jun 2012 00:32:02 UTC

Severity: normal

Tags: wontfix

Found in version 24.1.50

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 11756 in the body.
You can then email your comments to 11756 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#11756; Package emacs. (Thu, 21 Jun 2012 00:32:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to "Drew Adams" <drew.adams <at> oracle.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Thu, 21 Jun 2012 00:32:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: "Drew Adams" <drew.adams <at> oracle.com>
To: <bug-gnu-emacs <at> gnu.org>
Subject: 24.1.50; mode-line string and properties
Date: Wed, 20 Jun 2012 17:27:09 -0700
Consider this snippet from Dired+:
 
(setq mode-name
      `(,(format "Dired/%s"
                 (match-string 2 mode-name))
        (:eval (let* ((dired-marker-char
                       (if (eq ?D dired-marker-char)
                           ?*           ; `dired-do-flagged-delete' binds it.
                         dired-marker-char))
                      (marked-regexp  (dired-marker-regexp))
                      (nb-marked
                       (count-matches marked-regexp (point-min) (point-max))))
                 (if (not (> nb-marked 0))
                     ""
                   (propertize
                    (format
                     " %s%d%c"
                     (save-excursion
                       (forward-line 0)
                       (if (looking-at (concat marked-regexp ".*"))
                           (format "%d/" (1+ (count-matches
                                              marked-regexp (point-min)
(point))))
                         ""))
                     nb-marked dired-marker-char)
                    'face 'diredp-mode-line-marked))))
        (:eval (let* ((flagged-regexp  (let ((dired-marker-char
dired-del-marker))
                                         (dired-marker-regexp)))
                      (nb-flagged      (count-matches
                                        flagged-regexp (point-min)
(point-max))))
                 (if (not (> nb-flagged 0))
                     ""
                   (propertize
                    (format " %s%dD"
                            (save-excursion
                              (forward-line 0)
                              (if (looking-at (concat flagged-regexp ".*"))
                                  (format "%d/" (1+ (count-matches
                                                     flagged-regexp
                                                     (point-min) (point))))
                                ""))
                            nb-flagged)
                    'face 'diredp-mode-line-flagged))))))
 
Here we set `mode-name' to a list of three items: a string and
two :eval constructs that each evaluate to a string.
 
The result in the mode line is that what _should_ act as a single unit,
the `mode-name', ends up acting like 3 separate units, duplicates
except for their strings: same mouseover tooltip, same popup menus.
This is not good.
 
What's the alternative?  I tried using just one :eval construct that
produces a single string of the concatenated substrings.  That solves
the problem just mentioned, but introduces a worse problem: The
propertized portions of the string are ignored.
 
Or if you use two constructs: the first string from above and a single
:eval that concatenates the other two strings, then you get two
mode-line units (two popups etc.) (so the first problem isn't really
solved), and the face of the last string is ignored - the face of the
middle string is used for the whole second unit.
 
In sum, we should be able to use a propertized string as the value of
something like `mode-name', and have different portions of the string be
propertized with different faces.  You can define it that way, but what
you see in the code is not what you get in the mode line.

In GNU Emacs 24.1.50.1 (i386-mingw-nt5.1.2600)
 of 2012-06-18 on MARVIN
Bzr revision: 108646 michael.albinus <at> gmx.de-20120617185439-jfcgwwbr97nbflkz
Windowing system distributor `Microsoft Corp.', version 5.1.2600
Configured using:
 `configure --with-gcc (4.6) --no-opt --enable-checking --cflags
 -ID:/devel/emacs/libs/libXpm-3.5.8/include
 -ID:/devel/emacs/libs/libXpm-3.5.8/src
 -ID:/devel/emacs/libs/libpng-dev_1.4.3-1/include
 -ID:/devel/emacs/libs/zlib-dev_1.2.5-2/include
 -ID:/devel/emacs/libs/giflib-4.1.4-1/include
 -ID:/devel/emacs/libs/jpeg-6b-4/include
 -ID:/devel/emacs/libs/tiff-3.8.2-1/include
 -ID:/devel/emacs/libs/gnutls-3.0.9/include
 -ID:/devel/emacs/libs/libiconv-1.13.1-1-dev/include
 -ID:/devel/emacs/libs/libxml2-2.7.8/include/libxml2'
 





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#11756; Package emacs. (Thu, 21 Jun 2012 01:22:02 GMT) Full text and rfc822 format available.

Message #8 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Michael Heerdegen <michael_heerdegen <at> web.de>
To: bug-gnu-emacs <at> gnu.org
Subject: Re: bug#11756: 24.1.50; mode-line string and properties
Date: Thu, 21 Jun 2012 03:20:09 +0200
Hi,

to see with a short recipe that there is something wrong, try this in
emacs -Q:

  (setq A-red_B-C
        '(:eval (concat "A" (propertize "B" 'face 'font-lock-warning-face) "C"))
        red_B
        '(:eval (propertize "B" 'face 'font-lock-warning-face)))
  
  (setq mode-name red_B) ;; works
  
  (setq mode-name A-red_B-C) ;; doesn't work
  
  (setq mode-line-format A-red_B-C) ;; works


Michael.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#11756; Package emacs. (Thu, 21 Jun 2012 07:28:02 GMT) Full text and rfc822 format available.

Message #11 received at 11756 <at> debbugs.gnu.org (full text, mbox):

From: Andreas Schwab <schwab <at> linux-m68k.org>
To: Michael Heerdegen <michael_heerdegen <at> web.de>
Cc: 11756 <at> debbugs.gnu.org
Subject: Re: bug#11756: 24.1.50; mode-line string and properties
Date: Thu, 21 Jun 2012 09:24:18 +0200
Michael Heerdegen <michael_heerdegen <at> web.de> writes:

> to see with a short recipe that there is something wrong, try this in
> emacs -Q:
>
>   (setq A-red_B-C
>         '(:eval (concat "A" (propertize "B" 'face 'font-lock-warning-face) "C"))

The property merging done by display_mode_element is very simple-minded.
Only the properties on the first character are used, and it is assumed
that they are placed over the whole string.

Andreas.

-- 
Andreas Schwab, schwab <at> linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#11756; Package emacs. (Thu, 21 Jun 2012 14:06:02 GMT) Full text and rfc822 format available.

Message #14 received at 11756 <at> debbugs.gnu.org (full text, mbox):

From: "Drew Adams" <drew.adams <at> oracle.com>
To: "'Andreas Schwab'" <schwab <at> linux-m68k.org>,
	"'Michael Heerdegen'" <michael_heerdegen <at> web.de>
Cc: 11756 <at> debbugs.gnu.org
Subject: RE: bug#11756: 24.1.50; mode-line string and properties
Date: Thu, 21 Jun 2012 07:01:33 -0700
> > to see with a short recipe that there is something wrong, 
> > try this in emacs -Q:
> >
> >   (setq A-red_B-C
> >         '(:eval (concat "A" (propertize "B" 'face 
> >                              'font-lock-warning-face) "C"))
> 
> The property merging done by display_mode_element is very 
> simple-minded.  Only the properties on the first character
> are used, and it is assumed that they are placed over the
> whole string.

So I guess that's what needs to be fixed then.





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#11756; Package emacs. (Mon, 23 Aug 2021 15:01:02 GMT) Full text and rfc822 format available.

Message #17 received at 11756 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: "Drew Adams" <drew.adams <at> oracle.com>
Cc: 'Michael Heerdegen' <michael_heerdegen <at> web.de>, 11756 <at> debbugs.gnu.org,
 'Andreas Schwab' <schwab <at> linux-m68k.org>
Subject: Re: bug#11756: 24.1.50; mode-line string and properties
Date: Mon, 23 Aug 2021 17:00:14 +0200
"Drew Adams" <drew.adams <at> oracle.com> writes:

>> The property merging done by display_mode_element is very 
>> simple-minded.  Only the properties on the first character
>> are used, and it is assumed that they are placed over the
>> whole string.
>
> So I guess that's what needs to be fixed then.

This wasn't documented before, but it's been made explicit recentlyish.
The reason for this is because we want to the mode lines to be very fast
(and create as little garbage as possible).

If you want to have different text properties over stretches of a
string, you have to chop the string up and use the :propertize mode line
construct.

So I'm closing this bug report.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Added tag(s) wontfix. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Mon, 23 Aug 2021 15:01:02 GMT) Full text and rfc822 format available.

bug closed, send any further explanations to 11756 <at> debbugs.gnu.org and "Drew Adams" <drew.adams <at> oracle.com> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Mon, 23 Aug 2021 15:01:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Tue, 21 Sep 2021 11:24:05 GMT) Full text and rfc822 format available.

This bug report was last modified 3 years and 324 days ago.

Previous Next


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