Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

helpful-key throws wrong-type-arg error on closures #278

Open
shankar2k opened this issue Nov 19, 2021 · 0 comments
Open

helpful-key throws wrong-type-arg error on closures #278

shankar2k opened this issue Nov 19, 2021 · 0 comments

Comments

@shankar2k
Copy link

I'm having a error similar to one reported here, but for ordinary (non-byte-complied) closures.

Backtrace
Debugger entered--Lisp error: (wrong-type-argument symbolp (orig-fun . dired-next-line))
  symbol-name((orig-fun . dired-next-line))
  helpful--format-argument((orig-fun . dired-next-line))
  mapcar(helpful--format-argument ((orig-fun . dired-next-line) t))
  -map(helpful--format-argument ((orig-fun . dired-next-line) t))
  (cond (advertised-args (-map #'helpful--format-argument advertised-args)) ((listp function-args) (-map #'helpful--format-argument function-args)) (t (list function-args)))
  (let* ((function-args (cond ((symbolp sym) (help-function-arglist sym)) ((byte-code-function-p sym) (aref sym 0)) (t (cadr sym)))) (formatted-args (cond (advertised-args (-map #'helpful--format-argument advertised-args)) ((listp function-args) (-map #'helpful--format-argument function-args)) (t (list function-args))))) (setq source-sig (cond ((not (symbolp sym)) (format "(%s)" (s-join " " formatted-args))) (formatted-args (format "(%s %s)" (helpful--format-symbol sym) (s-join " " formatted-args))) (t (format "(%s)" (helpful--format-symbol sym))))))
  (let (docstring-sig source-sig (advertised-args (when (symbolp sym) (gethash (symbol-function sym) advertised-signature-table)))) (let* ((function-args (cond ((symbolp sym) (help-function-arglist sym)) ((byte-code-function-p sym) (aref sym 0)) (t (cadr sym)))) (formatted-args (cond (advertised-args (-map #'helpful--format-argument advertised-args)) ((listp function-args) (-map #'helpful--format-argument function-args)) (t (list function-args))))) (setq source-sig (cond ((not (symbolp sym)) (format "(%s)" (s-join " " formatted-args))) (formatted-args (format "(%s %s)" (helpful--format-symbol sym) (s-join " " formatted-args))) (t (format "(%s)" (helpful--format-symbol sym)))))) (-when-let (docstring (documentation sym)) (-when-let (docstring-with-usage (help-split-fundoc docstring sym)) (setq docstring-sig (car docstring-with-usage)))) (cond (advertised-args source-sig) (docstring-sig) (t source-sig)))
  helpful--signature((closure ((orig-fun . dired-next-line) t) (&optional arg) "Send a message before calling ORIG-FUN" (interactive "^p") (message "Foo is about to call %S" orig-fun) (call-interactively orig-fun)))
  helpful-update()
  helpful-key("\356")
  funcall-interactively(helpful-key "\356")
  call-interactively(helpful-key nil nil)
  command-execute(helpful-key)

Steps to Reproduce
Download the attached baz.el.txt to somewhere in your load-path and rename it to baz.el. Then run the following in Emacs:

(require 'helpful)
(require 'baz)
(dired ".")
(helpful-key (kbd "M-C"))

Potential Fix
I believe I was able to fix the problem with the following code modifications:

  1. In helpful--in-manual-p, change line 1270 from:
    (assoc-string sym completions))))
    to:
    (and (stringp sym) (assoc-string sym completions)))))
  2. In helpful--format-argument change line 2439 from
    (let ((arg-str (symbol-name arg)))
    to:
    (let ((arg-str (symbol-name (if (consp arg) (car arg) arg))))

I can provide this as a pull request if it would be more convenient.

Wilfred added a commit that referenced this issue Dec 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant