diff options
| author | Alan Mackenzie | 2022-01-22 11:02:50 +0000 |
|---|---|---|
| committer | Alan Mackenzie | 2022-01-22 11:02:50 +0000 |
| commit | 14d64a8adcc866deecd758b898e8ef2d836b354a (patch) | |
| tree | 83cff9669e266f8e283ccb8cd7518e909240f1e1 /lisp/eshell/em-basic.el | |
| parent | bdd9b5b8a0d37dd09ee530c1dab3a44bee09e0f8 (diff) | |
| parent | ebe334cdc234de2897263aed4c05ac7088c11857 (diff) | |
| download | emacs-scratch/correct-warning-pos.tar.gz emacs-scratch/correct-warning-pos.zip | |
Merge branch 'master' into scratch/correct-warning-posscratch/correct-warning-pos
Diffstat (limited to 'lisp/eshell/em-basic.el')
| -rw-r--r-- | lisp/eshell/em-basic.el | 37 |
1 files changed, 28 insertions, 9 deletions
diff --git a/lisp/eshell/em-basic.el b/lisp/eshell/em-basic.el index 27b343ad398..ba868cee59e 100644 --- a/lisp/eshell/em-basic.el +++ b/lisp/eshell/em-basic.el | |||
| @@ -82,7 +82,11 @@ equivalent of `echo' can always be achieved by using `identity'." | |||
| 82 | It returns a formatted value that should be passed to `eshell-print' | 82 | It returns a formatted value that should be passed to `eshell-print' |
| 83 | or `eshell-printn' for display." | 83 | or `eshell-printn' for display." |
| 84 | (if eshell-plain-echo-behavior | 84 | (if eshell-plain-echo-behavior |
| 85 | (concat (apply 'eshell-flatten-and-stringify args) "\n") | 85 | (progn |
| 86 | ;; If the output does not end in a newline, do not emit one. | ||
| 87 | (setq eshell-ensure-newline-p nil) | ||
| 88 | (concat (apply #'eshell-flatten-and-stringify args) | ||
| 89 | (when output-newline "\n"))) | ||
| 86 | (let ((value | 90 | (let ((value |
| 87 | (cond | 91 | (cond |
| 88 | ((= (length args) 0) "") | 92 | ((= (length args) 0) "") |
| @@ -109,18 +113,33 @@ or `eshell-printn' for display." | |||
| 109 | "Implementation of `echo'. See `eshell-plain-echo-behavior'." | 113 | "Implementation of `echo'. See `eshell-plain-echo-behavior'." |
| 110 | (eshell-eval-using-options | 114 | (eshell-eval-using-options |
| 111 | "echo" args | 115 | "echo" args |
| 112 | '((?n nil nil output-newline "terminate with a newline") | 116 | '((?n nil (nil) output-newline |
| 113 | (?h "help" nil nil "output this help screen") | 117 | "do not output the trailing newline") |
| 118 | (?N nil (t) output-newline | ||
| 119 | "terminate with a newline") | ||
| 120 | (?E nil nil _disable-escapes | ||
| 121 | "don't interpret backslash escapes (default)") | ||
| 122 | (?h "help" nil nil | ||
| 123 | "output this help screen") | ||
| 114 | :preserve-args | 124 | :preserve-args |
| 115 | :usage "[-n] [object]") | 125 | :usage "[OPTION]... [OBJECT]...") |
| 116 | (eshell-echo args output-newline))) | 126 | (if eshell-plain-echo-behavior |
| 127 | (eshell-echo args (if output-newline (car output-newline) t)) | ||
| 128 | ;; In Emacs 28.1 and earlier, "-n" was used to add a newline to | ||
| 129 | ;; non-plain echo in Eshell. This caused confusion due to "-n" | ||
| 130 | ;; generally having the opposite meaning for echo. Retain this | ||
| 131 | ;; compatibility for the time being. For more info, see | ||
| 132 | ;; bug#27361. | ||
| 133 | (when (equal output-newline '(nil)) | ||
| 134 | (display-warning | ||
| 135 | :warning "To terminate with a newline, you should use -N instead.")) | ||
| 136 | (eshell-echo args output-newline)))) | ||
| 117 | 137 | ||
| 118 | (defun eshell/printnl (&rest args) | 138 | (defun eshell/printnl (&rest args) |
| 119 | "Print out each of the arguments, separated by newlines." | 139 | "Print out each of the arguments as strings, separated by newlines." |
| 120 | (let ((elems (flatten-tree args))) | 140 | (let ((elems (flatten-tree args))) |
| 121 | (while elems | 141 | (dolist (elem elems) |
| 122 | (eshell-printn (eshell-echo (list (car elems)))) | 142 | (eshell-printn (eshell-stringify elem))))) |
| 123 | (setq elems (cdr elems))))) | ||
| 124 | 143 | ||
| 125 | (defun eshell/listify (&rest args) | 144 | (defun eshell/listify (&rest args) |
| 126 | "Return the argument(s) as a single list." | 145 | "Return the argument(s) as a single list." |