rougier / nano-modeline

GNU Emacs / N Λ N O Modeline
GNU General Public License v3.0
170 stars 29 forks source link

Wrong type argument: listp, nano-modeline--empty-face #59

Open teesh3rt opened 1 year ago

teesh3rt commented 1 year ago

I try to execute (nano-modeline-text-mode t), but it just shows this!: Wrong type argument: listp, nano-modeline--empty-face can anybody help me fix this?

yakhni commented 1 year ago

Facing the same issue...

rougier commented 1 year ago

I just pushed a fix on ELPA that hopefully will solve the problem. Just wait a few minutes for ELPA to update and update the package.

coldfish commented 1 year ago

Version bump is not worked on my side :(

Why can't we call thenano-modeline-mode from the config any more ?

rougier commented 1 year ago

How is it not working?

coldfish commented 1 year ago

Still getting the same error: (wrong-type-argument listp nano-modeline--empty-face)

Before upgrading the library, I was using this:

(use-package! nano-modeline
  :config
  (nano-modeline-mode))
rougier commented 1 year ago

Could you try opening the nano-modeline.el file (from github) and evaluate the buffer?

beneklins commented 1 year ago

Using vanilla Emacs 28.2, emacs -Q, and evaluating nano-modeline.el @ a18780c, I get the error reported above. For completeness, the stack trace is

Debugger entered--Lisp error: (wrong-type-argument listp nano-modeline--empty-face)
  face-remap-set-base(header-line nano-modeline--empty-face)
  nano-modeline-header(((nano-modeline-buffer-status) " " (nano-modeline-buffer-name) " " (nano-modeline-git-info)) ((nano-modeline-cursor-position) (nano-modeline-window-dedicated)) nil)
  funcall(nano-modeline-header ((nano-modeline-buffer-status) " " (nano-modeline-buffer-name) " " (nano-modeline-git-info)) ((nano-modeline-cursor-position) (nano-modeline-window-dedicated)) nil)
  nano-modeline-prog-mode()
  run-hooks(change-major-mode-after-body-hook prog-mode-hook)
  apply(run-hooks (change-major-mode-after-body-hook prog-mode-hook))
  run-mode-hooks(prog-mode-hook)
  prog-mode()
  funcall-interactively(prog-mode)
  call-interactively(prog-mode record nil)
  command-execute(prog-mode record)
  execute-extended-command(nil "prog-mode" nil)
  funcall-interactively(execute-extended-command nil "prog-mode" nil)
  call-interactively(execute-extended-command nil nil)
  command-execute(execute-extended-command)
aaronjensen commented 1 year ago

https://github.com/emacs-mirror/emacs/commit/7b0b27971b583c09cbc524d2215546f5dfe4a0e1

This is fixed in later (unreleased) versions of Emacs.

I don't know if there is or what the workaround would be

rougier commented 1 year ago

Sorry for late answer. @aaronjensen You mean the problem comes from Emacs itself?

aaronjensen commented 1 year ago

Correct. They broke it somewhat recently and have fixed it, but last I checked the fix was not released.

rougier commented 1 year ago

Better is to wait I guess. Or anyone sees a workaround?

aaronjensen commented 1 year ago

The only work around I can think of would be to do pass an extra nil:

(face-remap-set-base 'header-line 'nano-modeline--empty-face nil)

This probably doesn't have much impact (I believe the nil is treated as an empty property list), it's just a hack.

aaronjensen commented 1 year ago

Oh, and of course it's an option to provide a version of face-remap-set-base in nano and use that:

(defun nano-modeline-face-remap-set-base (face &rest specs)
  "Set the base remapping of FACE in the current buffer to SPECS.
This causes the remappings specified by `face-remap-add-relative'
to apply on top of the face specification given by SPECS.

The remaining arguments, SPECS, specify the base of the remapping.
Each one of SPECS should be either a face name or a property list
of face attribute/value pairs, like in a `face' text property.

If SPECS is empty or a single face `eq' to FACE, call `face-remap-reset-base'
to use the normal definition of FACE as the base remapping; note that
this is different from SPECS containing a single value nil, which means
not to inherit from the global definition of FACE at all."
  ;; Simplify the specs in the case where it's just a single face (and
  ;; it's not a list with just a nil).
  (while (and (consp specs) (not (null (car specs))) (null (cdr specs)))
    (setq specs (car specs)))
  (if (or (null specs)
    (eq specs face)) ; default
      ;; Set entry back to default
      (face-remap-reset-base face)
    ;; Set the base remapping
    (make-local-variable 'face-remapping-alist)
    (let ((entry (assq face face-remapping-alist)))
      (if entry
    (setcar (last entry) specs) ; overwrite existing base entry
  (push (list face specs) face-remapping-alist)))
    ;; Force redisplay of this buffer.
    (force-mode-line-update)))

Finally, per https://github.com/rougier/nano-modeline/issues/58 , this particular technique doesn't work in all cases, so it may be worth finding a way to do the faces that doesn't require a remap.

rougier commented 1 year ago

Back to work. What would be the limitations of the code above exactly?

aaronjensen commented 1 year ago

Now that Emacs 29.1 is released this may be moot unless you want to support Emacs 28.