emacs-devel
[Top][All Lists]
Advanced

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

Using pcomplete for read-shell-command


From: Stefan Monnier
Subject: Using pcomplete for read-shell-command
Date: Tue, 24 Nov 2009 16:10:37 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (gnu/linux)

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)))




reply via email to

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