bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#35055: 27.0.50; async-shell-command truncates output lines


From: Juri Linkov
Subject: bug#35055: 27.0.50; async-shell-command truncates output lines
Date: Mon, 08 Apr 2019 23:23:46 +0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (x86_64-pc-linux-gnu)

>>> If you add "COLUMNS=1024" to tramp-remote-process-environment, you would
>>> get this effect already w/o any change in Tramp. Maybe I shall document
>>> it somewhere in the Tramp manual.
>>
>> It seems it's impossible to set COLUMNS to the width of the output window
>> neither in Tramp nor in async-shell-command.  shell-mode can do this
>> using set-process-window-size.  But Tramp can't do the same for the
>> remote process, and for async-shell-command it's too late to do this
>> because when it displays a window with the output buffer,
>> the command is already finished.
>
> Again, using tramp-remote-process-environment seems to be the
> appropriate place.

Thanks for the suggestion, I customized it to '("COLUMNS=222")
that is approximately equal to my frame's width, thus `ps`
shows enough output, and `dpkg -l '*emacs*'` is not too wide
('dpkg' tries to fill all available columns).

Should a similar option be added for async-shell-command as well?

diff --git a/lisp/simple.el b/lisp/simple.el
index 857e0fc001..7212686add 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -3336,6 +3336,15 @@ async-shell-command-display-buffer
   :group 'shell
   :version "26.1")
 
+(defcustom async-shell-command-width nil
+  "Number of columns available for shell command.
+If nil, use the shell default number (usually 80).
+If a positive integer, use a fixed width."
+  :type '(choice (const :tag "Use system limit" nil)
+                 (integer :tag "Fixed width" :value 80))
+  :group 'shell
+  :version "27.1")
+
 (defcustom shell-command-dont-erase-buffer nil
   "If non-nil, output buffer is not erased between shell commands.
 Also, a non-nil value sets the point in the output buffer
@@ -3599,8 +3608,13 @@ shell-command
                (with-current-buffer buffer
                   (shell-command--save-pos-or-erase)
                  (setq default-directory directory)
-                  (setq proc
-                        (start-process-shell-command "Shell" buffer command))
+                 (let ((process-environment
+                        (if (natnump async-shell-command-width)
+                            (cons (format "COLUMNS=%d" 
async-shell-command-width)
+                                  process-environment)
+                          process-environment)))
+                   (setq proc
+                         (start-process-shell-command "Shell" buffer command)))
                  (setq mode-line-process '(":%s"))
                  (require 'shell) (shell-mode)
                   (set-process-sentinel proc #'shell-command-sentinel)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]