comparison lisp/lisp.el @ 444:576fb035e263 r21-2-37

Import from CVS: tag r21-2-37
author cvs
date Mon, 13 Aug 2007 11:36:19 +0200
parents 3ecd8885ac67
children 1ccc32a20af4
comparison
equal deleted inserted replaced
443:a8296e22da4e 444:576fb035e263
78 "Move backward across one balanced expression (sexp). 78 "Move backward across one balanced expression (sexp).
79 With argument, do it that many times. Negative arg -N means 79 With argument, do it that many times. Negative arg -N means
80 move forward across N balanced expressions." 80 move forward across N balanced expressions."
81 ;; XEmacs change (for zmacs regions) 81 ;; XEmacs change (for zmacs regions)
82 (interactive "_p") 82 (interactive "_p")
83 (or arg (setq arg 1)) 83 (forward-sexp (- (or arg 1))))
84 (forward-sexp (- arg))) 84
85 85 (defun mark-sexp (&optional arg)
86 (defun mark-sexp (arg)
87 "Set mark ARG sexps from point. 86 "Set mark ARG sexps from point.
88 The place mark goes is the same place \\[forward-sexp] would 87 The place mark goes is the same place \\[forward-sexp] would
89 move to with the same argument. 88 move to with the same argument.
90 Repeat this command to mark more sexps in the same direction." 89 Repeat this command to mark more sexps in the same direction."
91 (interactive "p") 90 (interactive "p")
92 ;; XEmacs change 91 (mark-something 'mark-sexp 'forward-sexp (or arg 1)))
93 (mark-something 'mark-sexp 'forward-sexp arg))
94 92
95 (defun forward-list (&optional arg) 93 (defun forward-list (&optional arg)
96 "Move forward across one balanced group of parentheses. 94 "Move forward across one balanced group of parentheses.
97 With argument, do it that many times. 95 With argument, do it that many times.
98 Negative arg -N means move backward across N groups of parentheses." 96 Negative arg -N means move backward across N groups of parentheses."
99 ;; XEmacs change 97 ;; XEmacs change
100 (interactive "_p") 98 (interactive "_p")
101 (or arg (setq arg 1)) 99 (goto-char (or (scan-lists (point) (or arg 1) 0) (buffer-end (or arg 1)))))
102 (goto-char (or (scan-lists (point) arg 0) (buffer-end arg))))
103 100
104 (defun backward-list (&optional arg) 101 (defun backward-list (&optional arg)
105 "Move backward across one balanced group of parentheses. 102 "Move backward across one balanced group of parentheses.
106 With argument, do it that many times. 103 With argument, do it that many times.
107 Negative arg -N means move forward across N groups of parentheses." 104 Negative arg -N means move forward across N groups of parentheses."
108 ;; XEmacs change (for zmacs regions) 105 ;; XEmacs change (for zmacs regions)
109 (interactive "_p") 106 (interactive "_p")
110 (or arg (setq arg 1)) 107 (forward-list (- (or arg 1))))
111 (forward-list (- arg))) 108
112 109 (defun down-list (&optional arg)
113 (defun down-list (arg)
114 "Move forward down one level of parentheses. 110 "Move forward down one level of parentheses.
115 With argument, do this that many times. 111 With argument, do this that many times.
116 A negative argument means move backward but still go down a level. 112 A negative argument means move backward but still go down a level."
117 In Lisp programs, an argument is required." 113 ;; XEmacs change (for zmacs regions)
118 ;; XEmacs change (for zmacs regions) 114 (interactive "_p")
119 (interactive "_p") 115 (or arg (setq arg 1))
120 (let ((inc (if (> arg 0) 1 -1))) 116 (let ((inc (if (> arg 0) 1 -1)))
121 (while (/= arg 0) 117 (while (/= arg 0)
122 (goto-char (or (scan-lists (point) inc -1) (buffer-end arg))) 118 (goto-char (or (scan-lists (point) inc -1) (buffer-end arg)))
123 (setq arg (- arg inc))))) 119 (setq arg (- arg inc)))))
124 120
125 (defun backward-up-list (arg) 121 (defun backward-up-list (&optional arg)
126 "Move backward out of one level of parentheses. 122 "Move backward out of one level of parentheses.
127 With argument, do this that many times. 123 With argument, do this that many times.
128 A negative argument means move forward but still to a less deep spot. 124 A negative argument means move forward but still to a less deep spot."
129 In Lisp programs, an argument is required." 125 (interactive "_p")
130 (interactive "_p") 126 (up-list (- (or arg 1))))
131 (up-list (- arg))) 127
132 128 (defun up-list (&optional arg)
133 (defun up-list (arg)
134 "Move forward out of one level of parentheses. 129 "Move forward out of one level of parentheses.
135 With argument, do this that many times. 130 With argument, do this that many times.
136 A negative argument means move backward but still to a less deep spot. 131 A negative argument means move backward but still to a less deep spot.
137 In Lisp programs, an argument is required." 132 In Lisp programs, an argument is required."
138 ;; XEmacs change (for zmacs regions) 133 ;; XEmacs change (for zmacs regions)
139 (interactive "_p") 134 (interactive "_p")
135 (or arg (setq arg 1))
140 (let ((inc (if (> arg 0) 1 -1))) 136 (let ((inc (if (> arg 0) 1 -1)))
141 (while (/= arg 0) 137 (while (/= arg 0)
142 (goto-char (or (scan-lists (point) inc 1) (buffer-end arg))) 138 (goto-char (or (scan-lists (point) inc 1) (buffer-end arg)))
143 (setq arg (- arg inc))))) 139 (setq arg (- arg inc)))))
144 140
145 (defun kill-sexp (arg) 141 (defun kill-sexp (&optional arg)
146 "Kill the sexp (balanced expression) following the cursor. 142 "Kill the sexp (balanced expression) following the cursor.
147 With argument, kill that many sexps after the cursor. 143 With argument, kill that many sexps after the cursor.
148 Negative arg -N means kill N sexps before the cursor." 144 Negative arg -N means kill N sexps before the cursor."
149 (interactive "p") 145 (interactive "p")
150 (let ((opoint (point))) 146 (let ((opoint (point)))
151 (forward-sexp arg) 147 (forward-sexp (or arg 1))
152 (kill-region opoint (point)))) 148 (kill-region opoint (point))))
153 149
154 (defun backward-kill-sexp (arg) 150 (defun backward-kill-sexp (&optional arg)
155 "Kill the sexp (balanced expression) preceding the cursor. 151 "Kill the sexp (balanced expression) preceding the cursor.
156 With argument, kill that many sexps before the cursor. 152 With argument, kill that many sexps before the cursor.
157 Negative arg -N means kill N sexps after the cursor." 153 Negative arg -N means kill N sexps after the cursor."
158 (interactive "p") 154 (interactive "p")
159 (kill-sexp (- arg))) 155 (kill-sexp (- (or arg 1))))
160 156
161 (defun beginning-of-defun (&optional arg) 157 (defun beginning-of-defun (&optional arg)
162 "Move backward to the beginning of a defun. 158 "Move backward to the beginning of a defun.
163 With argument, do it that many times. Negative arg -N 159 With argument, do it that many times. Negative arg -N
164 means move forward to Nth following beginning of defun. 160 means move forward to Nth following beginning of defun.