summaryrefslogtreecommitdiff
path: root/cider-format.el
diff options
context:
space:
mode:
Diffstat (limited to 'cider-format.el')
-rw-r--r--cider-format.el8
1 files changed, 4 insertions, 4 deletions
diff --git a/cider-format.el b/cider-format.el
index 0aa9e8f0..2cf9d09d 100644
--- a/cider-format.el
+++ b/cider-format.el
@@ -1,6 +1,6 @@
;;; cider-format.el --- Code and EDN formatting functionality -*- lexical-binding: t -*-
-;; Copyright © 2013-2018 Bozhidar Batsov, Artur Malabarba and CIDER contributors
+;; Copyright © 2013-2019 Bozhidar Batsov, Artur Malabarba and CIDER contributors
;;
;; Author: Bozhidar Batsov <bozhidar@batsov.com>
;; Artur Malabarba <bruce.connor.am@gmail.com>
@@ -68,6 +68,7 @@ Uses the following heuristic to try to maintain point position:
(endp (> (+ pos l) pos-max))
(snippet (thread-last (buffer-substring-no-properties
pos (min (+ pos l) pos-max))
+ (regexp-quote)
(replace-regexp-in-string "[[:space:]\t\n\r]+" "[[:space:]\t\n\r]*"))))
(delete-region start end)
(insert indented)
@@ -92,9 +93,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