unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#10457: (Broken?) programmable completion in shell buffers
@ 2012-01-08 19:40 Oleksandr Manzyuk
  2012-01-08 20:07 ` bug#10457: Oleksandr Manzyuk
  2012-01-09  1:26 ` bug#10457: (Broken?) programmable completion in shell buffers Stefan Monnier
  0 siblings, 2 replies; 14+ messages in thread
From: Oleksandr Manzyuk @ 2012-01-08 19:40 UTC (permalink / raw)
  To: 10457

Dear all,

I've decided to give Emacs 24 a try, primarily because I've read that
in Emacs 24 completion in `shell-mode' is performed using `pcomplete',
which is effectively broken in 23.2 and which I have always wanted to
try out.  I am on Ubuntu, so I've chosen to install emacs-snapshot
package from emacs-snapshot PPA (ppa:cassou/emacs).  The version I'm
running is

GNU Emacs 24.0.92.1 (x86_64-pc-linux-gnu, GTK+ Version 2.20.1) of
2012-01-05 on papaya, modified by Debian

I started a shell and tried to play with completion for various shell
commands defined in pcmpl-{gnu,unix,linux}.el, and it feels...
frustrating.  Let me explain what I mean by that.  Note: everything
below refers to emacs-snapshot run with -Q flag.

First, I'm unable to complete options to commands.  Take, for example,
"ssh".  If I'm in my home directory, type "ssh -", and hit TAB, the
command line changes to "ssh .-", and when I hit TAB again, a
completions buffer pops up showing only the file and directory names
starting with a dot and containing a dash.  I assume that instead of
offering the options available for ssh, Emacs performs some sort of
"fuzzy" matching against file and directory names.  Is this the
intended behavior, and if so, how can I disable this fuzzy matching?
Note that I do get completions for host names if I type "ssh " and hit
TAB.  When I am in a directory that doesn't contain files with a dash
in the name, typing "ssh -" and hitting TAB produces only "No match"
message in the minibuffer.

Second, more disturbingly, trying to complete options to "tar" locks
Emacs.  Here is how to reproduce it:

emacs -Q
M-x shell
cd <some directory without dashes in file and directory names>
tar - TAB SPC

(the last line means type "tar -" and hit TAB followed by SPC).  On my
machine this reliably locks Emacs: it becomes completely unresponsive,
I cannot close its window and have to open a terminal and kill it.
While it is locked, the system monitor shows that Emacs is using
almost 100% CPU.  As far as I can tell, this doesn't happen with the
other commands (pressing TAB followed by SPC simply inserts a space
into the shell buffer).

Is it only me or is it a bug?  I've had high hopes for `pcomplete',
but I am put off by its weirdness.  Am I missing something?  Please
let me know if I can provide more information.  I would submit a bug
report from within Emacs if it did not hang up.

Thanks,
Sasha
-- 
Oleksandr Manzyuk
http://oleksandrmanzyuk.wordpress.com





^ permalink raw reply	[flat|nested] 14+ messages in thread

* bug#10457:
  2012-01-08 19:40 bug#10457: (Broken?) programmable completion in shell buffers Oleksandr Manzyuk
@ 2012-01-08 20:07 ` Oleksandr Manzyuk
  2012-01-09  1:26 ` bug#10457: (Broken?) programmable completion in shell buffers Stefan Monnier
  1 sibling, 0 replies; 14+ messages in thread
From: Oleksandr Manzyuk @ 2012-01-08 20:07 UTC (permalink / raw)
  To: 10457

I have just checked: the issues I've described happen only in shell,
not in eshell (in eshell everything seems to work as expected).

Sasha
-- 
Oleksandr Manzyuk
http://oleksandrmanzyuk.wordpress.com





^ permalink raw reply	[flat|nested] 14+ messages in thread

* bug#10457: (Broken?) programmable completion in shell buffers
  2012-01-08 19:40 bug#10457: (Broken?) programmable completion in shell buffers Oleksandr Manzyuk
  2012-01-08 20:07 ` bug#10457: Oleksandr Manzyuk
@ 2012-01-09  1:26 ` Stefan Monnier
  2012-01-09  5:56   ` Thierry Volpiatto
                     ` (2 more replies)
  1 sibling, 3 replies; 14+ messages in thread
From: Stefan Monnier @ 2012-01-09  1:26 UTC (permalink / raw)
  To: Oleksandr Manzyuk; +Cc: 10457

