lem icon indicating copy to clipboard operation
lem copied to clipboard

M-x list-buffers is not working anymore: `The value NIL is not of type LEM/COMMON/COLOR:COLOR`

Open ryukinix opened this issue 3 months ago • 5 comments

Command from keybinding C-x C-b. Error:

The value NIL is not of type LEM/COMMON/COLOR:COLOR
Backtrace for: #<SB-THREAD:THREAD "editor" RUNNING {1009A54293}>
0: (LEM/COMMON/COLOR:RGB-TO-HSV NIL)
1: (LEM/MULTI-COLUMN-LIST::DARKEN-COLOR NIL :FACTOR 0.6)
2: (LEM/MULTI-COLUMN-LIST::PUT-HEADER-ATTRIBUTE #<LEM/BUFFER/INTERNAL:POINT (1, 0) "       Buffer         File " {1007E88223}> #<LEM-CORE:CURSOR (1, 27) "       Buffer         File " {1007E4FF83}>)
3: (LEM/POPUP-MENU::SETUP-MENU-BUFFER #<LEM/BUFFER/INTERNAL:TEXT-BUFFER *popup menu* NIL {1007E43CC3}> (#<LEM/MULTI-COLUMN-LIST::DEFAULT-MULTI-COLUMN-LIST-ITEM {1007E43103}> #<LEM/MULTI-COLUMN-LIST::DEFAULT-MULTI-COLUMN-LIST-ITEM {1007E43143}> #<LEM/MULTI-COLUMN-LIST::DEFAULT-MULTI-COLUMN-LIST-ITEM {1007E43183}> #<LEM/MULTI-COLUMN-LIST::DEFAULT-MULTI-COLUMN-LIST-ITEM {1007E431C3}>) #<LEM/MULTI-COLUMN-LIST::PRINT-SPEC {1007E43B43}> #<LEM-CORE:ATTRIBUTE (white RoyalBlue) {1006696E13}> NIL)
4: ((:METHOD LEM-INTERFACE:DISPLAY-POPUP-MENU (T T)) #<unused argument> (#<LEM/MULTI-COLUMN-LIST::DEFAULT-MULTI-COLUMN-LIST-ITEM {1007E43103}> #<LEM/MULTI-COLUMN-LIST::DEFAULT-MULTI-COLUMN-LIST-ITEM {1007E43143}> #<LEM/MULTI-COLUMN-LIST::DEFAULT-MULTI-COLUMN-LIST-ITEM {1007E43183}> #<LEM/MULTI-COLUMN-LIST::DEFAULT-MULTI-COLUMN-LIST-ITEM {1007E431C3}>) :ACTION-CALLBACK #<FUNCTION (LAMBDA (LEM/MULTI-COLUMN-LIST::ITEM) :IN LEM/MULTI-COLUMN-LIST:DISPLAY) {1007E43B7B}> :PRINT-SPEC #<LEM/MULTI-COLUMN-LIST::PRINT-SPEC {1007E43B43}> :STYLE (:GRAVITY :CENTER) :MAX-DISPLAY-ITEMS 56) [fast-method]
5: ((:METHOD LEM/MULTI-COLUMN-LIST:DISPLAY (LEM/MULTI-COLUMN-LIST:MULTI-COLUMN-LIST)) #<LEM/MULTI-COLUMN-LIST:MULTI-COLUMN-LIST {1007E42F53}> :STYLE (:GRAVITY :CENTER) :INDEX 0) [fast-method]
6: (LEM-CORE:CALL-COMMAND LEM/LIST-BUFFERS:LIST-BUFFERS NIL)
7: (LEM-CORE::COMMAND-LOOP-BODY)
8: (LEM-CORE:COMMAND-LOOP)
9: (LEM-CORE::TOPLEVEL-COMMAND-LOOP #<FUNCTION (LAMBDA NIL :IN LEM-CORE::RUN-EDITOR-THREAD) {10083534BB}>)
10: ((LAMBDA NIL :IN LEM-CORE::RUN-EDITOR-THREAD))
11: ((LAMBDA NIL :IN LEM-CORE::RUN-EDITOR-THREAD))
12: ((FLET BT2::RUN-FUNCTION :IN BT2::ESTABLISH-DYNAMIC-ENV))
13: ((LABELS BT2::%ESTABLISH-DYNAMIC-ENV-WRAPPER :IN BT2::ESTABLISH-DYNAMIC-ENV))
14: ((FLET SB-UNIX::BODY :IN SB-THREAD::RUN))
15: ((FLET "WITHOUT-INTERRUPTS-BODY-10" :IN SB-THREAD::RUN))
16: ((FLET SB-UNIX::BODY :IN SB-THREAD::RUN))
17: ((FLET "WITHOUT-INTERRUPTS-BODY-3" :IN SB-THREAD::RUN))
18: (SB-THREAD::RUN)
19: ("foreign function: call_into_lisp")
20: ("foreign function: funcall1")

Tested:

  • Webview from appimage: lem 2.3.0-0b55b4fb (X86-64-PC-003269)
  • SDL2 compiled from source: lem 2.3.0-0b55b4fb (X86-64-PC-003269)

This issue doesn't occurs with the ncurses frontend.

Minimal config to reproduce

(define-color-theme "leraxy" ("black-metal-immortal")                                                                                                                                          
  (syntax-keyword-attribute :foreground "dodger blue"))                                                                                                                                        
                                                                                                                                                                                               
(load-theme "leraxy")   

ryukinix avatar Oct 01 '25 16:10 ryukinix

Hi, it works for me, including on the WebView with the latest AppImage (20250927-0125).

Are you using more modes or color themes?

vindarel avatar Oct 02 '25 11:10 vindarel

I use a custom theme, but I tried to run without my config and default theme and I got the same error. My config is defined here: https://github.com/ryukinix/dotfiles/blob/master/.lem%2Finit.lisp

ryukinix avatar Oct 02 '25 22:10 ryukinix

@vindarel

Yes, I use some modes and custom color-theme. The issue seems related to the definition of color-theme inherited from another. I tried to reproduce the problem with a minimal config and I got this:

(define-color-theme "leraxy" ("black-metal-immortal")                                                                                                                                          
  (syntax-keyword-attribute :foreground "dodger blue"))                                                                                                                                        
                                                                                                                                                                                               
(load-theme "leraxy")   

This is the minimal. I updated the issue description with this, curiously selecting M-x load-theme black-metal-immortal works fine. In previous versions, this piece of code worked with C-x C-b too. For instance, this works fine in release v2.3.0, but not in the latest version from branch main.

ryukinix avatar Oct 13 '25 10:10 ryukinix

I confirmed that this version is working properly for me: https://github.com/lem-project/lem/releases/tag/nightly-20250810-0811

Hence the bug was introduced somewhere after the commit e89fac5f3d5e5a9e3f53bacd5b8494163e5fc0bc. Testing 17a5de0ab2529cffb38bbc542182be0e4c25f53f, the nightly-latest release, I already can reproduce this issue. So the problem is between these PRs:

git log --oneline --graph 17a5de0ab2529cffb38bbc542182be0e4c25f53f..e89fac5f3d5e5a9e3f53bacd5b8494163e5fc0bc | grep '#'
  • 0b55b4fb Fixed bugs in lem/link package and added link properties in Markdown Mode (#1965)
  • 7fe43e2e Merge pull request #1949 from vindarel/main
  • 82e27739 directory-mode: follow buffer name and directory when moving one file (r) (#1945)
  • 419cfebf Added option to hide mode lines (#1941)
  • 4e0e5fb1 update README.md (#1940)
  • b9e9a4b8 improve pop-up messages after compilation in lisp-mode (#1938)
  • a6ef9d17 Optimize performance: Reduce unnecessary redrawing (#1937)
  • ba3ddbc7 Reducing the number of syntax highlight calls (#1936)
  • fd0e95b9 Add terminal.so (#1935)
  • 291dcffe Optimize performance (#1934)
  • 4f2713e0 Claude Code (#1929)
  • 38a42242 add interactive-mode (#1928)
  • cba817ef Add an attached buffer and window (#1927)
  • 58753c39 Remove abundant closing paren (#1925)
  • 9a5df046 Synchronize the position and size of the prompt-window and completion-window (#1924)
  • b38a639b Html mode improved syntax highlighting (#1921)
  • 8db63f55 Update appearance (#1920)
  • cb85c675 Add a feature to customize CSS (#1917)
  • 50e46e1a Sort commands alphabetically (#1913)
  • 17c394e1 Change appearance of list buffers (#1910)
  • a65aaba9 Set the option to highlight the current line to true by default. (#1909)
  • 6dd1793b tweak (#1907)
  • df823c19 Remake command line arguments processor (#1905)
  • 4113df75 "M-x " -> "Comamnd: " (#1901)
  • 3bf46bf8 Automatic tab completion is now set to false by default. Also moved it so that it is accessible for lem package (#1898)
  • cd16e37e Fixes #1685 (#1890)
  • 18bfc593 Configurable Automatic Completions (#1884)
  • 2e36aa77 nightly build (macos) (#1883)

ryukinix avatar Oct 13 '25 10:10 ryukinix

@vindarel The cause of this problem it seems related with how theme inheritance works related to the methods get-foreground-color and get-background-color are being defined.

Instead of defining this as previously:

(define-color-theme "leraxy" ("black-metal-immortal")                                                                                                                                          
  (syntax-keyword-attribute :foreground "dodger blue"))                                                                                                                                        
                                                                                                                                                                                               
(load-theme "leraxy")   

If I define explicity the foreground/background colors, it works:

(define-color-theme "leraxy" ("black-metal-immortal")
  (:foreground "#c1c1c1") 
  (:background "#000000")
  (syntax-keyword-attribute :foreground "dodger blue"))

Check how these methods are being defined:

https://github.com/lem-project/lem/blob/aa7cf1aa21a810b1877567c4915e1247de7f8a24/src/color-theme.lisp#L109-L115

If we inspect the object of leraxy and black-metal-immortal we can see that that will not work properly:

Image

However I think the inheritance should consider the parent theme if is not found in the current theme, right?

Image

That's the reason why M-x list-buffers is not working anymore.

ryukinix avatar Nov 06 '25 19:11 ryukinix