You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
pidcat do not show anything if it's run through the emacs Terminal emulator.
Steps to reproduce:
Install Emacs and pidcat
Open up a terminal
Run emacs
Hit M-x (Alt+x)
Type shell and hit ENTER
Type pidcat.py and hit ENTER
Notes:
You can kill the python process by hitting C-c C-c (Control+C, Control+C)
You should see that the script is stuck in a loop in indent_wrap
To exit emacs, hit C-x C-c (Control+X, followed by Control+C). You may need to type yes if you're prompted to kill the active shell process
def indent_wrap(message):
if width == -1:
return message
message = message.replace('\t', ' ')
wrap_area = width - header_size
messagebuf = ''
current = 0
while current < len(message):
next = min(current + wrap_area, len(message))
messagebuf += message[current:next]
if next < len(message):
messagebuf += '\n'
messagebuf += ' ' * header_size
current = next
return messagebuf
The script is looping because width is 0, this causes wrap_area = width - header_size to produce a negative number, which causes next = min(current + wrap_area, len(message)) to continuously decrease in every loop iteration because the left-hand parameter of min is always negative.
There's a workaround that involves tweaking the initialisation of width:
width = -1
try:
# Get the current terminal width
import fcntl, termios, struct
h, width = struct.unpack('hh', fcntl.ioctl(0, termios.TIOCGWINSZ, struct.pack('hh', 0, 0)))
# ioctl may occasionally return 0 (example, in emacs terminal)
if width <= 0:
width = -1
except:
pass
The text was updated successfully, but these errors were encountered:
pidcat do not show anything if it's run through the emacs Terminal emulator.
Steps to reproduce:
emacs
M-x
(Alt+x)shell
and hit ENTERpidcat.py
and hit ENTERNotes:
C-c C-c
(Control+C, Control+C)indent_wrap
C-x C-c
(Control+X, followed by Control+C). You may need to typeyes
if you're prompted to kill the active shell processThe script is looping because
width
is0
, this causeswrap_area = width - header_size
to produce a negative number, which causesnext = min(current + wrap_area, len(message))
to continuously decrease in every loop iteration because the left-hand parameter ofmin
is always negative.There's a workaround that involves tweaking the initialisation of
width
:The text was updated successfully, but these errors were encountered: