Skip to content

Instantly share code, notes, and snippets.

@mattdeboard
Created October 21, 2014 17:58
Show Gist options
  • Save mattdeboard/c747a882ebadc4609a9c to your computer and use it in GitHub Desktop.
Save mattdeboard/c747a882ebadc4609a9c to your computer and use it in GitHub Desktop.
;;; HACK: This is to allow compatibility between emacs trunk (>= 25.0.5) and
;;; CIDER 0.7.0, which is the last known good version of CIDER I could find.
;;; Please see https://github.com/clojure-emacs/cider/issues/838
;;; for more information.
(defun 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))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment