;; Put the previous arg, if there was one, onto ARGS.
(setq str (substring string beg pos)
args (if quotes (cons str args)
- (nconc (comint-delim-arg str) args))
- count (1+ count)))
+ (nconc (comint-delim-arg str) args))))
+ (setq count (length args))
(setq quotes (match-beginning 1))
(setq beg (match-beginning 0))
(setq pos (match-end 0))))
(if beg
(setq str (substring string beg pos)
args (if quotes (cons str args)
- (nconc (comint-delim-arg str) args))
- count (1+ count)))
+ (nconc (comint-delim-arg str) args))))
+ (setq count (length args))
(let ((n (or nth (1- count)))
(m (if mth (1- (- count mth)) 0)))
(mapconcat
(comint-skip-input)
(interrupt-process nil comint-ptyp)
;; (process-send-string nil "\n")
- )
+)
(defun comint-kill-subjob ()
"Send kill signal to the current subjob.
(defvar comint-file-name-chars
(if (memq system-type '(ms-dos windows-nt cygwin))
"~/A-Za-z0-9_^$!#%&{}@`'.,:()-"
- "~/A-Za-z0-9+@:_.$#%,={}-")
+ "[]~/A-Za-z0-9+@:_.$#%,={}-")
"String of characters valid in a file name.
Note that all non-ASCII characters are considered valid in a file name
regardless of what this variable says.
inside of a \"[...]\" (see `skip-chars-forward'),
plus all non-ASCII characters."
(save-excursion
- (let ((non-word-chars (concat "[^\\\\" word-chars "]")) (here (point)))
- (while (and (re-search-backward non-word-chars nil 'move)
- ;;(memq (char-after (point)) shell-file-name-quote-list)
- (or (>= (following-char) 128)
- (eq (preceding-char) ?\\)))
- (backward-char 1))
- ;; Don't go forward over a word-char (this can happen if we're at bob).
- (when (or (not (bobp)) (looking-at non-word-chars))
- (forward-char 1))
+ (let ((here (point))
+ giveup)
+ (while (not giveup)
+ (let ((startpoint (point)))
+ (skip-chars-backward (concat "\\\\" word-chars))
+ (if (and (> (- (point) 2) (point-min))
+ (= (char-after (- (point) 2)) ?\\))
+ (forward-char -2))
+ (if (and (> (- (point) 1) (point-min))
+ (>= (char-after (- (point) 1)) 128))
+ (forward-char -1))
+ (if (= (point) startpoint)
+ (setq giveup t))))
;; Set match-data to match the entire string.
(when (< (point) here)
(set-match-data (list (point) here))
(t
(cdr comint-completion-addsuffix))))
(filename (or (comint-match-partial-filename) ""))
- (pathdir (file-name-directory filename))
- (pathnondir (file-name-nondirectory filename))
- (directory (if pathdir (comint-directory pathdir) default-directory))
- (completion (file-name-completion pathnondir directory)))
+ (filedir (file-name-directory filename))
+ (filenondir (file-name-nondirectory filename))
+ (directory (if filedir (comint-directory filedir) default-directory))
+ (completion (file-name-completion filenondir directory)))
(cond ((null completion)
(message "No completions of %s" filename)
(setq success nil))
(let ((file (concat (file-name-as-directory directory) completion)))
(insert (comint-quote-filename
(substring (directory-file-name completion)
- (length pathnondir))))
+ (length filenondir))))
(cond ((symbolp (file-name-completion completion directory))
;; We inserted a unique completion.
(insert (if (file-directory-p file) dirsuffix filesuffix))
(unless minibuffer-p
(message "Completed")))
((and comint-completion-recexact comint-completion-addsuffix
- (string-equal pathnondir completion)
+ (string-equal filenondir completion)
(file-exists-p file))
;; It's not unique, but user wants shortest match.
(insert (if (file-directory-p file) dirsuffix filesuffix))
(unless minibuffer-p
(message "Completed shortest")))
((or comint-completion-autolist
- (string-equal pathnondir completion))
+ (string-equal filenondir completion))
;; It's not unique, list possible completions.
(comint-dynamic-list-filename-completions))
(t
;; but subsequent changes may have made this unnecessary. sm.
;;(file-name-handler-alist nil)
(filename (or (comint-match-partial-filename) ""))
- (pathdir (file-name-directory filename))
- (pathnondir (file-name-nondirectory filename))
- (directory (if pathdir (comint-directory pathdir) default-directory))
- (completions (file-name-all-completions pathnondir directory)))
+ (filedir (file-name-directory filename))
+ (filenondir (file-name-nondirectory filename))
+ (directory (if filedir (comint-directory filedir) default-directory))
+ (completions (file-name-all-completions filenondir directory)))
(if (not completions)
(message "No completions of %s" filename)
(comint-dynamic-list-completions
;; command is repeatedly used without the set of completions changing.
(defvar comint-displayed-dynamic-completions nil)
+(defvar comint-dynamic-list-completions-config nil)
+
(defun comint-dynamic-list-completions (completions)
"List in help buffer sorted COMPLETIONS.
Typing SPC flushes the help buffer."
(select-window window)
(scroll-up))))
- (let ((conf (current-window-configuration)))
- (with-output-to-temp-buffer "*Completions*"
- (display-completion-list completions))
- (message "Type space to flush; repeat completion command to scroll")
- (let (key first)
- (if (save-excursion
- (set-buffer (get-buffer "*Completions*"))
- (set (make-local-variable
- 'comint-displayed-dynamic-completions)
- completions)
- (setq key (read-key-sequence nil)
- first (aref key 0))
- (and (consp first) (consp (event-start first))
- (eq (window-buffer (posn-window (event-start first)))
- (get-buffer "*Completions*"))
- (eq (key-binding key) 'mouse-choose-completion)))
- ;; If the user does mouse-choose-completion with the mouse,
- ;; execute the command, then delete the completion window.
- (progn
- (mouse-choose-completion first)
- (set-window-configuration conf))
- (if (eq first ?\ )
- (set-window-configuration conf)
- (setq unread-command-events (listify-key-sequence key)))))))))
+ ;; Display a completion list for the first time.
+ (setq comint-dynamic-list-completions-config
+ (current-window-configuration))
+ (with-output-to-temp-buffer "*Completions*"
+ (display-completion-list completions))
+ (message "Type space to flush; repeat completion command to scroll"))
+
+ ;; Read the next key, to process SPC.
+ (let (key first)
+ (if (save-excursion
+ (set-buffer (get-buffer "*Completions*"))
+ (set (make-local-variable
+ 'comint-displayed-dynamic-completions)
+ completions)
+ (setq key (read-key-sequence nil)
+ first (aref key 0))
+ (and (consp first) (consp (event-start first))
+ (eq (window-buffer (posn-window (event-start first)))
+ (get-buffer "*Completions*"))
+ (eq (key-binding key) 'mouse-choose-completion)))
+ ;; If the user does mouse-choose-completion with the mouse,
+ ;; execute the command, then delete the completion window.
+ (progn
+ (mouse-choose-completion first)
+ (set-window-configuration comint-dynamic-list-completions-config))
+ (unless (eq first ?\ )
+ (setq unread-command-events (listify-key-sequence key)))
+ (unless (eq first ?\t)
+ (set-window-configuration comint-dynamic-list-completions-config))))))
\f
(defun comint-get-next-from-history ()