summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTaylor R Campbell <campbell@mumble.net>2013-06-13 19:47:56 +0000
committerTaylor R Campbell <campbell@mumble.net>2013-06-13 19:47:59 +0000
commit014cdfea76267e57daafac82dff1103e5e34b753 (patch)
tree36ee6ed4f79a731676f34dc3ebbb0c83688f4aa7
parentdb99ca60b76d3a42dbf59b1e7bdda6320d48eb01 (diff)
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.
-rw-r--r--paredit.el50
1 files 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