comparison lisp/simple.el @ 5842:9e5f3a0d4e66

Add `noerror' optional argument to `live-move'. 2014-12-31 Michael Sperber <mike@xemacs.org> * simple.el (line-move): Add `noerror' optional argument, as in GNU Emacs.
author Mike Sperber <sperber@deinprogramm.de>
date Sat, 03 Jan 2015 16:24:56 +0100
parents b79e1e02bf01
children ccb0cff115d2
comparison
equal deleted inserted replaced
5841:bf1e13811159 5842:9e5f3a0d4e66
2439 :type 'boolean 2439 :type 'boolean
2440 :group 'editing-basics) 2440 :group 'editing-basics)
2441 2441
2442 ;; This is the guts of next-line and previous-line. 2442 ;; This is the guts of next-line and previous-line.
2443 ;; Count says how many lines to move. 2443 ;; Count says how many lines to move.
2444 (defun line-move (count) 2444 (defun line-move (count &optional noerror)
2445 ;; Don't run any point-motion hooks, and disregard intangibility, 2445 ;; Don't run any point-motion hooks, and disregard intangibility,
2446 ;; for intermediate positions. 2446 ;; for intermediate positions.
2447 (let ((inhibit-point-motion-hooks t) 2447 (let ((inhibit-point-motion-hooks t)
2448 (opoint (point)) 2448 (opoint (point))
2449 new) 2449 new)
2468 ;; It doesn't get confused by intangible text. 2468 ;; It doesn't get confused by intangible text.
2469 (end-of-line) 2469 (end-of-line)
2470 (zerop (forward-line 1))) 2470 (zerop (forward-line 1)))
2471 (and (zerop (forward-line count)) 2471 (and (zerop (forward-line count))
2472 (bolp))) 2472 (bolp)))
2473 (signal (if (< count 0) 2473 (if (not noerror)
2474 'beginning-of-buffer 2474 (signal (if (< count 0)
2475 'end-of-buffer) 2475 'beginning-of-buffer
2476 nil)) 2476 'end-of-buffer)
2477 nil)))
2477 ;; Move by count lines, but ignore invisible ones. 2478 ;; Move by count lines, but ignore invisible ones.
2478 (while (> count 0) 2479 (while (> count 0)
2479 (end-of-line) 2480 (end-of-line)
2480 (and (zerop (vertical-motion 1)) 2481 (and (zerop (vertical-motion 1))
2482 (not noerror)
2481 (signal 'end-of-buffer nil)) 2483 (signal 'end-of-buffer nil))
2482 ;; If the following character is currently invisible, 2484 ;; If the following character is currently invisible,
2483 ;; skip all characters with that same `invisible' property value. 2485 ;; skip all characters with that same `invisible' property value.
2484 (while (and (not (eobp)) 2486 (while (and (not (eobp))
2485 (let ((prop 2487 (let ((prop
2493 (goto-char (next-extent-change (point))))) ; XEmacs 2495 (goto-char (next-extent-change (point))))) ; XEmacs
2494 (setq count (1- count))) 2496 (setq count (1- count)))
2495 (while (< count 0) 2497 (while (< count 0)
2496 (beginning-of-line) 2498 (beginning-of-line)
2497 (and (zerop (vertical-motion -1)) 2499 (and (zerop (vertical-motion -1))
2500 (not noerror)
2498 (signal 'beginning-of-buffer nil)) 2501 (signal 'beginning-of-buffer nil))
2499 (while (and (not (bobp)) 2502 (while (and (not (bobp))
2500 (let ((prop 2503 (let ((prop
2501 (get-char-property (1- (point)) 'invisible))) 2504 (get-char-property (1- (point)) 'invisible)))
2502 (if (eq buffer-invisibility-spec t) 2505 (if (eq buffer-invisibility-spec t)