diff options
Diffstat (limited to 'lisp/simple.el')
| -rw-r--r-- | lisp/simple.el | 119 |
1 files changed, 68 insertions, 51 deletions
diff --git a/lisp/simple.el b/lisp/simple.el index deb5c888c92..a22fe03a0ae 100644 --- a/lisp/simple.el +++ b/lisp/simple.el | |||
| @@ -458,27 +458,18 @@ A non-nil INTERACTIVE argument means to run the `post-self-insert-hook'." | |||
| 458 | (put-text-property from (point) 'rear-nonsticky | 458 | (put-text-property from (point) 'rear-nonsticky |
| 459 | (cons 'hard sticky))))) | 459 | (cons 'hard sticky))))) |
| 460 | 460 | ||
| 461 | (declare-function electric-indent-just-newline "electric") | 461 | (defun open-line (n) |
| 462 | (defun open-line (n &optional interactive) | ||
| 463 | "Insert a newline and leave point before it. | 462 | "Insert a newline and leave point before it. |
| 464 | If `electric-indent-mode' is enabled, indent the new line if it's | ||
| 465 | not empty. | ||
| 466 | If there is a fill prefix and/or a `left-margin', insert them on | 463 | If there is a fill prefix and/or a `left-margin', insert them on |
| 467 | the new line. If the old line would have been blank, insert them | 464 | the new line if the line would have been blank. |
| 468 | on the old line as well. | 465 | With arg N, insert N newlines." |
| 469 | 466 | (interactive "*p") | |
| 470 | With arg N, insert N newlines. | ||
| 471 | A non-nil INTERACTIVE argument means to run the `post-self-insert-hook'." | ||
| 472 | (interactive "*p\np") | ||
| 473 | (let* ((do-fill-prefix (and fill-prefix (bolp))) | 467 | (let* ((do-fill-prefix (and fill-prefix (bolp))) |
| 474 | (do-left-margin (and (bolp) (> (current-left-margin) 0))) | 468 | (do-left-margin (and (bolp) (> (current-left-margin) 0))) |
| 475 | (loc (point-marker)) | 469 | (loc (point-marker)) |
| 476 | ;; Don't expand an abbrev before point. | 470 | ;; Don't expand an abbrev before point. |
| 477 | (abbrev-mode nil)) | 471 | (abbrev-mode nil)) |
| 478 | (if (and interactive | 472 | (newline n) |
| 479 | (looking-at-p "[[:space:]]*$")) | ||
| 480 | (electric-indent-just-newline n) | ||
| 481 | (newline n interactive)) | ||
| 482 | (goto-char loc) | 473 | (goto-char loc) |
| 483 | (while (> n 0) | 474 | (while (> n 0) |
| 484 | (cond ((bolp) | 475 | (cond ((bolp) |
| @@ -983,7 +974,8 @@ If DELETE is `delete-only', then only delete the region and the return value | |||
| 983 | is undefined. If DELETE is nil, just return the content as a string. | 974 | is undefined. If DELETE is nil, just return the content as a string. |
| 984 | If DELETE is `bounds', then don't delete, but just return the | 975 | If DELETE is `bounds', then don't delete, but just return the |
| 985 | boundaries of the region as a list of (START . END) positions. | 976 | boundaries of the region as a list of (START . END) positions. |
| 986 | If anything else, delete the region and return its content as a string.") | 977 | If anything else, delete the region and return its content as a string, |
| 978 | after filtering it with `filter-buffer-substring'.") | ||
| 987 | 979 | ||
| 988 | (defvar region-insert-function | 980 | (defvar region-insert-function |
| 989 | (lambda (lines) | 981 | (lambda (lines) |
| @@ -1008,6 +1000,10 @@ Optional second arg KILLFLAG, if non-nil, means to kill (save in | |||
| 1008 | kill ring) instead of delete. Interactively, N is the prefix | 1000 | kill ring) instead of delete. Interactively, N is the prefix |
| 1009 | arg, and KILLFLAG is set if N is explicitly specified. | 1001 | arg, and KILLFLAG is set if N is explicitly specified. |
| 1010 | 1002 | ||
| 1003 | When killing, the killed text is filtered by | ||
| 1004 | `filter-buffer-substring' before it is saved in the kill ring, so | ||
| 1005 | the actual saved text might be different from what was killed. | ||
| 1006 | |||
| 1011 | In Overwrite mode, single character backward deletion may replace | 1007 | In Overwrite mode, single character backward deletion may replace |
| 1012 | tabs with spaces so as to back over columns, unless point is at | 1008 | tabs with spaces so as to back over columns, unless point is at |
| 1013 | the end of the line." | 1009 | the end of the line." |
| @@ -1043,7 +1039,11 @@ To disable this, set variable `delete-active-region' to nil. | |||
| 1043 | 1039 | ||
| 1044 | Optional second arg KILLFLAG non-nil means to kill (save in kill | 1040 | Optional second arg KILLFLAG non-nil means to kill (save in kill |
| 1045 | ring) instead of delete. Interactively, N is the prefix arg, and | 1041 | ring) instead of delete. Interactively, N is the prefix arg, and |
| 1046 | KILLFLAG is set if N was explicitly specified." | 1042 | KILLFLAG is set if N was explicitly specified. |
| 1043 | |||
| 1044 | When killing, the killed text is filtered by | ||
| 1045 | `filter-buffer-substring' before it is saved in the kill ring, so | ||
| 1046 | the actual saved text might be different from what was killed." | ||
| 1047 | (declare (interactive-only delete-char)) | 1047 | (declare (interactive-only delete-char)) |
| 1048 | (interactive "p\nP") | 1048 | (interactive "p\nP") |
| 1049 | (unless (integerp n) | 1049 | (unless (integerp n) |
| @@ -2811,7 +2811,7 @@ an amalgamating command. The car of the list is the number of | |||
| 2811 | times an amalgamating command has been called, and the cdr are the | 2811 | times an amalgamating command has been called, and the cdr are the |
| 2812 | buffers that were changed during the last command.") | 2812 | buffers that were changed during the last command.") |
| 2813 | 2813 | ||
| 2814 | (defvar undo-auto--current-boundary-timer nil | 2814 | (defvar undo-auto-current-boundary-timer nil |
| 2815 | "Current timer which will run `undo-auto--boundary-timer' or nil. | 2815 | "Current timer which will run `undo-auto--boundary-timer' or nil. |
| 2816 | 2816 | ||
| 2817 | If set to non-nil, this will effectively disable the timer.") | 2817 | If set to non-nil, this will effectively disable the timer.") |
| @@ -2819,7 +2819,7 @@ If set to non-nil, this will effectively disable the timer.") | |||
| 2819 | (defvar undo-auto--this-command-amalgamating nil | 2819 | (defvar undo-auto--this-command-amalgamating nil |
| 2820 | "Non-nil if `this-command' should be amalgamated. | 2820 | "Non-nil if `this-command' should be amalgamated. |
| 2821 | This variable is set to nil by `undo-auto--boundaries' and is set | 2821 | This variable is set to nil by `undo-auto--boundaries' and is set |
| 2822 | by `undo-auto--amalgamate'." ) | 2822 | by `undo-auto-amalgamate'." ) |
| 2823 | 2823 | ||
| 2824 | (defun undo-auto--needs-boundary-p () | 2824 | (defun undo-auto--needs-boundary-p () |
| 2825 | "Return non-nil if `buffer-undo-list' needs a boundary at the start." | 2825 | "Return non-nil if `buffer-undo-list' needs a boundary at the start." |
| @@ -2829,7 +2829,7 @@ by `undo-auto--amalgamate'." ) | |||
| 2829 | "Return the number of amalgamating last commands or nil. | 2829 | "Return the number of amalgamating last commands or nil. |
| 2830 | Amalgamating commands are, by default, either | 2830 | Amalgamating commands are, by default, either |
| 2831 | `self-insert-command' and `delete-char', but can be any command | 2831 | `self-insert-command' and `delete-char', but can be any command |
| 2832 | that calls `undo-auto--amalgamate'." | 2832 | that calls `undo-auto-amalgamate'." |
| 2833 | (car-safe undo-auto--last-boundary-cause)) | 2833 | (car-safe undo-auto--last-boundary-cause)) |
| 2834 | 2834 | ||
| 2835 | (defun undo-auto--ensure-boundary (cause) | 2835 | (defun undo-auto--ensure-boundary (cause) |
| @@ -2860,13 +2860,13 @@ REASON describes the reason that the boundary is being added; see | |||
| 2860 | 2860 | ||
| 2861 | (defun undo-auto--boundary-timer () | 2861 | (defun undo-auto--boundary-timer () |
| 2862 | "Timer which will run `undo--auto-boundary-timer'." | 2862 | "Timer which will run `undo--auto-boundary-timer'." |
| 2863 | (setq undo-auto--current-boundary-timer nil) | 2863 | (setq undo-auto-current-boundary-timer nil) |
| 2864 | (undo-auto--boundaries 'timer)) | 2864 | (undo-auto--boundaries 'timer)) |
| 2865 | 2865 | ||
| 2866 | (defun undo-auto--boundary-ensure-timer () | 2866 | (defun undo-auto--boundary-ensure-timer () |
| 2867 | "Ensure that the `undo-auto-boundary-timer' is set." | 2867 | "Ensure that the `undo-auto-boundary-timer' is set." |
| 2868 | (unless undo-auto--current-boundary-timer | 2868 | (unless undo-auto-current-boundary-timer |
| 2869 | (setq undo-auto--current-boundary-timer | 2869 | (setq undo-auto-current-boundary-timer |
| 2870 | (run-at-time 10 nil #'undo-auto--boundary-timer)))) | 2870 | (run-at-time 10 nil #'undo-auto--boundary-timer)))) |
| 2871 | 2871 | ||
| 2872 | (defvar undo-auto--undoably-changed-buffers nil | 2872 | (defvar undo-auto--undoably-changed-buffers nil |
| @@ -2881,14 +2881,15 @@ See also `undo-auto--buffer-undoably-changed'.") | |||
| 2881 | (defun undo-auto--add-boundary () | 2881 | (defun undo-auto--add-boundary () |
| 2882 | "Add an `undo-boundary' in appropriate buffers." | 2882 | "Add an `undo-boundary' in appropriate buffers." |
| 2883 | (undo-auto--boundaries | 2883 | (undo-auto--boundaries |
| 2884 | (if undo-auto--this-command-amalgamating | 2884 | (let ((amal undo-auto--this-command-amalgamating)) |
| 2885 | 'amalgamate | 2885 | (setq undo-auto--this-command-amalgamating nil) |
| 2886 | 'command)) | 2886 | (if amal |
| 2887 | (setq undo-auto--this-command-amalgamating nil)) | 2887 | 'amalgamate |
| 2888 | 'command)))) | ||
| 2888 | 2889 | ||
| 2889 | (defun undo-auto--amalgamate () | 2890 | (defun undo-auto-amalgamate () |
| 2890 | "Amalgamate undo if necessary. | 2891 | "Amalgamate undo if necessary. |
| 2891 | This function can be called after an amalgamating command. It | 2892 | This function can be called before an amalgamating command. It |
| 2892 | removes the previous `undo-boundary' if a series of such calls | 2893 | removes the previous `undo-boundary' if a series of such calls |
| 2893 | have been made. By default `self-insert-command' and | 2894 | have been made. By default `self-insert-command' and |
| 2894 | `delete-char' are the only amalgamating commands, although this | 2895 | `delete-char' are the only amalgamating commands, although this |
| @@ -3359,13 +3360,12 @@ the use of a shell (with its need to quote arguments)." | |||
| 3359 | (shell-command-on-region (point) (point) command | 3360 | (shell-command-on-region (point) (point) command |
| 3360 | output-buffer nil error-buffer))))))) | 3361 | output-buffer nil error-buffer))))))) |
| 3361 | 3362 | ||
| 3362 | (defun display-message-or-buffer (message | 3363 | (defun display-message-or-buffer (message &optional buffer-name action frame) |
| 3363 | &optional buffer-name not-this-window frame) | ||
| 3364 | "Display MESSAGE in the echo area if possible, otherwise in a pop-up buffer. | 3364 | "Display MESSAGE in the echo area if possible, otherwise in a pop-up buffer. |
| 3365 | MESSAGE may be either a string or a buffer. | 3365 | MESSAGE may be either a string or a buffer. |
| 3366 | 3366 | ||
| 3367 | A buffer is displayed using `display-buffer' if MESSAGE is too long for | 3367 | A pop-up buffer is displayed using `display-buffer' if MESSAGE is too long |
| 3368 | the maximum height of the echo area, as defined by `max-mini-window-height' | 3368 | for maximum height of the echo area, as defined by `max-mini-window-height' |
| 3369 | if `resize-mini-windows' is non-nil. | 3369 | if `resize-mini-windows' is non-nil. |
| 3370 | 3370 | ||
| 3371 | Returns either the string shown in the echo area, or when a pop-up | 3371 | Returns either the string shown in the echo area, or when a pop-up |
| @@ -3377,8 +3377,8 @@ is used, defaulting to `*Message*'. In the case where MESSAGE is a | |||
| 3377 | string and it is displayed in the echo area, it is not specified whether | 3377 | string and it is displayed in the echo area, it is not specified whether |
| 3378 | the contents are inserted into the buffer anyway. | 3378 | the contents are inserted into the buffer anyway. |
| 3379 | 3379 | ||
| 3380 | Optional arguments NOT-THIS-WINDOW and FRAME are as for `display-buffer', | 3380 | Optional arguments ACTION and FRAME are as for `display-buffer', |
| 3381 | and only used if a buffer is displayed." | 3381 | and are only used if a pop-up buffer is displayed." |
| 3382 | (cond ((and (stringp message) (not (string-match "\n" message))) | 3382 | (cond ((and (stringp message) (not (string-match "\n" message))) |
| 3383 | ;; Trivial case where we can use the echo area | 3383 | ;; Trivial case where we can use the echo area |
| 3384 | (message "%s" message)) | 3384 | (message "%s" message)) |
| @@ -3424,8 +3424,7 @@ and only used if a buffer is displayed." | |||
| 3424 | (t | 3424 | (t |
| 3425 | ;; Buffer | 3425 | ;; Buffer |
| 3426 | (goto-char (point-min)) | 3426 | (goto-char (point-min)) |
| 3427 | (display-buffer (current-buffer) | 3427 | (display-buffer (current-buffer) action frame)))))))) |
| 3428 | not-this-window frame)))))))) | ||
| 3429 | 3428 | ||
| 3430 | 3429 | ||
| 3431 | ;; We have a sentinel to prevent insertion of a termination message | 3430 | ;; We have a sentinel to prevent insertion of a termination message |
| @@ -3817,7 +3816,9 @@ see other processes running on the system, use `list-system-processes'." | |||
| 3817 | (setq prefix-command--last-echo nil) | 3816 | (setq prefix-command--last-echo nil) |
| 3818 | 3817 | ||
| 3819 | (defun internal-echo-keystrokes-prefix () | 3818 | (defun internal-echo-keystrokes-prefix () |
| 3820 | ;; BEWARE: Called directly from the C code. | 3819 | ;; BEWARE: Called directly from C code. |
| 3820 | ;; If the return value is non-nil, it means we are in the middle of | ||
| 3821 | ;; a command with prefix, such as a command invoked with prefix-arg. | ||
| 3821 | (if (not prefix-command--needs-update) | 3822 | (if (not prefix-command--needs-update) |
| 3822 | prefix-command--last-echo | 3823 | prefix-command--last-echo |
| 3823 | (setq prefix-command--last-echo | 3824 | (setq prefix-command--last-echo |
| @@ -4257,21 +4258,25 @@ The command \\[yank] can retrieve it from there. | |||
| 4257 | If you want to append the killed region to the last killed text, | 4258 | If you want to append the killed region to the last killed text, |
| 4258 | use \\[append-next-kill] before \\[kill-region]. | 4259 | use \\[append-next-kill] before \\[kill-region]. |
| 4259 | 4260 | ||
| 4261 | Any command that calls this function is a \"kill command\". | ||
| 4262 | If the previous command was also a kill command, | ||
| 4263 | the text killed this time appends to the text killed last time | ||
| 4264 | to make one entry in the kill ring. | ||
| 4265 | |||
| 4266 | The killed text is filtered by `filter-buffer-substring' before it is | ||
| 4267 | saved in the kill ring, so the actual saved text might be different | ||
| 4268 | from what was killed. | ||
| 4269 | |||
| 4260 | If the buffer is read-only, Emacs will beep and refrain from deleting | 4270 | If the buffer is read-only, Emacs will beep and refrain from deleting |
| 4261 | the text, but put the text in the kill ring anyway. This means that | 4271 | the text, but put the text in the kill ring anyway. This means that |
| 4262 | you can use the killing commands to copy text from a read-only buffer. | 4272 | you can use the killing commands to copy text from a read-only buffer. |
| 4263 | 4273 | ||
| 4264 | Lisp programs should use this function for killing text. | 4274 | Lisp programs should use this function for killing text. |
| 4265 | (To delete text, use `delete-region'.) | 4275 | (To delete text, use `delete-region'.) |
| 4266 | Supply two arguments, character positions indicating the stretch of text | 4276 | Supply two arguments, character positions BEG and END indicating the |
| 4267 | to be killed. | 4277 | stretch of text to be killed. If the optional argument REGION is |
| 4268 | Any command that calls this function is a \"kill command\". | 4278 | non-nil, the function ignores BEG and END, and kills the current |
| 4269 | If the previous command was also a kill command, | 4279 | region instead." |
| 4270 | the text killed this time appends to the text killed last time | ||
| 4271 | to make one entry in the kill ring. | ||
| 4272 | |||
| 4273 | The optional argument REGION if non-nil, indicates that we're not just killing | ||
| 4274 | some text between BEG and END, but we're killing the region." | ||
| 4275 | ;; Pass mark first, then point, because the order matters when | 4280 | ;; Pass mark first, then point, because the order matters when |
| 4276 | ;; calling `kill-append'. | 4281 | ;; calling `kill-append'. |
| 4277 | (interactive (list (mark) (point) 'region)) | 4282 | (interactive (list (mark) (point) 'region)) |
| @@ -4316,8 +4321,14 @@ In Transient Mark mode, deactivate the mark. | |||
| 4316 | If `interprogram-cut-function' is non-nil, also save the text for a window | 4321 | If `interprogram-cut-function' is non-nil, also save the text for a window |
| 4317 | system cut and paste. | 4322 | system cut and paste. |
| 4318 | 4323 | ||
| 4319 | The optional argument REGION if non-nil, indicates that we're not just copying | 4324 | The copied text is filtered by `filter-buffer-substring' before it is |
| 4320 | some text between BEG and END, but we're copying the region. | 4325 | saved in the kill ring, so the actual saved text might be different |
| 4326 | from what was in the buffer. | ||
| 4327 | |||
| 4328 | When called from Lisp, save in the kill ring the stretch of text | ||
| 4329 | between BEG and END, unless the optional argument REGION is | ||
| 4330 | non-nil, in which case ignore BEG and END, and save the current | ||
| 4331 | region instead. | ||
| 4321 | 4332 | ||
| 4322 | This command's old key binding has been given to `kill-ring-save'." | 4333 | This command's old key binding has been given to `kill-ring-save'." |
| 4323 | ;; Pass mark first, then point, because the order matters when | 4334 | ;; Pass mark first, then point, because the order matters when |
| @@ -4342,8 +4353,14 @@ system cut and paste. | |||
| 4342 | If you want to append the killed line to the last killed text, | 4353 | If you want to append the killed line to the last killed text, |
| 4343 | use \\[append-next-kill] before \\[kill-ring-save]. | 4354 | use \\[append-next-kill] before \\[kill-ring-save]. |
| 4344 | 4355 | ||
| 4345 | The optional argument REGION if non-nil, indicates that we're not just copying | 4356 | The copied text is filtered by `filter-buffer-substring' before it is |
| 4346 | some text between BEG and END, but we're copying the region. | 4357 | saved in the kill ring, so the actual saved text might be different |
| 4358 | from what was in the buffer. | ||
| 4359 | |||
| 4360 | When called from Lisp, save in the kill ring the stretch of text | ||
| 4361 | between BEG and END, unless the optional argument REGION is | ||
| 4362 | non-nil, in which case ignore BEG and END, and save the current | ||
| 4363 | region instead. | ||
| 4347 | 4364 | ||
| 4348 | This command is similar to `copy-region-as-kill', except that it gives | 4365 | This command is similar to `copy-region-as-kill', except that it gives |
| 4349 | visual feedback indicating the extent of the region being copied." | 4366 | visual feedback indicating the extent of the region being copied." |
| @@ -8269,7 +8286,7 @@ backward. | |||
| 8269 | 8286 | ||
| 8270 | If set to nil, both Delete and Backspace keys delete backward. | 8287 | If set to nil, both Delete and Backspace keys delete backward. |
| 8271 | 8288 | ||
| 8272 | If set to 'maybe (which is the default), Emacs automatically | 8289 | If set to `maybe' (which is the default), Emacs automatically |
| 8273 | selects a behavior. On window systems, the behavior depends on | 8290 | selects a behavior. On window systems, the behavior depends on |
| 8274 | the keyboard used. If the keyboard has both a Backspace key and | 8291 | the keyboard used. If the keyboard has both a Backspace key and |
| 8275 | a Delete key, and both are mapped to their usual meanings, the | 8292 | a Delete key, and both are mapped to their usual meanings, the |