Mercurial > emacs
comparison lisp/emacs-lisp/lisp.el @ 58918:2ee970dcd072
* emacs-lisp/lisp.el (beginning-of-defun, end-of-defun):
Do not push mark when mark is active in transient-mark-mode.
* emacs-lisp/lisp.el (mark-sexp, mark-defun):
Extend the region when mark is active in transient-mark-mode,
regardless of the last command. Doc fix.
* emacs-lisp/lisp.el (mark-sexp): Reverse the condition for
preserving direction, to mark forward instead of backward when mark
is equal to point (e.g. when C-SPC C-M-SPC is typed in t-m-m).
author | Juri Linkov <juri@jurta.org> |
---|---|
date | Mon, 13 Dec 2004 03:09:59 +0000 |
parents | 8c6dae33cdc3 |
children | eb752b1a84b1 fb79180b618d |
comparison
equal
deleted
inserted
replaced
58917:44dfc09c6b67 | 58918:2ee970dcd072 |
---|---|
71 | 71 |
72 (defun mark-sexp (&optional arg) | 72 (defun mark-sexp (&optional arg) |
73 "Set mark ARG sexps from point. | 73 "Set mark ARG sexps from point. |
74 The place mark goes is the same place \\[forward-sexp] would | 74 The place mark goes is the same place \\[forward-sexp] would |
75 move to with the same argument. | 75 move to with the same argument. |
76 If this command is repeated, it marks the next ARG sexps after the ones | 76 If this command is repeated or mark is active in Transient Mark mode, |
77 already marked." | 77 it marks the next ARG sexps after the ones already marked." |
78 (interactive "P") | 78 (interactive "P") |
79 (cond ((and (eq last-command this-command) (mark t)) | 79 (cond ((or (and (eq last-command this-command) (mark t)) |
80 (and transient-mark-mode mark-active)) | |
80 (setq arg (if arg (prefix-numeric-value arg) | 81 (setq arg (if arg (prefix-numeric-value arg) |
81 (if (> (mark) (point)) 1 -1))) | 82 (if (< (mark) (point)) -1 1))) |
82 (set-mark | 83 (set-mark |
83 (save-excursion | 84 (save-excursion |
84 (goto-char (mark)) | 85 (goto-char (mark)) |
85 (forward-sexp arg) | 86 (forward-sexp arg) |
86 (point)))) | 87 (point)))) |
87 (t | 88 (t |
88 (push-mark | 89 (push-mark |
89 (save-excursion | 90 (save-excursion |
90 (forward-sexp (prefix-numeric-value arg)) | 91 (forward-sexp (prefix-numeric-value arg)) |
91 (point)) | 92 (point)) |
189 open-parenthesis, and point ends up at the beginning of the line. | 190 open-parenthesis, and point ends up at the beginning of the line. |
190 | 191 |
191 If variable `beginning-of-defun-function' is non-nil, its value | 192 If variable `beginning-of-defun-function' is non-nil, its value |
192 is called as a function to find the defun's beginning." | 193 is called as a function to find the defun's beginning." |
193 (interactive "p") | 194 (interactive "p") |
194 (and (eq this-command 'beginning-of-defun) | 195 (or inhibit-mark-movement |
195 (or inhibit-mark-movement (eq last-command 'beginning-of-defun) | 196 (not (eq this-command 'beginning-of-defun)) |
196 (push-mark))) | 197 (eq last-command 'beginning-of-defun) |
198 (and transient-mark-mode mark-active) | |
199 (push-mark)) | |
197 (and (beginning-of-defun-raw arg) | 200 (and (beginning-of-defun-raw arg) |
198 (progn (beginning-of-line) t))) | 201 (progn (beginning-of-line) t))) |
199 | 202 |
200 (defun beginning-of-defun-raw (&optional arg) | 203 (defun beginning-of-defun-raw (&optional arg) |
201 "Move point to the character that starts a defun. | 204 "Move point to the character that starts a defun. |
240 `beginning-of-defun'. | 243 `beginning-of-defun'. |
241 | 244 |
242 If variable `end-of-defun-function' is non-nil, its value | 245 If variable `end-of-defun-function' is non-nil, its value |
243 is called as a function to find the defun's end." | 246 is called as a function to find the defun's end." |
244 (interactive "p") | 247 (interactive "p") |
245 (and (eq this-command 'end-of-defun) | 248 (or inhibit-mark-movement |
246 (or inhibit-mark-movement (eq last-command 'end-of-defun) | 249 (not (eq this-command 'end-of-defun)) |
247 (push-mark))) | 250 (eq last-command 'end-of-defun) |
251 (and transient-mark-mode mark-active) | |
252 (push-mark)) | |
248 (if (or (null arg) (= arg 0)) (setq arg 1)) | 253 (if (or (null arg) (= arg 0)) (setq arg 1)) |
249 (if end-of-defun-function | 254 (if end-of-defun-function |
250 (if (> arg 0) | 255 (if (> arg 0) |
251 (dotimes (i arg) | 256 (dotimes (i arg) |
252 (funcall end-of-defun-function)) | 257 (funcall end-of-defun-function)) |
287 (setq arg (1+ arg)))))) | 292 (setq arg (1+ arg)))))) |
288 | 293 |
289 (defun mark-defun () | 294 (defun mark-defun () |
290 "Put mark at end of this defun, point at beginning. | 295 "Put mark at end of this defun, point at beginning. |
291 The defun marked is the one that contains point or follows point. | 296 The defun marked is the one that contains point or follows point. |
292 If this command is repeated, marks more defuns after the ones | 297 If this command is repeated or mark is active in Transient Mark mode, |
293 already marked." | 298 it marks more defuns after the ones already marked." |
294 (interactive) | 299 (interactive) |
295 (cond ((and (eq last-command this-command) (mark t)) | 300 (cond ((or (and (eq last-command this-command) (mark t)) |
301 (and transient-mark-mode mark-active)) | |
296 (set-mark | 302 (set-mark |
297 (save-excursion | 303 (save-excursion |
298 (goto-char (mark)) | 304 (goto-char (mark)) |
299 (end-of-defun) | 305 (end-of-defun) |
300 (point)))) | 306 (point)))) |