diff options
| author | Karl Heuer | 1999-08-16 20:42:38 +0000 |
|---|---|---|
| committer | Karl Heuer | 1999-08-16 20:42:38 +0000 |
| commit | 93be67de75a83425a02209dca9ec4f08d23b2c17 (patch) | |
| tree | 0dad199955e0f6fc78a796a0a7487c7c54d880a4 | |
| parent | 6e1e8dbcd1b862a16a7cd62edb4f23d39aceb25a (diff) | |
| download | emacs-93be67de75a83425a02209dca9ec4f08d23b2c17.tar.gz emacs-93be67de75a83425a02209dca9ec4f08d23b2c17.zip | |
Functions reordered.
| -rw-r--r-- | lisp/simple.el | 539 |
1 files changed, 274 insertions, 265 deletions
diff --git a/lisp/simple.el b/lisp/simple.el index a3118855351..fe13802654b 100644 --- a/lisp/simple.el +++ b/lisp/simple.el | |||
| @@ -41,6 +41,14 @@ | |||
| 41 | :group 'matching) | 41 | :group 'matching) |
| 42 | 42 | ||
| 43 | 43 | ||
| 44 | (defun fundamental-mode () | ||
| 45 | "Major mode not specialized for anything in particular. | ||
| 46 | Other major modes are defined by comparison with this one." | ||
| 47 | (interactive) | ||
| 48 | (kill-all-local-variables)) | ||
| 49 | |||
| 50 | ;; Making and deleting lines. | ||
| 51 | |||
| 44 | (defun newline (&optional arg) | 52 | (defun newline (&optional arg) |
| 45 | "Insert a newline, and move to left margin of the new line if it's blank. | 53 | "Insert a newline, and move to left margin of the new line if it's blank. |
| 46 | The newline is marked with the text-property `hard'. | 54 | The newline is marked with the text-property `hard'. |
| @@ -125,7 +133,7 @@ In Auto Fill mode, if no numeric arg, break the preceding line if it's long." | |||
| 125 | (if (and (listp sticky) (not (memq 'hard sticky))) | 133 | (if (and (listp sticky) (not (memq 'hard sticky))) |
| 126 | (put-text-property from (point) 'rear-nonsticky | 134 | (put-text-property from (point) 'rear-nonsticky |
| 127 | (cons 'hard sticky))))) | 135 | (cons 'hard sticky))))) |
| 128 | 136 | ||
| 129 | (defun open-line (arg) | 137 | (defun open-line (arg) |
| 130 | "Insert a newline and leave point before it. | 138 | "Insert a newline and leave point before it. |
| 131 | If there is a fill prefix and/or a left-margin, insert them on the new line | 139 | If there is a fill prefix and/or a left-margin, insert them on the new line |
| @@ -156,44 +164,6 @@ With arg N, insert N newlines." | |||
| 156 | (indent-to col 0) | 164 | (indent-to col 0) |
| 157 | (goto-char pos))) | 165 | (goto-char pos))) |
| 158 | 166 | ||
| 159 | (defun quoted-insert (arg) | ||
| 160 | "Read next input character and insert it. | ||
| 161 | This is useful for inserting control characters. | ||
| 162 | |||
| 163 | If the first character you type after this command is an octal digit, | ||
| 164 | you should type a sequence of octal digits which specify a character code. | ||
| 165 | Any nondigit terminates the sequence. If the terminator is a RET, | ||
| 166 | it is discarded; any other terminator is used itself as input. | ||
| 167 | The variable `read-quoted-char-radix' specifies the radix for this feature; | ||
| 168 | set it to 10 or 16 to use decimal or hex instead of octal. | ||
| 169 | |||
| 170 | In overwrite mode, this function inserts the character anyway, and | ||
| 171 | does not handle octal digits specially. This means that if you use | ||
| 172 | overwrite as your normal editing mode, you can use this function to | ||
| 173 | insert characters when necessary. | ||
| 174 | |||
| 175 | In binary overwrite mode, this function does overwrite, and octal | ||
| 176 | digits are interpreted as a character code. This is intended to be | ||
| 177 | useful for editing binary files." | ||
| 178 | (interactive "*p") | ||
| 179 | (let ((char (if (or (not overwrite-mode) | ||
| 180 | (eq overwrite-mode 'overwrite-mode-binary)) | ||
| 181 | (read-quoted-char) | ||
| 182 | (read-char)))) | ||
| 183 | ;; Assume character codes 0240 - 0377 stand for characters in some | ||
| 184 | ;; single-byte character set, and convert them to Emacs | ||
| 185 | ;; characters. | ||
| 186 | (if (and enable-multibyte-characters | ||
| 187 | (>= char ?\240) | ||
| 188 | (<= char ?\377)) | ||
| 189 | (setq char (unibyte-char-to-multibyte char))) | ||
| 190 | (if (> arg 0) | ||
| 191 | (if (eq overwrite-mode 'overwrite-mode-binary) | ||
| 192 | (delete-char arg))) | ||
| 193 | (while (> arg 0) | ||
| 194 | (insert-and-inherit char) | ||
| 195 | (setq arg (1- arg))))) | ||
| 196 | |||
| 197 | (defun delete-indentation (&optional arg) | 167 | (defun delete-indentation (&optional arg) |
| 198 | "Join this line to previous and fix up whitespace at join. | 168 | "Join this line to previous and fix up whitespace at join. |
| 199 | If there is a fill prefix, delete it from the beginning of this line. | 169 | If there is a fill prefix, delete it from the beginning of this line. |
| @@ -215,34 +185,7 @@ With argument, join this line to following line." | |||
| 215 | (fixup-whitespace)))) | 185 | (fixup-whitespace)))) |
| 216 | 186 | ||
| 217 | (defalias 'join-line #'delete-indentation) ; easier to find | 187 | (defalias 'join-line #'delete-indentation) ; easier to find |
| 218 | 188 | ||
| 219 | (defun fixup-whitespace () | ||
| 220 | "Fixup white space between objects around point. | ||
| 221 | Leave one space or none, according to the context." | ||
| 222 | (interactive "*") | ||
| 223 | (save-excursion | ||
| 224 | (delete-horizontal-space) | ||
| 225 | (if (or (looking-at "^\\|\\s)") | ||
| 226 | (save-excursion (forward-char -1) | ||
| 227 | (looking-at "$\\|\\s(\\|\\s'"))) | ||
| 228 | nil | ||
| 229 | (insert ?\ )))) | ||
| 230 | |||
| 231 | (defun delete-horizontal-space () | ||
| 232 | "Delete all spaces and tabs around point." | ||
| 233 | (interactive "*") | ||
| 234 | (skip-chars-backward " \t") | ||
| 235 | (delete-region (point) (progn (skip-chars-forward " \t") (point)))) | ||
| 236 | |||
| 237 | (defun just-one-space () | ||
| 238 | "Delete all spaces and tabs around point, leaving one space." | ||
| 239 | (interactive "*") | ||
| 240 | (skip-chars-backward " \t") | ||
| 241 | (if (= (following-char) ? ) | ||
| 242 | (forward-char 1) | ||
| 243 | (insert ? )) | ||
| 244 | (delete-region (point) (progn (skip-chars-forward " \t") (point)))) | ||
| 245 | |||
| 246 | (defun delete-blank-lines () | 189 | (defun delete-blank-lines () |
| 247 | "On blank line, delete all surrounding blank lines, leaving just one. | 190 | "On blank line, delete all surrounding blank lines, leaving just one. |
| 248 | On isolated blank line, delete that one. | 191 | On isolated blank line, delete that one. |
| @@ -283,12 +226,6 @@ On nonblank line, delete any immediately following blank lines." | |||
| 283 | (if (looking-at "^[ \t]*\n\\'") | 226 | (if (looking-at "^[ \t]*\n\\'") |
| 284 | (delete-region (point) (point-max))))) | 227 | (delete-region (point) (point-max))))) |
| 285 | 228 | ||
| 286 | (defun back-to-indentation () | ||
| 287 | "Move point to the first non-whitespace character on this line." | ||
| 288 | (interactive) | ||
| 289 | (beginning-of-line 1) | ||
| 290 | (skip-chars-forward " \t")) | ||
| 291 | |||
| 292 | (defun newline-and-indent () | 229 | (defun newline-and-indent () |
| 293 | "Insert a newline, then indent according to major mode. | 230 | "Insert a newline, then indent according to major mode. |
| 294 | Indentation is done using the value of `indent-line-function'. | 231 | Indentation is done using the value of `indent-line-function'. |
| @@ -313,64 +250,91 @@ column specified by the function `current-left-margin'." | |||
| 313 | (indent-according-to-mode)) | 250 | (indent-according-to-mode)) |
| 314 | (newline) | 251 | (newline) |
| 315 | (indent-according-to-mode)) | 252 | (indent-according-to-mode)) |
| 253 | |||
| 254 | (defun quoted-insert (arg) | ||
| 255 | "Read next input character and insert it. | ||
| 256 | This is useful for inserting control characters. | ||
| 316 | 257 | ||
| 317 | ;; Internal subroutine of delete-char | 258 | If the first character you type after this command is an octal digit, |
| 318 | (defun kill-forward-chars (arg) | 259 | you should type a sequence of octal digits which specify a character code. |
| 319 | (if (listp arg) (setq arg (car arg))) | 260 | Any nondigit terminates the sequence. If the terminator is a RET, |
| 320 | (if (eq arg '-) (setq arg -1)) | 261 | it is discarded; any other terminator is used itself as input. |
| 321 | (kill-region (point) (forward-point arg))) | 262 | The variable `read-quoted-char-radix' specifies the radix for this feature; |
| 263 | set it to 10 or 16 to use decimal or hex instead of octal. | ||
| 322 | 264 | ||
| 323 | ;; Internal subroutine of backward-delete-char | 265 | In overwrite mode, this function inserts the character anyway, and |
| 324 | (defun kill-backward-chars (arg) | 266 | does not handle octal digits specially. This means that if you use |
| 325 | (if (listp arg) (setq arg (car arg))) | 267 | overwrite as your normal editing mode, you can use this function to |
| 326 | (if (eq arg '-) (setq arg -1)) | 268 | insert characters when necessary. |
| 327 | (kill-region (point) (forward-point (- arg)))) | ||
| 328 | 269 | ||
| 329 | (defcustom backward-delete-char-untabify-method 'untabify | 270 | In binary overwrite mode, this function does overwrite, and octal |
| 330 | "*The method for untabifying when deleting backward. | 271 | digits are interpreted as a character code. This is intended to be |
| 331 | Can be `untabify' -- turn a tab to many spaces, then delete one space. | 272 | useful for editing binary files." |
| 332 | `hungry' -- delete all whitespace, both tabs and spaces. | 273 | (interactive "*p") |
| 333 | nil -- just delete one character." | 274 | (let ((char (if (or (not overwrite-mode) |
| 334 | :type '(choice (const untabify) (const hungry) (const nil)) | 275 | (eq overwrite-mode 'overwrite-mode-binary)) |
| 335 | :group 'killing) | 276 | (read-quoted-char) |
| 277 | (read-char)))) | ||
| 278 | ;; Assume character codes 0240 - 0377 stand for characters in some | ||
| 279 | ;; single-byte character set, and convert them to Emacs | ||
| 280 | ;; characters. | ||
| 281 | (if (and enable-multibyte-characters | ||
| 282 | (>= char ?\240) | ||
| 283 | (<= char ?\377)) | ||
| 284 | (setq char (unibyte-char-to-multibyte char))) | ||
| 285 | (if (> arg 0) | ||
| 286 | (if (eq overwrite-mode 'overwrite-mode-binary) | ||
| 287 | (delete-char arg))) | ||
| 288 | (while (> arg 0) | ||
| 289 | (insert-and-inherit char) | ||
| 290 | (setq arg (1- arg))))) | ||
| 291 | |||
| 292 | (defun forward-to-indentation (arg) | ||
| 293 | "Move forward ARG lines and position at first nonblank character." | ||
| 294 | (interactive "p") | ||
| 295 | (forward-line arg) | ||
| 296 | (skip-chars-forward " \t")) | ||
| 336 | 297 | ||
| 337 | (defun backward-delete-char-untabify (arg &optional killp) | 298 | (defun backward-to-indentation (arg) |
| 338 | "Delete characters backward, changing tabs into spaces. | 299 | "Move backward ARG lines and position at first nonblank character." |
| 339 | The exact behavior depends on `backward-delete-char-untabify-method'. | 300 | (interactive "p") |
| 340 | Delete ARG chars, and kill (save in kill ring) if KILLP is non-nil. | 301 | (forward-line (- arg)) |
| 341 | Interactively, ARG is the prefix arg (default 1) | 302 | (skip-chars-forward " \t")) |
| 342 | and KILLP is t if a prefix arg was specified." | ||
| 343 | (interactive "*p\nP") | ||
| 344 | (when (eq backward-delete-char-untabify-method 'untabify) | ||
| 345 | (let ((count arg)) | ||
| 346 | (save-excursion | ||
| 347 | (while (and (> count 0) (not (bobp))) | ||
| 348 | (if (= (preceding-char) ?\t) | ||
| 349 | (let ((col (current-column))) | ||
| 350 | (forward-char -1) | ||
| 351 | (setq col (- col (current-column))) | ||
| 352 | (insert-char ?\ col) | ||
| 353 | (delete-char 1))) | ||
| 354 | (forward-char -1) | ||
| 355 | (setq count (1- count)))))) | ||
| 356 | (delete-backward-char | ||
| 357 | (if (eq backward-delete-char-untabify-method 'hungry) | ||
| 358 | (let ((wh (- (point) (save-excursion (skip-chars-backward " \t") | ||
| 359 | (point))))) | ||
| 360 | (+ arg (if (zerop wh) 0 (1- wh)))) | ||
| 361 | arg) | ||
| 362 | killp)) | ||
| 363 | 303 | ||
| 364 | (defun zap-to-char (arg char) | 304 | (defun back-to-indentation () |
| 365 | "Kill up to and including ARG'th occurrence of CHAR. | 305 | "Move point to the first non-whitespace character on this line." |
| 366 | Case is ignored if `case-fold-search' is non-nil in the current buffer. | 306 | (interactive) |
| 367 | Goes backward if ARG is negative; error if CHAR not found." | 307 | (beginning-of-line 1) |
| 368 | (interactive "*p\ncZap to char: ") | 308 | (skip-chars-forward " \t")) |
| 369 | (kill-region (point) (progn | ||
| 370 | (search-forward (char-to-string char) nil nil arg) | ||
| 371 | ; (goto-char (if (> arg 0) (1- (point)) (1+ (point)))) | ||
| 372 | (point)))) | ||
| 373 | 309 | ||
| 310 | (defun fixup-whitespace () | ||
| 311 | "Fixup white space between objects around point. | ||
| 312 | Leave one space or none, according to the context." | ||
| 313 | (interactive "*") | ||
| 314 | (save-excursion | ||
| 315 | (delete-horizontal-space) | ||
| 316 | (if (or (looking-at "^\\|\\s)") | ||
| 317 | (save-excursion (forward-char -1) | ||
| 318 | (looking-at "$\\|\\s(\\|\\s'"))) | ||
| 319 | nil | ||
| 320 | (insert ?\ )))) | ||
| 321 | |||
| 322 | (defun delete-horizontal-space () | ||
| 323 | "Delete all spaces and tabs around point." | ||
| 324 | (interactive "*") | ||
| 325 | (skip-chars-backward " \t") | ||
| 326 | (delete-region (point) (progn (skip-chars-forward " \t") (point)))) | ||
| 327 | |||
| 328 | (defun just-one-space () | ||
| 329 | "Delete all spaces and tabs around point, leaving one space." | ||
| 330 | (interactive "*") | ||
| 331 | (skip-chars-backward " \t") | ||
| 332 | (if (= (following-char) ? ) | ||
| 333 | (forward-char 1) | ||
| 334 | (insert ? )) | ||
| 335 | (delete-region (point) (progn (skip-chars-forward " \t") (point)))) | ||
| 336 | |||
| 337 | |||
| 374 | (defun beginning-of-buffer (&optional arg) | 338 | (defun beginning-of-buffer (&optional arg) |
| 375 | "Move point to the beginning of the buffer; leave mark at previous position. | 339 | "Move point to the beginning of the buffer; leave mark at previous position. |
| 376 | With arg N, put point N/10 of the way from the beginning. | 340 | With arg N, put point N/10 of the way from the beginning. |
| @@ -436,6 +400,19 @@ that uses or sets the mark." | |||
| 436 | (push-mark (point)) | 400 | (push-mark (point)) |
| 437 | (push-mark (point-max) nil t) | 401 | (push-mark (point-max) nil t) |
| 438 | (goto-char (point-min))) | 402 | (goto-char (point-min))) |
| 403 | |||
| 404 | ;; Counting lines, one way or another. | ||
| 405 | |||
| 406 | (defun goto-line (arg) | ||
| 407 | "Goto line ARG, counting from line 1 at beginning of buffer." | ||
| 408 | (interactive "NGoto line: ") | ||
| 409 | (setq arg (prefix-numeric-value arg)) | ||
| 410 | (save-restriction | ||
| 411 | (widen) | ||
| 412 | (goto-char 1) | ||
| 413 | (if (eq selective-display t) | ||
| 414 | (re-search-forward "[\n\C-m]" nil 'end (1- arg)) | ||
| 415 | (forward-line (1- arg))))) | ||
| 439 | 416 | ||
| 440 | (defun count-lines-region (start end) | 417 | (defun count-lines-region (start end) |
| 441 | "Print number of lines and characters in the region." | 418 | "Print number of lines and characters in the region." |
| @@ -461,7 +438,6 @@ that uses or sets the mark." | |||
| 461 | (1+ (count-lines start (point)))) | 438 | (1+ (count-lines start (point)))) |
| 462 | (message "Line %d" (1+ (count-lines 1 (point))))))))) | 439 | (message "Line %d" (1+ (count-lines 1 (point))))))))) |
| 463 | 440 | ||
| 464 | |||
| 465 | (defun count-lines (start end) | 441 | (defun count-lines (start end) |
| 466 | "Return number of lines between START and END. | 442 | "Return number of lines between START and END. |
| 467 | This is usually the number of newlines between them, | 443 | This is usually the number of newlines between them, |
| @@ -484,7 +460,7 @@ and the greater of them is not at the start of a line." | |||
| 484 | (1+ done) | 460 | (1+ done) |
| 485 | done))) | 461 | done))) |
| 486 | (- (buffer-size) (forward-line (buffer-size))))))) | 462 | (- (buffer-size) (forward-line (buffer-size))))))) |
| 487 | 463 | ||
| 488 | (defun what-cursor-position (&optional detail) | 464 | (defun what-cursor-position (&optional detail) |
| 489 | "Print info on cursor position (on screen and within buffer). | 465 | "Print info on cursor position (on screen and within buffer). |
| 490 | Also describe the character after point, and give its character code | 466 | Also describe the character after point, and give its character code |
| @@ -566,13 +542,7 @@ addition, the encoding is fully shown." | |||
| 566 | (single-key-description char) | 542 | (single-key-description char) |
| 567 | (buffer-substring (point) (1+ (point)))) | 543 | (buffer-substring (point) (1+ (point)))) |
| 568 | encoding-msg pos total percent col hscroll))))))) | 544 | encoding-msg pos total percent col hscroll))))))) |
| 569 | 545 | ||
| 570 | (defun fundamental-mode () | ||
| 571 | "Major mode not specialized for anything in particular. | ||
| 572 | Other major modes are defined by comparison with this one." | ||
| 573 | (interactive) | ||
| 574 | (kill-all-local-variables)) | ||
| 575 | |||
| 576 | (defvar read-expression-map (cons 'keymap minibuffer-local-map) | 546 | (defvar read-expression-map (cons 'keymap minibuffer-local-map) |
| 577 | "Minibuffer keymap used for reading Lisp expressions.") | 547 | "Minibuffer keymap used for reading Lisp expressions.") |
| 578 | (define-key read-expression-map "\M-\t" 'lisp-complete-symbol) | 548 | (define-key read-expression-map "\M-\t" 'lisp-complete-symbol) |
| @@ -850,17 +820,6 @@ Get previous element of history which is a completion of minibuffer contents." | |||
| 850 | (interactive "p") | 820 | (interactive "p") |
| 851 | (next-complete-history-element (- n))) | 821 | (next-complete-history-element (- n))) |
| 852 | 822 | ||
| 853 | (defun goto-line (arg) | ||
| 854 | "Goto line ARG, counting from line 1 at beginning of buffer." | ||
| 855 | (interactive "NGoto line: ") | ||
| 856 | (setq arg (prefix-numeric-value arg)) | ||
| 857 | (save-restriction | ||
| 858 | (widen) | ||
| 859 | (goto-char 1) | ||
| 860 | (if (eq selective-display t) | ||
| 861 | (re-search-forward "[\n\C-m]" nil 'end (1- arg)) | ||
| 862 | (forward-line (1- arg))))) | ||
| 863 | |||
| 864 | ;Put this on C-x u, so we can force that rather than C-_ into startup msg | 823 | ;Put this on C-x u, so we can force that rather than C-_ into startup msg |
| 865 | (defalias 'advertised-undo 'undo) | 824 | (defalias 'advertised-undo 'undo) |
| 866 | 825 | ||
| @@ -1485,125 +1444,6 @@ These commands include \\[set-mark-command] and \\[start-kbd-macro]." | |||
| 1485 | (reset-this-command-lengths) | 1444 | (reset-this-command-lengths) |
| 1486 | (setq overriding-terminal-local-map nil)) | 1445 | (setq overriding-terminal-local-map nil)) |
| 1487 | 1446 | ||
| 1488 | (defun forward-to-indentation (arg) | ||
| 1489 | "Move forward ARG lines and position at first nonblank character." | ||
| 1490 | (interactive "p") | ||
| 1491 | (forward-line arg) | ||
| 1492 | (skip-chars-forward " \t")) | ||
| 1493 | |||
| 1494 | (defun backward-to-indentation (arg) | ||
| 1495 | "Move backward ARG lines and position at first nonblank character." | ||
| 1496 | (interactive "p") | ||
| 1497 | (forward-line (- arg)) | ||
| 1498 | (skip-chars-forward " \t")) | ||
| 1499 | |||
| 1500 | (defcustom kill-whole-line nil | ||
| 1501 | "*If non-nil, `kill-line' with no arg at beg of line kills the whole line." | ||
| 1502 | :type 'boolean | ||
| 1503 | :group 'killing) | ||
| 1504 | |||
| 1505 | (defun kill-line (&optional arg) | ||
| 1506 | "Kill the rest of the current line; if no nonblanks there, kill thru newline. | ||
| 1507 | With prefix argument, kill that many lines from point. | ||
| 1508 | Negative arguments kill lines backward. | ||
| 1509 | |||
| 1510 | When calling from a program, nil means \"no arg\", | ||
| 1511 | a number counts as a prefix arg. | ||
| 1512 | |||
| 1513 | To kill a whole line, when point is not at the beginning, type \ | ||
| 1514 | \\[beginning-of-line] \\[kill-line] \\[kill-line]. | ||
| 1515 | |||
| 1516 | If `kill-whole-line' is non-nil, then this command kills the whole line | ||
| 1517 | including its terminating newline, when used at the beginning of a line | ||
| 1518 | with no argument. As a consequence, you can always kill a whole line | ||
| 1519 | by typing \\[beginning-of-line] \\[kill-line]." | ||
| 1520 | (interactive "*P") | ||
| 1521 | (kill-region (point) | ||
| 1522 | ;; It is better to move point to the other end of the kill | ||
| 1523 | ;; before killing. That way, in a read-only buffer, point | ||
| 1524 | ;; moves across the text that is copied to the kill ring. | ||
| 1525 | ;; The choice has no effect on undo now that undo records | ||
| 1526 | ;; the value of point from before the command was run. | ||
| 1527 | (progn | ||
| 1528 | (if arg | ||
| 1529 | (forward-visible-line (prefix-numeric-value arg)) | ||
| 1530 | (if (eobp) | ||
| 1531 | (signal 'end-of-buffer nil)) | ||
| 1532 | (if (or (looking-at "[ \t]*$") (and kill-whole-line (bolp))) | ||
| 1533 | (forward-visible-line 1) | ||
| 1534 | (end-of-visible-line))) | ||
| 1535 | (point)))) | ||
| 1536 | |||
| 1537 | (defun forward-visible-line (arg) | ||
| 1538 | "Move forward by ARG lines, ignoring currently invisible newlines only. | ||
| 1539 | If ARG is negative, move backward -ARG lines. | ||
| 1540 | If ARG is zero, move to the beginning of the current line." | ||
| 1541 | (condition-case nil | ||
| 1542 | (if (> arg 0) | ||
| 1543 | (while (> arg 0) | ||
| 1544 | (or (zerop (forward-line 1)) | ||
| 1545 | (signal 'end-of-buffer nil)) | ||
| 1546 | ;; If the following character is currently invisible, | ||
| 1547 | ;; skip all characters with that same `invisible' property value, | ||
| 1548 | ;; then find the next newline. | ||
| 1549 | (while (and (not (eobp)) | ||
| 1550 | (let ((prop | ||
| 1551 | (get-char-property (point) 'invisible))) | ||
| 1552 | (if (eq buffer-invisibility-spec t) | ||
| 1553 | prop | ||
| 1554 | (or (memq prop buffer-invisibility-spec) | ||
| 1555 | (assq prop buffer-invisibility-spec))))) | ||
| 1556 | (goto-char | ||
| 1557 | (if (get-text-property (point) 'invisible) | ||
| 1558 | (or (next-single-property-change (point) 'invisible) | ||
| 1559 | (point-max)) | ||
| 1560 | (next-overlay-change (point)))) | ||
| 1561 | (or (zerop (forward-line 1)) | ||
| 1562 | (signal 'end-of-buffer nil))) | ||
| 1563 | (setq arg (1- arg))) | ||
| 1564 | (let ((first t)) | ||
| 1565 | (while (or first (< arg 0)) | ||
| 1566 | (if (zerop arg) | ||
| 1567 | (beginning-of-line) | ||
| 1568 | (or (zerop (forward-line -1)) | ||
| 1569 | (signal 'beginning-of-buffer nil))) | ||
| 1570 | (while (and (not (bobp)) | ||
| 1571 | (let ((prop | ||
| 1572 | (get-char-property (1- (point)) 'invisible))) | ||
| 1573 | (if (eq buffer-invisibility-spec t) | ||
| 1574 | prop | ||
| 1575 | (or (memq prop buffer-invisibility-spec) | ||
| 1576 | (assq prop buffer-invisibility-spec))))) | ||
| 1577 | (goto-char | ||
| 1578 | (if (get-text-property (1- (point)) 'invisible) | ||
| 1579 | (or (previous-single-property-change (point) 'invisible) | ||
| 1580 | (point-min)) | ||
| 1581 | (previous-overlay-change (point)))) | ||
| 1582 | (or (zerop (forward-line -1)) | ||
| 1583 | (signal 'beginning-of-buffer nil))) | ||
| 1584 | (setq first nil) | ||
| 1585 | (setq arg (1+ arg))))) | ||
| 1586 | ((beginning-of-buffer end-of-buffer) | ||
| 1587 | nil))) | ||
| 1588 | |||
| 1589 | (defun end-of-visible-line () | ||
| 1590 | "Move to end of current visible line." | ||
| 1591 | (end-of-line) | ||
| 1592 | ;; If the following character is currently invisible, | ||
| 1593 | ;; skip all characters with that same `invisible' property value, | ||
| 1594 | ;; then find the next newline. | ||
| 1595 | (while (and (not (eobp)) | ||
| 1596 | (let ((prop | ||
| 1597 | (get-char-property (point) 'invisible))) | ||
| 1598 | (if (eq buffer-invisibility-spec t) | ||
| 1599 | prop | ||
| 1600 | (or (memq prop buffer-invisibility-spec) | ||
| 1601 | (assq prop buffer-invisibility-spec))))) | ||
| 1602 | (if (get-text-property (point) 'invisible) | ||
| 1603 | (goto-char (next-single-property-change (point) 'invisible)) | ||
| 1604 | (goto-char (next-overlay-change (point)))) | ||
| 1605 | (end-of-line))) | ||
| 1606 | |||
| 1607 | ;;;; Window system cut and paste hooks. | 1447 | ;;;; Window system cut and paste hooks. |
| 1608 | 1448 | ||
| 1609 | (defvar interprogram-cut-function nil | 1449 | (defvar interprogram-cut-function nil |
| @@ -1852,6 +1692,8 @@ The argument is used for internal purposes; do not supply one." | |||
| 1852 | (setq this-command 'kill-region) | 1692 | (setq this-command 'kill-region) |
| 1853 | (message "If the next command is a kill, it will append")) | 1693 | (message "If the next command is a kill, it will append")) |
| 1854 | (setq last-command 'kill-region))) | 1694 | (setq last-command 'kill-region))) |
| 1695 | |||
| 1696 | ;; Yanking. | ||
| 1855 | 1697 | ||
| 1856 | (defun yank-pop (arg) | 1698 | (defun yank-pop (arg) |
| 1857 | "Replace just-yanked stretch of killed text with a different stretch. | 1699 | "Replace just-yanked stretch of killed text with a different stretch. |
| @@ -1921,7 +1763,174 @@ See also the command \\[yank-pop]." | |||
| 1921 | With argument, rotate that many kills forward (or backward, if negative)." | 1763 | With argument, rotate that many kills forward (or backward, if negative)." |
| 1922 | (interactive "p") | 1764 | (interactive "p") |
| 1923 | (current-kill arg)) | 1765 | (current-kill arg)) |
| 1766 | |||
| 1767 | ;; Some kill commands. | ||
| 1924 | 1768 | ||
| 1769 | ;; Internal subroutine of delete-char | ||
| 1770 | (defun kill-forward-chars (arg) | ||
| 1771 | (if (listp arg) (setq arg (car arg))) | ||
| 1772 | (if (eq arg '-) (setq arg -1)) | ||
| 1773 | (kill-region (point) (forward-point arg))) | ||
| 1774 | |||
| 1775 | ;; Internal subroutine of backward-delete-char | ||
| 1776 | (defun kill-backward-chars (arg) | ||
| 1777 | (if (listp arg) (setq arg (car arg))) | ||
| 1778 | (if (eq arg '-) (setq arg -1)) | ||
| 1779 | (kill-region (point) (forward-point (- arg)))) | ||
| 1780 | |||
| 1781 | (defcustom backward-delete-char-untabify-method 'untabify | ||
| 1782 | "*The method for untabifying when deleting backward. | ||
| 1783 | Can be `untabify' -- turn a tab to many spaces, then delete one space. | ||
| 1784 | `hungry' -- delete all whitespace, both tabs and spaces. | ||
| 1785 | nil -- just delete one character." | ||
| 1786 | :type '(choice (const untabify) (const hungry) (const nil)) | ||
| 1787 | :group 'killing) | ||
| 1788 | |||
| 1789 | (defun backward-delete-char-untabify (arg &optional killp) | ||
| 1790 | "Delete characters backward, changing tabs into spaces. | ||
| 1791 | The exact behavior depends on `backward-delete-char-untabify-method'. | ||
| 1792 | Delete ARG chars, and kill (save in kill ring) if KILLP is non-nil. | ||
| 1793 | Interactively, ARG is the prefix arg (default 1) | ||
| 1794 | and KILLP is t if a prefix arg was specified." | ||
| 1795 | (interactive "*p\nP") | ||
| 1796 | (when (eq backward-delete-char-untabify-method 'untabify) | ||
| 1797 | (let ((count arg)) | ||
| 1798 | (save-excursion | ||
| 1799 | (while (and (> count 0) (not (bobp))) | ||
| 1800 | (if (= (preceding-char) ?\t) | ||
| 1801 | (let ((col (current-column))) | ||
| 1802 | (forward-char -1) | ||
| 1803 | (setq col (- col (current-column))) | ||
| 1804 | (insert-char ?\ col) | ||
| 1805 | (delete-char 1))) | ||
| 1806 | (forward-char -1) | ||
| 1807 | (setq count (1- count)))))) | ||
| 1808 | (delete-backward-char | ||
| 1809 | (if (eq backward-delete-char-untabify-method 'hungry) | ||
| 1810 | (let ((wh (- (point) (save-excursion (skip-chars-backward " \t") | ||
| 1811 | (point))))) | ||
| 1812 | (+ arg (if (zerop wh) 0 (1- wh)))) | ||
| 1813 | arg) | ||
| 1814 | killp)) | ||
| 1815 | |||
| 1816 | (defun zap-to-char (arg char) | ||
| 1817 | "Kill up to and including ARG'th occurrence of CHAR. | ||
| 1818 | Case is ignored if `case-fold-search' is non-nil in the current buffer. | ||
| 1819 | Goes backward if ARG is negative; error if CHAR not found." | ||
| 1820 | (interactive "*p\ncZap to char: ") | ||
| 1821 | (kill-region (point) (progn | ||
| 1822 | (search-forward (char-to-string char) nil nil arg) | ||
| 1823 | ; (goto-char (if (> arg 0) (1- (point)) (1+ (point)))) | ||
| 1824 | (point)))) | ||
| 1825 | |||
| 1826 | ;; kill-line and its subroutines. | ||
| 1827 | |||
| 1828 | (defcustom kill-whole-line nil | ||
| 1829 | "*If non-nil, `kill-line' with no arg at beg of line kills the whole line." | ||
| 1830 | :type 'boolean | ||
| 1831 | :group 'killing) | ||
| 1832 | |||
| 1833 | (defun kill-line (&optional arg) | ||
| 1834 | "Kill the rest of the current line; if no nonblanks there, kill thru newline. | ||
| 1835 | With prefix argument, kill that many lines from point. | ||
| 1836 | Negative arguments kill lines backward. | ||
| 1837 | |||
| 1838 | When calling from a program, nil means \"no arg\", | ||
| 1839 | a number counts as a prefix arg. | ||
| 1840 | |||
| 1841 | To kill a whole line, when point is not at the beginning, type \ | ||
| 1842 | \\[beginning-of-line] \\[kill-line] \\[kill-line]. | ||
| 1843 | |||
| 1844 | If `kill-whole-line' is non-nil, then this command kills the whole line | ||
| 1845 | including its terminating newline, when used at the beginning of a line | ||
| 1846 | with no argument. As a consequence, you can always kill a whole line | ||
| 1847 | by typing \\[beginning-of-line] \\[kill-line]." | ||
| 1848 | (interactive "*P") | ||
| 1849 | (kill-region (point) | ||
| 1850 | ;; It is better to move point to the other end of the kill | ||
| 1851 | ;; before killing. That way, in a read-only buffer, point | ||
| 1852 | ;; moves across the text that is copied to the kill ring. | ||
| 1853 | ;; The choice has no effect on undo now that undo records | ||
| 1854 | ;; the value of point from before the command was run. | ||
| 1855 | (progn | ||
| 1856 | (if arg | ||
| 1857 | (forward-visible-line (prefix-numeric-value arg)) | ||
| 1858 | (if (eobp) | ||
| 1859 | (signal 'end-of-buffer nil)) | ||
| 1860 | (if (or (looking-at "[ \t]*$") (and kill-whole-line (bolp))) | ||
| 1861 | (forward-visible-line 1) | ||
| 1862 | (end-of-visible-line))) | ||
| 1863 | (point)))) | ||
| 1864 | |||
| 1865 | (defun forward-visible-line (arg) | ||
| 1866 | "Move forward by ARG lines, ignoring currently invisible newlines only. | ||
| 1867 | If ARG is negative, move backward -ARG lines. | ||
| 1868 | If ARG is zero, move to the beginning of the current line." | ||
| 1869 | (condition-case nil | ||
| 1870 | (if (> arg 0) | ||
| 1871 | (while (> arg 0) | ||
| 1872 | (or (zerop (forward-line 1)) | ||
| 1873 | (signal 'end-of-buffer nil)) | ||
| 1874 | ;; If the following character is currently invisible, | ||
| 1875 | ;; skip all characters with that same `invisible' property value, | ||
| 1876 | ;; then find the next newline. | ||
| 1877 | (while (and (not (eobp)) | ||
| 1878 | (let ((prop | ||
| 1879 | (get-char-property (point) 'invisible))) | ||
| 1880 | (if (eq buffer-invisibility-spec t) | ||
| 1881 | prop | ||
| 1882 | (or (memq prop buffer-invisibility-spec) | ||
| 1883 | (assq prop buffer-invisibility-spec))))) | ||
| 1884 | (goto-char | ||
| 1885 | (if (get-text-property (point) 'invisible) | ||
| 1886 | (or (next-single-property-change (point) 'invisible) | ||
| 1887 | (point-max)) | ||
| 1888 | (next-overlay-change (point)))) | ||
| 1889 | (or (zerop (forward-line 1)) | ||
| 1890 | (signal 'end-of-buffer nil))) | ||
| 1891 | (setq arg (1- arg))) | ||
| 1892 | (let ((first t)) | ||
| 1893 | (while (or first (< arg 0)) | ||
| 1894 | (if (zerop arg) | ||
| 1895 | (beginning-of-line) | ||
| 1896 | (or (zerop (forward-line -1)) | ||
| 1897 | (signal 'beginning-of-buffer nil))) | ||
| 1898 | (while (and (not (bobp)) | ||
| 1899 | (let ((prop | ||
| 1900 | (get-char-property (1- (point)) 'invisible))) | ||
| 1901 | (if (eq buffer-invisibility-spec t) | ||
| 1902 | prop | ||
| 1903 | (or (memq prop buffer-invisibility-spec) | ||
| 1904 | (assq prop buffer-invisibility-spec))))) | ||
| 1905 | (goto-char | ||
| 1906 | (if (get-text-property (1- (point)) 'invisible) | ||
| 1907 | (or (previous-single-property-change (point) 'invisible) | ||
| 1908 | (point-min)) | ||
| 1909 | (previous-overlay-change (point)))) | ||
| 1910 | (or (zerop (forward-line -1)) | ||
| 1911 | (signal 'beginning-of-buffer nil))) | ||
| 1912 | (setq first nil) | ||
| 1913 | (setq arg (1+ arg))))) | ||
| 1914 | ((beginning-of-buffer end-of-buffer) | ||
| 1915 | nil))) | ||
| 1916 | |||
| 1917 | (defun end-of-visible-line () | ||
| 1918 | "Move to end of current visible line." | ||
| 1919 | (end-of-line) | ||
| 1920 | ;; If the following character is currently invisible, | ||
| 1921 | ;; skip all characters with that same `invisible' property value, | ||
| 1922 | ;; then find the next newline. | ||
| 1923 | (while (and (not (eobp)) | ||
| 1924 | (let ((prop | ||
| 1925 | (get-char-property (point) 'invisible))) | ||
| 1926 | (if (eq buffer-invisibility-spec t) | ||
| 1927 | prop | ||
| 1928 | (or (memq prop buffer-invisibility-spec) | ||
| 1929 | (assq prop buffer-invisibility-spec))))) | ||
| 1930 | (if (get-text-property (point) 'invisible) | ||
| 1931 | (goto-char (next-single-property-change (point) 'invisible)) | ||
| 1932 | (goto-char (next-overlay-change (point)))) | ||
| 1933 | (end-of-line))) | ||
| 1925 | 1934 | ||
| 1926 | (defun insert-buffer (buffer) | 1935 | (defun insert-buffer (buffer) |
| 1927 | "Insert after point the contents of BUFFER. | 1936 | "Insert after point the contents of BUFFER. |
| @@ -2251,7 +2260,7 @@ to use and more reliable (no dependence on goal column, etc.)." | |||
| 2251 | ((beginning-of-buffer end-of-buffer) (ding))) | 2260 | ((beginning-of-buffer end-of-buffer) (ding))) |
| 2252 | (line-move (- arg))) | 2261 | (line-move (- arg))) |
| 2253 | nil) | 2262 | nil) |
| 2254 | 2263 | ||
| 2255 | (defcustom track-eol nil | 2264 | (defcustom track-eol nil |
| 2256 | "*Non-nil means vertical motion starting at end of line keeps to ends of lines. | 2265 | "*Non-nil means vertical motion starting at end of line keeps to ends of lines. |
| 2257 | This means moving to the end of each line moved onto. | 2266 | This means moving to the end of each line moved onto. |