diff options
| author | Eric S. Raymond | 1993-04-23 06:50:37 +0000 |
|---|---|---|
| committer | Eric S. Raymond | 1993-04-23 06:50:37 +0000 |
| commit | 38ebcf290b687a01b019861dbc8f509e54c796d7 (patch) | |
| tree | f468a8673384759fe5838e5dd98d4edbdfcfd3a0 | |
| parent | cdccfc0d1c8960af4d5f38450acfa583549d29a7 (diff) | |
| download | emacs-38ebcf290b687a01b019861dbc8f509e54c796d7.tar.gz emacs-38ebcf290b687a01b019861dbc8f509e54c796d7.zip | |
All fsets changed to defaliases.
(kill-forward-chars, kill-backward-chars): Deleted. These were
internal subroutines used by delete-char and delete-backward-char
before those functions were moved into the C kernel. Now nothing uses
them.
(kill-line): Added kill-whole-line variable. Defaults to nil; a
non-nil value causes a kill-line at the beginning of a line to kill
the newline as well as the line. I find it very convenient. Emulates
Unipress' &kill-lines-magic variable.
(next-line): Added next-line-add-newlines variable. If nil, next-line will not
insert newlines when invoked at the end of a buffer. This obviates three LCD
packages.
(left-arrow, right-arrow): New functions. These do backward-char and
forward-char first. If line truncation is on, they then scroll left or
right as necessary to make sure point is visible.
| -rw-r--r-- | lisp/simple.el | 79 |
1 files changed, 51 insertions, 28 deletions
diff --git a/lisp/simple.el b/lisp/simple.el index 0a7a5bc19af..1662127fe57 100644 --- a/lisp/simple.el +++ b/lisp/simple.el | |||
| @@ -201,18 +201,6 @@ column specified by the variable `left-margin'." | |||
| 201 | (newline) | 201 | (newline) |
| 202 | (indent-according-to-mode)) | 202 | (indent-according-to-mode)) |
| 203 | 203 | ||
| 204 | ;; Internal subroutine of delete-char | ||
| 205 | (defun kill-forward-chars (arg) | ||
| 206 | (if (listp arg) (setq arg (car arg))) | ||
| 207 | (if (eq arg '-) (setq arg -1)) | ||
| 208 | (kill-region (point) (+ (point) arg))) | ||
| 209 | |||
| 210 | ;; Internal subroutine of backward-delete-char | ||
| 211 | (defun kill-backward-chars (arg) | ||
| 212 | (if (listp arg) (setq arg (car arg))) | ||
| 213 | (if (eq arg '-) (setq arg -1)) | ||
| 214 | (kill-region (point) (- (point) arg))) | ||
| 215 | |||
| 216 | (defun backward-delete-char-untabify (arg &optional killp) | 204 | (defun backward-delete-char-untabify (arg &optional killp) |
| 217 | "Delete characters backward, changing tabs into spaces. | 205 | "Delete characters backward, changing tabs into spaces. |
| 218 | Delete ARG chars, and kill (save in kill ring) if KILLP is non-nil. | 206 | Delete ARG chars, and kill (save in kill ring) if KILLP is non-nil. |
| @@ -580,7 +568,7 @@ Get previous element of history which is a completion of minibuffer contents." | |||
| 580 | (forward-line (1- arg))))) | 568 | (forward-line (1- arg))))) |
| 581 | 569 | ||
| 582 | ;Put this on C-x u, so we can force that rather than C-_ into startup msg | 570 | ;Put this on C-x u, so we can force that rather than C-_ into startup msg |
| 583 | (fset 'advertised-undo 'undo) | 571 | (defalias 'advertised-undo 'undo) |
| 584 | 572 | ||
| 585 | (defun undo (&optional arg) | 573 | (defun undo (&optional arg) |
| 586 | "Undo some previous changes. | 574 | "Undo some previous changes. |
| @@ -849,8 +837,13 @@ Repeating \\[universal-argument] without digits or minus sign | |||
| 849 | (forward-line (- arg)) | 837 | (forward-line (- arg)) |
| 850 | (skip-chars-forward " \t")) | 838 | (skip-chars-forward " \t")) |
| 851 | 839 | ||
| 840 | (defvar kill-whole-line nil | ||
| 841 | "*If non-nil, kill-line kills the whole line (including the newline) | ||
| 842 | if point is positioned at the beginning of a line.") | ||
| 843 | |||
| 852 | (defun kill-line (&optional arg) | 844 | (defun kill-line (&optional arg) |
| 853 | "Kill the rest of the current line; if no nonblanks there, kill thru newline. | 845 | "Kill the rest of the current line; if the line is blank, or if point is at |
| 846 | the beginning of the line and kill-whole-line is non-nil, kill thru newline. | ||
| 854 | With prefix argument, kill that many lines from point. | 847 | With prefix argument, kill that many lines from point. |
| 855 | Negative arguments kill lines backward. | 848 | Negative arguments kill lines backward. |
| 856 | 849 | ||
| @@ -865,7 +858,7 @@ a number counts as a prefix arg." | |||
| 865 | (forward-line (prefix-numeric-value arg)) | 858 | (forward-line (prefix-numeric-value arg)) |
| 866 | (if (eobp) | 859 | (if (eobp) |
| 867 | (signal 'end-of-buffer nil)) | 860 | (signal 'end-of-buffer nil)) |
| 868 | (if (looking-at "[ \t]*$") | 861 | (if (or (looking-at "[ \t]*$") (and kill-whole-line (bolp))) |
| 869 | (forward-line 1) | 862 | (forward-line 1) |
| 870 | (end-of-line))) | 863 | (end-of-line))) |
| 871 | (point)))) | 864 | (point)))) |
| @@ -1261,7 +1254,7 @@ Does not set point. Does nothing if mark ring is empty." | |||
| 1261 | (if (null (mark)) (ding)) | 1254 | (if (null (mark)) (ding)) |
| 1262 | (setq mark-ring (cdr mark-ring))))) | 1255 | (setq mark-ring (cdr mark-ring))))) |
| 1263 | 1256 | ||
| 1264 | (fset 'exchange-dot-and-mark 'exchange-point-and-mark) | 1257 | (defalias 'exchange-dot-and-mark 'exchange-point-and-mark) |
| 1265 | (defun exchange-point-and-mark () | 1258 | (defun exchange-point-and-mark () |
| 1266 | "Put the mark where point is now, and point where the mark is now. | 1259 | "Put the mark where point is now, and point where the mark is now. |
| 1267 | This command works even when the mark is not active, | 1260 | This command works even when the mark is not active, |
| @@ -1274,14 +1267,21 @@ and it reactivates the mark." | |||
| 1274 | (goto-char omark) | 1267 | (goto-char omark) |
| 1275 | nil)) | 1268 | nil)) |
| 1276 | 1269 | ||
| 1270 | (defvar next-line-add-newlines t | ||
| 1271 | "*If non-nil, next-line will insert a newline into the buffer | ||
| 1272 | when invoked with no newline character between the point and the end | ||
| 1273 | of the buffer.") | ||
| 1274 | |||
| 1277 | (defun next-line (arg) | 1275 | (defun next-line (arg) |
| 1278 | "Move cursor vertically down ARG lines. | 1276 | "Move cursor vertically down ARG lines. |
| 1279 | If there is no character in the target line exactly under the current column, | 1277 | If there is no character in the target line exactly under the current column, |
| 1280 | the cursor is positioned after the character in that line which spans this | 1278 | the cursor is positioned after the character in that line which spans this |
| 1281 | column, or at the end of the line if it is not long enough. | 1279 | column, or at the end of the line if it is not long enough. |
| 1282 | If there is no line in the buffer after this one, | 1280 | If there is no line in the buffer after this one, behavior depends on the |
| 1283 | a newline character is inserted to create a line | 1281 | value of next-line-add-newlines. If non-nil, a newline character is inserted |
| 1284 | and the cursor moves to that line. | 1282 | to create a line and the cursor moves to that line, otherwise the cursor is |
| 1283 | moved to the end of the buffer (if already at the end of the buffer, an error | ||
| 1284 | is signaled). | ||
| 1285 | 1285 | ||
| 1286 | The command \\[set-goal-column] can be used to create | 1286 | The command \\[set-goal-column] can be used to create |
| 1287 | a semipermanent goal column to which this command always moves. | 1287 | a semipermanent goal column to which this command always moves. |
| @@ -1292,15 +1292,20 @@ If you are thinking of using this in a Lisp program, consider | |||
| 1292 | using `forward-line' instead. It is usually easier to use | 1292 | using `forward-line' instead. It is usually easier to use |
| 1293 | and more reliable (no dependence on goal column, etc.)." | 1293 | and more reliable (no dependence on goal column, etc.)." |
| 1294 | (interactive "p") | 1294 | (interactive "p") |
| 1295 | (if (= arg 1) | 1295 | (let ((opoint (point))) |
| 1296 | (let ((opoint (point))) | 1296 | (if next-line-add-newlines |
| 1297 | (forward-line 1) | 1297 | (if (/= arg 1) |
| 1298 | (if (or (= opoint (point)) | 1298 | (line-move arg) |
| 1299 | (not (eq (preceding-char) ?\n))) | 1299 | (forward-line 1) |
| 1300 | (insert ?\n) | 1300 | (if (or (= opoint (point)) (not (eq (preceding-char) ?\n))) |
| 1301 | (goto-char opoint) | 1301 | (insert ?\n) |
| 1302 | (line-move arg))) | 1302 | (goto-char opoint) |
| 1303 | (line-move arg)) | 1303 | (line-move arg))) |
| 1304 | (if (eobp) | ||
| 1305 | (signal 'end-of-buffer nil)) | ||
| 1306 | (line-move arg) | ||
| 1307 | (if (= opoint (point)) | ||
| 1308 | (end-of-line)))) | ||
| 1304 | nil) | 1309 | nil) |
| 1305 | 1310 | ||
| 1306 | (defun previous-line (arg) | 1311 | (defun previous-line (arg) |
| @@ -1382,6 +1387,24 @@ The goal column is stored in the variable `goal-column'." | |||
| 1382 | goal-column)) | 1387 | goal-column)) |
| 1383 | nil) | 1388 | nil) |
| 1384 | 1389 | ||
| 1390 | (defun right-arrow (arg) | ||
| 1391 | "Move right one character on the screen (with prefix ARG, that many chars). | ||
| 1392 | Scroll right if needed to keep point horizontally onscreen." | ||
| 1393 | (interactive "P") | ||
| 1394 | (forward-char arg) | ||
| 1395 | (if truncate-lines | ||
| 1396 | (let ((x (current-column)) (w (- (window-width) 2))) | ||
| 1397 | (set-window-hscroll (selected-window) (- x (% x w)) )))) | ||
| 1398 | |||
| 1399 | (defun left-arrow (arg) | ||
| 1400 | "Move left one character on the screen (with prefix ARG, that many chars). | ||
| 1401 | Scroll left if needed to keep point horizontally onscreen." | ||
| 1402 | (interactive "P") | ||
| 1403 | (backward-char arg) | ||
| 1404 | (if truncate-lines | ||
| 1405 | (let ((x (current-column)) (w (- (window-width) 2))) | ||
| 1406 | (set-window-hscroll (selected-window) (- x (% x w)) )))) | ||
| 1407 | |||
| 1385 | (defun transpose-chars (arg) | 1408 | (defun transpose-chars (arg) |
| 1386 | "Interchange characters around point, moving forward one character. | 1409 | "Interchange characters around point, moving forward one character. |
| 1387 | With prefix arg ARG, effect is to take character before point | 1410 | With prefix arg ARG, effect is to take character before point |