GNU bug report logs - #54776
28.1; shell-resync-dirs hangs

Previous Next

Package: emacs;

Reported by: "Kevin K. Lin" <klin <at> math.arizona.edu>

Date: Thu, 7 Apr 2022 20:47:01 UTC

Severity: normal

Found in version 28.1

Fixed in versions 29.1, 28.2

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 54776 in the body.
You can then email your comments to 54776 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#54776; Package emacs. (Thu, 07 Apr 2022 20:47:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to "Kevin K. Lin" <klin <at> math.arizona.edu>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Thu, 07 Apr 2022 20:47:01 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: "Kevin K. Lin" <klin <at> math.arizona.edu>
To: bug-gnu-emacs <at> gnu.org
Subject: 28.1; shell-resync-dirs hangs
Date: Thu, 07 Apr 2022 13:26:29 -0700
Hi,

Starting with

emacs -Q

I do

M-x shell
M-x dirs

and Emacs hangs.  C-g breaks the loop and puts me back
at the prompt.  FYI, I use /bin/tcsh, but the same
thing happens in other shells I tried (zsh, bash).
I'm on macOS; not sure the problem is Mac-specific.

I found bug #54384 on the bug tracker, which seems to
describe a similar problem in Emacs 29.  Wondering if
it's indeed the same issue, and if so whether the
solution would be backported to 28?

Thanks,
Kevin


In GNU Emacs 28.1 (build 1, x86_64-apple-darwin19.6.0)
 of 2022-04-04 built on iMac-Pro
System Description:  Mac OS X 10.15.7

Configured using:
 'configure --disable-silent-rules
 --enable-locallisppath=/usr/local/share/emacs/site-lisp
 --infodir=/usr/local/Cellar/emacs/28.1/share/info/emacs
 --prefix=/usr/local/Cellar/emacs/28.1 --with-gnutls --without-x
 --with-xml2 --without-dbus --with-modules --without-ns
 --without-imagemagick --without-selinux'

Configured features:
ACL GMP GNUTLS JSON LIBXML2 MODULES NOTIFY KQUEUE PDUMPER THREADS ZLIB

Important settings:
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix

Major mode: Lisp Interaction

Minor modes in effect:
  shell-dirtrack-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  show-paren-mode: t
  electric-indent-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  indent-tabs-mode: t
  transient-mark-mode: t

Load-path shadows:
None found.

Features:
(help-mode pp shadow sort mail-extr emacsbug message rmc puny dired
dired-loaddefs rfc822 mml mml-sec epa derived epg rfc6068 epg-config
gnus-util rmail tool-bar rmail-loaddefs auth-source cl-seq eieio
eieio-core cl-macs eieio-loaddefs password-cache json map
text-property-search time-date subr-x seq mm-decode mm-bodies mm-encode
mail-parse rfc2231 mailabbrev gmm-utils mailheader cl-loaddefs cl-lib
sendmail rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils shell
pcomplete comint regexp-opt ansi-color ring term/xterm xterm byte-opt gv
bytecomp byte-compile cconv iso-transl tooltip eldoc paren electric
uniquify ediff-hook vc-hooks lisp-float-type elisp-mode tabulated-list
replace newcomment text-mode lisp-mode prog-mode register page tab-bar
menu-bar rfn-eshadow isearch easymenu timer select mouse jit-lock
font-lock syntax font-core term/tty-colors frame minibuffer cl-generic
cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao
korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech
european ethiopic indian cyrillic chinese composite emoji-zwj charscript
charprop case-table epa-hook jka-cmpr-hook help simple abbrev obarray
cl-preloaded nadvice button loaddefs faces cus-face macroexp files
window text-properties overlay sha1 md5 base64 format env code-pages
mule custom widget hashtable-print-readable backquote threads kqueue
multi-tty make-network-process emacs)

Memory information:
((conses 16 60451 7936)
 (symbols 48 7359 3)
 (strings 32 20473 1785)
 (string-bytes 1 674989)
 (vectors 16 12526)
 (vector-slots 8 145293 8573)
 (floats 8 29 293)
 (intervals 56 220 54)
 (buffers 992 12))




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#54776; Package emacs. (Fri, 08 Apr 2022 13:19:02 GMT) Full text and rfc822 format available.

