;;; complete.el --- partial completion mechanism plus other goodies
;; Copyright (C) 1990, 1991, 1992, 1993, 1999, 2000, 2001, 2002, 2003,
-;; 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+;; 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
;; Author: Dave Gillespie <daveg@synaptics.com>
;; Keywords: abbrev convenience
This can be bound to other keys, like `-' and `.', if you wish."
(interactive)
(if (eq (PC-was-meta-key) PC-meta-flag)
- (if (eq last-command-char ? )
+ (if (eq last-command-event ? )
(minibuffer-complete-word)
(self-insert-command 1))
(self-insert-command 1)
((= (point-max) (minibuffer-prompt-end))
;; Duplicate the "bug" that Info-menu relies on...
(exit-minibuffer))
- ((eq minibuffer-completion-confirm 'confirm-only)
+ ((eq minibuffer-completion-confirm 'confirm)
(if (or (eq last-command this-command)
(test-completion (field-string)
minibuffer-completion-table
minibuffer-completion-predicate))
(exit-minibuffer)
(PC-temp-minibuffer-message " [Confirm]")))
+ ((eq minibuffer-completion-confirm 'confirm-after-completion)
+ ;; Similar to the above, but only if trying to exit immediately
+ ;; after typing TAB (this catches most minibuffer typos).
+ (if (and (memq last-command minibuffer-confirm-exit-commands)
+ (not (test-completion (field-string)
+ minibuffer-completion-table
+ minibuffer-completion-predicate)))
+ (PC-temp-minibuffer-message " [Confirm]")
+ (exit-minibuffer)))
(t
(let ((flag (PC-do-completion 'exit)))
(and flag
;; Check if buffer contents can already be considered complete
(if (and (eq mode 'exit)
(test-completion str table pred))
- (progn
- ;; If completion-ignore-case is non-nil, insert the
- ;; completion string since that may have a different case.
- (when completion-ignore-case
- (setq str (PC-try-completion str table pred))
- (delete-region beg end)
- (insert str))
- 'complete)
+ 'complete
;; Do substitutions in directory names
(and filename
(setq prefix (PC-try-completion
(PC-chunk-after basestr skip) poss)))
(let ((first t) i)
- ;; Retain capitalization of user input even if
- ;; completion-ignore-case is set.
(if (eq mode 'word)
(setq prefix (PC-chop-word prefix basestr)))
(goto-char (+ beg (length dirname)))
(setq i 0) ; index into prefix string
(while (< i (length prefix))
(if (and (< (point) end)
- (eq (downcase (aref prefix i))
- (downcase (following-char))))
- ;; same char (modulo case); no action
- (forward-char 1)
- (if (and (< (point) end)
- (and (looking-at " ")
- (memq (aref prefix i)
- PC-delims-list)))
- ;; replace " " by the actual delimiter
- (progn
- (delete-char 1)
- (insert (substring prefix i (1+ i))))
- ;; insert a new character
+ (or (eq (downcase (aref prefix i))
+ (downcase (following-char)))
+ (and (looking-at " ")
+ (memq (aref prefix i)
+ PC-delims-list))))
+ ;; replace " " by the actual delimiter
+ ;; or input char by prefix char
(progn
- (and filename (looking-at "\\*")
- (progn
- (delete-char 1)
- (setq end (1- end))))
- (setq improved t)
- (insert (substring prefix i (1+ i)))
- (setq end (1+ end)))))
+ (delete-char 1)
+ (insert (substring prefix i (1+ i))))
+ ;; insert a new character
+ (progn
+ (and filename (looking-at "\\*")
+ (progn
+ (delete-char 1)
+ (setq end (1- end))))
+ (setq improved t)
+ (insert (substring prefix i (1+ i)))
+ (setq end (1+ end))))
(setq i (1+ i)))
(or pt (setq pt (point)))
(looking-at PC-delim-regex))
(if improved
;; We changed it... would it be complete without the space?
- (if (test-completion (buffer-substring 1 (1- end))
+ (if (test-completion (buffer-substring
+ (field-beginning) (1- end))
table pred)
(delete-region (1- end) end)))