casouri / valign

Pixel-perfect visual alignment for Org and Markdown tables.
444 stars 22 forks source link

Invalid face: markdown-table-face #19

Closed Dieken closed 3 years ago

Dieken commented 3 years ago

在 doom emacs 里 markdown 模式下报错:

Invalid face: markdown-table-face

似乎跟这个相关:

https://github.com/casouri/valign/blob/jit/valign.el#L324

(defun valign--table-face ()
  "Return the table face for this buffer."
  (cond ((derived-mode-p 'org-mode)
         'org-table)
        ((derived-mode-p 'markdown-mode)
         'markdown-table-face)
        (t 'default)))
casouri commented 3 years ago

奇怪,markdown–mode有这个face的啊。你的markdown版本是什么?完整backtrace?

Dieken commented 3 years ago

doom emacs 带的 markdown-mode 版本:https://github.com/jrblevin/markdown-mode/commit/6d64f9e96203b1e76e3f0adfd2f545b5b02f5ffb

Debugger entered--Lisp error: (error "Invalid face" markdown-table-face)
  internal-get-lisp-face-attribute((markdown-table-face) :extend nil)
  face-attribute((markdown-table-face) :extend nil t)
  face-extend-p((markdown-table-face) nil t)
  adaptive-wrap--face-extends((markdown-table-face))
  adaptive-wrap--prefix-face("" 20 45)
  #f(compiled-function (beg end) #<bytecode 0x1fe30f69253d>)(20 45)
  funcall(#f(compiled-function (beg end) #<bytecode 0x1fe30f69253d>) 20 45)
  (let ((adaptive-wrap-extra-indent (+word-wrap--calc-extra-indent beg))) (funcall orig-fn beg end))
  +word-wrap--adjust-extra-indent-a(#f(compiled-function (beg end) #<bytecode 0x1fe30f69253d>) 20 45)
  apply(+word-wrap--adjust-extra-indent-a #f(compiled-function (beg end) #<bytecode 0x1fe30f69253d>) (20 45))
  adaptive-wrap-fill-context-prefix(20 45)
  adaptive-wrap-prefix-function(22 114)
  #f(compiled-function (fun) #<bytecode 0x1fe30b354ffd>)(adaptive-wrap-prefix-function)
  run-hook-wrapped(#f(compiled-function (fun) #<bytecode 0x1fe30b354ffd>) adaptive-wrap-prefix-function)
  jit-lock--run-functions(22 114)
  poly-lock-fontify-now(22 114)
  poly-lock-function(22)
  vertical-motion(0)
  beginning-of-visual-line()
  nav-flash-show()
  (if (minibufferp) nil (nav-flash-show) (overlay-put compilation-highlight-overlay 'window (selected-window)))
  +nav-flash-blink-cursor()
  (if (or (memq this-command +nav-flash-exclude-commands) (and (boundp 'so-long-minor-mode) so-long-minor-mode) (derived-mode-p 'so-long-mode 'special-mode 'term-mode 'vterm-mode) (and (equal (point-marker) (car +nav-flash--last-point)) (equal (selected-window) (cdr +nav-flash--last-point)))) nil (+nav-flash-blink-cursor) (setq +nav-flash--last-point (cons (point-marker) (selected-window))))
  +nav-flash-blink-cursor-a()
  apply(+nav-flash-blink-cursor-a nil)
  #f(advice-wrapper :after #f(compiled-function () #<bytecode 0x1fe30bfc0735>) +nav-flash-blink-cursor-a)()
  apply(#f(advice-wrapper :after #f(compiled-function () #<bytecode 0x1fe30bfc0735>) +nav-flash-blink-cursor-a) nil)
  #f(advice-wrapper :after-while #f(advice-wrapper :after #f(compiled-function () #<bytecode 0x1fe30bfc0735>) +nav-flash-blink-cursor-a) doom--recenter-on-load-saveplace-a)()
  ad-Advice-save-place-find-file-hook(#f(advice-wrapper :after-while #f(advice-wrapper :after #f(compiled-function () #<bytecode 0x1fe30bfc0735>) +nav-flash-blink-cursor-a) doom--recenter-on-load-saveplace-a))
  apply(ad-Advice-save-place-find-file-hook #f(advice-wrapper :after-while #f(advice-wrapper :after #f(compiled-function () #<bytecode 0x1fe30bfc0735>) +nav-flash-blink-cursor-a) doom--recenter-on-load-saveplace-a) nil)
  save-place-find-file-hook()
  run-hooks(find-file-hook)
  #f(compiled-function (&optional error warn noauto after-find-file-from-revert-buffer nomodes) "Called after finding a file and by the default revert function.\nSets buffer mode, parses file-local and directory-local variables.\nOptional args ERROR, WARN, and NOAUTO: ERROR non-nil means there was an\nerror in reading the file.  WARN non-nil means warn if there\nexists an auto-save file more recent than the visited file.\nNOAUTO means don't mess with auto-save mode.\nFourth arg AFTER-FIND-FILE-FROM-REVERT-BUFFER is ignored\n(see `revert-buffer-in-progress-p' for similar functionality).\nFifth arg NOMODES non-nil means don't alter the file's modes.\nFinishes by calling the functions in `find-file-hook'\nunless NOMODES is non-nil." #<bytecode 0x410656db>)(nil t)
  apply(#f(compiled-function (&optional error warn noauto after-find-file-from-revert-buffer nomodes) "Called after finding a file and by the default revert function.\nSets buffer mode, parses file-local and directory-local variables.\nOptional args ERROR, WARN, and NOAUTO: ERROR non-nil means there was an\nerror in reading the file.  WARN non-nil means warn if there\nexists an auto-save file more recent than the visited file.\nNOAUTO means don't mess with auto-save mode.\nFourth arg AFTER-FIND-FILE-FROM-REVERT-BUFFER is ignored\n(see `revert-buffer-in-progress-p' for similar functionality).\nFifth arg NOMODES non-nil means don't alter the file's modes.\nFinishes by calling the functions in `find-file-hook'\nunless NOMODES is non-nil." #<bytecode 0x410656db>) (nil t))
  #f(advice-wrapper :before #f(compiled-function (&optional error warn noauto after-find-file-from-revert-buffer nomodes) "Called after finding a file and by the default revert function.\nSets buffer mode, parses file-local and directory-local variables.\nOptional args ERROR, WARN, and NOAUTO: ERROR non-nil means there was an\nerror in reading the file.  WARN non-nil means warn if there\nexists an auto-save file more recent than the visited file.\nNOAUTO means don't mess with auto-save mode.\nFourth arg AFTER-FIND-FILE-FROM-REVERT-BUFFER is ignored\n(see `revert-buffer-in-progress-p' for similar functionality).\nFifth arg NOMODES non-nil means don't alter the file's modes.\nFinishes by calling the functions in `find-file-hook'\nunless NOMODES is non-nil." #<bytecode 0x410656db>) doom-first-buffer-hook-h)(nil t)
  apply(#f(advice-wrapper :before #f(compiled-function (&optional error warn noauto after-find-file-from-revert-buffer nomodes) "Called after finding a file and by the default revert function.\nSets buffer mode, parses file-local and directory-local variables.\nOptional args ERROR, WARN, and NOAUTO: ERROR non-nil means there was an\nerror in reading the file.  WARN non-nil means warn if there\nexists an auto-save file more recent than the visited file.\nNOAUTO means don't mess with auto-save mode.\nFourth arg AFTER-FIND-FILE-FROM-REVERT-BUFFER is ignored\n(see `revert-buffer-in-progress-p' for similar functionality).\nFifth arg NOMODES non-nil means don't alter the file's modes.\nFinishes by calling the functions in `find-file-hook'\nunless NOMODES is non-nil." #<bytecode 0x410656db>) doom-first-buffer-hook-h) (nil t))
  after-find-file(nil t)
  find-file-noselect-1(#<buffer a.md> "~/tmp/a.md" nil nil "~/tmp/a.md" (336814000 16777220))
  find-file-noselect("/Users/liuyb/tmp/a.md" nil nil nil)
  find-file("/Users/liuyb/tmp/a.md")
  counsel-find-file-action("/Users/liuyb/tmp/a.md")
  ivy-call()
  ivy-read("Find file: " read-file-name-internal :matcher counsel--find-file-matcher :initial-input nil :action counsel-find-file-action :preselect nil :require-match confirm-after-completion :history file-name-history :keymap (keymap (remap keymap (undo . counsel-find-file-undo)) (67108960 lambda (&optional arg) "nil (`nil')" (interactive "p") (if (string= "" ivy-text) (execute-kbd-macro (kbd "M-o b")) (self-insert-command arg))) (96 . counsel-file-jump-from-find) (C-backspace . counsel-up-directory) (67108991 . counsel-up-directory)) :caller counsel-find-file)
  counsel--find-file-1("Find file: " nil counsel-find-file-action counsel-find-file)
  counsel-find-file()
  funcall-interactively(counsel-find-file)
  call-interactively(counsel-find-file nil nil)
  command-execute(counsel-find-file)
Dieken commented 3 years ago

markdown 文件:

# Document Title

| aa  | bb   | cc      |
|-----|------|---------|
| aaa | bb   | cc 中国 |
| abc | 不错 | 很好    |
casouri commented 3 years ago

这看着像adaptive-wrap的问题。

Dieken commented 3 years ago

嗯,这东西的 bug,抱歉。。。

diff --git a/adaptive-wrap.el b/adaptive-wrap.el
index b075b3b..add994c 100644
--- a/adaptive-wrap.el
+++ b/adaptive-wrap.el
@@ -78,7 +78,7 @@ extra indent = 2
         ;; line has the diff-removed face.
         ((= (char-before end) ?\n)
          (let ((eol-face (get-text-property (1- end) 'face)))
-           (and eol-face (adaptive-wrap--face-extends eol-face) eol-face)))))
+           (and eol-face (adaptive-wrap--face-extends (first eol-face)) eol-face)))))

 (defun adaptive-wrap--prefix (fcp)
   (let ((fcp-len (string-width fcp)))
Dieken commented 3 years ago

// I can't comment on doom emacs project, it's locked now.

Possibly similar issues:

Dieken commented 3 years ago

In case anybody comes here, the upstream maintainer has provided a more thorough fix:

http://git.savannah.gnu.org/gitweb/?p=emacs/elpa.git;a=blobdiff;f=adaptive-wrap.el;h=3e891af1c55f7c1c53f8414ccfe00bc99b3bcb48;hp=b075b3b7e3bc0e9afee0892c2e036076ae2e086e;hb=a4c49ef906b0318485ae053c344fc524c2d8be7c;hpb=603648e22a28afd2f1c7a7f9c230751cde2dfeca;ds=sidebyside