comparison lisp/simple.el @ 10085:f7b9813ea757

(keyboard-escape-quit): New command. (beginning-of-buffer, end-of-buffer): With argument, calculate fraction wrt accessible portion of buffer.
author Richard M. Stallman <rms@gnu.org>
date Mon, 28 Nov 1994 19:44:16 +0000
parents db01a04d2afb
children 10a032873be6
comparison
equal deleted inserted replaced
10084:e930bf84753c 10085:f7b9813ea757
246 ; (goto-char (if (> arg 0) (1- (point)) (1+ (point)))) 246 ; (goto-char (if (> arg 0) (1- (point)) (1+ (point))))
247 (point)))) 247 (point))))
248 248
249 (defun beginning-of-buffer (&optional arg) 249 (defun beginning-of-buffer (&optional arg)
250 "Move point to the beginning of the buffer; leave mark at previous position. 250 "Move point to the beginning of the buffer; leave mark at previous position.
251 With arg N, put point N/10 of the way from the true beginning. 251 With arg N, put point N/10 of the way from the beginning.
252
253 If the buffer is narrowed, this command uses the beginning and size
254 of the accessible part of the buffer.
252 255
253 Don't use this command in Lisp programs! 256 Don't use this command in Lisp programs!
254 \(goto-char (point-min)) is faster and avoids clobbering the mark." 257 \(goto-char (point-min)) is faster and avoids clobbering the mark."
255 (interactive "P") 258 (interactive "P")
256 (push-mark) 259 (push-mark)
257 (goto-char (if arg 260 (let ((size (- (point-max) (point-min))))
258 (if (> (buffer-size) 10000) 261 (goto-char (if arg
259 ;; Avoid overflow for large buffer sizes! 262 (+ (point-min)
260 (* (prefix-numeric-value arg) 263 (if (> size 10000)
261 (/ (buffer-size) 10)) 264 ;; Avoid overflow for large buffer sizes!
262 (/ (+ 10 (* (buffer-size) (prefix-numeric-value arg))) 10)) 265 (* (prefix-numeric-value arg)
263 (point-min))) 266 (/ size 10))
267 (/ (+ 10 (* size (prefix-numeric-value arg))) 10)))
268 (point-min))))
264 (if arg (forward-line 1))) 269 (if arg (forward-line 1)))
265 270
266 (defun end-of-buffer (&optional arg) 271 (defun end-of-buffer (&optional arg)
267 "Move point to the end of the buffer; leave mark at previous position. 272 "Move point to the end of the buffer; leave mark at previous position.
268 With arg N, put point N/10 of the way from the true end. 273 With arg N, put point N/10 of the way from the end.
274
275 If the buffer is narrowed, this command uses the beginning and size
276 of the accessible part of the buffer.
269 277
270 Don't use this command in Lisp programs! 278 Don't use this command in Lisp programs!
271 \(goto-char (point-max)) is faster and avoids clobbering the mark." 279 \(goto-char (point-max)) is faster and avoids clobbering the mark."
272 (interactive "P") 280 (interactive "P")
273 (push-mark) 281 (push-mark)
274 (goto-char (if arg 282 (let ((size (- (point-max) (point-min))))
275 (- (1+ (buffer-size)) 283 (goto-char (if arg
276 (if (> (buffer-size) 10000) 284 (- (point-max)
277 ;; Avoid overflow for large buffer sizes! 285 (if (> size 10000)
278 (* (prefix-numeric-value arg) 286 ;; Avoid overflow for large buffer sizes!
279 (/ (buffer-size) 10)) 287 (* (prefix-numeric-value arg)
280 (/ (* (buffer-size) (prefix-numeric-value arg)) 10))) 288 (/ size 10))
281 (point-max))) 289 (/ (* size (prefix-numeric-value arg)) 10)))
290 (point-max))))
282 ;; If we went to a place in the middle of the buffer, 291 ;; If we went to a place in the middle of the buffer,
283 ;; adjust it to the beginning of a line. 292 ;; adjust it to the beginning of a line.
284 (if arg (forward-line 1) 293 (if arg (forward-line 1)
285 ;; If the end of the buffer is not already on the screen, 294 ;; If the end of the buffer is not already on the screen,
286 ;; then scroll specially to put it near, but not at, the bottom. 295 ;; then scroll specially to put it near, but not at, the bottom.
2489 (interactive) 2498 (interactive)
2490 (deactivate-mark) 2499 (deactivate-mark)
2491 (signal 'quit nil)) 2500 (signal 'quit nil))
2492 2501
2493 (define-key global-map "\C-g" 'keyboard-quit) 2502 (define-key global-map "\C-g" 'keyboard-quit)
2503
2504 (defun keyboard-escape-quit ()
2505 "Exit the current \"mode\" (in a generalized sense of the word).
2506 This command can exit an interactive command such as `query-replace',
2507 can clear out a prefix argument or a region,
2508 can get out of the minibuffer or other recursive edit,
2509 or delete other windows."
2510 (interactive)
2511 (cond ((eq last-command 'mode-exited) nil)
2512 ((> (minibuffer-depth) 0)
2513 (abort-recursive-edit))
2514 (current-prefix-arg
2515 nil)
2516 ((and transient-mark-mode
2517 mark-active)
2518 (deactivate-mark))
2519 ((not (one-window-p t))
2520 (delete-other-windows))))
2521
2522 ;;; This may not be safe yet.
2523 ;;;(define-key global-map "\e\e\e" 'keyboard-escape-quit)
2494 2524
2495 (defun set-variable (var val) 2525 (defun set-variable (var val)
2496 "Set VARIABLE to VALUE. VALUE is a Lisp object. 2526 "Set VARIABLE to VALUE. VALUE is a Lisp object.
2497 When using this interactively, supply a Lisp expression for VALUE. 2527 When using this interactively, supply a Lisp expression for VALUE.
2498 If you want VALUE to be a string, you must surround it with doublequotes. 2528 If you want VALUE to be a string, you must surround it with doublequotes.