Mercurial > emacs
comparison lisp/simple.el @ 5675:3191bf405867
(next-line): Move error signaling and special end of
line behavior into line-move so that next-line is symmetric with
previous-line when next-line-add-newlines is nil.
(line-move): Move as far as possible and ding with a message
if the requested motion cannot be accomplished. When
selective-display is numeric, ensure point actually moves and does
so to a visible line.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Wed, 26 Jan 1994 17:19:32 +0000 |
parents | 82a127d7ef7d |
children | 5810e7311c05 |
comparison
equal
deleted
inserted
replaced
5674:bb8bfab97970 | 5675:3191bf405867 |
---|---|
1411 | 1411 |
1412 If you are thinking of using this in a Lisp program, consider | 1412 If you are thinking of using this in a Lisp program, consider |
1413 using `forward-line' instead. It is usually easier to use | 1413 using `forward-line' instead. It is usually easier to use |
1414 and more reliable (no dependence on goal column, etc.)." | 1414 and more reliable (no dependence on goal column, etc.)." |
1415 (interactive "p") | 1415 (interactive "p") |
1416 (let ((opoint (point))) | 1416 (if (and next-line-add-newlines (= arg 1)) |
1417 (if next-line-add-newlines | 1417 (let ((opoint (point))) |
1418 (if (/= arg 1) | 1418 (forward-line 1) |
1419 (line-move arg) | 1419 (if (or (= opoint (point)) (not (eq (preceding-char) ?\n))) |
1420 (forward-line 1) | 1420 (insert ?\n) |
1421 (if (or (= opoint (point)) (not (eq (preceding-char) ?\n))) | 1421 (goto-char opoint) |
1422 (insert ?\n) | 1422 (line-move arg))) |
1423 (goto-char opoint) | 1423 (line-move arg)) |
1424 (line-move arg))) | |
1425 (if (eobp) | |
1426 (signal 'end-of-buffer nil)) | |
1427 (line-move arg) | |
1428 (if (= opoint (point)) | |
1429 (end-of-line)))) | |
1430 nil) | 1424 nil) |
1431 | 1425 |
1432 (defun previous-line (arg) | 1426 (defun previous-line (arg) |
1433 "Move cursor vertically up ARG lines. | 1427 "Move cursor vertically up ARG lines. |
1434 If there is no character in the target line exactly over the current column, | 1428 If there is no character in the target line exactly over the current column, |
1460 It is the column where point was | 1454 It is the column where point was |
1461 at the start of current run of vertical motion commands. | 1455 at the start of current run of vertical motion commands. |
1462 When the `track-eol' feature is doing its job, the value is 9999.") | 1456 When the `track-eol' feature is doing its job, the value is 9999.") |
1463 | 1457 |
1464 (defun line-move (arg) | 1458 (defun line-move (arg) |
1465 (if (not (or (eq last-command 'next-line) | 1459 (let ((signal |
1466 (eq last-command 'previous-line))) | 1460 (catch 'exit |
1467 (setq temporary-goal-column | 1461 (if (not (or (eq last-command 'next-line) |
1468 (if (and track-eol (eolp) | 1462 (eq last-command 'previous-line))) |
1469 ;; Don't count beg of empty line as end of line | 1463 (setq temporary-goal-column |
1470 ;; unless we just did explicit end-of-line. | 1464 (if (and track-eol (eolp) |
1471 (or (not (bolp)) (eq last-command 'end-of-line))) | 1465 ;; Don't count beg of empty line as end of line |
1472 9999 | 1466 ;; unless we just did explicit end-of-line. |
1473 (current-column)))) | 1467 (or (not (bolp)) (eq last-command 'end-of-line))) |
1474 (if (not (integerp selective-display)) | 1468 9999 |
1475 (forward-line arg) | 1469 (current-column)))) |
1476 ;; Move by arg lines, but ignore invisible ones. | 1470 (if (not (integerp selective-display)) |
1477 (while (> arg 0) | 1471 (or (and (zerop (forward-line arg)) |
1478 (vertical-motion 1) | 1472 (bolp)) |
1479 (forward-char -1) | 1473 (throw 'exit (if (bobp) |
1480 (forward-line 1) | 1474 'beginning-of-buffer |
1481 (setq arg (1- arg))) | 1475 'end-of-buffer))) |
1482 (while (< arg 0) | 1476 ;; Move by arg lines, but ignore invisible ones. |
1483 (vertical-motion -1) | 1477 (while (> arg 0) |
1484 (beginning-of-line) | 1478 (end-of-line) |
1485 (setq arg (1+ arg)))) | 1479 (and (zerop (vertical-motion 1)) |
1486 (move-to-column (or goal-column temporary-goal-column)) | 1480 (throw 'exit 'end-of-buffer)) |
1487 nil) | 1481 (setq arg (1- arg))) |
1482 (while (< arg 0) | |
1483 (beginning-of-line) | |
1484 (and (zerop (vertical-motion -1)) | |
1485 (throw 'exit 'beginning-of-buffer)) | |
1486 (setq arg (1+ arg)))) | |
1487 (move-to-column (or goal-column temporary-goal-column)) | |
1488 nil))) | |
1489 (cond | |
1490 ((eq signal 'beginning-of-buffer) | |
1491 (message "Beginning of buffer") | |
1492 (ding)) | |
1493 ((eq signal 'end-of-buffer) | |
1494 (message "End of buffer") | |
1495 (ding))))) | |
1488 | 1496 |
1489 ;;; Many people have said they rarely use this feature, and often type | 1497 ;;; Many people have said they rarely use this feature, and often type |
1490 ;;; it by accident. Maybe it shouldn't even be on a key. | 1498 ;;; it by accident. Maybe it shouldn't even be on a key. |
1491 (put 'set-goal-column 'disabled t) | 1499 (put 'set-goal-column 'disabled t) |
1492 | 1500 |