Skip to content

Commit

Permalink
Fix scan-sexps error for C-defined variables
Browse files Browse the repository at this point in the history
  • Loading branch information
LemonBreezes authored and Wilfred committed Jun 13, 2024
1 parent a835b7e commit 4ba24ca
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 4 additions & 1 deletion helpful.el
Original file line number Diff line number Diff line change
Expand Up @@ -1259,7 +1259,10 @@ If the source code cannot be found, return the sexp used."
;; function.
(progn
(setq pos (line-beginning-position))
(forward-list)
;; HACK Use the elisp syntax table even though the file is a
;; C file. This is a temporary workaround for issue #329.
(with-syntax-table emacs-lisp-mode-syntax-table
(forward-list))
(forward-char)
(narrow-to-region pos (point)))
;; Narrow to the top-level definition.
Expand Down
6 changes: 6 additions & 0 deletions test/helpful-unit-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -782,6 +782,12 @@ in."
(should
(s-starts-with-p "(defun " source))))

(ert-deftest helpful--source-c-fn ()
(-let* (((buf pos _opened) (helpful--definition 'mode-line-format nil))
(source (helpful--source 'mode-line-format nil buf pos)))
(should
(s-starts-with-p "DEFVAR" (s-trim-left source)))))

(ert-deftest helpful--source-autoloaded ()
"We should include the autoload cookie."
(-let* (((buf pos _opened) (helpful--definition #'helpful-at-point t))
Expand Down

0 comments on commit 4ba24ca

Please sign in to comment.