diff options
Diffstat (limited to 'lisp/simple.el')
| -rw-r--r-- | lisp/simple.el | 85 |
1 files changed, 47 insertions, 38 deletions
diff --git a/lisp/simple.el b/lisp/simple.el index 979f3835c57..4a95b18bcb9 100644 --- a/lisp/simple.el +++ b/lisp/simple.el | |||
| @@ -123,33 +123,33 @@ to navigate in it.") | |||
| 123 | 123 | ||
| 124 | (make-variable-buffer-local 'next-error-function) | 124 | (make-variable-buffer-local 'next-error-function) |
| 125 | 125 | ||
| 126 | (defsubst next-error-buffer-p (buffer | 126 | (defsubst next-error-buffer-p (buffer |
| 127 | &optional | 127 | &optional |
| 128 | extra-test-inclusive | 128 | extra-test-inclusive |
| 129 | extra-test-exclusive) | 129 | extra-test-exclusive) |
| 130 | "Test if BUFFER is a next-error capable buffer. | 130 | "Test if BUFFER is a next-error capable buffer. |
| 131 | EXTRA-TEST-INCLUSIVE is called to allow extra buffers. | 131 | EXTRA-TEST-INCLUSIVE is called to allow extra buffers. |
| 132 | EXTRA-TEST-INCLUSIVE is called to disallow buffers." | 132 | EXTRA-TEST-EXCLUSIVE is called to disallow buffers." |
| 133 | (with-current-buffer buffer | 133 | (with-current-buffer buffer |
| 134 | (or (and extra-test-inclusive (funcall extra-test-inclusive)) | 134 | (or (and extra-test-inclusive (funcall extra-test-inclusive)) |
| 135 | (and (if extra-test-exclusive (funcall extra-test-exclusive) t) | 135 | (and (if extra-test-exclusive (funcall extra-test-exclusive) t) |
| 136 | next-error-function)))) | 136 | next-error-function)))) |
| 137 | 137 | ||
| 138 | (defun next-error-find-buffer (&optional other-buffer | 138 | (defun next-error-find-buffer (&optional other-buffer |
| 139 | extra-test-inclusive | 139 | extra-test-inclusive |
| 140 | extra-test-exclusive) | 140 | extra-test-exclusive) |
| 141 | "Return a next-error capable buffer. | 141 | "Return a next-error capable buffer. |
| 142 | OTHER-BUFFER will disallow the current buffer. | 142 | OTHER-BUFFER will disallow the current buffer. |
| 143 | EXTRA-TEST-INCLUSIVE is called to allow extra buffers. | 143 | EXTRA-TEST-INCLUSIVE is called to allow extra buffers. |
| 144 | EXTRA-TEST-INCLUSIVE is called to disallow buffers." | 144 | EXTRA-TEST-EXCLUSIVE is called to disallow buffers." |
| 145 | (or | 145 | (or |
| 146 | ;; 1. If one window on the selected frame displays such buffer, return it. | 146 | ;; 1. If one window on the selected frame displays such buffer, return it. |
| 147 | (let ((window-buffers | 147 | (let ((window-buffers |
| 148 | (delete-dups | 148 | (delete-dups |
| 149 | (delq nil (mapcar (lambda (w) | 149 | (delq nil (mapcar (lambda (w) |
| 150 | (if (next-error-buffer-p | 150 | (if (next-error-buffer-p |
| 151 | (window-buffer w) | 151 | (window-buffer w) |
| 152 | extra-test-inclusive extra-test-exclusive) | 152 | extra-test-inclusive extra-test-exclusive) |
| 153 | (window-buffer w))) | 153 | (window-buffer w))) |
| 154 | (window-list)))))) | 154 | (window-list)))))) |
| 155 | (if other-buffer | 155 | (if other-buffer |
| @@ -159,29 +159,29 @@ EXTRA-TEST-INCLUSIVE is called to disallow buffers." | |||
| 159 | ;; 2. If next-error-last-buffer is set to a live buffer, use that. | 159 | ;; 2. If next-error-last-buffer is set to a live buffer, use that. |
| 160 | (if (and next-error-last-buffer | 160 | (if (and next-error-last-buffer |
| 161 | (buffer-name next-error-last-buffer) | 161 | (buffer-name next-error-last-buffer) |
| 162 | (next-error-buffer-p next-error-last-buffer | 162 | (next-error-buffer-p next-error-last-buffer |
| 163 | extra-test-inclusive extra-test-exclusive) | 163 | extra-test-inclusive extra-test-exclusive) |
| 164 | (or (not other-buffer) | 164 | (or (not other-buffer) |
| 165 | (not (eq next-error-last-buffer (current-buffer))))) | 165 | (not (eq next-error-last-buffer (current-buffer))))) |
| 166 | next-error-last-buffer) | 166 | next-error-last-buffer) |
| 167 | ;; 3. If the current buffer is a next-error capable buffer, return it. | 167 | ;; 3. If the current buffer is a next-error capable buffer, return it. |
| 168 | (if (and (not other-buffer) | 168 | (if (and (not other-buffer) |
| 169 | (next-error-buffer-p (current-buffer) | 169 | (next-error-buffer-p (current-buffer) |
| 170 | extra-test-inclusive extra-test-exclusive)) | 170 | extra-test-inclusive extra-test-exclusive)) |
| 171 | (current-buffer)) | 171 | (current-buffer)) |
| 172 | ;; 4. Look for a next-error capable buffer in a buffer list. | 172 | ;; 4. Look for a next-error capable buffer in a buffer list. |
| 173 | (let ((buffers (buffer-list))) | 173 | (let ((buffers (buffer-list))) |
| 174 | (while (and buffers | 174 | (while (and buffers |
| 175 | (or (not (next-error-buffer-p | 175 | (or (not (next-error-buffer-p |
| 176 | (car buffers) | 176 | (car buffers) |
| 177 | extra-test-inclusive extra-test-exclusive)) | 177 | extra-test-inclusive extra-test-exclusive)) |
| 178 | (and other-buffer (eq (car buffers) (current-buffer))))) | 178 | (and other-buffer (eq (car buffers) (current-buffer))))) |
| 179 | (setq buffers (cdr buffers))) | 179 | (setq buffers (cdr buffers))) |
| 180 | (if buffers | 180 | (if buffers |
| 181 | (car buffers) | 181 | (car buffers) |
| 182 | (or (and other-buffer | 182 | (or (and other-buffer |
| 183 | (next-error-buffer-p (current-buffer) | 183 | (next-error-buffer-p (current-buffer) |
| 184 | extra-test-inclusive extra-test-exclusive) | 184 | extra-test-inclusive extra-test-exclusive) |
| 185 | ;; The current buffer is a next-error capable buffer. | 185 | ;; The current buffer is a next-error capable buffer. |
| 186 | (progn | 186 | (progn |
| 187 | (if other-buffer | 187 | (if other-buffer |
| @@ -646,7 +646,8 @@ If BACKWARD-ONLY is non-nil, only delete spaces before point." | |||
| 646 | (constrain-to-field nil orig-pos t))))) | 646 | (constrain-to-field nil orig-pos t))))) |
| 647 | 647 | ||
| 648 | (defvar inhibit-mark-movement nil | 648 | (defvar inhibit-mark-movement nil |
| 649 | "If non-nil, \\[beginning-of-buffer] and \\[end-of-buffer] does not set the mark.") | 649 | "If non-nil, movement commands, such as \\[beginning-of-buffer], \ |
| 650 | do not set the mark.") | ||
| 650 | 651 | ||
| 651 | (defun beginning-of-buffer (&optional arg) | 652 | (defun beginning-of-buffer (&optional arg) |
| 652 | "Move point to the beginning of the buffer; leave mark at previous position. | 653 | "Move point to the beginning of the buffer; leave mark at previous position. |
| @@ -659,8 +660,10 @@ of the accessible part of the buffer. | |||
| 659 | Don't use this command in Lisp programs! | 660 | Don't use this command in Lisp programs! |
| 660 | \(goto-char (point-min)) is faster and avoids clobbering the mark." | 661 | \(goto-char (point-min)) is faster and avoids clobbering the mark." |
| 661 | (interactive "P") | 662 | (interactive "P") |
| 662 | (unless (or inhibit-mark-movement (consp arg)) | 663 | (or inhibit-mark-movement |
| 663 | (push-mark)) | 664 | (consp arg) |
| 665 | (and transient-mark-mode mark-active) | ||
| 666 | (push-mark)) | ||
| 664 | (let ((size (- (point-max) (point-min)))) | 667 | (let ((size (- (point-max) (point-min)))) |
| 665 | (goto-char (if (and arg (not (consp arg))) | 668 | (goto-char (if (and arg (not (consp arg))) |
| 666 | (+ (point-min) | 669 | (+ (point-min) |
| @@ -683,8 +686,10 @@ of the accessible part of the buffer. | |||
| 683 | Don't use this command in Lisp programs! | 686 | Don't use this command in Lisp programs! |
| 684 | \(goto-char (point-max)) is faster and avoids clobbering the mark." | 687 | \(goto-char (point-max)) is faster and avoids clobbering the mark." |
| 685 | (interactive "P") | 688 | (interactive "P") |
| 686 | (unless (or inhibit-mark-movement (consp arg)) | 689 | (or inhibit-mark-movement |
| 687 | (push-mark)) | 690 | (consp arg) |
| 691 | (and transient-mark-mode mark-active) | ||
| 692 | (push-mark)) | ||
| 688 | (let ((size (- (point-max) (point-min)))) | 693 | (let ((size (- (point-max) (point-min)))) |
| 689 | (goto-char (if (and arg (not (consp arg))) | 694 | (goto-char (if (and arg (not (consp arg))) |
| 690 | (- (point-max) | 695 | (- (point-max) |
| @@ -2987,11 +2992,11 @@ You can also deactivate the mark by typing \\[keyboard-quit] or | |||
| 2987 | Many commands change their behavior when Transient Mark mode is in effect | 2992 | Many commands change their behavior when Transient Mark mode is in effect |
| 2988 | and the mark is active, by acting on the region instead of their usual | 2993 | and the mark is active, by acting on the region instead of their usual |
| 2989 | default part of the buffer's text. Examples of such commands include | 2994 | default part of the buffer's text. Examples of such commands include |
| 2990 | \\[comment-dwim], \\[flush-lines], \\[ispell], \\[keep-lines], | 2995 | \\[comment-dwim], \\[flush-lines], \\[keep-lines], \ |
| 2991 | \\[query-replace], \\[query-replace-regexp], and \\[undo]. Invoke | 2996 | \\[query-replace], \\[query-replace-regexp], \\[ispell], and \\[undo]. |
| 2992 | \\[apropos-documentation] and type \"transient\" or \"mark.*active\" at | 2997 | Invoke \\[apropos-documentation] and type \"transient\" or |
| 2993 | the prompt, to see the documentation of commands which are sensitive to | 2998 | \"mark.*active\" at the prompt, to see the documentation of |
| 2994 | the Transient Mark mode." | 2999 | commands which are sensitive to the Transient Mark mode." |
| 2995 | :global t :group 'editing-basics :require nil) | 3000 | :global t :group 'editing-basics :require nil) |
| 2996 | 3001 | ||
| 2997 | (defun pop-global-mark () | 3002 | (defun pop-global-mark () |
| @@ -3242,7 +3247,7 @@ Outline mode sets this." | |||
| 3242 | (if (if forward | 3247 | (if (if forward |
| 3243 | ;; If going forward, don't accept the previous | 3248 | ;; If going forward, don't accept the previous |
| 3244 | ;; allowable position if it is before the target line. | 3249 | ;; allowable position if it is before the target line. |
| 3245 | (< line-beg (point)) | 3250 | (< line-beg (point)) |
| 3246 | ;; If going backward, don't accept the previous | 3251 | ;; If going backward, don't accept the previous |
| 3247 | ;; allowable position if it is still after the target line. | 3252 | ;; allowable position if it is still after the target line. |
| 3248 | (<= (point) line-end)) | 3253 | (<= (point) line-end)) |
| @@ -3523,12 +3528,17 @@ With argument, do this that many times." | |||
| 3523 | (interactive "p") | 3528 | (interactive "p") |
| 3524 | (forward-word (- (or arg 1)))) | 3529 | (forward-word (- (or arg 1)))) |
| 3525 | 3530 | ||
| 3526 | (defun mark-word (arg) | 3531 | (defun mark-word (&optional arg) |
| 3527 | "Set mark arg words away from point. | 3532 | "Set mark ARG words away from point. |
| 3528 | If this command is repeated, it marks the next ARG words after the ones | 3533 | The place mark goes is the same place \\[forward-word] would |
| 3529 | already marked." | 3534 | move to with the same argument. |
| 3530 | (interactive "p") | 3535 | If this command is repeated or mark is active in Transient Mark mode, |
| 3531 | (cond ((and (eq last-command this-command) (mark t)) | 3536 | it marks the next ARG words after the ones already marked." |
| 3537 | (interactive "P") | ||
| 3538 | (cond ((or (and (eq last-command this-command) (mark t)) | ||
| 3539 | (and transient-mark-mode mark-active)) | ||
| 3540 | (setq arg (if arg (prefix-numeric-value arg) | ||
| 3541 | (if (< (mark) (point)) -1 1))) | ||
| 3532 | (set-mark | 3542 | (set-mark |
| 3533 | (save-excursion | 3543 | (save-excursion |
| 3534 | (goto-char (mark)) | 3544 | (goto-char (mark)) |
| @@ -3537,7 +3547,7 @@ already marked." | |||
| 3537 | (t | 3547 | (t |
| 3538 | (push-mark | 3548 | (push-mark |
| 3539 | (save-excursion | 3549 | (save-excursion |
| 3540 | (forward-word arg) | 3550 | (forward-word (prefix-numeric-value arg)) |
| 3541 | (point)) | 3551 | (point)) |
| 3542 | nil t)))) | 3552 | nil t)))) |
| 3543 | 3553 | ||
| @@ -4021,8 +4031,7 @@ or go back to just one window (by deleting all but the selected window)." | |||
| 4021 | (abort-recursive-edit)) | 4031 | (abort-recursive-edit)) |
| 4022 | (current-prefix-arg | 4032 | (current-prefix-arg |
| 4023 | nil) | 4033 | nil) |
| 4024 | ((and transient-mark-mode | 4034 | ((and transient-mark-mode mark-active) |
| 4025 | mark-active) | ||
| 4026 | (deactivate-mark)) | 4035 | (deactivate-mark)) |
| 4027 | ((> (recursion-depth) 0) | 4036 | ((> (recursion-depth) 0) |
| 4028 | (exit-recursive-edit)) | 4037 | (exit-recursive-edit)) |