greghendershott / racket-mode

Emacs major and minor modes for Racket: edit, REPL, check-syntax, debug, profile, packages, and more.
https://www.racket-mode.com/
GNU General Public License v3.0
680 stars 93 forks source link

sh-heredoc-face (and maybe other possibly outdated faces) are preventing `org-html-htmlize-generate-css` #508

Closed tyr898 closed 3 years ago

tyr898 commented 3 years ago

Doing org-html-htmlize-generate-css gives the (error "Invalid face" sh-heredoc-face). This command is supposed to create CSS files for org exports (to website, etc). It seems sh-heredoc-face is being used in Racket which is outdated (?). There may be other faces but this is the first one that prevents org-html-htmlize-generate-css from doing its job.

This is the entire stack trace for the error:

Debugger entered--Lisp error: (error "Invalid face" sh-heredoc-face)
  internal-get-lisp-face-attribute(sh-heredoc-face :inherit nil)
  face-attribute(sh-heredoc-face :inherit)
  htmlize-face-size(racket-here-string-face)
  htmlize-face-to-fstruct-1(racket-here-string-face)
  #f(compiled-function (face) #<bytecode 0x1ffff4afc1cd>)(racket-here-string-face)
  mapcar(#f(compiled-function (face) #<bytecode 0x1ffff4afc1cd>) (racket-here-string-face))
  htmlize-face-to-fstruct(racket-here-string-face)
  htmlize-make-face-map((default bold italic bold-italic underline fixed-pitch fixed-pitch-serif variable-pitch shadow link link-visited highlight region secondary-selection trailing-whitespace line-number-current-line line-number-major-tick line-number-minor-tick fill-column-indicator escape-glyph homoglyph nobreak-space nobreak-hyphen mode-line mode-line-inactive mode-line-highlight mode-line-emphasis mode-line-buffer-id header-line header-line-highlight vertical-border window-divider window-divider-first-pixel window-divider-last-pixel internal-border minibuffer-prompt fringe scroll-bar border cursor mouse tool-bar tab-bar tab-line menu help-argument-name glyphless-char error warning success ...))
  htmlize-buffer-1()
  htmlize-region(1 460)
  org-html-htmlize-generate-css()
  funcall-interactively(org-html-htmlize-generate-css)
  call-interactively(org-html-htmlize-generate-css record nil)
  command-execute(org-html-htmlize-generate-css record)
  counsel-M-x-action("org-html-htmlize-generate-css")
  ivy-call()
  ivy-read("M-x " [shr-image-fetched evil-forward-WORD-begin ansi-color-apply-overlay-face epg-context-signers locals 0 tramp-compat-exec-path vc-git-stash-snapshot denied counsel-compile-env tramp-adb-parse-device-names tramp-find-user bbdb-current-record 0 evil-replace-alist mml-secure-smime-sign-with-sender tramp-gvfs-handle-copy-file dired-backup-diff gnus-agent-group-covered-p ido-choice-list _message mixal gnus-summary-recenter avl-tree--stack-store--cmacro cl-print--preprocess ivy-sort-file-function-default selinux-context :examined org-agenda-regexp-filter-preset vc-git-conflicted-files 0 post-deadline cl--struct-epg-signature-p shr-parse-image-data \" gnus-tree-buffer message-kill-actions parameterize* & \' tramp-rename-files gnus-summary-catchup-from-here tramp-cache-data org-babel-results-keyword racket-lambda-char dont-create not-at-beginning-of-line gnus-data-mark expired message-send-mail-function ...] :predicate #f(compiled-function (sym) #<bytecode 0x1ffff4c516c5>) :require-match t :history counsel-M-x-history :action counsel-M-x-action :keymap (keymap (67108908 . counsel--info-lookup-symbol) (67108910 . counsel-find-symbol)) :initial-input nil :caller counsel-M-x)
  counsel-M-x()
  funcall-interactively(counsel-M-x)
  call-interactively(counsel-M-x nil nil)
  command-execute(counsel-M-x)
``` ((alist-get 'racket-mode package-alist) #s(package-desc racket-mode (20201022 1304) "Racket editing, REPL, and more" ((emacs (25 1)) (faceup (0 0 2)) (pos-tip (20191127 1028))) nil nil "/home/sailik/.emacs.d/elpa/racket-mode-20201022.1304" ((:url . "https://www.racket-mode.com/") (:maintainer "Greg Hendershott") (:authors ("Greg Hendershott")) (:commit . "41abea866709c5eb3b48f1876aa5dedc75080d6b")) nil)) ((emacs-version "27.1") (system-type gnu/linux) (x-gtk-use-system-tooltips t) (major-mode racket-mode) (racket--el-source-dir "/home/sailik/.emacs.d/elpa/racket-mode-20201022.1304/") (racket--rkt-source-dir "/home/sailik/.emacs.d/elpa/racket-mode-20201022.1304/racket/") (racket-program "racket") (racket-command-timeout 10) (racket-xp-after-change-refresh-delay 1) (racket-xp-highlight-unused-regexp "^[^_]") (racket-repl-buffer-name-function nil) (racket-memory-limit 2048) (racket-error-context medium) (racket-history-filter-regexp "\\`\\s *\\'") (racket-images-inline t) (racket-images-keep-last 100) (racket-images-system-viewer "display") (racket-images-system-viewer "display") (racket-use-repl-submit-predicate nil) (racket-pretty-print t) (racket-indent-curly-as-sequence t) (racket-indent-sequence-depth 0) (racket-pretty-lambda nil) (racket-smart-open-bracket-enable nil) (racket-module-forms "\\s(\\(?:module[*+]?\\|library\\)") (racket-logger-config ((cm-accomplice . warning) (GC . info) (module-prefetch . warning) (optimizer . info) (racket/contract . error) (sequence-specialization . info) (* . fatal))) (racket-show-functions (racket-show-pseudo-tooltip))) (enabled-minor-modes (auto-compile-on-load-mode) (auto-composition-mode) (auto-compression-mode) (auto-encryption-mode) (auto-fill-mode) (auto-save-mode) (blink-cursor-mode) (counsel-mode) (electric-indent-mode) (evil-local-mode) (evil-mode) (evil-surround-mode) (file-name-shadow-mode) (font-lock-mode) (global-eldoc-mode) (global-evil-surround-mode) (global-font-lock-mode) (global-hi-lock-mode) (global-undo-tree-mode) (hi-lock-mode) (hs-minor-mode) (ivy-mode) (line-number-mode) (menu-bar-mode) (mouse-wheel-mode) (override-global-mode) (paredit-mode) (rainbow-delimiters-mode) (recentf-mode) (savehist-mode) (shell-dirtrack-mode) (show-paren-mode) (tool-bar-mode) (tooltip-mode) (transient-mark-mode) (undo-tree-mode) (xterm-mouse-mode)) (disabled-minor-modes (2C-mode) (abbrev-mode) (anki-editor-mode) (auto-compile-mode) (auto-compile-on-save-mode) (auto-fill-function) (auto-revert-mode) (auto-revert-tail-mode) (auto-save-visited-mode) (buffer-read-only) (cl-old-struct-compat-mode) (column-number-mode) (compilation-minor-mode) (compilation-shell-minor-mode) (completion-in-region-mode) (defining-kbd-macro) (delete-selection-mode) (diff-auto-refine-mode) (diff-minor-mode) (dired-hide-details-mode) (display-line-numbers-mode) (display-time-mode) (doc-view-minor-mode) (doc-view-presentation-mode) (eldoc-mode) (electric-layout-mode) (electric-quote-mode) (evil-org-mode) (flyspell-mode) (global-auto-revert-mode) (global-display-line-numbers-mode) (global-linum-mode) (global-page-break-lines-mode) (global-prettify-symbols-mode) (global-reveal-mode) (global-visual-line-mode) (global-whitespace-mode) (global-whitespace-newline-mode) (gnus-dead-summary-mode) (gnus-undo-mode) (horizontal-scroll-bar-mode) (ido-everywhere) (image-minor-mode) (isearch-mode) (ispell-minor-mode) (jit-lock-debug-mode) (linum-mode) (mail-abbrevs-mode) (mml-mode) (next-error-follow-minor-mode) (org-cdlatex-mode) (org-src-mode) (org-table-follow-field-mode) (orgtbl-mode) (outline-minor-mode) (overwrite-mode) (page-break-lines-mode) (paragraph-indent-minor-mode) (prettify-symbols-mode) (racket-smart-open-bracket-mode) (racket-xp-mode) (rectangle-mark-mode) (reveal-mode) (sh-electric-here-document-mode) (size-indication-mode) (sublimity-mode) (tab-bar-history-mode) (tab-bar-mode) (table-fixed-width-mode) (table-mode-indicator) (temp-buffer-resize-mode) (undo-tree-visualizer-selection-mode) (unify-8859-on-decoding-mode) (unify-8859-on-encoding-mode) (url-handler-mode) (use-hard-newlines) (view-mode) (visible-mode) (visual-line-mode) (whitespace-mode) (whitespace-newline-mode) (window-divider-mode) (xref-etags-mode)) ```
greghendershott commented 3 years ago

All Racket Mode uses sh-heredoc-face for is the default value for its face, racket-here-string-face:

(defface-racket racket-here-string-face
  '((t (:inherit sh-heredoc-face)))
  "Face for here strings."
  "Here String Face")

So:

  1. To work around this, probably you could M-x customize-face, enter racket-here-string-face, and give it some other value?

  2. I'll push a commit (see below).

In Emacs 25.2.2 M-x describe-face sh-heredoc-face says:

sh-heredoc-face is an alias for the face ‘sh-heredoc’.
This face is obsolete since 22.1; use ‘sh-heredoc’ instead.

Because sh-script.el has:

(define-obsolete-face-alias 'sh-heredoc-face 'sh-heredoc "22.1")
(defvar sh-heredoc-face 'sh-heredoc)

And there is no problem.

Presumably in Emacs 27.1 or earlier, someone decided to remove that and let things break.

If so:

greghendershott commented 3 years ago

If you're only reading these comments via email, I pasted the wrong code snip above and edited that, just now.

greghendershott commented 3 years ago

I merged a commit, which auto-closed this issue.

It may take awhile to flow through to MELPA. Also, you might need to restart Emacs for the new definition of racket-here-string-face to take effect; in my experience such settings don't necessarily refresh from a package update.

Meanwhile/instead the work-around should help:

To work around this, probably you could M-x customize-face, enter racket-here-string-face, and give it some other value?

But if not, please let me know and feel free to re-open this issue.

greghendershott commented 3 years ago

Also, I'm curious: Did this happen when you were trying to "html-ize" a racket-mode buffer, and, was there actually a Racket "here string" in the buffer -- was racket-here-string-face actually being used in the buffer?

I don't know whether org-html-htmlize-generate-css enumerates all faces that could be used, or just those actually used. I'm not sure if matters, I'm just curious.

tyr898 commented 3 years ago

It may take awhile to flow through to MELPA. Also, you might need to restart Emacs for the new definition of racket-here-string-face to take effect; in my experience such settings don't necessarily refresh from a package update.

Alright, I'll check back in a couple days, doesn't seem to be working yet though (also restarted Emacs).

Also, I'm curious: Did this happen when you were trying to "html-ize" a racket-mode buffer, and, was there actually a Racket "here string" in the buffer -- was racket-here-string-face actually being used in the buffer?

I first tried doing this in Org mode actually, not racket-mode. I had a block as so:

#+BEGIN_SRC racket
(define (random-fun) ...)
#+END_SRC

Tried doing this in a Racket Mode buffer as well, same thing happened however.

Also, no I wasn't using Racket here-strings. In fact I had to look up the meaning of heredocs to get to this page: https://en.wikipedia.org/wiki/Here_document where Racket is explicitly mentioned, fortunately enough.

So yes, it seems org-html-htmlize-generate-css does enumerate all faces.

Thanks for the quick fix.