> First, I'm unable to complete options to commands.  Take, for example,
> "ssh".  If I'm in my home directory, type "ssh -", and hit TAB, the
> command line changes to "ssh .-", and when I hit TAB again, a
> completions buffer pops up showing only the file and directory names
> starting with a dot and containing a dash.  I assume that instead of
> offering the options available for ssh, Emacs performs some sort of
> "fuzzy" matching against file and directory names.

It's partial-completion at work: "a-b" matches "a*-b*" and "-" just
matches "*-*".  Apparently all your file names that contained "-"
started with ".", hence the ".-".

> Is this the intended behavior, and if so, how can I disable this
> fuzzy matching?

You can remove partial-completion from completion-styles.

> TAB.  When I am in a directory that doesn't contain files with a dash
> in the name, typing "ssh -" and hitting TAB produces only "No match"
> message in the minibuffer.

Indeed, pcomplete doesn't seem to provide any completion for ssh's "-"
options, currently, even though the code does do something for it:

(defun pcomplete/ssh ()
  "Completion rules for the `ssh' command."
  (pcomplete-opt "1246AaCfgKkMNnqsTtVvXxYbcDeFiLlmOopRSw")
  (pcomplete-here (pcmpl-ssh-hosts)))

I don't think completion of "-" is very useful for ssh since there's no
long options, and most ascii letters are valid options, but still it
seems we have a bug that prevents pcomplete-opt from doing its job.

> Second, more disturbingly, trying to complete options to "tar" locks Emacs.
> Here is how to reproduce it:

> emacs -Q
> M-x shell
> cd <some directory without dashes in file and directory names>
> tar - TAB SPC

I believe I've fixed this bug "recently".  If you can try the code in
the trunk to confirm that it's fixed, it would be wonderful.

> I've had high hopes for `pcomplete', but I am put off by its
> weirdness.

There's a lot more to it than "turning it on", so yes, it's been
a source of many bug reports.  Thank you for trying it out to help track
down the various problems.

> I have just checked: the issues I've described happen only in shell,
> not in eshell (in eshell everything seems to work as expected).

For ssh, eshell actually overwrites pcomplete/ssh with an alias for
pcomplete/rsh so it doesn't use the same code (I suspect that using
eshell and then doing M-x shell will similarly "work as expected").


        Stefan





^ permalink raw reply	[flat|nested] 14+ messages in thread

* bug#10457: (Broken?) programmable completion in shell buffers
  2012-01-09  1:26 ` bug#10457: (Broken?) programmable completion in shell buffers Stefan Monnier
@ 2012-01-09  5:56   ` Thierry Volpiatto
  2012-01-09 11:17     ` Thierry Volpiatto
       [not found]     ` <mailman.1502.1326107965.15002.bug-gnu-emacs@gnu.org>
  2012-01-09 15:41   ` Oleksandr Manzyuk
  2012-01-24 18:14   ` Glenn Morris
  2 siblings, 2 replies; 14+ messages in thread
From: Thierry Volpiatto @ 2012-01-09  5:56 UTC (permalink / raw)
  To: 10457

Stefan Monnier <monnier@IRO.UMontreal.CA> writes:

>> Second, more disturbingly, trying to complete options to "tar" locks Emacs.
>> Here is how to reproduce it:
>
>> emacs -Q
>> M-x shell
>> cd <some directory without dashes in file and directory names>
>> tar - TAB SPC
>
> I believe I've fixed this bug "recently".

It seem this is not fixed, i can reproduce the bug here.

-- 
  Thierry
Get my Gnupg key:
gpg --keyserver pgp.mit.edu --recv-keys 59F29997 






^ permalink raw reply	[flat|nested] 14+ messages in thread

