Skip to content

Commit c3a4235

Browse files
committed
Refactor logical sexps code a bit
1 parent 8db56ec commit c3a4235

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

clojure-mode.el

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1084,6 +1084,13 @@ Returns a list pair, e.g. (\"defn\" \"abc\") or (\"deftest\" \"some-test\")."
10841084

10851085

10861086
;;; Sexp navigation
1087+
(defun clojure--looking-at-logical-sexp ()
1088+
"Return non-nil if sexp after point represents code.
1089+
Sexps that don't represent code are ^metadata or #reader.macros."
1090+
(forward-sexp 1)
1091+
(forward-sexp -1)
1092+
(not (looking-at-p "\\^\\|#[[:alpha:]]")))
1093+
10871094
(defun clojure-forward-logical-sexp (&optional n)
10881095
"Move forward N logical sexps.
10891096
This will skip over sexps that don't represent objects, so that ^hints and
@@ -1093,10 +1100,7 @@ This will skip over sexps that don't represent objects, so that ^hints and
10931100
(if (< n 0)
10941101
(clojure-backward-logical-sexp (- n))
10951102
(while (> n 0)
1096-
;; Non-logical sexps.
1097-
(while (progn (forward-sexp 1)
1098-
(forward-sexp -1)
1099-
(looking-at-p "\\^\\|#[[:alpha:]]"))
1103+
(while (not (clojure--looking-at-logical-sexp))
11001104
(forward-sexp 1))
11011105
;; The actual sexp
11021106
(forward-sexp 1)

0 commit comments

Comments
 (0)