[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/paredit 7e3b3f0 096/224: In `paredit-recenter-on-sexp', ha
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/paredit 7e3b3f0 096/224: In `paredit-recenter-on-sexp', handle S-expressions larger than screen. |
Date: |
Sat, 7 Aug 2021 09:22:27 -0400 (EDT) |
branch: elpa/paredit
commit 7e3b3f0c7af3c67f9c9c3c6b901559ce8cf2824b
Author: Taylor R Campbell <campbell@mumble.net>
Commit: Taylor R Campbell <campbell@mumble.net>
In `paredit-recenter-on-sexp', handle S-expressions larger than screen.
Ignore-this: 617dee9b848d79adfb69c7c8ad53e3f6
New command `paredit-recenter-on-defun'.
Thanks to Eitan Postavsky for the report.
darcs-hash:20110323002413-00fcc-1b422d9a7c39f930a862f8917cec8a868fa066b0
---
paredit.el | 33 ++++++++++++++++++++++++++-------
1 file changed, 26 insertions(+), 7 deletions(-)
diff --git a/paredit.el b/paredit.el
index 2e2fb28..b851a67 100644
--- a/paredit.el
+++ b/paredit.el
@@ -1750,7 +1750,7 @@ If that text is unbalanced, signal an error instead."
(if end-char-quote "" "not ")
phrase)))))
-;;;; Cursor and Screen Movement
+;;;; Point Motion
(eval-and-compile
(defmacro defun-saving-mark (name bvl doc &rest body)
@@ -1792,6 +1792,8 @@ With ARG, do this that many times.
A negative argument means move forward but still descend a level."
(interactive "p")
(down-list (- (or arg 1))))
+
+;;;; Window Positioning
(defalias 'paredit-recentre-on-sexp 'paredit-recenter-on-sexp)
@@ -1799,13 +1801,30 @@ A negative argument means move forward but still
descend a level."
"Recenter the screen on the S-expression following the point.
With a prefix argument N, encompass all N S-expressions forward."
(interactive "P")
- (save-excursion
- (forward-sexp n)
- (let ((end-point (point)))
- (backward-sexp n)
- (let ((start-point (point)))
+ (let* ((p (point))
+ (end-point (progn (forward-sexp n) (point)))
+ (start-point (progn (goto-char end-point) (backward-sexp n) (point))))
+ ;; Point is at beginning of first S-expression.
+ (let ((p-visible nil) (start-visible nil))
+ (save-excursion
(forward-line (/ (count-lines start-point end-point) 2))
- (recenter)))))
+ (recenter)
+ (setq p-visible (pos-visible-in-window-p p))
+ (setq start-visible (pos-visible-in-window-p start-point)))
+ (cond ((not start-visible)
+ ;; Implies (not p-visible). Put the start at the top of
+ ;; the screen.
+ (recenter 0))
+ (p-visible
+ ;; Go back to p if we can.
+ (goto-char p))))))
+
+(defun paredit-recenter-on-defun ()
+ "Recenter the screen on the definition at point."
+ (interactive)
+ (save-excursion
+ (beginning-of-defun)
+ (paredit-recenter-on-sexp)))
(defun paredit-focus-on-defun ()
"Moves display to the top of the definition at point."
- [nongnu] elpa/paredit f7c26b9 027/224: Fix kill & yank errors with `paredit-lose-if-not-in-sexp' while barfing., (continued)
- [nongnu] elpa/paredit f7c26b9 027/224: Fix kill & yank errors with `paredit-lose-if-not-in-sexp' while barfing., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit 929e547 038/224: Fix some opening remarks about enabling paredit mode., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit 90c7eda 042/224: Revive `paredit-semicolon', with better behaviour., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit a26a9a7 075/224: Permit joining adjacent lists without intervening whitespace., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit f27c480 070/224: Implement `paredit-override-check-parens-function'., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit 67caf7e 071/224: Eliminate fboundp check for `check-parens' in `paredit-check-region'., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit ae53a2c 077/224: Show point in `paredit-semicolon' example., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit 26a3ddb 085/224: Add `paredit-doublequote' examples at end of string and in comment., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit 33463ae 102/224: Third argument to `indent-region' is not optional in GNU Emacs 21., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit c91bc2f 099/224: Fix bug in change to check structure in backward-delete of comment end., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit 7e3b3f0 096/224: In `paredit-recenter-on-sexp', handle S-expressions larger than screen.,
ELPA Syncer <=
- [nongnu] elpa/paredit 6918d89 108/224: Don't indent while the buffer is in intermediate broken states., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit adfccc5 123/224: Check `paredit-kill' in a comment more carefully., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit 23afafc 128/224: Add some trivial tests for region deletion/killing commands., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit 2e61740 134/224: Fix docstring of `paredit-check-region-for-delete'., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit eb138b5 135/224: Replace `paredit-wrap-sexp' tests by `paredit-wrap-round' &c. tests., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit a795774 143/224: Set `show-trailing-whitespace' to nil when running tests., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit f349cc5 003/224: Changes for version 7., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit f588dcb 007/224: Changes for version 11., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit a04d9b6 010/224: Changes for version 14, introducing fancy comment handling., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit 342fee5 017/224: Changes for version 21., ELPA Syncer, 2021/08/07