comparison lisp/simple.el @ 90066:fb79180b618d

Revision: miles@gnu.org--gnu-2004/emacs--unicode--0--patch-78 Merge from emacs--cvs-trunk--0 Patches applied: * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-719 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-732 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-733 Update from CVS: man/calc.texi: Fix some TeX definitions. * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-734 Merge from gnus--rel--5.10 * miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-75 Merge from emacs--cvs-trunk--0 * miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-76 - miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-77 Update from CVS
author Miles Bader <miles@gnu.org>
date Tue, 14 Dec 2004 07:34:55 +0000
parents f2ebccfa87d4 c7ebd794182b
children eac554634bfa
comparison
equal deleted inserted replaced
90065:c26eb15cd14a 90066:fb79180b618d
121 to indicate to `next-error' that this is a candidate buffer and how 121 to indicate to `next-error' that this is a candidate buffer and how
122 to navigate in it.") 122 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
156 (setq window-buffers (delq (current-buffer) window-buffers))) 156 (setq window-buffers (delq (current-buffer) window-buffers)))
157 (if (eq (length window-buffers) 1) 157 (if (eq (length window-buffers) 1)
158 (car window-buffers))) 158 (car window-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
188 (message "This is the only next-error capable buffer")) 188 (message "This is the only next-error capable buffer"))
189 (current-buffer))) 189 (current-buffer)))
644 (progn 644 (progn
645 (skip-chars-forward " \t") 645 (skip-chars-forward " \t")
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.
653 With \\[universal-argument] prefix, do not set mark at previous position. 654 With \\[universal-argument] prefix, do not set mark at previous position.
654 With numeric arg N, put point N/10 of the way from the beginning. 655 With numeric arg N, put point N/10 of the way from the beginning.
657 of the accessible part of the buffer. 658 of the accessible part of the buffer.
658 659
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)
667 (if (> size 10000) 670 (if (> size 10000)
668 ;; Avoid overflow for large buffer sizes! 671 ;; Avoid overflow for large buffer sizes!
681 of the accessible part of the buffer. 684 of the accessible part of the buffer.
682 685
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)
691 (if (> size 10000) 696 (if (> size 10000)
692 ;; Avoid overflow for large buffer sizes! 697 ;; Avoid overflow for large buffer sizes!
2985 \\[keyboard-escape-quit]. 2990 \\[keyboard-escape-quit].
2986 2991
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 ()
2998 "Pop off global mark ring and jump to the top location." 3003 "Pop off global mark ring and jump to the top location."
2999 (interactive) 3004 (interactive)
3240 ;; See if it is ok. 3245 ;; See if it is ok.
3241 (backward-char) 3246 (backward-char)
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))
3249 (setq new (point)) 3254 (setq new (point))
3250 ;; As a last resort, use the end of the line. 3255 ;; As a last resort, use the end of the line.
3521 "Move backward until encountering the beginning of a word. 3526 "Move backward until encountering the beginning of a word.
3522 With argument, do this that many times." 3527 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))
3535 (forward-word arg) 3545 (forward-word arg)
3536 (point)))) 3546 (point))))
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
3544 (defun kill-word (arg) 3554 (defun kill-word (arg)
3545 "Kill characters forward until encountering the end of a word. 3555 "Kill characters forward until encountering the end of a word.
4019 (cond ((eq last-command 'mode-exited) nil) 4029 (cond ((eq last-command 'mode-exited) nil)
4020 ((> (minibuffer-depth) 0) 4030 ((> (minibuffer-depth) 0)
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))
4029 (buffer-quit-function 4038 (buffer-quit-function
4030 (funcall buffer-quit-function)) 4039 (funcall buffer-quit-function))