Error in the example with quick-peek
mattiasdrp opened this issue · comments
The function provided outputs an error:
Flycheck error display error: (wrong-number-of-arguments ((t) (msg pos) (let* ((ov (quick-peek-overlay-ensure-at pos)) (contents (quick-peek-overlay-contents ov))) (let* ((v ov)) (overlay-put v 'quick-peek--contents (concat contents (if contents (progn
)) msg))) (quick-peek-update ov))) 3)
It looks like there is a missing parameter and the function should be:
(setq flycheck-inline-display-function
(lambda (msg pos err)
(let* ((ov (quick-peek-overlay-ensure-at pos))
(contents (quick-peek-overlay-contents ov)))
(setf (quick-peek-overlay-contents ov)
(concat contents (when contents "\n") msg))
(quick-peek-update ov)))
flycheck-inline-clear-function #'quick-peek-hide)
(notice the err
even though it's not used in the rest of the function. The description of flycheck-inline-display-function
actually states:
(defcustom flycheck-inline-display-function #'flycheck-inline-display-phantom
"Function to display inline errors.
This function is used to display inline all errors at point, as
well as all related errors. It has the signature (MSG &optional
POS ERR), where MSG is the error message to display, POS its
buffer position, and ERR is the flycheck error in general."
So it's expecting 3 arguments since this commit: 9d2d2d5
Thanks for catching this. I fixed the example.
It seems this is broken again but with a different error,
Flycheck error display error: (void-function (setf quick-peek-overlay-contents))
@chookity-pokk Can you show your config? I don't have your error but I may have an idea as to why it's happening.
@mattiasdrp Here is my whole flycheck config
(use-package flycheck :ensure t :init (global-flycheck-mode))
(require 'flycheck)
(with-eval-after-load 'flycheck
(add-hook 'flycheck-mode-hook #'flycheck-inline-mode))
(with-eval-after-load 'flycheck
(add-hook 'flycheck-mode-hook #'flycheck-status-emoji-mode))
(add-to-list 'global-mode-string flycheck-mode-line)
(package-install 'exec-path-from-shell)
(exec-path-from-shell-initialize);; From https://github.com/flycheck/flycheck/issues/1974#issuecomment-1343495202
(flycheck-define-checker python-ruff
"A Python syntax and style checker using the ruff utility.
To override the path to the ruff executable, set
`flycheck-python-ruff-executable'.
See URL `http://pypi.python.org/pypi/ruff'."
:command ("ruff"
"check"
"--config" "~/.ruff.toml"
"--output-format=text"
(eval (when buffer-file-name
(concat "--stdin-filename=" buffer-file-name)))
"-")
:standard-input t
:error-filter (lambda (errors)
(let ((errors (flycheck-sanitize-errors errors)))
(seq-map #'flycheck-flake8-fix-error-level errors)))
:error-patterns
((warning line-start
(file-name) ":" line ":" (optional column ":") " "
(id (one-or-more (any alpha)) (one-or-more digit)) " "
(message (one-or-more not-newline))
line-end))
:modes python-ts-mode)
(add-to-list 'flycheck-checkers 'python-ruff)
(setq flycheck-display-errors-delay 0.1)
;; (setq flycheck-inline-display-function
;; (lambda (msg pos err)
;; (let* ((ov (quick-peek-overlay-ensure-at pos))
;; (contents (quick-peek-overlay-contents ov)))
;; (setf (quick-peek-overlay-contents ov)
;; (concat contents (when contents "\n") msg))
;; (quick-peek-update ov)))
;; flycheck-inline-clear-function #'quick-peek-hide)
@chookity-pokk Where is quick-peek?
Your config is a bit messy 😄
I think it's better to keep everything related to a package in its use-package stance, something like this:
(use-package quick-peek
:ensure t)
(use-package flycheck
:ensure t
:init (global-flycheck-mode)
:config
(add-to-list 'global-mode-string flycheck-mode-line)
(package-install 'exec-path-from-shell)
(exec-path-from-shell-initialize);; From https://github.com/flycheck/flycheck/issues/1974#issuecomment-1343495202
(flycheck-define-checker python-ruff
"A Python syntax and style checker using the ruff utility.
To override the path to the ruff executable, set
`flycheck-python-ruff-executable'.
See URL `http://pypi.python.org/pypi/ruff'."
:command ("ruff"
"check"
"--config" "~/.ruff.toml"
"--output-format=text"
(eval (when buffer-file-name
(concat "--stdin-filename=" buffer-file-name)))
"-")
:standard-input t
:error-filter (lambda (errors)
(let ((errors (flycheck-sanitize-errors errors)))
(seq-map #'flycheck-flake8-fix-error-level errors)))
:error-patterns
((warning line-start
(file-name) ":" line ":" (optional column ":") " "
(id (one-or-more (any alpha)) (one-or-more digit)) " "
(message (one-or-more not-newline))
line-end))
:modes python-ts-mode)
(add-to-list 'flycheck-checkers 'python-ruff)
(setq flycheck-display-errors-delay 0.1))
(use-package flycheck-inline
:hook (flycheck-mode . flycheck-inline-mode)
:after quick-peek
:config
(setq flycheck-inline-display-function
(lambda (msg pos err)
(let* ((ov (quick-peek-overlay-ensure-at pos))
(contents (quick-peek-overlay-contents ov)))
(setf (quick-peek-overlay-contents ov)
(concat contents (when contents "\n") msg))
(quick-peek-update ov)))
flycheck-inline-clear-function #'quick-peek-hide))
(use-package flycheck-status-emoji
:hook (flycheck-mode . flycheck-status-emoji-mode))
You know what's crazy? I cleaned it up a bit before sending it over haha. I definitely should organize with use-package but I almost always forget.
Anyway, what you gave works. I thought I had something like (require quick-peek)
but I guess I didn't.
When I switched to elpaca I had the same error you had. Turns out quick-peek was loaded after flycheck-inline and even though it worked before, this was not the case anymore. So I thought your quick-peek stance was missing or not called early enough.
Organizing with use-package is really not that hard and it honestly makes maintaining your config way easier. If something doesn't work, just add :disabled
and you can investigate by dichotomy. And now that I added elpaca my life is so easy!
Good luck further :-)