changeset 94087:d23d9685c214

(file-cache-completions-keymap): Move init from file-cache-completion-setup-function into declaration. (file-cache-minibuffer-complete): Simplify. (file-cache-completion-setup-function): Use standard-output, preserve current-buffer.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Mon, 14 Apr 2008 18:11:52 +0000
parents 4dfdf555a78e
children 8518c76e4083
files lisp/ChangeLog lisp/filecache.el
diffstat 2 files changed, 17 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Mon Apr 14 18:09:49 2008 +0000
+++ b/lisp/ChangeLog	Mon Apr 14 18:11:52 2008 +0000
@@ -1,5 +1,11 @@
 2008-04-14  Stefan Monnier  <monnier@iro.umontreal.ca>
 
+	* filecache.el (file-cache-completions-keymap): Move init from
+	file-cache-completion-setup-function into declaration.
+	(file-cache-minibuffer-complete): Simplify.
+	(file-cache-completion-setup-function): Use standard-output,
+	preserve current-buffer.
+
 	* vc.el (vc-status-update): Fix typo.
 	(vc-status-update): Set needs-update.
 	(vc-status-refresh): η-reduce.
--- a/lisp/filecache.el	Mon Apr 14 18:09:49 2008 +0000
+++ b/lisp/filecache.el	Mon Apr 14 18:11:52 2008 +0000
@@ -259,7 +259,12 @@
 (defvar file-cache-alist nil
   "Internal data structure to hold cache of file names.")
 
-(defvar file-cache-completions-keymap nil
+(defvar file-cache-completions-keymap
+  (let ((map (make-sparse-keymap)))
+    (set-keymap-parent map completion-list-mode-map)
+    (define-key map [mouse-2] 'file-cache-mouse-choose-completion)
+    (define-key map "\C-m" 'file-cache-choose-completion)
+    map)
   "Keymap for file cache completions buffer.")
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -609,14 +614,10 @@
 	       (substring completion-string (length string)))
 	      ;; Add our own setup function to the Completions Buffer
 	      (let ((completion-setup-hook
-		   (reverse
-		    (append (list 'file-cache-completion-setup-function)
-			    completion-setup-hook)))
-		    )
+                     (append completion-setup-hook
+                             (list 'file-cache-completion-setup-function))))
 		(with-output-to-temp-buffer file-cache-completions-buffer
-		  (display-completion-list completion-list string))
-		)
-	      )
+		  (display-completion-list completion-list string))))
 	  (setq file-cache-string (file-cache-file-name completion-string))
 	  (if (string= file-cache-string (minibuffer-contents))
 	      (file-cache-temp-minibuffer-message
@@ -653,19 +654,8 @@
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
 (defun file-cache-completion-setup-function  ()
-  (set-buffer file-cache-completions-buffer)
-
-  (if file-cache-completions-keymap
-      nil
-    (setq file-cache-completions-keymap
-	  (copy-keymap completion-list-mode-map))
-    (define-key file-cache-completions-keymap [mouse-2]
-      'file-cache-mouse-choose-completion)
-    (define-key file-cache-completions-keymap "\C-m"
-      'file-cache-choose-completion))
-
-    (use-local-map file-cache-completions-keymap)
-    )
+  (with-current-buffer standard-output ;; i.e. file-cache-completions-buffer
+    (use-local-map file-cache-completions-keymap)))
 
 (defun file-cache-choose-completion  ()
   "Choose a completion in the `*Completions*' buffer."