summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Porter <jporterbugs@gmail.com>2023-01-08 13:05:59 -0800
committerJim Porter <jporterbugs@gmail.com>2023-01-14 11:09:02 -0800
commit54051c97f2e950eaa229b18f0cf209c727b2daa3 (patch)
tree6731fd8ed2a84064b871e7106e29409401f74c43
parent558f04c39e036d2f681f72556627768d7bee9ab5 (diff)
downloademacs-54051c97f2e950eaa229b18f0cf209c727b2daa3.tar.gz
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.el2
-rw-r--r--lisp/eshell/em-elecslash.el2
-rw-r--r--lisp/eshell/em-hist.el6
-rw-r--r--lisp/eshell/em-prompt.el2
-rw-r--r--lisp/eshell/em-rebind.el6
-rw-r--r--lisp/eshell/esh-mode.el31
-rw-r--r--test/lisp/eshell/eshell-tests.el15
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."
(eshell-interactive-process-p))
(eshell--pcomplete-insert-tab))
(let ((end (point-marker))
- (begin (save-excursion (eshell-bol) (point)))
+ (begin (save-excursion (beginning-of-line) (point)))
(posns (list t))
args delim)
(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."
(delete-char -1)
(let ((tilde-before (eq ?~ (char-before)))
(command (save-excursion
- (eshell-bol)
+ (beginning-of-line)
(skip-syntax-forward " ")
(thing-at-point 'sexp)))
(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'."
(defun eshell-hist-parse-arguments (&optional b e)
"Parse current command arguments in a history-code-friendly way."
(let ((end (or e (point)))
- (begin (or b (save-excursion (eshell-bol) (point))))
+ (begin (or b (save-excursion (beginning-of-line) (point))))
(posb (list t))
(pose (list t))
(textargs (list t))
@@ -913,7 +913,7 @@ If N is negative, search forwards for the -Nth following match."
eshell-next-matching-input-from-input)))
;; Starting a new search
(setq eshell-matching-input-from-input-string
- (buffer-substring (save-excursion (eshell-bol) (point))
+ (buffer-substring (save-excursion (beginning-of-line) (point))
(point))
eshell-history-index nil))
(eshell-previous-matching-input
@@ -933,7 +933,7 @@ If N is negative, search backwards for the -Nth previous match."
(if (get-text-property (point) 'history)
(progn (beginning-of-line) t)
(let ((before (point)))
- (eshell-bol)
+ (beginning-of-line)
(if (and (not (bolp))
(<= (point) before))
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."
(progn (message "Not found")
(ding))
(goto-char pos)
- (eshell-bol))))
+ (beginning-of-line))))
(defun eshell-forward-matching-input (regexp arg)
"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."
:group 'eshell-rebind)
(defcustom eshell-rebind-keys-alist
- '(([(control ?a)] . eshell-bol)
- ([home] . eshell-bol)
- ([(control ?d)] . eshell-delchar-or-maybe-eof)
+ '(([(control ?d)] . eshell-delchar-or-maybe-eof)
([backspace] . eshell-delete-backward-char)
([delete] . eshell-delete-backward-char)
([(control ?w)] . backward-kill-word)
@@ -190,7 +188,7 @@ lock it at that."
(and eshell-remap-previous-input
(setq begin
(save-excursion
- (eshell-bol)
+ (beginning-of-line)
(and (not (bolp)) (point))))
(>= pos begin)
(<= 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'."
"C-c" 'eshell-command-map
"RET" #'eshell-send-input
"M-RET" #'eshell-queue-input
- "C-M-l" #'eshell-show-output
- "C-a" #'eshell-bol)
+ "C-M-l" #'eshell-show-output)
(defvar-keymap eshell-command-map
:prefix 'eshell-command-map
"M-o" #'eshell-mark-output
"M-d" #'eshell-toggle-direct-send
- "C-a" #'eshell-bol
+ "C-a" #'move-beginning-of-line
"C-b" #'eshell-backward-argument
"C-e" #'eshell-show-maximum-output
"C-f" #'eshell-forward-argument
@@ -472,7 +471,7 @@ and the hook `eshell-exit-hook'."
(defun eshell-move-argument (limit func property arg)
"Move forward ARG arguments."
(catch 'eshell-incomplete
- (eshell-parse-arguments (save-excursion (eshell-bol) (point))
+ (eshell-parse-arguments (save-excursion (beginning-of-line) (point))
(line-end-position)))
(let ((pos (save-excursion
(funcall func 1)
@@ -505,12 +504,7 @@ and the hook `eshell-exit-hook'."
(kill-ring-save begin (point))
(yank)))
-(defun eshell-bol ()
- "Go to the beginning of line, then skip past the prompt, if any."
- (interactive)
- (beginning-of-line)
- (and eshell-skip-prompt-function
- (funcall eshell-skip-prompt-function)))
+(define-obsolete-function-alias 'eshell-bol #'beginning-of-line "30.1")
(defsubst eshell-push-command-mark ()
"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."
(if (> (point) eshell-last-output-end)
(kill-region eshell-last-output-end (point))
(let ((here (point)))
- (eshell-bol)
+ (beginning-of-line)
(kill-region (point) here))))
(defun eshell-show-maximum-output (&optional interactive)
@@ -884,17 +878,18 @@ If SCROLLBACK is non-nil, clear the scrollback contents."
(erase-buffer)))
(defun eshell-get-old-input (&optional use-current-region)
- "Return the command input on the current line."
+ "Return the command input on the current line.
+If USE-CURRENT-REGION is non-nil, return the current region."
(if use-current-region
(buffer-substring (min (point) (mark))
(max (point) (mark)))
(save-excursion
- (beginning-of-line)
- (and eshell-skip-prompt-function
- (funcall eshell-skip-prompt-function))
- (let ((beg (point)))
- (end-of-line)
- (buffer-substring beg (point))))))
+ (let ((inhibit-field-text-motion t))
+ (end-of-line))
+ (let ((inhibit-field-text-motion)
+ (end (point)))
+ (beginning-of-line)
+ (buffer-substring (point) end)))))
(defun eshell-copy-old-input ()
"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 @@
(with-temp-eshell
(eshell-insert-command "echo $(+ 1 (- 4 3)) \"alpha beta\" file" 'ignore)
(let ((here (point)) begin valid)
- (eshell-bol)
+ (beginning-of-line)
(setq begin (point))
(eshell-forward-argument 4)
(setq valid (= here (point)))
(eshell-backward-argument 4)
(prog1
(and valid (= begin (point)))
- (eshell-bol)
+ (beginning-of-line)
(delete-region (point) (point-max))))))
(ert-deftest eshell-test/queue-input ()
@@ -148,12 +148,17 @@ insert the queued one at the next prompt, and finally run it."
(should (eshell-match-output
(concat "^" (regexp-quote "*** output flushed ***\n") "$")))))
-(ert-deftest eshell-test/run-old-command ()
- "Re-run an old command"
+(ert-deftest eshell-test/get-old-input ()
+ "Test that we can get the input of a previous command."
(with-temp-eshell
(eshell-insert-command "echo alpha")
(goto-char eshell-last-input-start)
- (string= (eshell-get-old-input) "echo alpha")))
+ (should (string= (eshell-get-old-input) "echo alpha"))
+ ;; Make sure that `eshell-get-old-input' works even if the point is
+ ;; inside the prompt.
+ (let ((inhibit-field-text-motion t))
+ (beginning-of-line))
+ (should (string= (eshell-get-old-input) "echo alpha"))))
(provide 'eshell-tests)