Message #8 received at 54776 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: "Kevin K. Lin" <klin <at> math.arizona.edu>
Cc: 54776 <at> debbugs.gnu.org
Subject: Re: bug#54776: 28.1; shell-resync-dirs hangs
Date: Fri, 08 Apr 2022 15:18:50 +0200
"Kevin K. Lin" <klin <at> math.arizona.edu> writes:

> I found bug #54384 on the bug tracker, which seems to
> describe a similar problem in Emacs 29.  Wondering if
> it's indeed the same issue, and if so whether the
> solution would be backported to 28?

It's the same issue, and we're only backporting fixes for regressions or
serious bugs to Emacs 28, and I don't think this counts as either, so it
won't be backported.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




bug marked as fixed in version 29.1, send any further explanations to 54776 <at> debbugs.gnu.org and "Kevin K. Lin" <klin <at> math.arizona.edu> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Fri, 08 Apr 2022 13:20:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#54776; Package emacs. (Fri, 08 Apr 2022 15:25:01 GMT) Full text and rfc822 format available.

Message #13 received at 54776 <at> debbugs.gnu.org (full text, mbox):

From: Glenn Morris <rgm <at> gnu.org>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: "Kevin K. Lin" <klin <at> math.arizona.edu>, 54776 <at> debbugs.gnu.org
Subject: Re: bug#54776: 28.1; shell-resync-dirs hangs
Date: Fri, 08 Apr 2022 11:24:44 -0400
Lars Ingebrigtsen wrote:

> and we're only backporting fixes for regressions or serious bugs to
> Emacs 28, and I don't think this counts as either, so it won't be
> backported.

Are you sure this issue isn't due to the changes from
https://debbugs.gnu.org/23324, which were applied in Emacs 28.1 (which
would make it a regression from Emacs 27, no)?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#54776; Package emacs. (Sat, 09 Apr 2022 10:13:02 GMT) Full text and rfc822 format available.

Message #16 received at 54776 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Glenn Morris <rgm <at> gnu.org>
Cc: "Kevin K. Lin" <klin <at> math.arizona.edu>, 54776 <at> debbugs.gnu.org
Subject: Re: bug#54776: 28.1; shell-resync-dirs hangs
Date: Sat, 09 Apr 2022 12:11:50 +0200
[Message part 1 (text/plain, inline)]
Glenn Morris <rgm <at> gnu.org> writes:

> Are you sure this issue isn't due to the changes from
> https://debbugs.gnu.org/23324, which were applied in Emacs 28.1 (which
> would make it a regression from Emacs 27, no)?

Good catch.

Kevin, could you try reverting 90e65c826fa (or applying (in reverse) the
attached patch) and see whether that fixes the problem?  If so, we could
revert the patch for Emacs 28.2.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no
[resync.patch (text/x-diff, inline)]
commit 90e65c826fab2092ad2099d7763538194c93e021
Author:     Noah Friedman <friedman <at> splode.com>
AuthorDate: Wed Aug 19 15:59:59 2020 +0200
Commit:     Lars Ingebrigtsen <larsi <at> gnus.org>
CommitDate: Wed Aug 19 15:59:59 2020 +0200

    Make shell-resync-dirs handle whitespace in directory names
    
    * lisp/shell.el (shell-resync-dirs): Correctly handle
    whitespace in directory names (bug#23324).

diff --git a/lisp/shell.el b/lisp/shell.el
index 301a8cb083..9667dab2af 100644
--- a/lisp/shell.el
+++ b/lisp/shell.el
@@ -1035,25 +1035,41 @@ shell-resync-dirs
 	  (accept-process-output proc)
 	  (goto-char pt)))
       (goto-char pmark) (delete-char 1) ; remove the extra newline
