Skip to content

Commit

Permalink
Merge pull request #3 from j0ni/issue2
Browse files Browse the repository at this point in the history
Fix #2 - Include live-paredit-top-level-p in this package.
  • Loading branch information
samaaron committed Feb 21, 2013
2 parents 5b75824 + 1b6ddf2 commit 243f7f8
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions nrepl-eval-sexp-fu.el
Expand Up @@ -312,16 +312,30 @@ such that ignores any prefix arguments."
(intern (concat (symbol-name command-name-prefix) post)))
'("-inner-sexp" "-inner-list"))))))

(defun nesf-end-of-buffer-p ()
"Predicate fn to determine whether point is at the end of the
buffer"
(<= (buffer-size) (point)))

(defun nesf-paredit-forward-down ()
"Doesn't freeze Emacs if attempted to be called at end of
buffer. Otherwise similar to paredit-forward-down."
(interactive)
(if (save-excursion
(forward-comment (buffer-size))
(not (live-end-of-buffer-p)))
(not (nesf-end-of-buffer-p)))
(paredit-forward-down)
(error "unexpected end of buffer")))

(defun nesf-paredit-top-level-p ()
"Returns true if point is not within a given form i.e. it's in
toplevel 'whitespace'"
(not
(save-excursion
(ignore-errors
(paredit-forward-up)
t))))

;;; initialize.
(defun nesf-initialize ()
(define-nrepl-eval-sexp-fu-flash-command eval-last-sexp
Expand Down Expand Up @@ -349,13 +363,13 @@ such that ignores any prefix arguments."
(backward-char)
(bounds-of-thing-at-point 'sexp))))
(define-nrepl-eval-sexp-fu-flash-command nrepl-eval-expression-at-point
(nrepl-eval-sexp-fu-flash (when (not (and (live-paredit-top-level-p)
(nrepl-eval-sexp-fu-flash (when (not (and (nesf-paredit-top-level-p)
(save-excursion
(ignore-errors (forward-char))
(live-paredit-top-level-p))))
(nesf-paredit-top-level-p))))
(save-excursion
(save-match-data
(ignore-errors (live-paredit-forward-down))
(ignore-errors (nesf-paredit-forward-down))
(paredit-forward-up)
(while (ignore-errors (paredit-forward-up) t))
(let ((end (point)))
Expand Down

0 comments on commit 243f7f8

Please sign in to comment.