aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/shell.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/shell.el')
-rw-r--r--lisp/shell.el20
1 files changed, 18 insertions, 2 deletions
diff --git a/lisp/shell.el b/lisp/shell.el
index de811543ba0..01d1a688f0e 100644
--- a/lisp/shell.el
+++ b/lisp/shell.el
@@ -383,6 +383,21 @@ to `dirtrack-mode'."
383 :group 'shell 383 :group 'shell
384 :type '(choice (const nil) regexp)) 384 :type '(choice (const nil) regexp))
385 385
386(defun shell-parse-pcomplete-arguments ()
387 "Parse whitespace separated arguments in the current region."
388 (let ((begin (save-excursion (shell-backward-command 1) (point)))
389 (end (point))
390 begins args)
391 (save-excursion
392 (goto-char begin)
393 (while (< (point) end)
394 (skip-chars-forward " \t\n")
395 (push (point) begins)
396 (looking-at "\\(?:[^\s\t\n\\]\\|'[^']*'\\|\"\\(?:[^\"\\]\\|\\\\.\\)*\"\\|\\\\.\\)*\\(?:\\\\\\|'[^']*\\|\"\\(?:[^\"\\]\\|\\\\.\\)*\\)?")
397 (goto-char (match-end 0))
398 (push (buffer-substring-no-properties (car begins) (point))
399 args))
400 (cons (nreverse args) (nreverse begins)))))
386 401
387(defun shell-completion-vars () 402(defun shell-completion-vars ()
388 "Setup completion vars for `shell-mode' and `read-shell-command'." 403 "Setup completion vars for `shell-mode' and `read-shell-command'."
@@ -396,8 +411,9 @@ to `dirtrack-mode'."
396 (set (make-local-variable 'comint-dynamic-complete-functions) 411 (set (make-local-variable 'comint-dynamic-complete-functions)
397 shell-dynamic-complete-functions) 412 shell-dynamic-complete-functions)
398 (set (make-local-variable 'pcomplete-parse-arguments-function) 413 (set (make-local-variable 'pcomplete-parse-arguments-function)
399 ;; FIXME: This function should be moved to shell.el. 414 #'shell-parse-pcomplete-arguments)
400 #'pcomplete-parse-comint-arguments) 415 (set (make-local-variable 'pcomplete-arg-quote-list)
416 (append "\\ \t\n\r\"'`$|&;(){}[]<>#" nil))
401 (set (make-local-variable 'pcomplete-termination-string) 417 (set (make-local-variable 'pcomplete-termination-string)
402 (cond ((not comint-completion-addsuffix) "") 418 (cond ((not comint-completion-addsuffix) "")
403 ((stringp comint-completion-addsuffix) 419 ((stringp comint-completion-addsuffix)