diff options
author | dan sutton <danielsutton01@gmail.com> | 2018-08-14 08:15:47 -0500 |
---|---|---|
committer | Bozhidar Batsov <bozhidar.batsov@gmail.com> | 2018-08-18 04:53:04 +0200 |
commit | 9d2af835f2036c2f2f0cad82bfccea927b988ef0 (patch) | |
tree | d54c344a5bb03bc703ffc9bc0d3975d7a128e4b5 /cider-util.el | |
parent | 0a1f536bdf351ec756b7bd8c1bc0e8750a36b8aa (diff) |
Remove comment aware toplevel defun code
This code has migrated to clojure-mode and is now installed such that
`end-of-defun` and `beginning-of-defun` are aware of comment forms. As
such CIDER no longer needs to special case them and can just navigate
as usual.
Diffstat (limited to 'cider-util.el')
-rw-r--r-- | cider-util.el | 72 |
1 files changed, 6 insertions, 66 deletions
diff --git a/cider-util.el b/cider-util.el index 17d4e29f..6737b97e 100644 --- a/cider-util.el +++ b/cider-util.el @@ -105,76 +105,16 @@ positions. Else returns the substring from START to END." (funcall (if bounds #'list #'buffer-substring-no-properties) start end)) -(defun cider-top-level-comment-p () - "Return non-nil if point is in a comment form." - (save-excursion - (end-of-defun) - (clojure-backward-logical-sexp 1) - (forward-char 1) - (clojure-forward-logical-sexp 1) - (clojure-backward-logical-sexp 1) - (looking-at-p "comment"))) - -(defcustom cider-eval-toplevel-inside-comment-form nil - "Eval top level forms inside comment forms instead of the comment form itself. -Experimental. Function `cider-defun-at-point' is used extensively so if we -change this heuristic it needs to be bullet-proof and desired. While -testing, give an easy way to turn this new behavior off." - :group 'cider - :type 'boolean - :package-version '(cider . "0.18.0")) - -(defun cider-sexp-starts-until-position (position) - "Returns the starting points for forms before POSITION. -Positions are in descending order to aide in finding the first starting -position before the current position." - (save-excursion - (let (sexp-positions) - (condition-case nil - (while (< (point) position) - (clojure-forward-logical-sexp 1) - (clojure-backward-logical-sexp 1) - (push (point) sexp-positions) - (clojure-forward-logical-sexp 1)) - (scan-error nil)) - sexp-positions))) - -(defun cider-defun-inside-comment-form (&optional bounds) - "Return the toplevel form inside a comment containing point. -Assumes point is inside a (comment ....) form and will return the text of -that form or if BOUNDS, will return a list of the starting and ending -position." - (save-excursion - (save-match-data - (let ((original-position (point)) - cider-comment-start cider-comment-end) - (end-of-defun) - (setq cider-comment-end (point)) - (clojure-backward-logical-sexp 1) ;; beginning of comment form - (setq cider-comment-start (point)) - (forward-char 1) ;; skip paren so we start at comment - (clojure-forward-logical-sexp) ;; skip past the comment form itself - (if-let* ((sexp-start (seq-find (lambda (beg-pos) (< beg-pos original-position)) - (cider-sexp-starts-until-position cider-comment-end)))) - (progn - (goto-char sexp-start) - (clojure-forward-logical-sexp 1) - (cider--text-or-limits bounds sexp-start (point))) - (cider--text-or-limits bounds cider-comment-start cider-comment-end)))))) - (defun cider-defun-at-point (&optional bounds) "Return the text of the top level sexp at point. If BOUNDS is non-nil, return a list of its starting and ending position instead." - (if (and cider-eval-toplevel-inside-comment-form - (cider-top-level-comment-p)) - (cider-defun-inside-comment-form bounds) - (save-excursion - (save-match-data - (end-of-defun) - (let ((end (point))) - (clojure-backward-logical-sexp 1) - (cider--text-or-limits bounds (point) end)))))) + (save-excursion + (save-match-data + (end-of-defun) + (let ((end (point))) + (clojure-backward-logical-sexp 1) + (cider--text-or-limits bounds (point) end))))) (defun cider-ns-form () "Retrieve the ns form." |