Skip to content

Commit c421d99

Browse files
committed
[Fix #327] Indentation when a symbol ends in ? or '
1 parent 314de99 commit c421d99

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

clojure-mode.el

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -678,7 +678,9 @@ Implementation function for `clojure--find-indent-spec'."
678678
(let ((clojure--current-backtracking-depth (1+ clojure--current-backtracking-depth))
679679
(pos 0))
680680
;; Count how far we are from the start of the sexp.
681-
(while (ignore-errors (clojure-backward-logical-sexp 1) t)
681+
(while (ignore-errors (clojure-backward-logical-sexp 1)
682+
(not (or (bobp)
683+
(eq (char-before) ?\n))))
682684
(cl-incf pos))
683685
(let* ((function (thing-at-point 'symbol))
684686
(method (or (when function ;; Is there a spec here?
@@ -722,18 +724,20 @@ spec."
722724
"Return the normal indentation column for a sexp.
723725
LAST-SEXP is the start of the previous sexp."
724726
(goto-char last-sexp)
727+
(forward-sexp 1)
728+
(clojure-backward-logical-sexp 1)
725729
(let ((last-sexp-start nil))
726730
(unless (ignore-errors
727-
(while (progn (skip-chars-backward "#?'`~@[:blank:]")
728-
(not (looking-at "^")))
731+
(while (string-match
732+
"[^[:blank:]]"
733+
(buffer-substring (line-beginning-position) (point)))
729734
(setq last-sexp-start (prog1 (point)
730735
(forward-sexp -1))))
731736
t)
732737
;; If the last sexp was on the same line.
733738
(when (and last-sexp-start
734739
(> (line-end-position) last-sexp-start))
735740
(goto-char last-sexp-start)))
736-
(skip-chars-forward "[:blank:]")
737741
(current-column)))
738742

739743
(defun clojure--not-function-form-p ()

test/clojure-mode-indentation-test.el

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,15 @@ values of customisable variables."
279279
ok
280280
)")
281281

282+
(def-full-indent-test symbols-ending-in-crap
283+
"(msg? ExceptionInfo
284+
10)"
285+
"(thrown-with-msg? ExceptionInfo
286+
#\"Storage must be initialized before use\"
287+
(f))"
288+
"(msg' 1
289+
10)")
290+
282291

283292
;;; Misc
284293

0 commit comments

Comments
 (0)