aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1994-11-28 19:44:16 +0000
committerRichard M. Stallman1994-11-28 19:44:16 +0000
commitc66587feff67603818ea49fe4b7bfafe77a93e89 (patch)
treee8eb16d2ced416de573c2c9fcb5b5002b779db45
parent385b6cc702ce0e1fc88308ceac4cee19dfa20903 (diff)
downloademacs-c66587feff67603818ea49fe4b7bfafe77a93e89.tar.gz
emacs-c66587feff67603818ea49fe4b7bfafe77a93e89.zip
(keyboard-escape-quit): New command.
(beginning-of-buffer, end-of-buffer): With argument, calculate fraction wrt accessible portion of buffer.
-rw-r--r--lisp/simple.el64
1 files changed, 47 insertions, 17 deletions
diff --git a/lisp/simple.el b/lisp/simple.el
index 14e2c68aa14..157a5cb90d0 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -248,37 +248,46 @@ Goes backward if ARG is negative; error if CHAR not found."
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.
251With arg N, put point N/10 of the way from the true beginning. 251With arg N, put point N/10 of the way from the beginning.
252
253If the buffer is narrowed, this command uses the beginning and size
254of the accessible part of the buffer.
252 255
253Don't use this command in Lisp programs! 256Don'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.
268With arg N, put point N/10 of the way from the true end. 273With arg N, put point N/10 of the way from the end.
274
275If the buffer is narrowed, this command uses the beginning and size
276of the accessible part of the buffer.
269 277
270Don't use this command in Lisp programs! 278Don'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)
@@ -2491,6 +2500,27 @@ At top-level, as an editor command, this simply beeps."
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).
2506This command can exit an interactive command such as `query-replace',
2507can clear out a prefix argument or a region,
2508can get out of the minibuffer or other recursive edit,
2509or 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.