Eshell: Trim trailing spaces in commands

master
Pierre Neidhardt 2019-03-03 12:52:57 +01:00
parent b8bb5d7e9f
commit 99cb5bbff4
1 changed files with 10 additions and 7 deletions

View File

@ -70,11 +70,7 @@
;;; mu: no matches for search expression (4)
;;; See #21605 "24.3; Eshell not using stderr".
;;; REVIEW: Some parsing fails
;;; > echo -n $PATH | sed 's/:[^:]*sophos[^:]*/:/g'
;;; :s/:]*sophos[/:]*/:/"/
;;; Unknown modifier character /
;;;
;;; REVIEW: eshell/date does not support many options from GNU date.
;;; > date +%Z
;;; See #29157.
(when (< emacs-major-version 27)
@ -199,8 +195,6 @@
(add-hook 'eshell-mode-hook 'ambrevar/turn-off-nobreak-char-display)
;;; History
;;; Filter out space-beginning commands from history.
;;; TODO: history/command hook: trim spaces. Check `eshell-rewrite-command-hook'.
;;; REVIEW: history: do not save failed Eshell commands (See `eshell-last-command-status')
;;; Eshell commands always return 0.
(setq eshell-input-filter
@ -213,8 +207,17 @@
(string= "" str)
(string= "cd" str)
(string-prefix-p "cd " str)
;; Filter out space-beginning commands from history.
(string-prefix-p " " str)))))
(defun ambrevar/eshell-delete-trailing-whitespace (last-output-end point)
"Delete trailing whitespace in Eshell command.
This is useful to avoid dumb duplicates in history."
(save-mark-and-excursion
(goto-char (point-max))
(delete-trailing-whitespace)))
(add-hook 'eshell-expand-input-functions 'ambrevar/eshell-delete-trailing-whitespace)
;;; Shared history.
(defvar ambrevar/eshell-history-global-ring nil
"The history ring shared across Eshell sessions.")