diff options
| author | Jim Porter | 2023-01-08 13:05:59 -0800 |
|---|---|---|
| committer | Jim Porter | 2023-01-14 11:09:02 -0800 |
| commit | 54051c97f2e950eaa229b18f0cf209c727b2daa3 (patch) | |
| tree | 6731fd8ed2a84064b871e7106e29409401f74c43 | |
| parent | 558f04c39e036d2f681f72556627768d7bee9ab5 (diff) | |
| download | emacs-54051c97f2e950eaa229b18f0cf209c727b2daa3.tar.gz emacs-54051c97f2e950eaa229b18f0cf209c727b2daa3.zip | |
Make 'eshell-bol' obsolete
Now that Eshell uses fields for its output, 'eshell-bol' is no longer
needed, and we can just use 'beginning-of-line'.
* lisp/eshell/esh-mode.el (eshell-bol): Mark obsolete.
(eshell-mode-map): Remove 'C-a' mapping.
(eshell-command-map): Use 'move-beginning-of-line'.
(eshell-move-argument, eshell-kill-input): Use 'beginning-of-line'.
(eshell-get-old-input): Remove unnecessary call to
'eshell-skip-prompt-function'.
* lisp/eshell/em-rebind.el (eshell-rebind-keys-alist): Remove 'C-a'
and '<home>' mappings; the global mapping for these
('move-beginning-of-line') does the same thing now.
* lisp/eshell/em-cmpl.el (eshell-complete-parse-arguments):
* lisp/eshell/em-elecslash.el (eshell-electric-forward-slash):
* lisp/eshell/em-hist.el (eshell-hist-word-reference)
(eshell-previous-matching-input-from-input, eshell-test-imatch):
* lisp/eshell/em-prompt.el (eshell-backward-matching-input):
* lisp/eshell/em-rebind.el (eshell-point-within-input-p):
* test/lisp/eshell/eshell-tests.el (eshell-test/forward-arg): Use
'beginning-of-line'.
* test/lisp/eshell/eshell-tests.el (eshell-test/run-old-command):
Rename to...
(eshell-test/get-old-input): ... this, and expand the test.
| -rw-r--r-- | lisp/eshell/em-cmpl.el | 2 | ||||
| -rw-r--r-- | lisp/eshell/em-elecslash.el | 2 | ||||
| -rw-r--r-- | lisp/eshell/em-hist.el | 6 | ||||
| -rw-r--r-- | lisp/eshell/em-prompt.el | 2 | ||||
| -rw-r--r-- | lisp/eshell/em-rebind.el | 6 | ||||
| -rw-r--r-- | lisp/eshell/esh-mode.el | 31 | ||||
| -rw-r--r-- | test/lisp/eshell/eshell-tests.el | 15 |
7 files changed, 31 insertions, 33 deletions
diff --git a/lisp/eshell/em-cmpl.el b/lisp/eshell/em-cmpl.el index 94ec5e8f1db..4206ad048fa 100644 --- a/lisp/eshell/em-cmpl.el +++ b/lisp/eshell/em-cmpl.el | |||
| @@ -312,7 +312,7 @@ to writing a completion function." | |||
| 312 | (eshell-interactive-process-p)) | 312 | (eshell-interactive-process-p)) |
| 313 | (eshell--pcomplete-insert-tab)) | 313 | (eshell--pcomplete-insert-tab)) |
| 314 | (let ((end (point-marker)) | 314 | (let ((end (point-marker)) |
| 315 | (begin (save-excursion (eshell-bol) (point))) | 315 | (begin (save-excursion (beginning-of-line) (point))) |
| 316 | (posns (list t)) | 316 | (posns (list t)) |
| 317 | args delim) | 317 | args delim) |
| 318 | (when (and pcomplete-allow-modifications | 318 | (when (and pcomplete-allow-modifications |
diff --git a/lisp/eshell/em-elecslash.el b/lisp/eshell/em-elecslash.el index 80bc0f031ef..2b003f58dc7 100644 --- a/lisp/eshell/em-elecslash.el +++ b/lisp/eshell/em-elecslash.el | |||
| @@ -72,7 +72,7 @@ insertion." | |||
| 72 | (delete-char -1) | 72 | (delete-char -1) |
| 73 | (let ((tilde-before (eq ?~ (char-before))) | 73 | (let ((tilde-before (eq ?~ (char-before))) |
| 74 | (command (save-excursion | 74 | (command (save-excursion |
| 75 | (eshell-bol) | 75 | (beginning-of-line) |
| 76 | (skip-syntax-forward " ") | 76 | (skip-syntax-forward " ") |
| 77 | (thing-at-point 'sexp))) | 77 | (thing-at-point 'sexp))) |
| 78 | (prefix (file-remote-p default-directory))) | 78 | (prefix (file-remote-p default-directory))) |
diff --git a/lisp/eshell/em-hist.el b/lisp/eshell/em-hist.el index 05e9598f530..6e0e471d910 100644 --- a/lisp/eshell/em-hist.el +++ b/lisp/eshell/em-hist.el | |||
| @@ -555,7 +555,7 @@ See also `eshell-read-history'." | |||
| 555 | (defun eshell-hist-parse-arguments (&optional b e) | 555 | (defun eshell-hist-parse-arguments (&optional b e) |
| 556 | "Parse current command arguments in a history-code-friendly way." | 556 | "Parse current command arguments in a history-code-friendly way." |
| 557 | (let ((end (or e (point))) | 557 | (let ((end (or e (point))) |
| 558 | (begin (or b (save-excursion (eshell-bol) (point)))) | 558 | (begin (or b (save-excursion (beginning-of-line) (point)))) |
| 559 | (posb (list t)) | 559 | (posb (list t)) |
| 560 | (pose (list t)) | 560 | (pose (list t)) |
| 561 | (textargs (list t)) | 561 | (textargs (list t)) |
| @@ -913,7 +913,7 @@ If N is negative, search forwards for the -Nth following match." | |||
| 913 | eshell-next-matching-input-from-input))) | 913 | eshell-next-matching-input-from-input))) |
| 914 | ;; Starting a new search | 914 | ;; Starting a new search |
| 915 | (setq eshell-matching-input-from-input-string | 915 | (setq eshell-matching-input-from-input-string |
| 916 | (buffer-substring (save-excursion (eshell-bol) (point)) | 916 | (buffer-substring (save-excursion (beginning-of-line) (point)) |
| 917 | (point)) | 917 | (point)) |
| 918 | eshell-history-index nil)) | 918 | eshell-history-index nil)) |
| 919 | (eshell-previous-matching-input | 919 | (eshell-previous-matching-input |
| @@ -933,7 +933,7 @@ If N is negative, search backwards for the -Nth previous match." | |||
| 933 | (if (get-text-property (point) 'history) | 933 | (if (get-text-property (point) 'history) |
| 934 | (progn (beginning-of-line) t) | 934 | (progn (beginning-of-line) t) |
| 935 | (let ((before (point))) | 935 | (let ((before (point))) |
| 936 | (eshell-bol) | 936 | (beginning-of-line) |
| 937 | (if (and (not (bolp)) | 937 | (if (and (not (bolp)) |
| 938 | (<= (point) before)) | 938 | (<= (point) before)) |
| 939 | t | 939 | t |
diff --git a/lisp/eshell/em-prompt.el b/lisp/eshell/em-prompt.el index fdd16ca846a..5a89ff35a2b 100644 --- a/lisp/eshell/em-prompt.el +++ b/lisp/eshell/em-prompt.el | |||
| @@ -163,7 +163,7 @@ If N is negative, find the next or Nth next match." | |||
| 163 | (progn (message "Not found") | 163 | (progn (message "Not found") |
| 164 | (ding)) | 164 | (ding)) |
| 165 | (goto-char pos) | 165 | (goto-char pos) |
| 166 | (eshell-bol)))) | 166 | (beginning-of-line)))) |
| 167 | 167 | ||
| 168 | (defun eshell-forward-matching-input (regexp arg) | 168 | (defun eshell-forward-matching-input (regexp arg) |
| 169 | "Search forward through buffer for match for REGEXP. | 169 | "Search forward through buffer for match for REGEXP. |
diff --git a/lisp/eshell/em-rebind.el b/lisp/eshell/em-rebind.el index 2c95d4fdffb..f147d432300 100644 --- a/lisp/eshell/em-rebind.el +++ b/lisp/eshell/em-rebind.el | |||
| @@ -50,9 +50,7 @@ the behavior of normal shells while the user editing new input text." | |||
| 50 | :group 'eshell-rebind) | 50 | :group 'eshell-rebind) |
| 51 | 51 | ||
| 52 | (defcustom eshell-rebind-keys-alist | 52 | (defcustom eshell-rebind-keys-alist |
| 53 | '(([(control ?a)] . eshell-bol) | 53 | '(([(control ?d)] . eshell-delchar-or-maybe-eof) |
| 54 | ([home] . eshell-bol) | ||
| 55 | ([(control ?d)] . eshell-delchar-or-maybe-eof) | ||
| 56 | ([backspace] . eshell-delete-backward-char) | 54 | ([backspace] . eshell-delete-backward-char) |
| 57 | ([delete] . eshell-delete-backward-char) | 55 | ([delete] . eshell-delete-backward-char) |
| 58 | ([(control ?w)] . backward-kill-word) | 56 | ([(control ?w)] . backward-kill-word) |
| @@ -190,7 +188,7 @@ lock it at that." | |||
| 190 | (and eshell-remap-previous-input | 188 | (and eshell-remap-previous-input |
| 191 | (setq begin | 189 | (setq begin |
| 192 | (save-excursion | 190 | (save-excursion |
| 193 | (eshell-bol) | 191 | (beginning-of-line) |
| 194 | (and (not (bolp)) (point)))) | 192 | (and (not (bolp)) (point)))) |
| 195 | (>= pos begin) | 193 | (>= pos begin) |
| 196 | (<= pos (line-end-position)) | 194 | (<= pos (line-end-position)) |
diff --git a/lisp/eshell/esh-mode.el b/lisp/eshell/esh-mode.el index 97edc826c9a..90e003d188b 100644 --- a/lisp/eshell/esh-mode.el +++ b/lisp/eshell/esh-mode.el | |||
| @@ -262,14 +262,13 @@ This is used by `eshell-watch-for-password-prompt'." | |||
| 262 | "C-c" 'eshell-command-map | 262 | "C-c" 'eshell-command-map |
| 263 | "RET" #'eshell-send-input | 263 | "RET" #'eshell-send-input |
| 264 | "M-RET" #'eshell-queue-input | 264 | "M-RET" #'eshell-queue-input |
| 265 | "C-M-l" #'eshell-show-output | 265 | "C-M-l" #'eshell-show-output) |
| 266 | "C-a" #'eshell-bol) | ||
| 267 | 266 | ||
| 268 | (defvar-keymap eshell-command-map | 267 | (defvar-keymap eshell-command-map |
| 269 | :prefix 'eshell-command-map | 268 | :prefix 'eshell-command-map |
| 270 | "M-o" #'eshell-mark-output | 269 | "M-o" #'eshell-mark-output |
| 271 | "M-d" #'eshell-toggle-direct-send | 270 | "M-d" #'eshell-toggle-direct-send |
| 272 | "C-a" #'eshell-bol | 271 | "C-a" #'move-beginning-of-line |
| 273 | "C-b" #'eshell-backward-argument | 272 | "C-b" #'eshell-backward-argument |
| 274 | "C-e" #'eshell-show-maximum-output | 273 | "C-e" #'eshell-show-maximum-output |
| 275 | "C-f" #'eshell-forward-argument | 274 | "C-f" #'eshell-forward-argument |
| @@ -472,7 +471,7 @@ and the hook `eshell-exit-hook'." | |||
| 472 | (defun eshell-move-argument (limit func property arg) | 471 | (defun eshell-move-argument (limit func property arg) |
| 473 | "Move forward ARG arguments." | 472 | "Move forward ARG arguments." |
| 474 | (catch 'eshell-incomplete | 473 | (catch 'eshell-incomplete |
| 475 | (eshell-parse-arguments (save-excursion (eshell-bol) (point)) | 474 | (eshell-parse-arguments (save-excursion (beginning-of-line) (point)) |
| 476 | (line-end-position))) | 475 | (line-end-position))) |
| 477 | (let ((pos (save-excursion | 476 | (let ((pos (save-excursion |
| 478 | (funcall func 1) | 477 | (funcall func 1) |
| @@ -505,12 +504,7 @@ and the hook `eshell-exit-hook'." | |||
| 505 | (kill-ring-save begin (point)) | 504 | (kill-ring-save begin (point)) |
| 506 | (yank))) | 505 | (yank))) |
| 507 | 506 | ||
| 508 | (defun eshell-bol () | 507 | (define-obsolete-function-alias 'eshell-bol #'beginning-of-line "30.1") |
| 509 | "Go to the beginning of line, then skip past the prompt, if any." | ||
| 510 | (interactive) | ||
| 511 | (beginning-of-line) | ||
| 512 | (and eshell-skip-prompt-function | ||
| 513 | (funcall eshell-skip-prompt-function))) | ||
| 514 | 508 | ||
| 515 | (defsubst eshell-push-command-mark () | 509 | (defsubst eshell-push-command-mark () |
| 516 | "Push a mark at the end of the last input text." | 510 | "Push a mark at the end of the last input text." |
| @@ -856,7 +850,7 @@ With a prefix argument, narrows region to last command output." | |||
| 856 | (if (> (point) eshell-last-output-end) | 850 | (if (> (point) eshell-last-output-end) |
| 857 | (kill-region eshell-last-output-end (point)) | 851 | (kill-region eshell-last-output-end (point)) |
| 858 | (let ((here (point))) | 852 | (let ((here (point))) |
| 859 | (eshell-bol) | 853 | (beginning-of-line) |
| 860 | (kill-region (point) here)))) | 854 | (kill-region (point) here)))) |
| 861 | 855 | ||
| 862 | (defun eshell-show-maximum-output (&optional interactive) | 856 | (defun eshell-show-maximum-output (&optional interactive) |
| @@ -884,17 +878,18 @@ If SCROLLBACK is non-nil, clear the scrollback contents." | |||
| 884 | (erase-buffer))) | 878 | (erase-buffer))) |
| 885 | 879 | ||
| 886 | (defun eshell-get-old-input (&optional use-current-region) | 880 | (defun eshell-get-old-input (&optional use-current-region) |
| 887 | "Return the command input on the current line." | 881 | "Return the command input on the current line. |
| 882 | If USE-CURRENT-REGION is non-nil, return the current region." | ||
| 888 | (if use-current-region | 883 | (if use-current-region |
| 889 | (buffer-substring (min (point) (mark)) | 884 | (buffer-substring (min (point) (mark)) |
| 890 | (max (point) (mark))) | 885 | (max (point) (mark))) |
| 891 | (save-excursion | 886 | (save-excursion |
| 892 | (beginning-of-line) | 887 | (let ((inhibit-field-text-motion t)) |
| 893 | (and eshell-skip-prompt-function | 888 | (end-of-line)) |
| 894 | (funcall eshell-skip-prompt-function)) | 889 | (let ((inhibit-field-text-motion) |
| 895 | (let ((beg (point))) | 890 | (end (point))) |
| 896 | (end-of-line) | 891 | (beginning-of-line) |
| 897 | (buffer-substring beg (point)))))) | 892 | (buffer-substring (point) end))))) |
| 898 | 893 | ||
| 899 | (defun eshell-copy-old-input () | 894 | (defun eshell-copy-old-input () |
| 900 | "Insert after prompt old input at point as new input to be edited." | 895 | "Insert after prompt old input at point as new input to be edited." |
diff --git a/test/lisp/eshell/eshell-tests.el b/test/lisp/eshell/eshell-tests.el index be968e1558f..776cfb9b92f 100644 --- a/test/lisp/eshell/eshell-tests.el +++ b/test/lisp/eshell/eshell-tests.el | |||
| @@ -117,14 +117,14 @@ | |||
| 117 | (with-temp-eshell | 117 | (with-temp-eshell |
| 118 | (eshell-insert-command "echo $(+ 1 (- 4 3)) \"alpha beta\" file" 'ignore) | 118 | (eshell-insert-command "echo $(+ 1 (- 4 3)) \"alpha beta\" file" 'ignore) |
| 119 | (let ((here (point)) begin valid) | 119 | (let ((here (point)) begin valid) |
| 120 | (eshell-bol) | 120 | (beginning-of-line) |
| 121 | (setq begin (point)) | 121 | (setq begin (point)) |
| 122 | (eshell-forward-argument 4) | 122 | (eshell-forward-argument 4) |
| 123 | (setq valid (= here (point))) | 123 | (setq valid (= here (point))) |
| 124 | (eshell-backward-argument 4) | 124 | (eshell-backward-argument 4) |
| 125 | (prog1 | 125 | (prog1 |
| 126 | (and valid (= begin (point))) | 126 | (and valid (= begin (point))) |
| 127 | (eshell-bol) | 127 | (beginning-of-line) |
| 128 | (delete-region (point) (point-max)))))) | 128 | (delete-region (point) (point-max)))))) |
| 129 | 129 | ||
| 130 | (ert-deftest eshell-test/queue-input () | 130 | (ert-deftest eshell-test/queue-input () |
| @@ -148,12 +148,17 @@ insert the queued one at the next prompt, and finally run it." | |||
| 148 | (should (eshell-match-output | 148 | (should (eshell-match-output |
| 149 | (concat "^" (regexp-quote "*** output flushed ***\n") "$"))))) | 149 | (concat "^" (regexp-quote "*** output flushed ***\n") "$"))))) |
| 150 | 150 | ||
| 151 | (ert-deftest eshell-test/run-old-command () | 151 | (ert-deftest eshell-test/get-old-input () |
| 152 | "Re-run an old command" | 152 | "Test that we can get the input of a previous command." |
| 153 | (with-temp-eshell | 153 | (with-temp-eshell |
| 154 | (eshell-insert-command "echo alpha") | 154 | (eshell-insert-command "echo alpha") |
| 155 | (goto-char eshell-last-input-start) | 155 | (goto-char eshell-last-input-start) |
| 156 | (string= (eshell-get-old-input) "echo alpha"))) | 156 | (should (string= (eshell-get-old-input) "echo alpha")) |
| 157 | ;; Make sure that `eshell-get-old-input' works even if the point is | ||
| 158 | ;; inside the prompt. | ||
| 159 | (let ((inhibit-field-text-motion t)) | ||
| 160 | (beginning-of-line)) | ||
| 161 | (should (string= (eshell-get-old-input) "echo alpha")))) | ||
| 157 | 162 | ||
| 158 | (provide 'eshell-tests) | 163 | (provide 'eshell-tests) |
| 159 | 164 | ||