summaryrefslogtreecommitdiff
path: root/cider-eldoc.el
diff options
context:
space:
mode:
authorBozhidar Batsov <bozhidar@tradeo.com>2014-10-01 17:37:51 +0300
committerBozhidar Batsov <bozhidar@tradeo.com>2014-10-01 17:38:50 +0300
commitc5f140c0d548a4b96b6c099160209f7bc6b0d386 (patch)
treef6a960a4cf241230b15e1479757ffa56c5484e26 /cider-eldoc.el
parent062380944ddb6524e36d412e7a9d33c6b4bacc46 (diff)
[Fix #838] Inline eldoc-beginning-of-sexp
Diffstat (limited to 'cider-eldoc.el')
-rw-r--r--cider-eldoc.el27
1 files changed, 26 insertions, 1 deletions
diff --git a/cider-eldoc.el b/cider-eldoc.el
index 9ba0b146..1a856417 100644
--- a/cider-eldoc.el
+++ b/cider-eldoc.el
@@ -80,10 +80,35 @@ POS is the index of current argument."
" ")
")"))
+(defun cider-eldoc-beginning-of-sexp ()
+ "Move to the beginning of current sexp.
+
+Return the number of nested sexp the point was over or after. "
+ (let ((parse-sexp-ignore-comments t)
+ (num-skipped-sexps 0))
+ (condition-case _
+ (progn
+ ;; First account for the case the point is directly over a
+ ;; beginning of a nested sexp.
+ (condition-case _
+ (let ((p (point)))
+ (forward-sexp -1)
+ (forward-sexp 1)
+ (when (< (point) p)
+ (setq num-skipped-sexps 1)))
+ (error))
+ (while
+ (let ((p (point)))
+ (forward-sexp -1)
+ (when (< (point) p)
+ (setq num-skipped-sexps (1+ num-skipped-sexps))))))
+ (error))
+ num-skipped-sexps))
+
(defun cider-eldoc-info-in-current-sexp ()
"Return a list of the current sexp and the current argument index."
(save-excursion
- (let ((argument-index (1- (eldoc-beginning-of-sexp))))
+ (let ((argument-index (1- (cider-eldoc-beginning-of-sexp))))
;; If we are at the beginning of function name, this will be -1.
(when (< argument-index 0)
(setq argument-index 0))