diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2021-02-06 00:01:50 -0700 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2021-12-24 14:08:06 -0700 |
commit | d47446cbe7db5c7fb4eba71ab022cfae3de07799 (patch) | |
tree | e94bfe640a6193b4dee47c38028d73453035ef9d | |
parent | 4b7e73432cd07612e5225189e18696f755c8f954 (diff) | |
download | emacs-d47446cbe7db5c7fb4eba71ab022cfae3de07799.tar.gz |
Add eshell-restore-unexpanded-input
* lisp/eshell/esh-mode.el (eshell-send-input): Store the original
input before running eshell-expand-input-functions.
* lisp/eshell/esh-mode.el (eshell-restore-unexpanded-input): Define
new function and register as a customization option for
eshell-input-filter-functions.
-rw-r--r-- | lisp/eshell/esh-mode.el | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/lisp/eshell/esh-mode.el b/lisp/eshell/esh-mode.el index cae5236d894..87166ef3bf1 100644 --- a/lisp/eshell/esh-mode.el +++ b/lisp/eshell/esh-mode.el @@ -62,6 +62,7 @@ (require 'esh-module) (require 'esh-cmd) (require 'esh-arg) ;For eshell-parse-arguments +(require 'cl-lib) (defgroup eshell-mode nil "This module contains code for handling input from the user." @@ -197,6 +198,7 @@ This is used by `eshell-watch-for-password-prompt'." ;; byte-compiler, when compiling other files which `require' this one (defvar eshell-mode nil) (defvar eshell-command-running-string "--") +(defvar eshell-last-unexpanded-input nil) (defvar eshell-last-input-start nil) (defvar eshell-last-input-end nil) (defvar eshell-last-output-start nil) @@ -641,6 +643,7 @@ newline." (progn (setq input (buffer-substring-no-properties eshell-last-output-end (1- (point)))) + (setq eshell-last-unexpanded-input input) (run-hook-with-args 'eshell-expand-input-functions eshell-last-output-end (1- (point))) (let ((cmd (eshell-parse-command-input @@ -674,6 +677,23 @@ newline." (custom-add-option 'eshell-input-filter-functions 'eshell-kill-new) +(defun eshell-restore-unexpanded-input () + "Restore the input text before `eshell-expand-input-functions' ran. +Useful when you want to see the unexpanded input rather than the +expanded input in the Eshell buffer, and when you want later +entries in `eshell-input-filter-functions' to use the unexpanded +input." + (setf (buffer-substring eshell-last-input-start + (1- eshell-last-input-end)) + eshell-last-unexpanded-input) + ;; We have to move point for compatibility with smart display. + (save-excursion + (goto-char eshell-last-input-end) + (eshell-update-markers eshell-last-output-end))) + +(custom-add-option 'eshell-input-filter-functions + 'eshell-restore-unexpanded-input) + (defun eshell-output-filter (process string) "Send the output from PROCESS (STRING) to the interactive display. This is done after all necessary filtering has been done." |