@@ -1304,24 +1304,26 @@ no namespaces above point, return the first one in the buffer."
1304
1304
(re-search-forward clojure-namespace-name-regex nil t )))
1305
1305
(match-string-no-properties 4 )))))
1306
1306
1307
+ (defconst clojure-def-type-and-name-regex
1308
+ (concat " (\\ (?:\\ (?:\\ sw\\ |\\ s_\\ )+/\\ )?"
1309
+ ; ; Declaration
1310
+ " \\ (def\\ (?:\\ sw\\ |\\ s_\\ )*\\ )\\ >"
1311
+ ; ; Any whitespace
1312
+ " [ \r\n\t ]*"
1313
+ ; ; Possibly type or metadata
1314
+ " \\ (?:#?^\\ (?:{[^}]*}\\ |\\ (?:\\ sw\\ |\\ s_\\ )+\\ )[ \r\n\t ]*\\ )*"
1315
+ ; ; Symbol name
1316
+ " \\ (\\ (?:\\ sw\\ |\\ s_\\ )+\\ )" ))
1317
+
1307
1318
(defun clojure-find-def ()
1308
1319
" Find the var declaration macro and symbol name of the current form.
1309
1320
Returns a list pair, e.g. (\" defn\" \" abc\" ) or (\" deftest\" \" some-test\" )."
1310
- (let ((re (concat " (\\ (?:\\ (?:\\ sw\\ |\\ s_\\ )+/\\ )?"
1311
- ; ; Declaration
1312
- " \\ (def\\ (?:\\ sw\\ |\\ s_\\ )*\\ )\\ >"
1313
- ; ; Any whitespace
1314
- " [ \r\n\t ]*"
1315
- ; ; Possibly type or metadata
1316
- " \\ (?:#?^\\ (?:{[^}]*}\\ |\\ (?:\\ sw\\ |\\ s_\\ )+\\ )[ \r\n\t ]*\\ )*"
1317
- ; ; Symbol name
1318
- " \\ (\\ (?:\\ sw\\ |\\ s_\\ )+\\ )" )))
1319
- (save-excursion
1320
- (unless (looking-at re)
1321
- (beginning-of-defun ))
1322
- (when (search-forward-regexp re nil t )
1323
- (list (match-string-no-properties 1 )
1324
- (match-string-no-properties 2 ))))))
1321
+ (save-excursion
1322
+ (unless (looking-at clojure-def-type-and-name-regex)
1323
+ (beginning-of-defun ))
1324
+ (when (search-forward-regexp clojure-def-type-and-name-regex nil t )
1325
+ (list (match-string-no-properties 1 )
1326
+ (match-string-no-properties 2 )))))
1325
1327
1326
1328
1327
1329
; ;; Sexp navigation
0 commit comments