rougier / nano-emacs

GNU Emacs / N Λ N O - Emacs made simple
GNU General Public License v3.0
2.52k stars 194 forks source link

Emacs-lisp mode doesn't show correct major-mode #68

Closed dieggsy closed 3 years ago

dieggsy commented 3 years ago

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 ().

dieggsy commented 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.

mclearc commented 3 years ago

I found using mode-name cleared up the issue for me

rougier commented 3 years ago

Weird, on my machine (format-mode-line "%m") returns "Lisp". Can you try in the scratch buffer (after activating lisp-mode)?

dieggsy commented 3 years ago

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

rougier commented 3 years ago

For emacs-lisp-mode I get Emacs-Lisp.

dieggsy commented 3 years ago

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:

Maybe this has just changed across versions, but it may be something to watch out for in the future.

rougier commented 3 years ago

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.

dieggsy commented 3 years ago

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.

dieggsy commented 3 years ago

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.

rougier commented 3 years ago

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).