emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/clojure-mode fe29a03604 1/3: Fix imenu with Clojure code i


From: ELPA Syncer
Subject: [nongnu] elpa/clojure-mode fe29a03604 1/3: Fix imenu with Clojure code in string or comment
Date: Wed, 14 Dec 2022 04:58:37 -0500 (EST)

branch: elpa/clojure-mode
commit fe29a0360468f40a2ca3de36490f1b0237012697
Author: Daniel Kraus <daniel@kraus.my>
Commit: Bozhidar Batsov <bozhidar@batsov.dev>

    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.
---
 CHANGELOG.md    | 1 +
 clojure-mode.el | 4 +++-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 34ce38bf6a..f4e032f1d9 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -11,6 +11,7 @@
 
 * [#581](https://github.com/clojure-emacs/clojure-mode/issues/581): Fix font 
locking not working for keywords starting with a number.
 * [#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.
+* [#638](https://github.com/clojure-emacs/clojure-mode/pull/638): Fix imenu 
with Clojure code in string or comment.
 
 ## 5.15.1 (2022-07-30)
 
diff --git a/clojure-mode.el b/clojure-mode.el
index 27a02f8068..fc3813e554 100644
--- a/clojure-mode.el
+++ b/clojure-mode.el
@@ -777,7 +777,9 @@ Called by `imenu--generic-function'."
       (let (found?
             (deftype (match-string 2))
             (start (point)))
-        (down-list)
+        ;; ignore user-error from down-list when called from inside a string 
or comment
+        (ignore-errors
+          (down-list))
         (forward-sexp)
         (while (not found?)
           (ignore-errors



reply via email to

[Prev in Thread] Current Thread [Next in Thread]