unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: "Drew Adams" <drew.adams@oracle.com>
To: 11756@debbugs.gnu.org
Subject: bug#11756: 24.1.50; mode-line string and properties
Date: Wed, 20 Jun 2012 17:27:09 -0700	[thread overview]
Message-ID: <FBFF432C6A184C7FA5C381F4ADBED459@us.oracle.com> (raw)

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@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'
 






             reply	other threads:[~2012-06-21  0:27 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-21  0:27 Drew Adams [this message]
2012-06-21  1:20 ` bug#11756: 24.1.50; mode-line string and properties Michael Heerdegen
2012-06-21  7:24   ` Andreas Schwab
2012-06-21 14:01     ` Drew Adams
2021-08-23 15:00       ` Lars Ingebrigtsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=FBFF432C6A184C7FA5C381F4ADBED459@us.oracle.com \
    --to=drew.adams@oracle.com \
    --cc=11756@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).