summaryrefslogtreecommitdiff
path: root/cider-format.el
diff options
context:
space:
mode:
authorDieter Komendera <dieter@komendera.com>2018-09-30 18:40:49 +0200
committerBozhidar Batsov <bozhidar.batsov@gmail.com>2018-09-30 21:36:50 +0300
commit3cb2dbb701953c5fde9604d50bc5f791cc4ad721 (patch)
tree84745d667984c467bdfd84e8d874f95c983d54b4 /cider-format.el
parentc1a38bb56df38a5a736fa4a1f2f5c65d9fb02202 (diff)
More precise point positioning for cider-format-defun and no mark
cider-format-region uses the current point position to figure out where to place the point after formatting. mark-defun manipulates point, so if it was in the middle of some defun, after formatting the point would be placed at the beginning of the defun. Additonally, by not marking any region, it is not necessary to clean up, which previously was broken since save-excursion didn't restore mark since Emacs 25.1
Diffstat (limited to 'cider-format.el')
-rw-r--r--cider-format.el5
1 files changed, 2 insertions, 3 deletions
diff --git a/cider-format.el b/cider-format.el
index 0aa9e8f0..0bcbd9b3 100644
--- a/cider-format.el
+++ b/cider-format.el
@@ -92,9 +92,8 @@ START and END represent the region's boundaries."
"Format the code in the current defun."
(interactive)
(cider-ensure-connected)
- (save-excursion
- (mark-defun)
- (cider-format-region (region-beginning) (region-end))))
+ (let ((defun-bounds (cider-defun-at-point 't)))
+ (cider-format-region (car defun-bounds) (cadr defun-bounds))))
;;; Format buffer