diff options
| author | Jim Porter | 2023-08-23 13:29:19 -0700 |
|---|---|---|
| committer | Jim Porter | 2023-08-23 16:46:25 -0700 |
| commit | 08901e93797cd9e338883ab6153d98f15bc2ccfb (patch) | |
| tree | a43bec9652052bd4c6551f1f2551f9666ef0f7b4 /test | |
| parent | cb3731361f0cf4222d39aedcfc5188f0063ebc5e (diff) | |
| download | emacs-08901e93797cd9e338883ab6153d98f15bc2ccfb.tar.gz emacs-08901e93797cd9e338883ab6153d98f15bc2ccfb.zip | |
Support 'comint-pager' in Eshell
* lisp/eshell/esh-var.el (eshell-variable-aliases-list): Add "PAGER".
(eshell-var-initialize): Make 'comint-pager' buffer-local and bind it
in subcommands so that we can temporarily set it as necessary.
* test/lisp/eshell/esh-var-tests.el (esh-var-test/pager-var/default)
(esh-var-test/pager-var/set, esh-var-test/pager-var/unset)
(esh-var-test/pager-var/set-locally): New tests.
* doc/misc/eshell.texi (Variables): Document this (bug#63778).
Co-authored-by: Morgan Smith <Morgan.J.Smith@outlook.com>
Diffstat (limited to 'test')
| -rw-r--r-- | test/lisp/eshell/esh-var-tests.el | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/test/lisp/eshell/esh-var-tests.el b/test/lisp/eshell/esh-var-tests.el index 3e58fe749dd..ff646f5f977 100644 --- a/test/lisp/eshell/esh-var-tests.el +++ b/test/lisp/eshell/esh-var-tests.el | |||
| @@ -766,6 +766,52 @@ it, since the setter is nil." | |||
| 766 | (eshell-match-command-output "echo $INSIDE_EMACS[, 1]" | 766 | (eshell-match-command-output "echo $INSIDE_EMACS[, 1]" |
| 767 | "eshell"))) | 767 | "eshell"))) |
| 768 | 768 | ||
| 769 | (ert-deftest esh-var-test/pager-var/default () | ||
| 770 | "Test that retrieving the default value of $PAGER works. | ||
| 771 | This should be the value of `comint-pager' if non-nil, otherwise | ||
| 772 | the value of the $PAGER env var." | ||
| 773 | (let ((comint-pager nil) | ||
| 774 | (process-environment (cons "PAGER=cat" process-environment))) | ||
| 775 | (eshell-command-result-equal "echo $PAGER" "cat") | ||
| 776 | (setq comint-pager "less") | ||
| 777 | (eshell-command-result-equal "echo $PAGER" "less"))) | ||
| 778 | |||
| 779 | (ert-deftest esh-var-test/pager-var/set () | ||
| 780 | "Test that setting $PAGER in Eshell overrides the default value." | ||
| 781 | (let ((comint-pager nil) | ||
| 782 | (process-environment (cons "PAGER=cat" process-environment))) | ||
| 783 | (with-temp-eshell | ||
| 784 | (eshell-match-command-output "set PAGER bat" "bat") | ||
| 785 | (eshell-match-command-output "echo $PAGER" "bat")) | ||
| 786 | (setq comint-pager "less") | ||
| 787 | (with-temp-eshell | ||
| 788 | (eshell-match-command-output "set PAGER bat" "bat") | ||
| 789 | (eshell-match-command-output "echo $PAGER" "bat")))) | ||
| 790 | |||
| 791 | (ert-deftest esh-var-test/pager-var/unset () | ||
| 792 | "Test that unsetting $PAGER in Eshell overrides the default value." | ||
| 793 | (let ((comint-pager nil) | ||
| 794 | (process-environment (cons "PAGER=cat" process-environment))) | ||
| 795 | (with-temp-eshell | ||
| 796 | (eshell-insert-command "unset PAGER") | ||
| 797 | (eshell-match-command-output "echo $PAGER" "\\`\\'")) | ||
| 798 | (setq comint-pager "less") | ||
| 799 | (with-temp-eshell | ||
| 800 | (eshell-insert-command "unset PAGER") | ||
| 801 | (eshell-match-command-output "echo $PAGER" "\\`\\'")))) | ||
| 802 | |||
| 803 | (ert-deftest esh-var-test/pager-var/set-locally () | ||
| 804 | "Test setting $PAGER temporarily for a single command." | ||
| 805 | (let ((comint-pager nil) | ||
| 806 | (process-environment (cons "PAGER=cat" process-environment))) | ||
| 807 | (with-temp-eshell | ||
| 808 | (eshell-match-command-output "PAGER=bat env" "PAGER=bat\n") | ||
| 809 | (eshell-match-command-output "echo $PAGER" "cat")) | ||
| 810 | (setq comint-pager "less") | ||
| 811 | (with-temp-eshell | ||
| 812 | (eshell-match-command-output "PAGER=bat env" "PAGER=bat\n") | ||
| 813 | (eshell-match-command-output "echo $PAGER" "less")))) | ||
| 814 | |||
| 769 | (ert-deftest esh-var-test/path-var/local-directory () | 815 | (ert-deftest esh-var-test/path-var/local-directory () |
| 770 | "Test using $PATH in a local directory." | 816 | "Test using $PATH in a local directory." |
| 771 | (let ((expected-path (string-join (eshell-get-path t) (path-separator)))) | 817 | (let ((expected-path (string-join (eshell-get-path t) (path-separator)))) |