Revert "Make shell-resync-dirs handle whitespace in directory names"

This reverts commit 90e65c826f.

This change led to hangs (bug#54776).

Do not merge to master; it has been fixed in a more encompassing way there.
This commit is contained in:
Lars Ingebrigtsen 2022-04-10 13:48:46 +02:00
parent 84a2857722
commit b385fd0b88

View file

@ -1060,41 +1060,25 @@ command again."
(accept-process-output proc) (accept-process-output proc)
(goto-char pt))) (goto-char pt)))
(goto-char pmark) (delete-char 1) ; remove the extra newline (goto-char pmark) (delete-char 1) ; remove the extra newline
;; That's the dirlist. Grab it & parse it. ;; That's the dirlist. grab it & parse it.
(let* ((dls (buffer-substring-no-properties (let* ((dl (buffer-substring (match-beginning 2) (1- (match-end 2))))
(match-beginning 0) (1- (match-end 0)))) (dl-len (length dl))
(dlsl nil) (ds '()) ; new dir stack
(pos 0) (i 0))
(ds nil)) (while (< i dl-len)
;; Split the dirlist into whitespace and non-whitespace chunks. ;; regexp = optional whitespace, (non-whitespace), optional whitespace
;; dlsl will be a reversed list of tokens. (string-match "\\s *\\(\\S +\\)\\s *" dl i) ; pick off next dir
(while (string-match "\\(\\S-+\\|\\s-+\\)" dls pos) (setq ds (cons (concat comint-file-name-prefix
(push (match-string 1 dls) dlsl) (substring dl (match-beginning 1)
(setq pos (match-end 1))) (match-end 1)))
ds))
;; Prepend trailing entries until they form an existing directory, (setq i (match-end 0)))
;; whitespace and all. Discard the next whitespace and repeat. (let ((ds (nreverse ds)))
(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" (with-demoted-errors "Couldn't cd: %s"
(shell-cd (car ds)) (shell-cd (car ds))
(setq shell-dirstack (cdr ds) (setq shell-dirstack (cdr ds)
shell-last-dir (car shell-dirstack)) shell-last-dir (car shell-dirstack))
(shell-dirstack-message)))) (shell-dirstack-message)))))
(if started-at-pmark (goto-char (marker-position pmark))))) (if started-at-pmark (goto-char (marker-position pmark)))))
;; For your typing convenience: ;; For your typing convenience: