From: Joost Kremers <joostkremers@fastmail.fm>
To: gnu-emacs-help@gnu.org
Subject: mode line construct question
Date: Wed, 28 Aug 2024 11:18:51 +0200 [thread overview]
Message-ID: <86frqp57k4.fsf@fastmail.fm> (raw)
Hi list,
I'm trying to prettify my mode line a bit, but am running into a strange
issue.
Specifically, I'm trying to modify the way pyvenv.el[1] displays the
virtual environment in the mode line. The package itself defines a variable
`pyvenv-mode-line-indicator`:
```
(defvar pyvenv-mode-line-indicator '(pyvenv-virtual-env-name
("[" pyvenv-virtual-env-name "] ")))
```
Then it adds the following to `mode-line-misc-info`:
```
(add-to-list 'mode-line-misc-info '(pyvenv-mode pyvenv-mode-line-indicator))
```
This works, but because my virtual environment names contain a hash for the
project's directory path, they are rather long and ugly. So I was hoping to
redefine `pyvenv-mode-line-indicator` to something like this:
```
(setq pyvenv-mode-line-indicator
'(pyvenv-virtual-env-name
("[" (:eval (jk-pyvenv-prettify-name pyvenv-virtual-env-name)) "] ")))
```
Where the function `jk-pyvenv-prettify-name` takes the venv's name (which
is just a string) and returns a prettified version of it.
Problem is, this doesn't work... As soon as I add an `:eval` construct to
the value of `pyvenv-mode-line-indicator`, it stops working. All I see in
the mode line are the square brackets "[]" that surround the `:eval`.
What's even more surprising to me is that if put the value of
`pyvenv-mode-line-indicator` in `mode-line-misc-info` directly, it *does*
work:
```
(add-to-list 'mode-line-misc-info
'(pyvenv-mode
(pyvenv-virtual-env-name
("[" (:eval (jk-pyvenv-prettify-name pyvenv-virtual-env-name)) "] "))))
```
Is there anyone who can shed some light on this? Why is it possible to put
`pyvenv-mode-line-construct` in `mode-line-misc-info` when it has its
original value, but not when I redefine it to something that works fine
when used directly as part of `mode-line-misc-info`?
TIA
Joost
Footnotes:
[1] https://github.com/jorgenschaefer/pyvenv
--
Joost Kremers
Life has its moments
next reply other threads:[~2024-08-28 9:18 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-28 9:18 Joost Kremers [this message]
2024-08-28 9:30 ` mode line construct question Joost Kremers
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=86frqp57k4.fsf@fastmail.fm \
--to=joostkremers@fastmail.fm \
--cc=gnu-emacs-help@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.
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).