Closed dieggsy closed 3 years ago
One possibility could be to use the built-in mode-name
variable and do something like (if (listp mode-name) (car mode-name) mode-name)
, though maybe there's a more elegant solution.
I found using mode-name
cleared up the issue for me
Weird, on my machine (format-mode-line "%m")
returns "Lisp". Can you try in the scratch buffer (after activating lisp-mode)?
@rougier the issue is with emacs-lisp-mode
in this case, not lisp-mode
. I am also running a nightly Emacs build, so it's possible some behavior is different because of that.
For emacs-lisp-mode
I get Emacs-Lisp
.
In an emacs -Q
session with version GNU Emacs 28.0.50 (build 1, x86_64-pc-linux-gnu, X toolkit, cairo version 1.17.4) of 2021-05-03
, in an emacs-lisp buffer:
M-: (format-mode-line "%m") RET
-> ""
M-: mode-name RET
-> ("ELisp" (lexical-binding (:propertize "/l" help-echo "Using lexical-binding mode" (:propertize "/d" help-echo "Using old dynamic scoping mode mouse-1: Enable lexical-binding mode" face warning mouse-face mode-line-highlight local-map (keymap ...))))
Maybe this has just changed across versions, but it may be something to watch out for in the future.
Interesting and weird. Probably a bug then. Can you make a PR to replace %m
with mode-name
. Just realized that we can just get rid of the local mode-name
variable.
well, you'd likely need the listp
check described above too, at least on version 28.0.50. I can maybe make a PR later today.
It occurs to me this is likely a bug in the later emacs version, as it doesn't make sense for (format-mode-line "%m")
to return the empty string. Regardless, it would still make sense to use the built-in mode-name
variable.
PR would be nice. But I agree this looks like a bug or a deprecation of the %m
construct (but without warning, it is doubtful).
Hey, really neat project you have here! Provides some great aesthetic inspiration for my own config. I found that
(format-mode-line "%m")
in emacs-lisp-mode returns an empty string, so in emacs-lisp buffers the mode shows up as()
.