[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/paredit 014cdfe 177/224: Handle shift selection in motion
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/paredit 014cdfe 177/224: Handle shift selection in motion commands in recent GNU Emacs. |
Date: |
Sat, 7 Aug 2021 09:22:45 -0400 (EDT) |
branch: elpa/paredit
commit 014cdfea76267e57daafac82dff1103e5e34b753
Author: Taylor R Campbell <campbell@mumble.net>
Commit: Taylor R Campbell <campbell@mumble.net>
Handle shift selection in motion commands in recent GNU Emacs.
Drop `backward-down-list'. All four {backward, forward} x {up, down}
motion commands are done pareditishly now.
---
paredit.el | 50 +++++++++++++++++++++++++-------------------------
1 file changed, 25 insertions(+), 25 deletions(-)
diff --git a/paredit.el b/paredit.el
index 1f1a2c7..0be1477 100644
--- a/paredit.el
+++ b/paredit.el
@@ -1775,20 +1775,37 @@ With a prefix argument, skip the balance check."
;;;; Point Motion
(eval-and-compile
- (defmacro defun-saving-mark (name bvl doc &rest body)
+ (defmacro defun-motion (name bvl doc &rest body)
`(defun ,name ,bvl
,doc
,(xcond ((paredit-xemacs-p)
'(interactive "_"))
((paredit-gnu-emacs-p)
- '(interactive)))
+ ;++ Not sure this is sufficient for the `^'.
+ (if (fboundp 'handle-shift-selection)
+ '(interactive "^p")
+ '(interactive "p"))))
,@body)))
-(defun-saving-mark paredit-forward ()
+(defun-motion paredit-forward (&optional arg)
"Move forward an S-expression, or up an S-expression forward.
If there are no more S-expressions in this one before the closing
delimiter, move past that closing delimiter; otherwise, move forward
past the S-expression following the point."
+ (let ((n (or arg 1)))
+ (cond ((< 0 n) (dotimes (i n) (paredit-move-forward)))
+ ((< n 0) (dotimes (i (- n)) (paredit-move-backward))))))
+
+(defun-motion paredit-backward (&optional arg)
+ "Move backward an S-expression, or up an S-expression backward.
+If there are no more S-expressions in this one before the opening
+ delimiter, move past that opening delimiter backward; otherwise, move
+ move backward past the S-expression preceding the point."
+ (let ((n (or arg 1)))
+ (cond ((< 0 n) (dotimes (i n) (paredit-move-backward)))
+ ((< n 0) (dotimes (i (- n)) (paredit-move-forward))))))
+
+(defun paredit-move-forward ()
(cond ((paredit-in-string-p)
(let ((end (paredit-enclosing-string-end)))
;; `forward-sexp' and `up-list' may move into the next string
@@ -1805,11 +1822,7 @@ If there are no more S-expressions in this one before
the closing
(paredit-handle-sexp-errors (forward-sexp)
(up-list)))))
-(defun-saving-mark paredit-backward ()
- "Move backward an S-expression, or up an S-expression backward.
-If there are no more S-expressions in this one before the opening
- delimiter, move past that opening delimiter backward; otherwise, move
- move backward past the S-expression preceding the point."
+(defun paredit-move-backward ()
(cond ((paredit-in-string-p)
(let ((start (paredit-enclosing-string-start)))
(if (paredit-handle-sexp-errors
@@ -1824,15 +1837,6 @@ If there are no more S-expressions in this one before
the opening
(t
(paredit-handle-sexp-errors (backward-sexp)
(backward-up-list)))))
-
-;;; Why is this not in lisp.el?
-
-(defun backward-down-list (&optional arg)
- "Move backward and descend into one level of parentheses.
-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
@@ -1942,34 +1946,30 @@ With a prefix argument N, encompass all N S-expressions
forward."
(throw 'exit (+ (point) horizontal-direction)))))))
nil)))
-(defun paredit-forward-down (&optional argument)
+(defun-motion paredit-forward-down (&optional argument)
"Move forward down into a list.
With a positive argument, move forward down that many levels.
With a negative argument, move backward down that many levels."
- (interactive "p")
(paredit-up/down (or argument +1) -1))
-(defun paredit-backward-up (&optional argument)
+(defun-motion paredit-backward-up (&optional argument)
"Move backward up out of the enclosing list.
With a positive argument, move backward up that many levels.
With a negative argument, move forward up that many levels.
If in a string initially, that counts as one level."
- (interactive "p")
(paredit-up/down (- 0 (or argument +1)) +1))
-(defun paredit-forward-up (&optional argument)
+(defun-motion paredit-forward-up (&optional argument)
"Move forward up out of the enclosing list.
With a positive argument, move forward up that many levels.
With a negative argument, move backward up that many levels.
If in a string initially, that counts as one level."
- (interactive "p")
(paredit-up/down (or argument +1) +1))
-(defun paredit-backward-down (&optional argument)
+(defun-motion paredit-backward-down (&optional argument)
"Move backward down into a list.
With a positive argument, move backward down that many levels.
With a negative argument, move forward down that many levels."
- (interactive "p")
(paredit-up/down (- 0 (or argument +1)) -1))
;;;; Depth-Changing Commands: Wrapping, Splicing, & Raising
- [nongnu] elpa/paredit 540bc9c 153/224: Remove unnecessarily nasty text about reporting bugs., (continued)
- [nongnu] elpa/paredit 540bc9c 153/224: Remove unnecessarily nasty text about reporting bugs., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit b02f509 156/224: New file NEWS from paredit.release., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit b647a1a 158/224: Bump copyright year on test.el to 2013., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit f25cd3b 159/224: Add a zillion paredit-kill tests. Fix a tiny bug they revealed., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit 460254d 162/224: Fix paredit-doublequote inside a string escape., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit db82936 163/224: Make `paredit-forward' and `paredit-backward' move out of strings., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit 18cf19f 164/224: Implement `paredit-preserving-column'., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit 5840f55 165/224: Preserve column better in `paredit-join'., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit 9838fe2 174/224: In check.sh, use $EMACS if set, defaulting to `emacs'., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit 3bdd840 175/224: Rework paredit-semicolon and add some tests for it., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit 014cdfe 177/224: Handle shift selection in motion commands in recent GNU Emacs.,
ELPA Syncer <=
- [nongnu] elpa/paredit be28e85 178/224: Mention shift selection for motion commands in NEWS., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit 42a0494 179/224: Use $EMACS in genhtml.sh too., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit 856d927 180/224: Use `paredit-preserving-column' in `paredit-reindent-defun'., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit a26c148 182/224: Bind M-[ to paredit-wrap-square., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit 4e5ba81 184/224: Make slurping `(|) foo' yield `(|foo)', not `(| foo)'., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit 0c805ec 188/224: Rework HTML output to simplify and prettify everything., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit 5114a62 193/224: If in a string, slurp into the enclosing list if necessary., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit 8b38538 190/224: A little more HTML tweaking. Not perfect, but enough for the day., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit 6304b64 191/224: Suggest `M-x enable-paredit-mode RET'., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit b68216f 197/224: Add news item about changes to HTML reference., ELPA Syncer, 2021/08/07