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

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

bug#9160: 24.0.50; Emacs freezes in *shell* buffer.


From: Stefan Monnier
Subject: bug#9160: 24.0.50; Emacs freezes in *shell* buffer.
Date: Tue, 23 Aug 2011 00:49:35 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)

> The latest trunk Emacs freezes in *shell* buffer in the
> following scenario.

> % emacs -Q
> M-x shell RET
> .. in *shell* buffer
> % mkdir tmp  (or if you already have tmp dir, % rm -rf tmp; mkdir tmp)
> % cd tmp
> % touch '0 a' '0-a'
> % ls 0<TAB>
> .. here <TAB> is a single tab and *Completions* buffer is
>    shown with this contents ...
> ------------------------------------------------------------
> Click <mouse-2> on ...
> In this buffer, ...

`ls 0\ TAB' hangs as well, but with the advantage that it can be stopped
with C-g, making it easier to debug.

I've installed the patch below which should fix the immediate problem as
well as improve completion behavior when you use "&&", pipes, or ";".


        Stefan


=== modified file 'lisp/pcomplete.el'
--- lisp/pcomplete.el   2011-06-17 18:52:46 +0000
+++ lisp/pcomplete.el   2011-08-23 04:44:56 +0000
@@ -811,15 +811,19 @@
       (while (< (point) end)
        (skip-chars-forward " \t\n")
        (push (point) begins)
-       (let ((skip t))
-         (while skip
-           (skip-chars-forward "^ \t\n")
-           (if (eq (char-before) ?\\)
-               (skip-chars-forward " \t\n")
-             (setq skip nil))))
+        (while
+            (progn
+              (skip-chars-forward "^ \t\n\\")
+              (when (eq (char-after) ?\\)
+                (forward-char 1)
+                (unless (eolp)
+                  (forward-char 1)
+                  t))))
        (push (buffer-substring-no-properties (car begins) (point))
               args))
       (cons (nreverse args) (nreverse begins)))))
+(make-obsolete 'pcomplete-parse-comint-arguments
+               'comint-parse-pcomplete-arguments "24.1")
 
 (defun pcomplete-parse-arguments (&optional expand-p)
   "Parse the command line arguments.  Most completions need this info."

=== modified file 'lisp/shell.el'
--- lisp/shell.el       2011-06-17 18:52:46 +0000
+++ lisp/shell.el       2011-08-23 04:46:07 +0000
@@ -383,6 +383,21 @@
   :group 'shell
   :type '(choice (const nil) regexp))
 
+(defun shell-parse-pcomplete-arguments ()
+  "Parse whitespace separated arguments in the current region."
+  (let ((begin (save-excursion (shell-backward-command 1) (point)))
+       (end (point))
+       begins args)
+    (save-excursion
+      (goto-char begin)
+      (while (< (point) end)
+       (skip-chars-forward " \t\n")
+       (push (point) begins)
+        (looking-at 
"\\(?:[^\s\t\n\\]\\|'[^']*'\\|\"\\(?:[^\"\\]\\|\\\\.\\)*\"\\|\\\\.\\)*\\(?:\\\\\\|'[^']*\\|\"\\(?:[^\"\\]\\|\\\\.\\)*\\)?")
+        (goto-char (match-end 0))
+       (push (buffer-substring-no-properties (car begins) (point))
+              args))
+      (cons (nreverse args) (nreverse begins)))))
 
 (defun shell-completion-vars ()
   "Setup completion vars for `shell-mode' and `read-shell-command'."
@@ -396,8 +411,7 @@
   (set (make-local-variable 'comint-dynamic-complete-functions)
        shell-dynamic-complete-functions)
   (set (make-local-variable 'pcomplete-parse-arguments-function)
-       ;; FIXME: This function should be moved to shell.el.
-       #'pcomplete-parse-comint-arguments)
+       #'shell-parse-pcomplete-arguments)
   (set (make-local-variable 'pcomplete-termination-string)
        (cond ((not comint-completion-addsuffix) "")
              ((stringp comint-completion-addsuffix)






reply via email to

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