magit / forge

Work with Git forges from the comfort of Magit
GNU General Public License v3.0
1.33k stars 117 forks source link

Issue with dimmer integration #629

Closed Davidbrcz closed 9 months ago

Davidbrcz commented 9 months ago

Hello

Not sure it's a magit or dimmer issue

I using dimmer to dim the inactive buffers, Everything has been working fine for years. Recently, I started to get errors, for instance, when pressing Enter to see a commit content in the recent commit lists and the buffers are not dimmed any more.

The commit that introduced the code that seems related to the issue is In forge-topic-mode use forge--format-topic-line for header-line

A full backtrace.

Debugger entered--Lisp error: (wrong-type-argument stringp reset)
  color-defined-p(reset)
  dimmer-face-color(forge-topic-header-line 0.3)
  dimmer-dim-buffer(#<buffer GimbalManager.cpp> 0.3)
  dimmer-process-all(t)
  dimmer-config-change-handler()
  redisplay_internal\ \(C\ function\)()
  read-from-minibuffer("M-x " nil (keymap (keymap (67108908 . counsel--info-lookup-symbol) (67108910 . counsel-find-symbol)) keymap (67108903 . ivy-avy) (36 . ivy-magic-read-file-env) (3 keymap (19 . ivy-rotate-sort) (1 . ivy-toggle-ignore) (15 . ivy-occur)) (33554464 . ivy-restrict-to-matches) (15 . hydra-ivy/body) (22 . ivy-scroll-up-command) (prior . ivy-scroll-down-command) (next . ivy-scroll-up-command) (7 . minibuffer-keyboard-quit) (right . ivy-forward-char) (32 . self-insert-command) (18 . ivy-reverse-i-search) (remap keymap (describe-mode . ivy-help) (kill-ring-save . ivy-kill-ring-save) (kill-whole-line . ivy-kill-whole-line) (kill-line . ivy-kill-line) (scroll-down-command . ivy-scroll-down-command) (scroll-up-command . ivy-scroll-up-command) (end-of-buffer . ivy-end-of-buffer) (beginning-of-buffer . ivy-beginning-of-buffer) (kill-word . ivy-kill-word) (forward-char . ivy-forward-char) (delete-char . ivy-delete-char) (backward-kill-word . ivy-backward-kill-word) (backward-delete-char-untabify . ivy-backward-delete-char) (delete-backward-char . ivy-backward-delete-char) (previous-line . ivy-previous-line) (next-line . ivy-next-line)) (9 . ivy-partial-or-done) (10 . ivy-alt-done) (27 keymap (1 . ivy-read-action) (15 . ivy-dispatching-call) (111 . ivy-dispatching-done) (25 . ivy-insert-current-full) (105 . ivy-insert-current) (106 . ivy-yank-word) (114 . ivy-toggle-regexp-quote) (97 . ivy-toggle-marks) (16 . ivy-previous-line-and-call) (14 . ivy-next-line-and-call) (118 . ivy-scroll-down-command) (112 . ivy-previous-history-element) (110 . ivy-next-history-element) (10 . ivy-immediate-done) (13 . ivy-call)) (mouse-3 . ivy-mouse-dispatching-done) (mouse-1 . ivy-mouse-done) (down-mouse-1 . ignore) (13 . ivy-done)) nil counsel-M-x-history)
  ivy-read("M-x " [python-imenu-format-parent-item-label lsp-erlang-ls-server-start-fun AND vls-tramp archive-proper-file-start unbreakable archive--file-desc-mode nxml-clear-char-ref-extra-display python-nav-beginning-of-defun-regexp \.hasIssuesEnabled ert-test-passed-duration--cmacro merge_error lsp-rust-analyzer-injected-modifier-face lispyscript-mode old-track-mouse SHORTCUT rng-parse-validate-file cl-struct-flycheck-syntax-check-tags gnus-mime-security-details-buffer eslint-tramp tramp-compat-string-equal-ignore-case ef-themes--load-theme message-expand-name-databases C-i treemacs--button-symbol-switch python-shell-get-process-or-error traversed kotlin-language-server pullreq_label:pullreq which-key--stop-timer python-syntax--context-compiler-macro flycheck-pug-executable passed-expected org-table-get-range vc-bzr-shelve-menu rng-match-infer-start-tag-namespace proced-memory-high-usage lsp-pyls-plugins-flake8-hang-closing python-skeleton-available org-agenda-menu-show-matcher rng-c-parse-name-class lsp-lua-hint-enable lsp-headerline--face-for-symbol :kill-buffer star_count diredfl-symlink Noto\ Sans\ Gurmukhi rng-start-tag-expand-recover exprs eieio-instance-tracker-child-p ...] :predicate #f(compiled-function (sym) #<bytecode -0xc460efe74b47fc3>) :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)
  command-execute(counsel-M-x)

Thanks !

tarsius commented 9 months ago

dimmer has to be taught that since Emacs 29.1 face attributes, including :foreground, can be set to the symbol reset.

Davidbrcz commented 9 months ago

This seems to work

(defun dimmer-face-color (f frac)
  "Compute a dimmed version of the foreground color of face F.
If `dimmer-adjust-background-color` is true, adjust the
background color as well.  FRAC is the amount of dimming where
0.0 is no change and 1.0 is maximum change.  Returns a plist
containing the new foreground (and if needed, new background)
suitable for use with `face-remap-add-relative`."
  (let* (
         (fg-original (face-foreground f))
         (fg (if (eq 'reset fg-original) 'unspecified  fg-original))
         (bg-original (face-background f))
         (bg (if (eq 'reset bg-original) 'unspecified  bg-original))