-      ;; That's the dirlist. grab it & parse it.
-      (let* ((dl (buffer-substring (match-beginning 2) (1- (match-end 2))))
-	     (dl-len (length dl))
-	     (ds '())			; new dir stack
-	     (i 0))
-	(while (< i dl-len)
-	  ;; regexp = optional whitespace, (non-whitespace), optional whitespace
-	  (string-match "\\s *\\(\\S +\\)\\s *" dl i) ; pick off next dir
-	  (setq ds (cons (concat comint-file-name-prefix
-				 (substring dl (match-beginning 1)
-					    (match-end 1)))
-			 ds))
-	  (setq i (match-end 0)))
-	(let ((ds (nreverse ds)))
-	  (with-demoted-errors "Couldn't cd: %s"
-	    (shell-cd (car ds))
-	    (setq shell-dirstack (cdr ds)
-		  shell-last-dir (car shell-dirstack))
-	    (shell-dirstack-message)))))
+      ;; That's the dirlist.  Grab it & parse it.
+      (let* ((dls (buffer-substring-no-properties
+                   (match-beginning 0) (1- (match-end 0))))
+             (dlsl nil)
+             (pos 0)
+             (ds nil))
+        ;; Split the dirlist into whitespace and non-whitespace chunks.
+        ;; dlsl will be a reversed list of tokens.
+        (while (string-match "\\(\\S-+\\|\\s-+\\)" dls pos)
+          (push (match-string 1 dls) dlsl)
+          (setq pos (match-end 1)))
+
+        ;; Prepend trailing entries until they form an existing directory,
+        ;; whitespace and all.  Discard the next whitespace and repeat.
+        (while dlsl
+          (let ((newelt "")
+                tem1 tem2)
+            (while newelt
+              ;; We need tem1 because we don't want to prepend
+              ;; `comint-file-name-prefix' repeatedly into newelt via tem2.
+              (setq tem1 (pop dlsl)
+                    tem2 (concat comint-file-name-prefix tem1 newelt))
+              (cond ((file-directory-p tem2)
+                     (push tem2 ds)
+                     (when (string= " " (car dlsl))
+                       (pop dlsl))
+                     (setq newelt nil))
+                    (t
+                     (setq newelt (concat tem1 newelt)))))))
+
+        (with-demoted-errors "Couldn't cd: %s"
+          (shell-cd (car ds))
+          (setq shell-dirstack (cdr ds)
+                shell-last-dir (car shell-dirstack))
+          (shell-dirstack-message))))
     (if started-at-pmark (goto-char (marker-position pmark)))))
 
 ;; For your typing convenience:

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#54776; Package emacs. (Sat, 09 Apr 2022 16:31:02 GMT) Full text and rfc822 format available.

Message #19 received at 54776 <at> debbugs.gnu.org (full text, mbox):

From: "Kevin K. Lin" <klin <at> math.arizona.edu>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: Glenn Morris <rgm <at> gnu.org>, "Kevin K. Lin" <klin <at> math.arizona.edu>,
 54776 <at> debbugs.gnu.org
Subject: Re: bug#54776: 28.1; shell-resync-dirs hangs
Date: Sat, 09 Apr 2022 09:23:48 -0700
Hi Lars,

I just tried the patch, and it works fine on my end.
Thanks!

Kevin




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#54776; Package emacs. (Sun, 10 Apr 2022 11:51:01 GMT) Full text and rfc822 format available.

Message #22 received at 54776 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: "Kevin K. Lin" <klin <at> math.arizona.edu>
Cc: Glenn Morris <rgm <at> gnu.org>, 54776 <at> debbugs.gnu.org
Subject: Re: bug#54776: 28.1; shell-resync-dirs hangs
Date: Sun, 10 Apr 2022 13:50:02 +0200
"Kevin K. Lin" <klin <at> math.arizona.edu> writes:

> I just tried the patch, and it works fine on my end.

Thanks for testing; I've now reverted the offending change on the
emacs-28 branch, so it'll be included in the Emacs 28.2 release.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




bug marked as fixed in version 28.2, send any further explanations to 54776 <at> debbugs.gnu.org and "Kevin K. Lin" <klin <at> math.arizona.edu> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Sun, 10 Apr 2022 11:51:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Mon, 09 May 2022 11:24:09 GMT) Full text and rfc822 format available.

This bug report was last modified 3 years and 44 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.