Skip to content

Commit

Permalink
Catch scan errors when speculatively moving backwards to check for #,…
Browse files Browse the repository at this point in the history
… so that paredit doesn't swallow them up
  • Loading branch information
amalloy committed May 15, 2011
1 parent 4495e39 commit db9080c
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions clojure-mode.el
Expand Up @@ -550,15 +550,18 @@ elements of a def* forms."
as a single sexp so that slime will send them properly. Arguably
this behavior is unintuitive for the user pressing (eg) C-M-f
himself, but since these are single objects I think it's right."
(let ((dir (if (> n 0) 1 -1)))
(let ((dir (if (> n 0) 1 -1))
(forward-sexp-function nil)) ; force the built-in version
(while (not (zerop n))
(let ((forward-sexp-function nil)) ; force the built-in version
(forward-sexp dir)
(when (save-excursion
(backward-sexp) ; call it again if we're inside a
(looking-at "#\\w")) ; record literal
(forward-sexp dir))
(setq n (- n dir))))))
(forward-sexp dir)
(when (save-excursion ; move back to see if we're in a record literal
(and
(condition-case nil
(progn (backward-sexp) 't)
('scan-error nil))
(looking-at "#\\w")))
(forward-sexp dir)) ; if so, jump over it
(setq n (- n dir)))))

(defun clojure-indent-function (indent-point state)
"This function is the normal value of the variable `lisp-indent-function'.
Expand Down

0 comments on commit db9080c

Please sign in to comment.