@@ -2142,23 +2142,30 @@ DIRECTION is `forward' or `backward'."
2142
2142
(setq candidate (string-remove-prefix " '" (thing-at-point 'symbol ))))))))
2143
2143
candidate))
2144
2144
2145
- (defun clojure-find-ns ()
2146
- " Return the namespace of the current Clojure buffer.
2145
+ (defun clojure-find-ns (&optional suppress-errors )
2146
+ " Return the namespace of the current Clojure buffer, honor `SUPPRESS-ERRORS' .
2147
2147
Return the namespace closest to point and above it. If there are
2148
2148
no namespaces above point, return the first one in the buffer.
2149
2149
2150
+ If `SUPPRESS-ERRORS' is t, errors during ns form parsing will be swallowed,
2151
+ and nil will be returned instead of letting this function fail.
2152
+
2150
2153
The results will be cached if `clojure-cache-ns' is set to t."
2151
2154
(if (and clojure-cache-ns clojure-cached-ns)
2152
2155
clojure-cached-ns
2153
- (let ((ns (save-excursion
2154
- (save-restriction
2155
- (widen )
2156
-
2157
- ; ; Move to top-level to avoid searching from inside ns
2158
- (ignore-errors (while t (up-list nil t t )))
2159
-
2160
- (or (clojure--find-ns-in-direction 'backward )
2161
- (clojure--find-ns-in-direction 'forward ))))))
2156
+ (let* ((f (lambda (direction )
2157
+ (if suppress-errors
2158
+ (ignore-errors (clojure--find-ns-in-direction direction))
2159
+ (clojure--find-ns-in-direction direction))))
2160
+ (ns (save-excursion
2161
+ (save-restriction
2162
+ (widen )
2163
+
2164
+ ; ; Move to top-level to avoid searching from inside ns
2165
+ (ignore-errors (while t (up-list nil t t )))
2166
+
2167
+ (or (funcall f 'backward )
2168
+ (funcall f 'forward ))))))
2162
2169
(setq clojure-cached-ns ns)
2163
2170
ns)))
2164
2171
0 commit comments