all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Using pcomplete for read-shell-command
@ 2009-11-24 21:10 Stefan Monnier
  2009-11-25 17:31 ` Juri Linkov
  0 siblings, 1 reply; 3+ messages in thread
From: Stefan Monnier @ 2009-11-24 21:10 UTC (permalink / raw)
  To: emacs-devel

I don't use shell-mode much, but I enter shell commands occasionally and
find the completion behavior to be a bit poor sometimes.
Pcomplete is a bit more clever, since it knows about the arguments of
various commands.  I've been using the patch below for that reason.

Using pcomplete there was proposed a long time ago and was rejected
because the behavior was too different from our normal completion, but
the patch below uses the new pcomplete-std-complete which uses
pcomplete's infrastructure but with the normal UI on top of it.

As mentioned, I only enter commands occasionally, so it hasn't been
tested extensively.  The only problem I already know with it is that it
doesn't do partial-completion of file names (tho I have a patch for it
in pcomplete.el, but it's a bit risky, so I'd rather leave it for
later).


        Stefan


Using submit branch file:///home/monnier/src/emacs/bzr/trunk/
=== modified file 'lisp/simple.el'
--- lisp/simple.el	2009-11-20 03:58:42 +0000
+++ lisp/simple.el	2009-11-24 20:50:45 +0000
@@ -2038,11 +2093,18 @@
 (defun minibuffer-complete-shell-command ()
   "Dynamically complete shell command at point."
   (interactive)
+  ;; Do a mini shell-mode setup.
   (require 'shell)
-  (let ((comint-delimiter-argument-list shell-delimiter-argument-list)
-	(comint-file-name-chars shell-file-name-chars)
-	(comint-file-name-quote-list shell-file-name-quote-list))
-    (run-hook-with-args-until-success 'shell-dynamic-complete-functions)))
+  (set (make-local-variable 'comint-delimiter-argument-list)
+       shell-delimiter-argument-list)
+  (set (make-local-variable 'comint-file-name-chars) shell-file-name-chars)
+  (set (make-local-variable 'comint-file-name-quote-list)
+       shell-file-name-quote-list)
+  (set (make-local-variable 'comint-dynamic-complete-functions)
+       shell-dynamic-complete-functions)
+  (pcomplete-shell-setup)
+  ;; Perform the actual completion.
+  (pcomplete-std-complete))
 
 (defvar minibuffer-local-shell-command-map
   (let ((map (make-sparse-keymap)))




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

* Re: Using pcomplete for read-shell-command
  2009-11-24 21:10 Using pcomplete for read-shell-command Stefan Monnier
@ 2009-11-25 17:31 ` Juri Linkov
  2009-11-25 17:52   ` Stefan Monnier
  0 siblings, 1 reply; 3+ messages in thread
From: Juri Linkov @ 2009-11-25 17:31 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

> I don't use shell-mode much, but I enter shell commands occasionally and
> find the completion behavior to be a bit poor sometimes.
> Pcomplete is a bit more clever, since it knows about the arguments of
> various commands.  I've been using the patch below for that reason.
>
> Using pcomplete there was proposed a long time ago and was rejected
> because the behavior was too different from our normal completion, but
> the patch below uses the new pcomplete-std-complete which uses
> pcomplete's infrastructure but with the normal UI on top of it.
>
> As mentioned, I only enter commands occasionally, so it hasn't been
> tested extensively.  The only problem I already know with it is that it
> doesn't do partial-completion of file names (tho I have a patch for it
> in pcomplete.el, but it's a bit risky, so I'd rather leave it for
> later).

I tried, and it doesn't complete command names at the beginning of
the command line.  For instance, without your patch `M-! ca TAB'
displayed a list of command names.  But with your patch it displays
a list of files in the current directory.

BTW, I now noticed that switch-to-completions is not bound to
M-v/<prior> in minibuffer-local-shell-command-map.  Maybe
minibuffer-local-shell-command-map should inherit from
minibuffer-local-completion-map where M-v/<prior> are bound?

-- 
Juri Linkov
http://www.jurta.org/emacs/




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

* Re: Using pcomplete for read-shell-command
  2009-11-25 17:31 ` Juri Linkov
@ 2009-11-25 17:52   ` Stefan Monnier
  0 siblings, 0 replies; 3+ messages in thread
From: Stefan Monnier @ 2009-11-25 17:52 UTC (permalink / raw)
  To: Juri Linkov; +Cc: emacs-devel

> I tried, and it doesn't complete command names at the beginning of
> the command line.  For instance, without your patch `M-! ca TAB'
> displayed a list of command names.  But with your patch it displays
> a list of files in the current directory.

Good point.  Shouldn't be hard to fix.

> BTW, I now noticed that switch-to-completions is not bound to
> M-v/<prior> in minibuffer-local-shell-command-map.  Maybe
> minibuffer-local-shell-command-map should inherit from
> minibuffer-local-completion-map where M-v/<prior> are bound?

I'd say "yes" at first, but minibuffer-local-completion-map also binds
all kinds of other keys (such as ? or SPC) to commands which don't work
correctly in that minibuffer.  We probably want to make such commands
work there (or provide alternatives that do), but that's for later.


        Stefan




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

end of thread, other threads:[~2009-11-25 17:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-11-24 21:10 Using pcomplete for read-shell-command Stefan Monnier
2009-11-25 17:31 ` Juri Linkov
2009-11-25 17:52   ` Stefan Monnier

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.