aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman2003-12-29 19:10:24 +0000
committerRichard M. Stallman2003-12-29 19:10:24 +0000
commit55e9b10d6959a34f537caab0e76079f1c6badd32 (patch)
tree5412fb7c3426f1ba1af023a201a6bfbc7dcbe7e9
parentd09596261d476518b62c603e40b198dbaed71d6f (diff)
downloademacs-55e9b10d6959a34f537caab0e76079f1c6badd32.tar.gz
emacs-55e9b10d6959a34f537caab0e76079f1c6badd32.zip
(comint-arguments): Set COUNT after ARGS is complete.
(comint-dynamic-complete-as-filename): Rename local vars. (comint-dynamic-list-filename-completions): Likewise. (comint-dynamic-list-completions-config): New var. (comint-dynamic-list-completions): Handle both SPC and TAB right. (comint-file-name-chars): Add []. (comint-word): Use skip-chars-backward, not search.
-rw-r--r--lisp/comint.el111
1 files changed, 61 insertions, 50 deletions
diff --git a/lisp/comint.el b/lisp/comint.el
index bc9d2b017cb..6bc40a01bd3 100644
--- a/lisp/comint.el
+++ b/lisp/comint.el
@@ -1344,16 +1344,16 @@ Argument 0 is the command name."
1344 ;; Put the previous arg, if there was one, onto ARGS. 1344 ;; Put the previous arg, if there was one, onto ARGS.
1345 (setq str (substring string beg pos) 1345 (setq str (substring string beg pos)
1346 args (if quotes (cons str args) 1346 args (if quotes (cons str args)
1347 (nconc (comint-delim-arg str) args)) 1347 (nconc (comint-delim-arg str) args))))
1348 count (1+ count))) 1348 (setq count (length args))
1349 (setq quotes (match-beginning 1)) 1349 (setq quotes (match-beginning 1))
1350 (setq beg (match-beginning 0)) 1350 (setq beg (match-beginning 0))
1351 (setq pos (match-end 0)))) 1351 (setq pos (match-end 0))))
1352 (if beg 1352 (if beg
1353 (setq str (substring string beg pos) 1353 (setq str (substring string beg pos)
1354 args (if quotes (cons str args) 1354 args (if quotes (cons str args)
1355 (nconc (comint-delim-arg str) args)) 1355 (nconc (comint-delim-arg str) args))))
1356 count (1+ count))) 1356 (setq count (length args))
1357 (let ((n (or nth (1- count))) 1357 (let ((n (or nth (1- count)))
1358 (m (if mth (1- (- count mth)) 0))) 1358 (m (if mth (1- (- count mth)) 0)))
1359 (mapconcat 1359 (mapconcat
@@ -2082,7 +2082,7 @@ between the process-mark and point."
2082 (comint-skip-input) 2082 (comint-skip-input)
2083 (interrupt-process nil comint-ptyp) 2083 (interrupt-process nil comint-ptyp)
2084;; (process-send-string nil "\n") 2084;; (process-send-string nil "\n")
2085 ) 2085)
2086 2086
2087(defun comint-kill-subjob () 2087(defun comint-kill-subjob ()
2088 "Send kill signal to the current subjob. 2088 "Send kill signal to the current subjob.
@@ -2551,7 +2551,7 @@ directory tracking functions.")
2551(defvar comint-file-name-chars 2551(defvar comint-file-name-chars
2552 (if (memq system-type '(ms-dos windows-nt cygwin)) 2552 (if (memq system-type '(ms-dos windows-nt cygwin))
2553 "~/A-Za-z0-9_^$!#%&{}@`'.,:()-" 2553 "~/A-Za-z0-9_^$!#%&{}@`'.,:()-"
2554 "~/A-Za-z0-9+@:_.$#%,={}-") 2554 "[]~/A-Za-z0-9+@:_.$#%,={}-")
2555 "String of characters valid in a file name. 2555 "String of characters valid in a file name.
2556Note that all non-ASCII characters are considered valid in a file name 2556Note that all non-ASCII characters are considered valid in a file name
2557regardless of what this variable says. 2557regardless of what this variable says.
@@ -2577,15 +2577,19 @@ Word constituents are considered to be those in WORD-CHARS, which is like the
2577inside of a \"[...]\" (see `skip-chars-forward'), 2577inside of a \"[...]\" (see `skip-chars-forward'),
2578plus all non-ASCII characters." 2578plus all non-ASCII characters."
2579 (save-excursion 2579 (save-excursion
2580 (let ((non-word-chars (concat "[^\\\\" word-chars "]")) (here (point))) 2580 (let ((here (point))
2581 (while (and (re-search-backward non-word-chars nil 'move) 2581 giveup)
2582 ;;(memq (char-after (point)) shell-file-name-quote-list) 2582 (while (not giveup)
2583 (or (>= (following-char) 128) 2583 (let ((startpoint (point)))
2584 (eq (preceding-char) ?\\))) 2584 (skip-chars-backward (concat "\\\\" word-chars))
2585 (backward-char 1)) 2585 (if (and (> (- (point) 2) (point-min))
2586 ;; Don't go forward over a word-char (this can happen if we're at bob). 2586 (= (char-after (- (point) 2)) ?\\))
2587 (when (or (not (bobp)) (looking-at non-word-chars)) 2587 (forward-char -2))
2588 (forward-char 1)) 2588 (if (and (> (- (point) 1) (point-min))
2589 (>= (char-after (- (point) 1)) 128))
2590 (forward-char -1))
2591 (if (= (point) startpoint)
2592 (setq giveup t))))
2589 ;; Set match-data to match the entire string. 2593 ;; Set match-data to match the entire string.
2590 (when (< (point) here) 2594 (when (< (point) here)
2591 (set-match-data (list (point) here)) 2595 (set-match-data (list (point) here))
@@ -2697,10 +2701,10 @@ See `comint-dynamic-complete-filename'. Returns t if successful."
2697 (t 2701 (t
2698 (cdr comint-completion-addsuffix)))) 2702 (cdr comint-completion-addsuffix))))
2699 (filename (or (comint-match-partial-filename) "")) 2703 (filename (or (comint-match-partial-filename) ""))
2700 (pathdir (file-name-directory filename)) 2704 (filedir (file-name-directory filename))
2701 (pathnondir (file-name-nondirectory filename)) 2705 (filenondir (file-name-nondirectory filename))
2702 (directory (if pathdir (comint-directory pathdir) default-directory)) 2706 (directory (if filedir (comint-directory filedir) default-directory))
2703 (completion (file-name-completion pathnondir directory))) 2707 (completion (file-name-completion filenondir directory)))
2704 (cond ((null completion) 2708 (cond ((null completion)
2705 (message "No completions of %s" filename) 2709 (message "No completions of %s" filename)
2706 (setq success nil)) 2710 (setq success nil))
@@ -2714,21 +2718,21 @@ See `comint-dynamic-complete-filename'. Returns t if successful."
2714 (let ((file (concat (file-name-as-directory directory) completion))) 2718 (let ((file (concat (file-name-as-directory directory) completion)))
2715 (insert (comint-quote-filename 2719 (insert (comint-quote-filename
2716 (substring (directory-file-name completion) 2720 (substring (directory-file-name completion)
2717 (length pathnondir)))) 2721 (length filenondir))))
2718 (cond ((symbolp (file-name-completion completion directory)) 2722 (cond ((symbolp (file-name-completion completion directory))
2719 ;; We inserted a unique completion. 2723 ;; We inserted a unique completion.
2720 (insert (if (file-directory-p file) dirsuffix filesuffix)) 2724 (insert (if (file-directory-p file) dirsuffix filesuffix))
2721 (unless minibuffer-p 2725 (unless minibuffer-p
2722 (message "Completed"))) 2726 (message "Completed")))
2723 ((and comint-completion-recexact comint-completion-addsuffix 2727 ((and comint-completion-recexact comint-completion-addsuffix
2724 (string-equal pathnondir completion) 2728 (string-equal filenondir completion)
2725 (file-exists-p file)) 2729 (file-exists-p file))
2726 ;; It's not unique, but user wants shortest match. 2730 ;; It's not unique, but user wants shortest match.
2727 (insert (if (file-directory-p file) dirsuffix filesuffix)) 2731 (insert (if (file-directory-p file) dirsuffix filesuffix))
2728 (unless minibuffer-p 2732 (unless minibuffer-p
2729 (message "Completed shortest"))) 2733 (message "Completed shortest")))
2730 ((or comint-completion-autolist 2734 ((or comint-completion-autolist
2731 (string-equal pathnondir completion)) 2735 (string-equal filenondir completion))
2732 ;; It's not unique, list possible completions. 2736 ;; It's not unique, list possible completions.
2733 (comint-dynamic-list-filename-completions)) 2737 (comint-dynamic-list-filename-completions))
2734 (t 2738 (t
@@ -2812,10 +2816,10 @@ See also `comint-dynamic-complete-filename'."
2812 ;; but subsequent changes may have made this unnecessary. sm. 2816 ;; but subsequent changes may have made this unnecessary. sm.
2813 ;;(file-name-handler-alist nil) 2817 ;;(file-name-handler-alist nil)
2814 (filename (or (comint-match-partial-filename) "")) 2818 (filename (or (comint-match-partial-filename) ""))
2815 (pathdir (file-name-directory filename)) 2819 (filedir (file-name-directory filename))
2816 (pathnondir (file-name-nondirectory filename)) 2820 (filenondir (file-name-nondirectory filename))
2817 (directory (if pathdir (comint-directory pathdir) default-directory)) 2821 (directory (if filedir (comint-directory filedir) default-directory))
2818 (completions (file-name-all-completions pathnondir directory))) 2822 (completions (file-name-all-completions filenondir directory)))
2819 (if (not completions) 2823 (if (not completions)
2820 (message "No completions of %s" filename) 2824 (message "No completions of %s" filename)
2821 (comint-dynamic-list-completions 2825 (comint-dynamic-list-completions
@@ -2827,6 +2831,8 @@ See also `comint-dynamic-complete-filename'."
2827;; command is repeatedly used without the set of completions changing. 2831;; command is repeatedly used without the set of completions changing.
2828(defvar comint-displayed-dynamic-completions nil) 2832(defvar comint-displayed-dynamic-completions nil)
2829 2833
2834(defvar comint-dynamic-list-completions-config nil)
2835
2830(defun comint-dynamic-list-completions (completions) 2836(defun comint-dynamic-list-completions (completions)
2831 "List in help buffer sorted COMPLETIONS. 2837 "List in help buffer sorted COMPLETIONS.
2832Typing SPC flushes the help buffer." 2838Typing SPC flushes the help buffer."
@@ -2856,30 +2862,35 @@ Typing SPC flushes the help buffer."
2856 (select-window window) 2862 (select-window window)
2857 (scroll-up)))) 2863 (scroll-up))))
2858 2864
2859 (let ((conf (current-window-configuration))) 2865 ;; Display a completion list for the first time.
2860 (with-output-to-temp-buffer "*Completions*" 2866 (setq comint-dynamic-list-completions-config
2861 (display-completion-list completions)) 2867 (current-window-configuration))
2862 (message "Type space to flush; repeat completion command to scroll") 2868 (with-output-to-temp-buffer "*Completions*"
2863 (let (key first) 2869 (display-completion-list completions))
2864 (if (save-excursion 2870 (message "Type space to flush; repeat completion command to scroll"))
2865 (set-buffer (get-buffer "*Completions*")) 2871
2866 (set (make-local-variable 2872 ;; Read the next key, to process SPC.
2867 'comint-displayed-dynamic-completions) 2873 (let (key first)
2868 completions) 2874 (if (save-excursion
2869 (setq key (read-key-sequence nil) 2875 (set-buffer (get-buffer "*Completions*"))
2870 first (aref key 0)) 2876 (set (make-local-variable
2871 (and (consp first) (consp (event-start first)) 2877 'comint-displayed-dynamic-completions)
2872 (eq (window-buffer (posn-window (event-start first))) 2878 completions)
2873 (get-buffer "*Completions*")) 2879 (setq key (read-key-sequence nil)
2874 (eq (key-binding key) 'mouse-choose-completion))) 2880 first (aref key 0))
2875 ;; If the user does mouse-choose-completion with the mouse, 2881 (and (consp first) (consp (event-start first))
2876 ;; execute the command, then delete the completion window. 2882 (eq (window-buffer (posn-window (event-start first)))
2877 (progn 2883 (get-buffer "*Completions*"))
2878 (mouse-choose-completion first) 2884 (eq (key-binding key) 'mouse-choose-completion)))
2879 (set-window-configuration conf)) 2885 ;; If the user does mouse-choose-completion with the mouse,
2880 (if (eq first ?\ ) 2886 ;; execute the command, then delete the completion window.
2881 (set-window-configuration conf) 2887 (progn
2882 (setq unread-command-events (listify-key-sequence key))))))))) 2888 (mouse-choose-completion first)
2889 (set-window-configuration comint-dynamic-list-completions-config))
2890 (unless (eq first ?\ )
2891 (setq unread-command-events (listify-key-sequence key)))
2892 (unless (eq first ?\t)
2893 (set-window-configuration comint-dynamic-list-completions-config))))))
2883 2894
2884 2895
2885(defun comint-get-next-from-history () 2896(defun comint-get-next-from-history ()