Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 83c4103

Browse filesBrowse files
committed
Fix imenu with Clojure code in string or comment
Ignore error that's thrown from `down-list` when called with point inside a string or comment. E.g. with code like: ``` (defn foo [] (let [a " (defn b [_] (bar {:bla \"bla\"}))"])) ``` `clojure-match-next-def` calls `down-list` with point inside the string and `down-list` will throw an user-error with "This command doesn't work in strings or comments". This user-error in `down-list` got introduced 2022-05-06 with https://git.savannah.gnu.org/cgit/emacs.git/commit/?id=0b3b295776ce723885c9997ab26d57314db2a5df The `when ignore-errors` could be replaced with `unless (ppss-comment-or-string-start (syntax-ppss))` once the minimum requirement for clojure-mode is Emacs 27.
1 parent 414157c commit 83c4103
Copy full SHA for 83c4103

File tree

2 files changed

+4
-1
lines changed
Filter options

2 files changed

+4
-1
lines changed

‎CHANGELOG.md

Copy file name to clipboardExpand all lines: CHANGELOG.md
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
* [#581](https://github.com/clojure-emacs/clojure-mode/issues/581): Fix font locking not working for keywords starting with a number.
1212
* [#377](https://github.com/clojure-emacs/clojure-mode/issues/377): Fix everything starting with the prefix 'def' being highlighted as a definition form. Now definition forms are enumerated explicitly in the font-locking code, like all other forms.
13+
* [#638](https://github.com/clojure-emacs/clojure-mode/pull/638): Fix imenu with Clojure code in string or comment.
1314

1415
## 5.15.1 (2022-07-30)
1516

‎clojure-mode.el

Copy file name to clipboardExpand all lines: clojure-mode.el
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -776,7 +776,9 @@ Called by `imenu--generic-function'."
776776
(let (found?
777777
(deftype (match-string 2))
778778
(start (point)))
779-
(down-list)
779+
;; ignore user-error from down-list when called from inside a string or comment
780+
(ignore-errors
781+
(down-list))
780782
(forward-sexp)
781783
(while (not found?)
782784
(ignore-errors

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.