[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#11756: 24.1.50; mode-line string and properties

From: Drew Adams
Subject: bug#11756: 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.
                      (marked-regexp  (dired-marker-regexp))
                       (count-matches marked-regexp (point-min) (point-max))))
                 (if (not (> nb-marked 0))
                     " %s%d%c"
                       (forward-line 0)
                       (if (looking-at (concat marked-regexp ".*"))
                           (format "%d/" (1+ (count-matches
                                              marked-regexp (point-min)
                     nb-marked dired-marker-char)
                    'face 'diredp-mode-line-marked))))
        (:eval (let* ((flagged-regexp  (let ((dired-marker-char
                      (nb-flagged      (count-matches
                                        flagged-regexp (point-min)
                 (if (not (> nb-flagged 0))
                    (format " %s%dD"
                              (forward-line 0)
                              (if (looking-at (concat flagged-regexp ".*"))
                                  (format "%d/" (1+ (count-matches
                                                     (point-min) (point))))
                    '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 (i386-mingw-nt5.1.2600)
 of 2012-06-18 on MARVIN
Bzr revision: 108646 address@hidden
Windowing system distributor `Microsoft Corp.', version 5.1.2600
Configured using:
 `configure --with-gcc (4.6) --no-opt --enable-checking --cflags

reply via email to

[Prev in Thread] Current Thread [Next in Thread]