ema2159 / centaur-tabs

Emacs plugin aiming to become an aesthetic, modern looking tabs plugin
GNU General Public License v3.0
757 stars 51 forks source link

Error during redisplay: (eval (centaur-tabs-line)) signaled (wrong-type-argument stringp nil) [84 times] #227

Open avdv opened 10 months ago

avdv commented 10 months ago

Hi.

I am using GNU Emacs 30.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.38, cairo version 1.18.0) and installed centaur-tabs 20230607.1501 from elpa.

The message buffer is spammed with those messages on every key stroke and the tab bar is not shown.

Debugger entered--entering a function:
* substitute-command-keys("Wrong type argument")
* propertize(nil centaur-tabs-tab (#<buffer centaur-tabs-functions.el> . \.emacs.d) pointer hand local-map (keymap (tab-line keymap (mouse-2 . centaur-tabs-do-close) (mouse-1 . centaur-tabs-do-select))))
* centaur-tabs-line-tab((#<buffer centaur-tabs-functions.el> . \.emacs.d))
* (cons (centaur-tabs-line-tab (car tabs)) elts)
* (setq elts (cons (centaur-tabs-line-tab (car tabs)) elts))
* (progn (setq elts (cons (centaur-tabs-line-tab (car tabs)) elts)) (setq atsel (eq (car tabs) sel)) (setq tabs (cdr tabs)))
* (while (and tabs (not atsel)) (progn (setq elts (cons (centaur-tabs-line-tab (car tabs)) elts)) (setq atsel (eq (car tabs) sel)) (setq tabs (cdr tabs))))
* (progn (while (not (memq sel tabs)) (centaur-tabs-scroll tabset -1) (setq tabs (centaur-tabs-view tabset))) (while (and tabs (not atsel)) (progn (setq elts (cons (centaur-tabs-line-tab (car tabs)) elts)) (setq atsel (eq (car tabs) sel)) (setq tabs (cdr tabs)))) (setq elts (nreverse elts)) (let (buffer-list-update-hook) (let ((temp-buffer (generate-new-buffer " *temp*" t))) (save-current-buffer (set-buffer temp-buffer) (unwind-protect (progn (let (... ... deactivate-mark start) (progn ... ...) (setq start ...) (while ... ... ...))) (and (buffer-name temp-buffer) (kill-buffer temp-buffer)))))) (setq elts (nreverse elts)) (setq centaur-tabs--track-selected nil))
* (if centaur-tabs--track-selected (progn (while (not (memq sel tabs)) (centaur-tabs-scroll tabset -1) (setq tabs (centaur-tabs-view tabset))) (while (and tabs (not atsel)) (progn (setq elts (cons (centaur-tabs-line-tab (car tabs)) elts)) (setq atsel (eq (car tabs) sel)) (setq tabs (cdr tabs)))) (setq elts (nreverse elts)) (let (buffer-list-update-hook) (let ((temp-buffer (generate-new-buffer " *temp*" t))) (save-current-buffer (set-buffer temp-buffer) (unwind-protect (progn (let ... ... ... ...)) (and (buffer-name temp-buffer) (kill-buffer temp-buffer)))))) (setq elts (nreverse elts)) (setq centaur-tabs--track-selected nil)))
* (let* ((sel (centaur-tabs-selected-tab tabset)) (tabs (centaur-tabs-view tabset)) (padcolor centaur-tabs-background-color) (all-tabs (centaur-tabs-tabs tabset)) (total-tabs (length all-tabs)) (sel-index (+ (cl-position (car sel) (cl-mapcar 'car all-tabs)) 1)) atsel elts) (if centaur-tabs--track-selected (progn (while (not (memq sel tabs)) (centaur-tabs-scroll tabset -1) (setq tabs (centaur-tabs-view tabset))) (while (and tabs (not atsel)) (progn (setq elts (cons (centaur-tabs-line-tab ...) elts)) (setq atsel (eq (car tabs) sel)) (setq tabs (cdr tabs)))) (setq elts (nreverse elts)) (let (buffer-list-update-hook) (let ((temp-buffer (generate-new-buffer " *temp*" t))) (save-current-buffer (set-buffer temp-buffer) (unwind-protect (progn ...) (and ... ...))))) (setq elts (nreverse elts)) (setq centaur-tabs--track-selected nil))) (while tabs (progn (setq elts (cons (centaur-tabs-line-tab (car tabs)) elts)) (setq tabs (cdr tabs)))) (centaur-tabs-set-template tabset (list (centaur-tabs-count sel-index total-tabs) (centaur-tabs-line-format--buttons) (nreverse elts) (propertize "% " 'face (list :background padcolor) 'pointer 'arrow) (centaur-tabs-line-format--new-button))))
* (closure (helm-source-centaur-tabs-group t) (tabset) "Return the `centaur-tabs-display-line-format' value to display TABSET." (let* ((sel (centaur-tabs-selected-tab tabset)) (tabs (centaur-tabs-view tabset)) (padcolor centaur-tabs-background-color) (all-tabs (centaur-tabs-tabs tabset)) (total-tabs (length all-tabs)) (sel-index (+ (cl-position (car sel) (cl-mapcar ... all-tabs)) 1)) atsel elts) (if centaur-tabs--track-selected (progn (while (not (memq sel tabs)) (centaur-tabs-scroll tabset -1) (setq tabs (centaur-tabs-view tabset))) (while (and tabs (not atsel)) (progn (setq elts ...) (setq atsel ...) (setq tabs ...))) (setq elts (nreverse elts)) (let (buffer-list-update-hook) (let (...) (save-current-buffer ... ...))) (setq elts (nreverse elts)) (setq centaur-tabs--track-selected nil))) (while tabs (progn (setq elts (cons (centaur-tabs-line-tab ...) elts)) (setq tabs (cdr tabs)))) (centaur-tabs-set-template tabset (list (centaur-tabs-count sel-index total-tabs) (centaur-tabs-line-format--buttons) (nreverse elts) (propertize "% " 'face (list :background padcolor) 'pointer 'arrow) (centaur-tabs-line-format--new-button)))))(\.emacs.d)
* apply((closure (helm-source-centaur-tabs-group t) (tabset) "Return the `centaur-tabs-display-line-format' value to display TABSET." (let* ((sel (centaur-tabs-selected-tab tabset)) (tabs (centaur-tabs-view tabset)) (padcolor centaur-tabs-background-color) (all-tabs (centaur-tabs-tabs tabset)) (total-tabs (length all-tabs)) (sel-index (+ (cl-position (car sel) (cl-mapcar ... all-tabs)) 1)) atsel elts) (if centaur-tabs--track-selected (progn (while (not (memq sel tabs)) (centaur-tabs-scroll tabset -1) (setq tabs (centaur-tabs-view tabset))) (while (and tabs (not atsel)) (progn (setq elts ...) (setq atsel ...) (setq tabs ...))) (setq elts (nreverse elts)) (let (buffer-list-update-hook) (let (...) (save-current-buffer ... ...))) (setq elts (nreverse elts)) (setq centaur-tabs--track-selected nil))) (while tabs (progn (setq elts (cons (centaur-tabs-line-tab ...) elts)) (setq tabs (cdr tabs)))) (centaur-tabs-set-template tabset (list (centaur-tabs-count sel-index total-tabs) (centaur-tabs-line-format--buttons) (nreverse elts) (propertize "% " 'face (list :background padcolor) 'pointer 'arrow) (centaur-tabs-line-format--new-button))))) \.emacs.d)
* centaur-tabs-line-format(\.emacs.d)

Seems like the centaur-tabs-active-bar is nil?

realark commented 5 months ago

I'm seeing this too. Seems to happen when buffers that don't have a tabset are opened (for example, org-agenda). Adding a simple null check to centaur-tabs-make-tabset resolves the problem, but I'm not sure if this is the desired solution:

(defun centaur-tabs-make-tabset (name &rest objects)
  "Make a new tab set whose name is the string NAME.
It is initialized with tabs build from the list of OBJECTS."
  (when name
    (let* ((tabset (intern name centaur-tabs-tabsets))
           (tabs (mapcar #'(lambda (object)
                             (centaur-tabs-make-tab object tabset))
                         objects)))
      (set tabset tabs)
      (centaur-tabs-put-cache tabset 'select (car tabs))
      (put tabset 'start 0)
      tabset)))
avdv commented 5 months ago

Unfortunately, #235 does not fix it for me, I still see these errors in the message buffer (and it's slowing Emacs down).

jcs090218 commented 5 months ago

Does the error exist in only Emacs 30? 🤔 Can you tell me how to reproduce this error? Thanks!

avdv commented 5 months ago

Does the error exist in only Emacs 30? 🤔

In the meantime, I switched back to Emacs 29.3 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.41, cairo version 1.18.0) hoping that it would fix the error.

Can you tell me how to reproduce this error? Thanks!

It fails in centaur-tabs-line-format and later in centaur-tabs-line-tab, here's a backtrace:

Debugger entered--entering a function:
* substitute-command-keys("Wrong type argument")
* propertize(nil centaur-tabs-tab (#<buffer centaur-tabs-functions.el> . \.emacs.d) pointer hand local-map (keymap (tab-line keymap (mouse-2 . centaur-tabs-do-close) (mouse-1 . centaur-tabs-do-select))))
* centaur-tabs-line-tab((#<buffer centaur-tabs-functions.el> . \.emacs.d))
    [no locals]
* (cons (centaur-tabs-line-tab (car tabs)) elts)
* (setq elts (cons (centaur-tabs-line-tab (car tabs)) elts))
* (progn (setq elts (cons (centaur-tabs-line-tab (car tabs)) elts)) (setq tabs (cdr tabs)))
* (while tabs (progn (setq elts (cons (centaur-tabs-line-tab (car tabs)) elts)) (setq tabs (cdr tabs))))
* (let* ((sel (centaur-tabs-selected-tab tabset)) (tabs (centaur-tabs-view tabset)) (padcolor centaur-tabs-background-color) (all-tabs (centaur-tabs-tabs tabset)) (total-tabs (length all-tabs)) (sel-index (+ (cl-position (car sel) (mapcar 'car all-tabs)) 1)) atsel elts) (if nil (progn (while (not (memq sel tabs)) (centaur-tabs-scroll tabset -1) (setq tabs (centaur-tabs-view tabset))) (while (and tabs (not atsel)) (progn (setq elts (cons (centaur-tabs-line-tab ...) elts)) (setq atsel (eq (car tabs) sel)) (setq tabs (cdr tabs)))) (setq elts (nreverse elts)) (let (buffer-list-update-hook) (let ((temp-buffer (generate-new-buffer " *temp*" t))) (save-current-buffer (set-buffer temp-buffer) (unwind-protect (progn ...) (and ... ...))))) (setq elts (nreverse elts)) (setq centaur-tabs--track-selected nil))) (while tabs (progn (setq elts (cons (centaur-tabs-line-tab (car tabs)) elts)) (setq tabs (cdr tabs)))) (centaur-tabs-set-template tabset (list (centaur-tabs-count sel-index total-tabs) (centaur-tabs-line-format--buttons) (nreverse elts) (propertize "% " 'face (list :background padcolor) 'pointer 'arrow) (centaur-tabs-line-format--new-button))))
* (closure (t) (tabset) "Return the `centaur-tabs-display-line-format' valu..." (let* ((sel (centaur-tabs-selected-tab tabset)) (tabs (centaur-tabs-view tabset)) (padcolor centaur-tabs-background-color) (all-tabs (centaur-tabs-tabs tabset)) (total-tabs (length all-tabs)) (sel-index (+ (cl-position (car sel) (mapcar ... all-tabs)) 1)) atsel elts) (if nil (progn (while (not (memq sel tabs)) (centaur-tabs-scroll tabset -1) (setq tabs (centaur-tabs-view tabset))) (while (and tabs (not atsel)) (progn (setq elts ...) (setq atsel ...) (setq tabs ...))) (setq elts (nreverse elts)) (let (buffer-list-update-hook) (let (...) (save-current-buffer ... ...))) (setq elts (nreverse elts)) (setq centaur-tabs--track-selected nil))) (while tabs (progn (setq elts (cons (centaur-tabs-line-tab ...) elts)) (setq tabs (cdr tabs)))) (centaur-tabs-set-template tabset (list (centaur-tabs-count sel-index total-tabs) (centaur-tabs-line-format--buttons) (nreverse elts) (propertize "% " 'face (list :background padcolor) 'pointer 'arrow) (centaur-tabs-line-format--new-button)))))(\.emacs.d)
* apply((closure (t) (tabset) "Return the `centaur-tabs-display-line-format' valu..." (let* ((sel (centaur-tabs-selected-tab tabset)) (tabs (centaur-tabs-view tabset)) (padcolor centaur-tabs-background-color) (all-tabs (centaur-tabs-tabs tabset)) (total-tabs (length all-tabs)) (sel-index (+ (cl-position (car sel) (mapcar ... all-tabs)) 1)) atsel elts) (if nil (progn (while (not (memq sel tabs)) (centaur-tabs-scroll tabset -1) (setq tabs (centaur-tabs-view tabset))) (while (and tabs (not atsel)) (progn (setq elts ...) (setq atsel ...) (setq tabs ...))) (setq elts (nreverse elts)) (let (buffer-list-update-hook) (let (...) (save-current-buffer ... ...))) (setq elts (nreverse elts)) (setq centaur-tabs--track-selected nil))) (while tabs (progn (setq elts (cons (centaur-tabs-line-tab ...) elts)) (setq tabs (cdr tabs)))) (centaur-tabs-set-template tabset (list (centaur-tabs-count sel-index total-tabs) (centaur-tabs-line-format--buttons) (nreverse elts) (propertize "% " 'face (list :background padcolor) 'pointer 'arrow) (centaur-tabs-line-format--new-button))))) \.emacs.d)
* centaur-tabs-line-format(\.emacs.d)
  (progn (centaur-tabs-line-format centaur-tabs-current-tabset))

It seems like centaur-tabs-active-bar is nil. (Oh, I just discovered this in my initial report too. :facepalm:)

\edit: After evaluating the (defvar centaur-tabs-active-bar ...) in centaur-tabs-elements.el the error is gone, and the tabs are displayed.

Is this some sort of initialization problem then? I am using spacemacs.

avdv commented 4 months ago

Oh, that may be related to #127 since I am running Emacs as a service / daemon, too. So centaur-tabs-active-bar being nil is probably just because centaur-tabs--make-xpm indeed returned nil...

When starting Emacs directly the tabs seem to work just fine.

amosbird commented 4 months ago

The issue can be reproduced when checking out a different branch with a different set of project files using Git, causing (centaur-tabs-selected-tab tabset) to return nil.