aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2008-05-22 03:15:32 +0000
committerStefan Monnier2008-05-22 03:15:32 +0000
commit31d4b748c2bba64d922e6b6e7880aa113b00c955 (patch)
treefad3195961a66bfe00b3478c04f151e2fc2babdb
parenta77b655d874ebe7c40fe244d91e1e607e4fcfb25 (diff)
downloademacs-31d4b748c2bba64d922e6b6e7880aa113b00c955.tar.gz
emacs-31d4b748c2bba64d922e6b6e7880aa113b00c955.zip
(icomplete-eoinput): Remove.
(icomplete-overlay): New var to replace it. (icomplete-tidy): Rewrite. (icomplete-exhibit): Use an overlay. (icomplete-completions): Use completion-all-sorted-completions. Obey completion-ignore-case.
-rw-r--r--lisp/ChangeLog7
-rw-r--r--lisp/icomplete.el58
2 files changed, 34 insertions, 31 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 213cfd9b98a..9d95e7db89a 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,12 @@
12008-05-22 Stefan Monnier <monnier@iro.umontreal.ca> 12008-05-22 Stefan Monnier <monnier@iro.umontreal.ca>
2 2
3 * icomplete.el (icomplete-eoinput): Remove.
4 (icomplete-overlay): New var to replace it.
5 (icomplete-tidy): Rewrite.
6 (icomplete-exhibit): Use an overlay.
7 (icomplete-completions): Use completion-all-sorted-completions.
8 Obey completion-ignore-case.
9
3 * files.el (locate-dominating-file): Accept non-existing argument. 10 * files.el (locate-dominating-file): Accept non-existing argument.
4 (project-find-settings-file): Rewrite, using locate-dominating-file. 11 (project-find-settings-file): Rewrite, using locate-dominating-file.
5 12
diff --git a/lisp/icomplete.el b/lisp/icomplete.el
index 369342e4d91..cacb7b26f19 100644
--- a/lisp/icomplete.el
+++ b/lisp/icomplete.el
@@ -117,9 +117,9 @@ icompletion is occurring."
117 117
118;;;_ + Internal Variables 118;;;_ + Internal Variables
119;;;_ = icomplete-eoinput nil 119;;;_ = icomplete-eoinput nil
120(defvar icomplete-eoinput nil 120(defvar icomplete-overlay (make-overlay (point-min) (point-min) nil t t)
121 "Point where minibuffer input ends and completion info begins.") 121 "Overlay used to display the list of completions.")
122(make-variable-buffer-local 'icomplete-eoinput) 122
123;;;_ = icomplete-pre-command-hook 123;;;_ = icomplete-pre-command-hook
124(defvar icomplete-pre-command-hook nil 124(defvar icomplete-pre-command-hook nil
125 "Incremental-minibuffer-completion pre-command-hook. 125 "Incremental-minibuffer-completion pre-command-hook.
@@ -215,15 +215,7 @@ Usually run by inclusion in `minibuffer-setup-hook'."
215 "Remove completions display \(if any) prior to new user input. 215 "Remove completions display \(if any) prior to new user input.
216Should be run in on the minibuffer `pre-command-hook'. See `icomplete-mode' 216Should be run in on the minibuffer `pre-command-hook'. See `icomplete-mode'
217and `minibuffer-setup-hook'." 217and `minibuffer-setup-hook'."
218 (when (and icomplete-mode icomplete-eoinput) 218 (delete-overlay icomplete-overlay))
219
220 (unless (>= icomplete-eoinput (point-max))
221 (let ((buffer-undo-list t) ; prevent entry
222 deactivate-mark)
223 (delete-region icomplete-eoinput (point-max))))
224
225 ;; Reestablish the safe value.
226 (setq icomplete-eoinput nil)))
227 219
228;;;_ > icomplete-exhibit () 220;;;_ > icomplete-exhibit ()
229(defun icomplete-exhibit () 221(defun icomplete-exhibit ()
@@ -233,9 +225,6 @@ and `minibuffer-setup-hook'."
233 (when (and icomplete-mode (icomplete-simple-completing-p)) 225 (when (and icomplete-mode (icomplete-simple-completing-p))
234 (save-excursion 226 (save-excursion
235 (goto-char (point-max)) 227 (goto-char (point-max))
236 ;; Register the end of input, so we know where the extra stuff
237 ;; (match-status info) begins:
238 (setq icomplete-eoinput (point))
239 ; Insert the match-status information: 228 ; Insert the match-status information:
240 (if (and (> (point-max) (minibuffer-prompt-end)) 229 (if (and (> (point-max) (minibuffer-prompt-end))
241 buffer-undo-list ; Wait for some user input. 230 buffer-undo-list ; Wait for some user input.
@@ -250,16 +239,21 @@ and `minibuffer-setup-hook'."
250 ;; embarking on computing completions: 239 ;; embarking on computing completions:
251 (sit-for icomplete-compute-delay))) 240 (sit-for icomplete-compute-delay)))
252 (let ((text (while-no-input 241 (let ((text (while-no-input
253 (list
254 (icomplete-completions 242 (icomplete-completions
255 (field-string) 243 (field-string)
256 minibuffer-completion-table 244 minibuffer-completion-table
257 minibuffer-completion-predicate 245 minibuffer-completion-predicate
258 (not minibuffer-completion-confirm))))) 246 (not minibuffer-completion-confirm))))
259 (buffer-undo-list t) 247 (buffer-undo-list t)
260 deactivate-mark) 248 deactivate-mark)
261 ;; Do nothing if while-no-input was aborted. 249 ;; Do nothing if while-no-input was aborted.
262 (if (consp text) (insert (car text)))))))) 250 (when (stringp text)
251 (move-overlay icomplete-overlay (point) (point) (current-buffer))
252 ;; The current C cursor code doesn't know to use the overlay's
253 ;; marker's stickiness to figure out whether to place the cursor
254 ;; before or after the string, so let's spoon-feed it the pos.
255 (put-text-property 0 1 'cursor t text)
256 (overlay-put icomplete-overlay 'after-string text)))))))
263 257
264;;;_ > icomplete-completions (name candidates predicate require-match) 258;;;_ > icomplete-completions (name candidates predicate require-match)
265(defun icomplete-completions (name candidates predicate require-match) 259(defun icomplete-completions (name candidates predicate require-match)
@@ -281,16 +275,16 @@ The displays for unambiguous matches have ` [Matched]' appended
281matches exist. \(Keybindings for uniquely matched commands 275matches exist. \(Keybindings for uniquely matched commands
282are exhibited within the square braces.)" 276are exhibited within the square braces.)"
283 277
284 (let* ((comps (completion-all-completions name candidates predicate 278 (let* ((comps (completion-all-sorted-completions))
285 (length name))) 279 (last (if (consp comps) (last comps)))
286 (last (last comps)) 280 (base-size (cdr last))
287 (base-size (if (consp last) (prog1 (cdr last) (setcdr last nil))))
288 (open-bracket (if require-match "(" "[")) 281 (open-bracket (if require-match "(" "["))
289 (close-bracket (if require-match ")" "]"))) 282 (close-bracket (if require-match ")" "]")))
290 ;; `concat'/`mapconcat' is the slow part. With the introduction of 283 ;; `concat'/`mapconcat' is the slow part. With the introduction of
291 ;; `icomplete-prospects-length', there is no need for `catch'/`throw'. 284 ;; `icomplete-prospects-length', there is no need for `catch'/`throw'.
292 (if (null comps) 285 (if (not (consp comps))
293 (format " %sNo matches%s" open-bracket close-bracket) 286 (format " %sNo matches%s" open-bracket close-bracket)
287 (if last (setcdr last nil))
294 (let* ((most-try 288 (let* ((most-try
295 (if (and base-size (> base-size 0)) 289 (if (and base-size (> base-size 0))
296 (completion-try-completion 290 (completion-try-completion
@@ -299,7 +293,8 @@ are exhibited within the square braces.)"
299 ;; the same with `comps'. 293 ;; the same with `comps'.
300 (completion-try-completion 294 (completion-try-completion
301 name comps nil (length name)))) 295 name comps nil (length name))))
302 (most (if (consp most-try) (car most-try) (car comps))) 296 (most (if (consp most-try) (car most-try)
297 (if most-try (car comps) "")))
303 ;; Compare name and most, so we can determine if name is 298 ;; Compare name and most, so we can determine if name is
304 ;; a prefix of most, or something else. 299 ;; a prefix of most, or something else.
305 (compare (compare-strings name nil nil 300 (compare (compare-strings name nil nil
@@ -320,7 +315,7 @@ are exhibited within the square braces.)"
320 (prefix-len 315 (prefix-len
321 ;; Find the common prefix among `comps'. 316 ;; Find the common prefix among `comps'.
322 (if (eq t (compare-strings (car comps) nil (length most) 317 (if (eq t (compare-strings (car comps) nil (length most)
323 most nil nil case-fold-search)) 318 most nil nil completion-ignore-case))
324 ;; Common case. 319 ;; Common case.
325 (length most) 320 (length most)
326 ;; Else, use try-completion. 321 ;; Else, use try-completion.
@@ -329,7 +324,7 @@ are exhibited within the square braces.)"
329 (length comps-prefix))))) 324 (length comps-prefix)))))
330 325
331 prospects most-is-exact comp limit) 326 prospects most-is-exact comp limit)
332 (if (or (eq most-try t) (null (cdr comps))) 327 (if (eq most-try t) ;; (or (null (cdr comps))
333 (setq prospects nil) 328 (setq prospects nil)
334 (while (and comps (not limit)) 329 (while (and comps (not limit))
335 (setq comp 330 (setq comp
@@ -339,16 +334,17 @@ are exhibited within the square braces.)"
339 ((member comp prospects)) 334 ((member comp prospects))
340 (t (setq prospects-len (+ (length comp) 1 prospects-len)) 335 (t (setq prospects-len (+ (length comp) 1 prospects-len))
341 (if (< prospects-len icomplete-prospects-length) 336 (if (< prospects-len icomplete-prospects-length)
342 (setq prospects (cons comp prospects)) 337 (push comp prospects)
343 (setq limit t)))))) 338 (setq limit t))))))
339 ;; Restore the base-size info, since completion-all-sorted-completions
340 ;; is cached.
341 (if last (setcdr last base-size))
344 (if prospects 342 (if prospects
345 (concat determ 343 (concat determ
346 "{" 344 "{"
347 (and most-is-exact ",") 345 (and most-is-exact ",")
348 (mapconcat 'identity 346 (mapconcat 'identity (nreverse prospects) ",")
349 (sort prospects (function string-lessp)) 347 (and limit ",...")
350 ",")
351 (and comps ",...")
352 "}") 348 "}")
353 (concat determ 349 (concat determ
354 " [Matched" 350 " [Matched"