* bug#10457: (Broken?) programmable completion in shell buffers
  2012-01-09  5:56   ` Thierry Volpiatto
@ 2012-01-09 11:17     ` Thierry Volpiatto
       [not found]     ` <mailman.1502.1326107965.15002.bug-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 14+ messages in thread
From: Thierry Volpiatto @ 2012-01-09 11:17 UTC (permalink / raw)
  To: 10457

[-- Attachment #1: Type: text/plain, Size: 566 bytes --]

Thierry Volpiatto <thierry.volpiatto@gmail.com> writes:

> Stefan Monnier <monnier@IRO.UMontreal.CA> writes:
>
>>> Second, more disturbingly, trying to complete options to "tar" locks Emacs.
>>> Here is how to reproduce it:
>>
>>> emacs -Q
>>> M-x shell
>>> cd <some directory without dashes in file and directory names>
>>> tar - TAB SPC
>>
>> I believe I've fixed this bug "recently".
>
> It seem this is not fixed, i can reproduce the bug here.

This seem to work as expected, not hanging at least, and completing
against long and short opts and then filenames.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Fix eshell/tar hanging forever --]
[-- Type: text/x-diff, Size: 10097 bytes --]

# HG changeset patch
# User Thierry Volpiatto <thierry.volpiatto@gmail.com>
# Date 1326107014 -3600
# Node ID 10a15a1251fd3e4ba77eb3e2b35a5bf4c4c50ed2
# Parent  2175cc538ceea5e0b7395e8be10c884b02386d1d
"New patch"

diff --git a/lisp/pcmpl-gnu.el b/lisp/pcmpl-gnu.el
--- a/lisp/pcmpl-gnu.el
+++ b/lisp/pcmpl-gnu.el
@@ -152,6 +152,20 @@
          (when (and (not ,exist) (buffer-live-p ,buf))
            (kill-buffer ,buf))))))
 
+
+(defun eshell-collect-tar-long-opts ()
+  (with-temp-buffer
+    (call-process "tar" nil (current-buffer) nil "--help")
+    (goto-char (point-min))
+    (loop with lo while
+          (re-search-forward "^\\( *-[a-zA-Z0-9], --[a-zA-Z0-9-]*=?\\)\
+\\|\\( *--[a-zA-Z0-9-]*=?\\)" nil t)
+          for opts = (split-string (match-string 0) ",")
+          append (loop for i in (if (> (length opts) 1) (cdr opts) opts)
+                       for op = (replace-regexp-in-string " " "" i)
+                       unless (member op lo)
+                       do (push op lo) and collect op))))
+
 ;;;###autoload
 (defun pcomplete/tar ()
   "Completion for the GNU tar utility."
@@ -160,89 +174,10 @@
     (let ((pcomplete-suffix-list (cons ?= pcomplete-suffix-list)))
       (while (pcomplete-match "^-" 0)
         (setq saw-option t)
-        (if (pcomplete-match "^--" 0)
-            (if (pcomplete-match "^--\\([^= \t\n\f]*\\)\\'" 0)
-                ;; FIXME: Extract this list from "tar --help".
-                (pcomplete-here*
-                 '("--absolute-names"
-                   "--after-date="
-                   "--append"
-                   "--atime-preserve"
-                   "--backup"
-                   "--block-number"
-                   "--blocking-factor="
-                   "--catenate"
-                   "--checkpoint"
-                   "--compare"
-                   "--compress"
-                   "--concatenate"
-                   "--confirmation"
-                   "--create"
-                   "--delete"
-                   "--dereference"
-                   "--diff"
-                   "--directory="
-                   "--exclude="
-                   "--exclude-from="
-                   "--extract"
-                   "--file="
-                   "--files-from="
-                   "--force-local"
-                   "--get"
-                   "--group="
-                   "--gzip"
-                   "--help"
-                   "--ignore-failed-read"
-                   "--ignore-zeros"
-                   "--incremental"
-                   "--info-script="
-                   "--interactive"
-                   "--keep-old-files"
-                   "--label="
-                   "--list"
-                   "--listed-incremental"
-                   "--mode="
-                   "--modification-time"
-                   "--multi-volume"
-                   "--new-volume-script="
-                   "--newer="
-                   "--newer-mtime"
-                   "--no-recursion"
-                   "--null"
-                   "--numeric-owner"
-                   "--old-archive"
-                   "--one-file-system"
-                   "--owner="
-                   "--portability"
-                   "--posix"
-                   "--preserve"
-                   "--preserve-order"
-                   "--preserve-permissions"
-                   "--read-full-records"
-                   "--record-size="
-                   "--recursive-unlink"
-                   "--remove-files"
-                   "--rsh-command="
-                   "--same-order"
-                   "--same-owner"
-                   "--same-permissions"
-                   "--sparse"
-                   "--starting-file="
-                   "--suffix="
-                   "--tape-length="
-                   "--to-stdout"
-                   "--totals"
-                   "--uncompress"
-                   "--ungzip"
-                   "--unlink-first"
-                   "--update"
-                   "--use-compress-program="
-                   "--verbose"
-                   "--verify"
-                   "--version"
-                   "--volno-file=")))
-          (pcomplete-opt "01234567ABCFGKLMNOPRSTUVWXZbcdfghiklmoprstuvwxz"))
         (cond
+         ((and (pcomplete-match "^--" 0)
+               (pcomplete-match "^--\\([^= \t\n\f]*\\)\\'" 0))
+          (pcomplete-here* (eshell-collect-tar-long-opts)))
          ((pcomplete-match "\\`--after-date=" 0)
           (pcomplete-here*))
          ((pcomplete-match "\\`--backup=" 0)
@@ -300,14 +235,16 @@
                            (pcomplete-match-string 1 0)))
          ((pcomplete-match "\\`--volno-file=\\(.*\\)" 0)
           (pcomplete-here* (pcomplete-entries)
-                           (pcomplete-match-string 1 0))))))
+                           (pcomplete-match-string 1 0)))
+         ((pcomplete-match "^-\\([^= \t\n\f]*\\)\\'" 0)
+          (pcomplete-opt "01234567ABCFGKLMNOPRSTUVWXZbcdfghiklmoprstuvwxz")))))
     (unless saw-option
       (pcomplete-here
        (mapcar 'char-to-string
 	       (string-to-list
 		"01234567ABCFGIKLMNOPRSTUVWXZbcdfghiklmoprstuvwxz")))
-      (if (pcomplete-match "[xt]" 'first 1)
-	  (setq complete-within t)))
+      (when (pcomplete-match "[xt]" 'first 1)
+        (setq complete-within t)))
     (pcomplete-here (pcomplete-dirs-or-entries pcmpl-gnu-tarfile-regexp))
     (while (pcomplete-here
 	    (if (and complete-within
@@ -320,10 +257,11 @@
                   (completion-table-dynamic
                    (lambda (_string)
                      (pcmpl-gnu-with-file-buffer file
-                       (mapcar #'tar-header-name tar-parse-info)))))
-	      (pcomplete-entries))
+                                                 (mapcar #'tar-header-name tar-parse-info)))))
+              (pcomplete-entries))
 	    nil 'identity))))
 
+
 ;;;###autoload
 (defalias 'pcomplete/gdb 'pcomplete/xargs)
 
diff --git a/lisp/pcomplete.el b/lisp/pcomplete.el
--- a/lisp/pcomplete.el
+++ b/lisp/pcomplete.el
@@ -981,54 +981,56 @@
 the argument appear after a ganged set of options.  This is how tar
 behaves, for example.
 Arguments NO-GANGING and ARGS-FOLLOW are currently ignored."
-  (if (and (= pcomplete-index pcomplete-last)
-	   (string= (pcomplete-arg) "-"))
-      (let ((len (length options))
-	    (index 0)
-	    char choices)
-	(while (< index len)
-	  (setq char (aref options index))
-	  (if (eq char ?\()
-	      (let ((result (read-from-string options index)))
-		(setq index (cdr result)))
-	    (unless (memq char '(?/ ?* ?? ?.))
-	      (push (char-to-string char) choices))
-	    (setq index (1+ index))))
-	(throw 'pcomplete-completions
-	       (mapcar
-		(function
-		 (lambda (opt)
-		   (concat "-" opt)))
-		(pcomplete-uniqify-list choices))))
-    (let ((arg (pcomplete-arg)))
-      (when (and (> (length arg) 1)
-		 (stringp arg)
-		 (eq (aref arg 0) (or prefix ?-)))
-	(pcomplete-next-arg)
-	(let ((char (aref arg 1))
-	      (len (length options))
-	      (index 0)
-	      opt-char arg-char result)
-	  (while (< (1+ index) len)
-	    (setq opt-char (aref options index)
-		  arg-char (aref options (1+ index)))
-	    (if (eq arg-char ?\()
-		(setq result
-		      (read-from-string options (1+ index))
-		      index (cdr result)
-		      result (car result))
-	      (setq result nil))
-	    (when (and (eq char opt-char)
-		       (memq arg-char '(?\( ?/ ?* ?? ?.)))
-	      (if (< pcomplete-index pcomplete-last)
-		  (pcomplete-next-arg)
-		(throw 'pcomplete-completions
-		       (cond ((eq arg-char ?/) (pcomplete-dirs))
-			     ((eq arg-char ?*) (pcomplete-executables))
-			     ((eq arg-char ??) nil)
-			     ((eq arg-char ?.) (pcomplete-entries))
-			     ((eq arg-char ?\() (eval result))))))
-	    (setq index (1+ index))))))))
+  (or
+   (if (and (= pcomplete-index pcomplete-last)
+            (string= (pcomplete-arg) "-"))
+       (let ((len (length options))
+             (index 0)
+             char choices)
+         (while (< index len)
+           (setq char (aref options index))
+           (if (eq char ?\()
+               (let ((result (read-from-string options index)))
+                 (setq index (cdr result)))
+             (unless (memq char '(?/ ?* ?? ?.))
+               (push (char-to-string char) choices))
+             (setq index (1+ index))))
+         (throw 'pcomplete-completions
+                (mapcar
+                 (function
+                  (lambda (opt)
+                    (concat "-" opt)))
+                 (pcomplete-uniqify-list choices))))
+     (let ((arg (pcomplete-arg)))
+       (when (and (> (length arg) 1)
+                  (stringp arg)
+                  (eq (aref arg 0) (or prefix ?-)))
+         (pcomplete-next-arg)
+         (let ((char (aref arg 1))
+               (len (length options))
+               (index 0)
+               opt-char arg-char result)
+           (while (< (1+ index) len)
+             (setq opt-char (aref options index)
+                   arg-char (aref options (1+ index)))
+             (if (eq arg-char ?\()
+                 (setq result
+                       (read-from-string options (1+ index))
+                       index (cdr result)
+                       result (car result))
+               (setq result nil))
+             (when (and (eq char opt-char)
+                        (memq arg-char '(?\( ?/ ?* ?? ?.)))
+               (if (< pcomplete-index pcomplete-last)
+                   (pcomplete-next-arg)
+                 (throw 'pcomplete-completions
+                        (cond ((eq arg-char ?/) (pcomplete-dirs))
+                              ((eq arg-char ?*) (pcomplete-executables))
+                              ((eq arg-char ??) nil)
+                              ((eq arg-char ?.) (pcomplete-entries))
+                              ((eq arg-char ?\() (eval result))))))
+             (setq index (1+ index)))))))
+   (throw 'pcomplete-completions nil)))
 
 (defun pcomplete--here (&optional form stub paring form-only)
   "Complete against the current argument, if at the end.

[-- Attachment #3: Type: text/plain, Size: 83 bytes --]


-- 
  Thierry
Get my Gnupg key:
gpg --keyserver pgp.mit.edu --recv-keys 59F29997 

^ permalink raw reply	[flat|nested] 14+ messages in thread

* bug#10457: (Broken?) programmable completion in shell buffers
  2012-01-09  1:26 ` bug#10457: (Broken?) programmable completion in shell buffers Stefan Monnier
  2012-01-09  5:56   ` Thierry Volpiatto
@ 2012-01-09 15:41   ` Oleksandr Manzyuk
  2012-01-09 17:41     ` Oleksandr Manzyuk
  2012-01-24 18:14   ` Glenn Morris
  2 siblings, 1 reply; 14+ messages in thread
From: Oleksandr Manzyuk @ 2012-01-09 15:41 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 10457

On Mon, Jan 9, 2012 at 1:26 AM, Stefan Monnier <monnier@iro.umontreal.ca> wrote:
>> First, I'm unable to complete options to commands.  Take, for example,
>> "ssh".  If I'm in my home directory, type "ssh -", and hit TAB, the
>> command line changes to "ssh .-", and when I hit TAB again, a
>> completions buffer pops up showing only the file and directory names
>> starting with a dot and containing a dash.  I assume that instead of
>> offering the options available for ssh, Emacs performs some sort of
>> "fuzzy" matching against file and directory names.
>
> It's partial-completion at work: "a-b" matches "a*-b*" and "-" just
> matches "*-*".  Apparently all your file names that contained "-"
> started with ".", hence the ".-".
>
>> Is this the intended behavior, and if so, how can I disable this
>> fuzzy matching?
>
> You can remove partial-completion from completion-styles.

Thanks for the explanation.  I'll keep it for a while, maybe I like it.

>> TAB.  When I am in a directory that doesn't contain files with a dash
>> in the name, typing "ssh -" and hitting TAB produces only "No match"
>> message in the minibuffer.
>
> Indeed, pcomplete doesn't seem to provide any completion for ssh's "-"
> options, currently, even though the code does do something for it:
>
> (defun pcomplete/ssh ()
>  "Completion rules for the `ssh' command."
>  (pcomplete-opt "1246AaCfgKkMNnqsTtVvXxYbcDeFiLlmOopRSw")
>  (pcomplete-here (pcmpl-ssh-hosts)))
>
> I don't think completion of "-" is very useful for ssh since there's no
> long options, and most ascii letters are valid options, but still it
> seems we have a bug that prevents pcomplete-opt from doing its job.

I have just finished building Emacs from the savannah repo, and this
problem seems to be gone.  Now when I type "ssh -" and hit TAB, a
completions buffer showing a list of one-letter options pops up.  BTW,
even though I have file names containing dashes, I no longer observe
the behavior I described in my previous email: it seems that
completion of options correctly takes preference over
`partial-completion'.  Ssh was only an example -- I couldn't get
completions for any command with options.  In particular, tar admits
long options, which I was unable to access via completion.  Now it
works fine with tar too: typing "tar -" and hitting TAB shows a
completions buffer with one-letter options, typing "tar --" and
hitting TAB pops up a completions buffer with long options.

HOWEVER, curiously, the issue with Emacs being locked as a result of
typing "tar -" and hitting TAB followed by SPC in a shell buffer is
still present.  Typing "tar --" and hitting TAB pops up a completions
buffer, and hitting SPC flushes it, as it should.  I am mystified.
Can anybody else confirm this issue?

Sasha

-- 
Oleksandr Manzyuk
http://oleksandrmanzyuk.wordpress.com





^ permalink raw reply	[flat|nested] 14+ messages in thread

* bug#10457: (Broken?) programmable completion in shell buffers
  2012-01-09 15:41   ` Oleksandr Manzyuk
@ 2012-01-09 17:41     ` Oleksandr Manzyuk
  2012-01-09 20:20       ` Oleksandr Manzyuk
  0 siblings, 1 reply; 14+ messages in thread
From: Oleksandr Manzyuk @ 2012-01-09 17:41 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 10457

In `pcomplete/tar', the call to `pcomplete-opt' happens inside a
(while (pcomplete-match "^-" 0) ...) loop.  Here is a minimal example
that has the same problem as `pcomplete/tar':

(defun pcomplete/shell-mode/foo ()
  (while (pcomplete-match "^-" 0)
    (pcomplete-opt "hv")))

Start emacs with -Q flag, evaluate the above code in the *scratch*
buffer, start a shell, type "foo -", hit TAB.  A completions buffer
showing two completions "-h" and "-v" should pop up.  Press SPC --
voila, Emacs is locked.

Sasha

-- 
Oleksandr Manzyuk
http://oleksandrmanzyuk.wordpress.com





^ permalink raw reply	[flat|nested] 14+ messages in thread

* bug#10457: (Broken?) programmable completion in shell buffers
  2012-01-09 17:41     ` Oleksandr Manzyuk
@ 2012-01-09 20:20       ` Oleksandr Manzyuk
  2012-01-24 18:12         ` Glenn Morris
  0 siblings, 1 reply; 14+ messages in thread
From: Oleksandr Manzyuk @ 2012-01-09 20:20 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 10457

[-- Attachment #1: Type: text/plain, Size: 873 bytes --]

I don't yet fully understand what is going on here, but I think I have
a fix (arguably, not very attractive) for the lockup problem: if I
replace the line

(pcomplete-opt "01234567ABCFGKLMNOPRSTUVWXZbcdfghiklmoprstuvwxz")

in the code for `pcomplete/tar' in pcmpl-gnu.el with

(pcomplete-here*
 (mapcar
  (lambda (char)
    (concat "-" (char-to-string char)))
  (string-to-list
   "01234567ABCFGKLMNOPRSTUVWXZbcdfghiklmoprstuvwxz")))

then I finally get the behavior I am after: typing "tar -" and
pressing TAB pops up a completions buffer with short options, and if I
press SPC now, the completions buffer is popped down (ditto for "tar
--").

The two versions seem to be equivalent modulo bookkeeping, except that
`pcomplete-here*' runs `pcomplete-try-first-hook'.  Why are they
operationally different?

Sasha
-- 
Oleksandr Manzyuk
http://oleksandrmanzyuk.wordpress.com

[-- Attachment #2: 10457.patch --]
[-- Type: text/x-patch, Size: 649 bytes --]

diff --git a/lisp/pcmpl-gnu.el b/lisp/pcmpl-gnu.el
index 6ce51d1..8ac86ac 100644
--- a/lisp/pcmpl-gnu.el
+++ b/lisp/pcmpl-gnu.el
@@ -241,7 +241,12 @@
                    "--verify"
                    "--version"
                    "--volno-file=")))
-          (pcomplete-opt "01234567ABCFGKLMNOPRSTUVWXZbcdfghiklmoprstuvwxz"))
+          (pcomplete-here*
+           (mapcar
+            (lambda (char)
+              (concat "-" (char-to-string char)))
+            (string-to-list
+             "01234567ABCFGKLMNOPRSTUVWXZbcdfghiklmoprstuvwxz"))))
         (cond
          ((pcomplete-match "\\`--after-date=" 0)
           (pcomplete-here*))

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: bug#10457: (Broken?) programmable completion in shell buffers
       [not found]     ` <mailman.1502.1326107965.15002.bug-gnu-emacs@gnu.org>
@ 2012-01-10 23:27       ` manzyuk
  0 siblings, 0 replies; 14+ messages in thread
From: manzyuk @ 2012-01-10 23:27 UTC (permalink / raw)
  To: bug-gnu-emacs

On Jan 9, 11:17 am, Thierry Volpiatto <thierry.volpia...@gmail.com>
wrote:
> Thierry Volpiatto <thierry.volpia...@gmail.com> writes:
> > Stefan Monnier <monn...@IRO.UMontreal.CA> writes:
>
> >>> Second, more disturbingly, trying to complete options to "tar" locks Emacs.
> >>> Here is how to reproduce it:
>
> >>> emacs -Q
> >>> M-x shell
> >>> cd <some directory without dashes in file and directory names>
> >>> tar - TAB SPC
>
> >> I believe I've fixed this bug "recently".
>
> > It seem this is not fixed, i can reproduce the bug here.
>
> This seem to work as expected, not hanging at least, and completing
> against long and short opts and then filenames.

I apologize, I didn't realize there was somebody else involved in the
discussion (I didn't receive any updates about postings here).

Has this patch been merged in?

Sasha


^ permalink raw reply	[flat|nested] 14+ messages in thread

* bug#10457: (Broken?) programmable completion in shell buffers
  2012-01-09 20:20       ` Oleksandr Manzyuk
@ 2012-01-24 18:12         ` Glenn Morris
  0 siblings, 0 replies; 14+ messages in thread
From: Glenn Morris @ 2012-01-24 18:12 UTC (permalink / raw)
  To: Oleksandr Manzyuk; +Cc: 10457


I installed a simple-minded solution that works for me.
Anyone should feel free to replace it with something better.

*** lisp/pcmpl-gnu.el	2012-01-19 07:21:25 +0000
--- lisp/pcmpl-gnu.el	2012-01-24 18:06:37 +0000
***************
*** 243,248 ****
--- 243,250 ----
                     "--volno-file=")))
            (pcomplete-opt "01234567ABCFGKLMNOPRSTUVWXZbcdfghiklmoprstuvwxz"))
          (cond
+          ((pcomplete-match "\\`-\\'" 0)
+           (pcomplete-here*))
           ((pcomplete-match "\\`--after-date=" 0)
            (pcomplete-here*))
           ((pcomplete-match "\\`--backup=" 0)






^ permalink raw reply	[flat|nested] 14+ messages in thread

* bug#10457: (Broken?) programmable completion in shell buffers
  2012-01-09  1:26 ` bug#10457: (Broken?) programmable completion in shell buffers Stefan Monnier
  2012-01-09  5:56   ` Thierry Volpiatto
  2012-01-09 15:41   ` Oleksandr Manzyuk
@ 2012-01-24 18:14   ` Glenn Morris
  2012-01-24 18:28     ` Oleksandr Manzyuk
  2 siblings, 1 reply; 14+ messages in thread
From: Glenn Morris @ 2012-01-24 18:14 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: Oleksandr Manzyuk, 10457


>> When I am in a directory that doesn't contain files with a dash
>> in the name, typing "ssh -" and hitting TAB produces only "No match"
>> message in the minibuffer.

I can't reproduce this. I get the expected completions buffer.





^ permalink raw reply	[flat|nested] 14+ messages in thread

* bug#10457: (Broken?) programmable completion in shell buffers
  2012-01-24 18:14   ` Glenn Morris
@ 2012-01-24 18:28     ` Oleksandr Manzyuk
  2012-01-24 21:39       ` Glenn Morris
  0 siblings, 1 reply; 14+ messages in thread
From: Oleksandr Manzyuk @ 2012-01-24 18:28 UTC (permalink / raw)
  To: Glenn Morris; +Cc: 10457

On Tue, Jan 24, 2012 at 6:14 PM, Glenn Morris <rgm@gnu.org> wrote:
>
>>> When I am in a directory that doesn't contain files with a dash
>>> in the name, typing "ssh -" and hitting TAB produces only "No match"
>>> message in the minibuffer.
>
> I can't reproduce this. I get the expected completions buffer.

Meanwhile I purged the emacs-snapshot Ubuntu package and built Emacs
24.0.92 from sources, and I can confirm that this problem is gone.
The lockup issue is still there, but I have temporarily fixed it as
follows, following Thierry's idea:

(defadvice pcomplete-opt (around ensure-completions-pcomplete-opt)
  "Temporary fix of bug#10457."
  (or ad-do-it
      (throw 'pcomplete-completions nil)))

(ad-activate 'pcomplete-opt)

-- 
Oleksandr Manzyuk
http://oleksandrmanzyuk.wordpress.com





^ permalink raw reply	[flat|nested] 14+ messages in thread

* bug#10457: (Broken?) programmable completion in shell buffers
  2012-01-24 18:28     ` Oleksandr Manzyuk
@ 2012-01-24 21:39       ` Glenn Morris
  2012-01-24 22:29         ` Oleksandr Manzyuk
  0 siblings, 1 reply; 14+ messages in thread
From: Glenn Morris @ 2012-01-24 21:39 UTC (permalink / raw)
  To: Oleksandr Manzyuk; +Cc: 10457

Oleksandr Manzyuk wrote:

> The lockup issue is still there

With today's version? Because I cannot reproduce that either, now.





^ permalink raw reply	[flat|nested] 14+ messages in thread

* bug#10457: (Broken?) programmable completion in shell buffers
  2012-01-24 21:39       ` Glenn Morris
@ 2012-01-24 22:29         ` Oleksandr Manzyuk
  0 siblings, 0 replies; 14+ messages in thread
From: Oleksandr Manzyuk @ 2012-01-24 22:29 UTC (permalink / raw)
  To: Glenn Morris

On Tue, Jan 24, 2012 at 9:39 PM, Glenn Morris <rgm@gnu.org> wrote:
> Oleksandr Manzyuk wrote:
>
>> The lockup issue is still there
>
> With today's version? Because I cannot reproduce that either, now.

No, I've been running the version tagged as EMACS_PRETEST_24_0_92.
I've tried the version from git, and the issue seems to be resolved
now.  Thank you very much!

Best,
Sasha
-- 
Oleksandr Manzyuk
http://oleksandrmanzyuk.wordpress.com





^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2012-01-24 22:29 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-08 19:40 bug#10457: (Broken?) programmable completion in shell buffers Oleksandr Manzyuk
2012-01-08 20:07 ` bug#10457: Oleksandr Manzyuk
2012-01-09  1:26 ` bug#10457: (Broken?) programmable completion in shell buffers Stefan Monnier
2012-01-09  5:56   ` Thierry Volpiatto
2012-01-09 11:17     ` Thierry Volpiatto
     [not found]     ` <mailman.1502.1326107965.15002.bug-gnu-emacs@gnu.org>
2012-01-10 23:27       ` manzyuk
2012-01-09 15:41   ` Oleksandr Manzyuk
2012-01-09 17:41     ` Oleksandr Manzyuk
2012-01-09 20:20       ` Oleksandr Manzyuk
2012-01-24 18:12         ` Glenn Morris
2012-01-24 18:14   ` Glenn Morris
2012-01-24 18:28     ` Oleksandr Manzyuk
2012-01-24 21:39       ` Glenn Morris
2012-01-24 22:29         ` Oleksandr Manzyuk

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).