rougier / nano-emacs

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

wrong-type-argument char-table-p #28

Closed ndw closed 3 years ago

ndw commented 3 years ago

If I byte compile Nano, I get the following error when loading nano-layout:

Debugger entered--Lisp error: (wrong-type-argument char-table-p nil)
  set-char-table-extra-slot(nil 0 (8230 . 101))
  set-display-table-slot(nil truncation (8230 . 101))
  byte-code("\306\307\310\311\312\313\314\315\316\317\320\321\257\13!\20\322\323\324\325#\210\326\11\327\330\331\323\"#\210\326\11\332\330\333\323\"#\210\334\335\336\"\210\337\211\22\23\337..." [default-frame-alist standard-display-table inhibit-startup-screen inhibit-startup-message inhibit-startup-echo-area-message initial-scratch-message append (font . "Roboto Mono:style=Light:size=14") (min-height . 1) (height . 45) (min-width . 1) (width . 81) (vertical-scroll-bars) (internal-border-width . 24) (left-fringe . 0) (right-fringe . 0) (tool-bar-lines . 0) (menu-bar-lines . 0) custom-declare-face fallback ((t :family "Fira Code" :inherit 'nano-face-faded)) "Fallback" set-display-table-slot truncation make-glyph-code 8230 wrap 8617 add-hook term-mode-hook #f(compiled-function () #<bytecode 0x1fe646e81999>) t nil tool-bar-mode 0 tooltip-mode menu-bar-mode global-hl-line-mode 1 24 right-only window-divider-mode provide nano-layout x-underline-at-descent-line window-divider-default-right-width window-divider-default-places widget-image-enable org-hide-emphasis-markers] 13)
  require(nano-layout)
  eval-buffer(#<buffer  *load*> nil "/Users/ndw/testemacs/.emacs.d/init.el" nil t)  ; Reading at buffer position 92
  load-with-code-conversion("/Users/ndw/testemacs/.emacs.d/init.el" "/Users/ndw/testemacs/.emacs.d/init.el" t t)
  load("/Users/ndw/testemacs/.emacs.d/init" noerror nomessage)
  startup--load-user-init-file(#f(compiled-function () #<bytecode 0x1fe646e7f5a9>) #f(compiled-function () #<bytecode 0x1fe646e7f5c1>) t)
  command-line()
  normal-top-level()

I'm running this in a test home directory (HOME=/Users/ndw/testemacs emacs) with this init file:

(add-to-list 'load-path "/Users/ndw/testemacs/.emacs.d/nano-emacs")

(require 'nano-layout)

The nano-emacs directory is just what I cloned from GitHub, with the files byte compiled. I have no trouble loading nano-layout if I delete the .elc file.

ndw commented 3 years ago

I should have said, this is an Emacs 27.1 that I compiled myself on MacOS.

rougier commented 3 years ago

Thanks for the report. I'm not too familiar with byte compilation and I don't quite understand why the byte compiled code would fail. If you comment out the faulty line, compilation is ok?

ndw commented 3 years ago

It compiles just fine, that's an error I get when the compiled code runs. For the moment, I've just deleted nano-layout.elc.

rougier commented 3 years ago

From the error, the faulty line is around L44. Can you check if you comment it ?

ndw commented 3 years ago

If I comment out that line (and the set-display-table-slot below it, for good measure), the error does not occur. I can't tell what other effect this might have though. I'm not sure what that code is supposed to accomplish.

rougier commented 3 years ago

This line replaces the default continuation character ($) with a nicer glyph (…) . No idea why byte compiling it poses a problem. Maybe you can test this line with emacs -q and check if the problem persists. In such case, you would need to report the problem to emacs+bug.

baodrate commented 3 years ago

Could this have to do with the font? Not sure how the bytecode compilation process works (or how fonts are handled, I'm new to emacs), but the error went away when I installed Fira Code (I had neither Fira Code nor Roboto installed in my system)

rougier commented 3 years ago

That might be an explanation yes if the compiled code doesn't do all the checks on the availability of fonts.

brongulus commented 3 years ago

Hi I'm facing the same error even when I have both the fonts installed on my system, and I commented out the lines and checked too, the error persists. Any insight?

rougier commented 3 years ago

Do you mean that you get the same behavior with/without faulty line when compiling?

ndw commented 3 years ago

I noticed that I didn't have Fira Code installed and wondered if that was it. It wasn't. I've now got both Fira Code and Roboto Mono installed and I'm still getting the same error. Emacs 27.1.91 built by me in March on MacOS.

I poked at it a bit more without any luck. I did observe the following, however: nano-layout contains a reference to 'nano-face-faded:

(defface fallback '((t :family "Fira Code"
                       :inherit 'nano-face-faded)) "Fallback")
(set-display-table-slot standard-display-table 'truncation
                        (make-glyph-code ?… 'fallback))

FWIW, that face isn't defined until 'nano-faces is loaded. But my random attempt to load the faces before loading layout didn't have any effect.

rougier commented 3 years ago

Good point. Can you try to remove the inherit part (or replace with default) and check if this solves the problem?

ndw commented 3 years ago

While I'm no closer to understanding what the problem is, I've managed to completely separate it from NΛNO. Put the following lines in testdt.el:

(message "Hello")
(describe-display-table standard-display-table)
(message (format "%s" (char-table-p standard-display-table)))
(message "Goodbye")

Start emacs: emacs -q -l testdt.el

You'll get this in the *Message* buffer:

For information about GNU Emacs and the GNU system, type C-h C-a.
Hello
Type C-x 1 to delete the help window.
t
Goodbye

And this in the *Help* buffer:

Truncation glyph: nil
Wrap glyph: nil
Escape glyph: nil
Ctrl glyph: nil
Selective display glyph sequence: nil
Vertical window border glyph: nil
Character display glyph sequences:

Now byte compile the file and start emacs: emacs -q -l testdt.elc

You'll get an the wrong-type-argument error and the *Messages* buffer will contain:

For information about GNU Emacs and the GNU system, type C-h C-a.
Hello
display-table-slot: Wrong type argument: char-table-p, nil

The *Help* buffer will contain:

Truncation glyph: 

So there's something wrong with attempting to access the standard-display-table from byte compiled code.

I've no clue what to do next with this information. I'm not on the Emacas developers list anymore, maybe it's time to send it there?

rougier commented 3 years ago

I think you can directly file a bug from inside emacs (M-x report-emacs-bug) with your explanation.

ndw commented 3 years ago

Done.