Skip to content

Commit

Permalink
Use clojure-mode's sexp navigation commands
Browse files Browse the repository at this point in the history
  • Loading branch information
Malabarba committed Jul 2, 2015
1 parent 005c97a commit eabfac8
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 21 deletions.
20 changes: 3 additions & 17 deletions cider-debug.el
Expand Up @@ -133,7 +133,7 @@ is displayed at point."
(cider--make-result-overlay value 'debug-result cider-debug-use-overlays
'before-string cider--fringe-arrow-string)
;; Code
(cider--make-overlay (save-excursion (forward-sexp -1) (point))
(cider--make-overlay (save-excursion (clojure-backward-logical-sexp 1) (point))
(point) 'debug-code
'face 'cider-debug-code-overlay-face
;; Higher priority than `show-paren'.
Expand Down Expand Up @@ -281,20 +281,6 @@ ID is the id of the message that instrumented CODE."
(set-buffer-modified-p nil))))
(switch-to-buffer buffer-name)))

(defun cider--forward-sexp (n)
"Move forward N logical sexps.
This will skip over sexps that don't represent objects, such as ^hints and
#reader.macros."
(while (> n 0)
;; Non-logical sexps.
(while (progn (forward-sexp 1)
(forward-sexp -1)
(looking-at-p "\\^\\|#[[:alpha:]]"))
(forward-sexp 1))
;; The actual sexp
(forward-sexp 1)
(setq n (1- n))))

(defun cider--debug-goto-keyval (key)
"Find KEY in current sexp or return nil."
(-when-let (limit (ignore-errors (save-excursion (up-list) (point))))
Expand All @@ -318,12 +304,12 @@ sexp."
;; String coordinates are map keys.
(if (stringp next)
(cider--debug-goto-keyval next)
(cider--forward-sexp next)))
(clojure-forward-logical-sexp (pop coordinates))))
;; If that extra pop was the last coordinate, this represents the
;; entire #(...), so we should move back out.
(backward-up-list)))
;; Place point at the end of instrumented sexp.
(cider--forward-sexp 1))
(clojure-forward-logical-sexp 1))
;; Avoid throwing actual errors, since this happens on every breakpoint.
(error (message "Can't find instrumented sexp, did you edit the source?"))))

Expand Down
4 changes: 2 additions & 2 deletions cider-interaction.el
Expand Up @@ -631,7 +631,7 @@ When invoked with a prefix ARG the command doesn't prompt for confirmation."
"Return the sexp preceding the point."
(buffer-substring-no-properties
(save-excursion
(backward-sexp)
(clojure-backward-logical-sexp 1)
(point))
(point)))

Expand Down Expand Up @@ -1715,7 +1715,7 @@ If invoked with a PREFIX argument, print the result in the current buffer."
(interactive "P")
(cider-interactive-eval (cider-last-sexp)
(when prefix (cider-eval-print-handler))
(save-excursion (backward-sexp 1) (point))))
(save-excursion (clojure-backward-logical-sexp 1) (point))))

(defun cider-eval-last-sexp-and-replace ()
"Evaluate the expression preceding point and replace it with its result."
Expand Down
2 changes: 1 addition & 1 deletion cider-macroexpansion.el
Expand Up @@ -101,7 +101,7 @@ This variable specifies both what was expanded and the expander.")
"Substitute the form preceding point with its macroexpansion using EXPANDER."
(interactive)
(let* ((expansion (cider-sync-request:macroexpand expander (cider-last-sexp)))
(bounds (cons (save-excursion (backward-sexp) (point)) (point))))
(bounds (cons (save-excursion (clojure-backward-logical-sexp 1) (point)) (point))))
(cider-redraw-macroexpansion-buffer
expansion (current-buffer) (car bounds) (cdr bounds))))

Expand Down
2 changes: 1 addition & 1 deletion cider.el
Expand Up @@ -11,7 +11,7 @@
;; Maintainer: Bozhidar Batsov <bozhidar@batsov.com>
;; URL: http://www.github.com/clojure-emacs/cider
;; Version: 0.10.0-cvs
;; Package-Requires: ((clojure-mode "4.0.0") (dash "2.4.1") (pkg-info "0.4") (emacs "24.3") (queue "0.1.1"))
;; Package-Requires: ((clojure-mode "4.2.0") (dash "2.4.1") (pkg-info "0.4") (emacs "24.3") (queue "0.1.1"))
;; Keywords: languages, clojure, cider

;; This program is free software: you can redistribute it and/or modify
Expand Down

0 comments on commit eabfac8

Please sign in to comment.