diff --git a/CHANGELOG.md b/CHANGELOG.md index d4ba472f..fa048e34 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ * [#483](https://github.com/clojure-emacs/clojure-mode/issues/483): Support alignment for reader conditionals, with the new `clojure-align-reader-conditionals` user option. +### Bugs fixed + +* [#489](https://github.com/clojure-emacs/clojure-mode/issues/489) Inserting parens before comment form doesn't move point + ## 5.9.1 (2018-08-27) * [#485](https://github.com/clojure-emacs/clojure-mode/issues/485): Fix a regression in `end-f-defun`. diff --git a/clojure-mode.el b/clojure-mode.el index f4f597ff..4cad827a 100644 --- a/clojure-mode.el +++ b/clojure-mode.el @@ -1967,8 +1967,7 @@ This will skip over sexps that don't represent objects, so that ^hints and "Return truthy if the first form matches FIRST-FORM." (condition-case nil (save-excursion - (end-of-defun) - (clojure-backward-logical-sexp 1) + (beginning-of-defun) (forward-char 1) (clojure-forward-logical-sexp 1) (clojure-backward-logical-sexp 1) @@ -2022,10 +2021,11 @@ many times." (save-match-data (let ((original-position (point)) clojure-comment-start clojure-comment-end) + (beginning-of-defun) + (setq clojure-comment-start (point)) (end-of-defun) (setq clojure-comment-end (point)) - (clojure-backward-logical-sexp 1) ;; beginning of comment form - (setq clojure-comment-start (point)) + (beginning-of-defun) (forward-char 1) ;; skip paren so we start at comment (clojure-forward-logical-sexp) ;; skip past the comment form itself (if-let ((sexp-start (clojure-find-first (lambda (beg-pos) diff --git a/test/clojure-mode-sexp-test.el b/test/clojure-mode-sexp-test.el index 40f861c0..a15a3194 100644 --- a/test/clojure-mode-sexp-test.el +++ b/test/clojure-mode-sexp-test.el @@ -65,7 +65,15 @@ and point left there." (wrong))" (let ((clojure-toplevel-inside-comment-form t)) (beginning-of-defun)) - (should (looking-at-p "[[:space:]]*(right)")))) + (should (looking-at-p "[[:space:]]*(right)"))) + (clojure-buffer-with-text + " +(formA) +| +(formB)" + (let ((clojure-toplevel-inside-comment-form t)) + (beginning-of-defun) + (should (looking-at-p "(formA)"))))) (ert-deftest test-clojure-end-of-defun-function () (clojure-buffer-with-text