/[slime]/slime/contrib/slime-fuzzy.el
ViewVC logotype

Contents of /slime/contrib/slime-fuzzy.el

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.24 - (show annotations)
Fri Oct 19 05:18:05 2012 UTC (17 months, 3 weeks ago) by sboukarev
Branch: MAIN
CVS Tags: HEAD
Changes since 1.23: +61 -49 lines
* contrib/slime-fuzzy.el (slime-fuzzy-choices-buffer): Don't move position
in the current buffer, call (slime-fuzzy-next) after switching to
the completion buffer.
1
2 (define-slime-contrib slime-fuzzy
3 "Fuzzy symbol completion."
4 (:authors "Brian Downing <bdowning@lavos.net>"
5 "Tobias C. Rittweiler <tcr@freebits.de>"
6 "Attila Lendvai <attila.lendvai@gmail.com>")
7 (:license "GPL")
8 (:swank-dependencies swank-fuzzy)
9 (:on-load
10 (define-key slime-mode-map "\C-c\M-i" 'slime-fuzzy-complete-symbol)
11 (when (featurep 'slime-repl)
12 (define-key slime-repl-mode-map "\C-c\M-i"
13 'slime-fuzzy-complete-symbol))))
14
15 (defcustom slime-fuzzy-completion-in-place t
16 "When non-NIL the fuzzy symbol completion is done in place as
17 opposed to moving the point to the completion buffer."
18 :group 'slime-mode
19 :type 'boolean)
20
21 (defcustom slime-fuzzy-completion-limit 300
22 "Only return and present this many symbols from swank."
23 :group 'slime-mode
24 :type 'integer)
25
26 (defcustom slime-fuzzy-completion-time-limit-in-msec 1500
27 "Limit the time spent (given in msec) in swank while gathering
28 comletitions."
29 :group 'slime-mode
30 :type 'integer)
31
32 (defcustom slime-when-complete-filename-expand nil
33 "Use comint-replace-by-expanded-filename instead of
34 comint-dynamic-complete-as-filename to complete file names"
35 :group 'slime-mode
36 :type 'boolean)
37
38
39 (defvar slime-fuzzy-target-buffer nil
40 "The buffer that is the target of the completion activities.")
41 (defvar slime-fuzzy-saved-window-configuration nil
42 "The saved window configuration before the fuzzy completion
43 buffer popped up.")
44 (defvar slime-fuzzy-start nil
45 "The beginning of the completion slot in the target buffer.
46 This is a non-advancing marker.")
47 (defvar slime-fuzzy-end nil
48 "The end of the completion slot in the target buffer.
49 This is an advancing marker.")
50 (defvar slime-fuzzy-original-text nil
51 "The original text that was in the completion slot in the
52 target buffer. This is what is put back if completion is
53 aborted.")
54 (defvar slime-fuzzy-text nil
55 "The text that is currently in the completion slot in the
56 target buffer. If this ever doesn't match, the target buffer has
57 been modified and we abort without touching it.")
58 (defvar slime-fuzzy-first nil
59 "The position of the first completion in the completions buffer.
60 The descriptive text and headers are above this.")
61 (defvar slime-fuzzy-last nil
62 "The position of the last completion in the completions buffer.
63 If the time limit has exhausted during generation possible completion
64 choices inside SWANK, an indication is printed below this.")
65 (defvar slime-fuzzy-current-completion nil
66 "The current completion object. If this is the same before and
67 after point moves in the completions buffer, the text is not
68 replaced in the target for efficiency.")
69 (defvar slime-fuzzy-current-completion-overlay nil
70 "The overlay representing the current completion in the completion
71 buffer. This is used to hightlight the text.")
72
73 ;;;;;;; slime-target-buffer-fuzzy-completions-mode
74 ;; NOTE: this mode has to be able to override key mappings in slime-mode
75
76 (defvar slime-target-buffer-fuzzy-completions-map
77 (let ((map (make-sparse-keymap)))
78 (flet ((def (keys command)
79 (unless (listp keys)
80 (setq keys (list keys)))
81 (dolist (key keys)
82 (define-key map key command))))
83 (def `([remap keyboard-quit]
84 ,(kbd "C-g"))
85 'slime-fuzzy-abort)
86 (def `([remap slime-fuzzy-indent-and-complete-symbol]
87 [remap slime-indent-and-complete-symbol]
88 ,(kbd "<tab>"))
89 'slime-fuzzy-select-or-update-completions)
90 (def `([remap previous-line]
91 ,(kbd "<up>"))
92 'slime-fuzzy-prev)
93 (def `([remap next-line]
94 ,(kbd "<down>"))
95 'slime-fuzzy-next)
96 (def `([remap isearch-forward]
97 ,(kbd "C-s"))
98 'slime-fuzzy-continue-isearch-in-fuzzy-buffer)
99 ;; some unconditional direct bindings
100 (def (list (kbd "<return>") (kbd "RET") (kbd "<SPC>") "(" ")" "[" "]")
101 'slime-fuzzy-select-and-process-event-in-target-buffer))
102 map)
103 "Keymap for slime-target-buffer-fuzzy-completions-mode.
104 This will override the key bindings in the target buffer
105 temporarily during completion.")
106
107 ;; Make sure slime-fuzzy-target-buffer-completions-mode's map is
108 ;; before everything else.
109 (setf minor-mode-map-alist
110 (stable-sort minor-mode-map-alist
111 (lambda (a b)
112 (eq a 'slime-fuzzy-target-buffer-completions-mode))
113 :key #'car))
114
115 (defun slime-fuzzy-continue-isearch-in-fuzzy-buffer ()
116 (interactive)
117 (select-window (get-buffer-window (slime-get-fuzzy-buffer)))
118 (call-interactively 'isearch-forward))
119
120 (define-minor-mode slime-fuzzy-target-buffer-completions-mode
121 "This minor mode is intented to override key bindings during
122 fuzzy completions in the target buffer. Most of the bindings will
123 do an implicit select in the completion window and let the
124 keypress be processed in the target buffer."
125 nil
126 nil
127 slime-target-buffer-fuzzy-completions-map)
128
129 (add-to-list 'minor-mode-alist
130 '(slime-fuzzy-target-buffer-completions-mode
131 " Fuzzy Target Buffer Completions"))
132
133 (define-derived-mode slime-fuzzy-completions-mode
134 fundamental-mode "Fuzzy Completions"
135 "Major mode for presenting fuzzy completion results.
136
137 When you run `slime-fuzzy-complete-symbol', the symbol token at
138 point is completed using the Fuzzy Completion algorithm; this
139 means that the token is taken as a sequence of characters and all
140 the various possibilities that this sequence could meaningfully
141 represent are offered as selectable choices, sorted by how well
142 they deem to be a match for the token. (For instance, the first
143 choice of completing on \"mvb\" would be \"multiple-value-bind\".)
144
145 Therefore, a new buffer (*Fuzzy Completions*) will pop up that
146 contains the different completion choices. Simultaneously, a
147 special minor-mode will be temporarily enabled in the original
148 buffer where you initiated fuzzy completion (also called the
149 ``target buffer'') in order to navigate through the *Fuzzy
150 Completions* buffer without leaving.
151
152 With focus in *Fuzzy Completions*:
153 Type `n' and `p' (`UP', `DOWN') to navigate between completions.
154 Type `RET' or `TAB' to select the completion near point.
155 Type `q' to abort.
156
157 With focus in the target buffer:
158 Type `UP' and `DOWN' to navigate between completions.
159 Type a character that does not constitute a symbol name
160 to insert the current choice and then that character (`(', `)',
161 `SPACE', `RET'.) Use `TAB' to simply insert the current choice.
162 Use C-g to abort.
163
164 Alternatively, you can click <mouse-2> on a completion to select it.
165
166
167 Complete listing of keybindings within the target buffer:
168
169 \\<slime-target-buffer-fuzzy-completions-map>\
170 \\{slime-target-buffer-fuzzy-completions-map}
171
172 Complete listing of keybindings with *Fuzzy Completions*:
173
174 \\<slime-fuzzy-completions-map>\
175 \\{slime-fuzzy-completions-map}"
176 (use-local-map slime-fuzzy-completions-map)
177 (set (make-local-variable 'slime-fuzzy-current-completion-overlay)
178 (make-overlay (point) (point) nil t nil)))
179
180 (defvar slime-fuzzy-completions-map
181 (let ((map (make-sparse-keymap)))
182 (flet ((def (keys command)
183 (unless (listp keys)
184 (setq keys (list keys)))
185 (dolist (key keys)
186 (define-key map key command))))
187 (def `([remap keyboard-quit]
188 "q"
189 ,(kbd "C-g"))
190 'slime-fuzzy-abort)
191 (def `([remap previous-line]
192 "p"
193 "\M-p"
194 ,(kbd "<up>"))
195 'slime-fuzzy-prev)
196 (def `([remap next-line]
197 "n"
198 "\M-n"
199 ,(kbd "<down>"))
200 'slime-fuzzy-next)
201 (def "\d" 'scroll-down)
202 (def `([remap slime-fuzzy-indent-and-complete-symbol]
203 [remap slime-indent-and-complete-symbol]
204 ,(kbd "<tab>"))
205 'slime-fuzzy-select)
206 (def (kbd "<mouse-2>") 'slime-fuzzy-select/mouse)
207 (def `(,(kbd "RET")
208 ,(kbd "<SPC>"))
209 'slime-fuzzy-select))
210 map)
211 "Keymap for slime-fuzzy-completions-mode when in the completion buffer.")
212
213 (defun slime-fuzzy-completions (prefix &optional default-package)
214 "Get the list of sorted completion objects from completing
215 `prefix' in `package' from the connected Lisp."
216 (let ((prefix (etypecase prefix
217 (symbol (symbol-name prefix))
218 (string prefix))))
219 (slime-eval `(swank:fuzzy-completions ,prefix
220 ,(or default-package
221 (slime-current-package))
222 :limit ,slime-fuzzy-completion-limit
223 :time-limit-in-msec
224 ,slime-fuzzy-completion-time-limit-in-msec))))
225
226 (defun slime-fuzzy-selected (prefix completion)
227 "Tell the connected Lisp that the user selected completion
228 `completion' as the completion for `prefix'."
229 (let ((no-properties (copy-sequence prefix)))
230 (set-text-properties 0 (length no-properties) nil no-properties)
231 (slime-eval `(swank:fuzzy-completion-selected ,no-properties
232 ',completion))))
233
234 (defun slime-fuzzy-indent-and-complete-symbol ()
235 "Indent the current line and perform fuzzy symbol completion. First
236 indent the line. If indenting doesn't move point, complete the
237 symbol. If there's no symbol at the point, show the arglist for the
238 most recently enclosed macro or function."
239 (interactive)
240 (let ((pos (point)))
241 (unless (get-text-property (line-beginning-position) 'slime-repl-prompt)
242 (lisp-indent-line))
243 (when (= pos (point))
244 (cond ((save-excursion (re-search-backward "[^() \n\t\r]+\\=" nil t))
245 (slime-fuzzy-complete-symbol))
246 ((memq (char-before) '(?\t ?\ ))
247 (slime-echo-arglist))))))
248
249 (defun* slime-fuzzy-complete-symbol ()
250 "Fuzzily completes the abbreviation at point into a symbol."
251 (interactive)
252 (when (save-excursion (re-search-backward "\"[^ \t\n]+\\=" nil t))
253 (return-from slime-fuzzy-complete-symbol
254 ;; don't add space after completion
255 (let ((comint-completion-addsuffix '("/" . "")))
256 (if slime-when-complete-filename-expand
257 (comint-replace-by-expanded-filename)
258 (comint-dynamic-complete-as-filename)))))
259 (let* ((end (move-marker (make-marker) (slime-symbol-end-pos)))
260 (beg (move-marker (make-marker) (slime-symbol-start-pos)))
261 (prefix (buffer-substring-no-properties beg end)))
262 (destructuring-bind (completion-set interrupted-p)
263 (slime-fuzzy-completions prefix)
264 (if (null completion-set)
265 (progn (slime-minibuffer-respecting-message
266 "Can't find completion for \"%s\"" prefix)
267 (ding)
268 (slime-fuzzy-done))
269 (goto-char end)
270 (cond ((slime-length= completion-set 1)
271 ;; insert completed string
272 (insert-and-inherit (caar completion-set))
273 (delete-region beg end)
274 (goto-char (+ beg (length (caar completion-set))))
275 (slime-minibuffer-respecting-message "Sole completion")
276 (slime-fuzzy-done))
277 ;; Incomplete
278 (t
279 (slime-fuzzy-choices-buffer completion-set interrupted-p
280 beg end)
281 (slime-minibuffer-respecting-message
282 "Complete but not unique")))))))
283
284
285 (defun slime-get-fuzzy-buffer ()
286 (get-buffer-create "*Fuzzy Completions*"))
287
288 (defvar slime-fuzzy-explanation
289 "For help on how the use this buffer, see `slime-fuzzy-completions-mode'.
290
291 Flags: boundp fboundp generic-function class macro special-operator package
292 \n"
293 "The explanation that gets inserted at the beginning of the
294 *Fuzzy Completions* buffer.")
295
296 (defun slime-fuzzy-insert-completion-choice (completion max-length)
297 "Inserts the completion object `completion' as a formatted
298 completion choice into the current buffer, and mark it with the
299 proper text properties."
300 (destructuring-bind (symbol-name score chunks classification-string)
301 completion
302 (let ((start (point))
303 (end))
304 (insert symbol-name)
305 (setq end (point))
306 (dolist (chunk chunks)
307 (put-text-property (+ start (first chunk))
308 (+ start (first chunk)
309 (length (second chunk)))
310 'face 'bold))
311 (put-text-property start (point) 'mouse-face 'highlight)
312 (dotimes (i (- max-length (- end start)))
313 (insert " "))
314 (insert (format " %s %s\n"
315 classification-string
316 score))
317 (put-text-property start (point) 'completion completion))))
318
319 (defun slime-fuzzy-insert (text)
320 "Inserts `text' into the target buffer in the completion slot.
321 If the buffer has been modified in the meantime, abort the
322 completion process. Otherwise, update all completion variables
323 so that the new text is present."
324 (with-current-buffer slime-fuzzy-target-buffer
325 (cond
326 ((not (string-equal slime-fuzzy-text
327 (buffer-substring slime-fuzzy-start
328 slime-fuzzy-end)))
329 (slime-fuzzy-done)
330 (beep)
331 (message "Target buffer has been modified!"))
332 (t
333 (goto-char slime-fuzzy-start)
334 (delete-region slime-fuzzy-start slime-fuzzy-end)
335 (insert-and-inherit text)
336 (setq slime-fuzzy-text text)
337 (goto-char slime-fuzzy-end)))))
338
339 (defun slime-minibuffer-p (buffer)
340 (if (featurep 'xemacs)
341 (eq buffer (window-buffer (minibuffer-window)))
342 (minibufferp buffer)))
343
344 (defun slime-fuzzy-choices-buffer (completions interrupted-p start end)
345 "Creates (if neccessary), populates, and pops up the *Fuzzy
346 Completions* buffer with the completions from `completions' and
347 the completion slot in the current buffer bounded by `start' and
348 `end'. This saves the window configuration before popping the
349 buffer so that it can possibly be restored when the user is
350 done."
351 (let ((new-completion-buffer (not slime-fuzzy-target-buffer))
352 (connection (slime-connection)))
353 (when new-completion-buffer
354 (setq slime-fuzzy-saved-window-configuration
355 (current-window-configuration)))
356 (slime-fuzzy-enable-target-buffer-completions-mode)
357 (setq slime-fuzzy-target-buffer (current-buffer))
358 (setq slime-fuzzy-start (move-marker (make-marker) start))
359 (setq slime-fuzzy-end (move-marker (make-marker) end))
360 (set-marker-insertion-type slime-fuzzy-end t)
361 (setq slime-fuzzy-original-text (buffer-substring start end))
362 (setq slime-fuzzy-text slime-fuzzy-original-text)
363 (slime-fuzzy-fill-completions-buffer completions interrupted-p)
364 (pop-to-buffer (slime-get-fuzzy-buffer))
365 (slime-fuzzy-next)
366 (setq slime-buffer-connection connection)
367 (when new-completion-buffer
368 ;; Hook to nullify window-config restoration if the user changes
369 ;; the window configuration himself.
370 (when (boundp 'window-configuration-change-hook)
371 (add-hook 'window-configuration-change-hook
372 'slime-fuzzy-window-configuration-change))
373 (slime-add-local-hook 'kill-buffer-hook 'slime-fuzzy-abort)
374 (set (make-local-variable 'cursor-type) nil)
375 (setq buffer-quit-function 'slime-fuzzy-abort)) ; M-Esc Esc
376 (when slime-fuzzy-completion-in-place
377 ;; switch back to the original buffer
378 (if (slime-minibuffer-p slime-fuzzy-target-buffer)
379 (select-window (minibuffer-window))
380 (switch-to-buffer-other-window slime-fuzzy-target-buffer)))))
381
382 (defun slime-fuzzy-fill-completions-buffer (completions interrupted-p)
383 "Erases and fills the completion buffer with the given completions."
384 (with-current-buffer (slime-get-fuzzy-buffer)
385 (setq buffer-read-only nil)
386 (erase-buffer)
387 (slime-fuzzy-completions-mode)
388 (insert slime-fuzzy-explanation)
389 (let ((max-length 12))
390 (dolist (completion completions)
391 (setf max-length (max max-length (length (first completion)))))
392
393 (insert "Completion:")
394 (dotimes (i (- max-length 10)) (insert " "))
395 ;; Flags: Score:
396 ;; ... ------- --------
397 ;; bfgctmsp
398 (let* ((example-classification-string (fourth (first completions)))
399 (classification-length (length example-classification-string))
400 (spaces (- classification-length (length "Flags:"))))
401 (insert "Flags:")
402 (dotimes (i spaces) (insert " "))
403 (insert " Score:\n")
404 (dotimes (i max-length) (insert "-"))
405 (insert " ")
406 (dotimes (i classification-length) (insert "-"))
407 (insert " --------\n")
408 (setq slime-fuzzy-first (point)))
409
410 (dolist (completion completions)
411 (setq slime-fuzzy-last (point)) ; will eventually become the last entry
412 (slime-fuzzy-insert-completion-choice completion max-length))
413
414 (when interrupted-p
415 (insert "...\n")
416 (insert "[Interrupted: time limit exhausted]"))
417
418 (setq buffer-read-only t))
419 (setq slime-fuzzy-current-completion
420 (caar completions))
421 (goto-char 0)))
422
423 (defun slime-fuzzy-enable-target-buffer-completions-mode ()
424 "Store the target buffer's local map, so that we can restore it."
425 (unless slime-fuzzy-target-buffer-completions-mode
426 ; (slime-log-event "Enabling target buffer completions mode")
427 (slime-fuzzy-target-buffer-completions-mode 1)))
428
429 (defun slime-fuzzy-disable-target-buffer-completions-mode ()
430 "Restores the target buffer's local map when completion is finished."
431 (when slime-fuzzy-target-buffer-completions-mode
432 ; (slime-log-event "Disabling target buffer completions mode")
433 (slime-fuzzy-target-buffer-completions-mode 0)))
434
435 (defun slime-fuzzy-insert-from-point ()
436 "Inserts the completion that is under point in the completions
437 buffer into the target buffer. If the completion in question had
438 already been inserted, it does nothing."
439 (with-current-buffer (slime-get-fuzzy-buffer)
440 (let ((current-completion (get-text-property (point) 'completion)))
441 (when (and current-completion
442 (not (eq slime-fuzzy-current-completion
443 current-completion)))
444 (slime-fuzzy-insert
445 (first (get-text-property (point) 'completion)))
446 (setq slime-fuzzy-current-completion
447 current-completion)))))
448
449 (defun slime-fuzzy-post-command-hook ()
450 "The post-command-hook for the *Fuzzy Completions* buffer.
451 This makes sure the completion slot in the target buffer matches
452 the completion that point is on in the completions buffer."
453 (condition-case err
454 (when slime-fuzzy-target-buffer
455 (slime-fuzzy-insert-from-point))
456 (error
457 ;; Because this is called on the post-command-hook, we mustn't let
458 ;; errors propagate.
459 (message "Error in slime-fuzzy-post-command-hook: %S" err))))
460
461 (defun slime-fuzzy-next ()
462 "Moves point directly to the next completion in the completions
463 buffer."
464 (interactive)
465 (with-current-buffer (slime-get-fuzzy-buffer)
466 (let ((point (next-single-char-property-change
467 (point) 'completion nil slime-fuzzy-last)))
468 (set-window-point (get-buffer-window (current-buffer)) point)
469 (goto-char point))
470 (slime-fuzzy-highlight-current-completion)))
471
472 (defun slime-fuzzy-prev ()
473 "Moves point directly to the previous completion in the
474 completions buffer."
475 (interactive)
476 (with-current-buffer (slime-get-fuzzy-buffer)
477 (let ((point (previous-single-char-property-change
478 (point)
479 'completion nil slime-fuzzy-first)))
480 (set-window-point (get-buffer-window (current-buffer)) point)
481 (goto-char point))
482 (slime-fuzzy-highlight-current-completion)))
483
484 (defun slime-fuzzy-highlight-current-completion ()
485 "Highlights the current completion,
486 so that the user can see it on the screen."
487 (let ((pos (point)))
488 (when (overlayp slime-fuzzy-current-completion-overlay)
489 (move-overlay slime-fuzzy-current-completion-overlay
490 (point) (1- (search-forward " ")))
491 (overlay-put slime-fuzzy-current-completion-overlay
492 'face 'secondary-selection))
493 (goto-char pos)))
494
495 (defun slime-fuzzy-abort ()
496 "Aborts the completion process, setting the completions slot in
497 the target buffer back to its original contents."
498 (interactive)
499 (when slime-fuzzy-target-buffer
500 (slime-fuzzy-done)))
501
502 (defun slime-fuzzy-select ()
503 "Selects the current completion, making sure that it is inserted
504 into the target buffer. This tells the connected Lisp what completion
505 was selected."
506 (interactive)
507 (when slime-fuzzy-target-buffer
508 (with-current-buffer (slime-get-fuzzy-buffer)
509 (let ((completion (get-text-property (point) 'completion)))
510 (when completion
511 (slime-fuzzy-insert (first completion))
512 (slime-fuzzy-selected slime-fuzzy-original-text
513 completion)
514 (slime-fuzzy-done))))))
515
516 (defun slime-fuzzy-select-or-update-completions ()
517 "If there were no changes since the last time fuzzy completion was started
518 this function will select the current completion.
519 Otherwise refreshes the completion list based on the changes made."
520 (interactive)
521 ; (slime-log-event "Selecting or updating completions")
522 (if (string-equal slime-fuzzy-original-text
523 (buffer-substring slime-fuzzy-start
524 slime-fuzzy-end))
525 (slime-fuzzy-select)
526 (slime-fuzzy-complete-symbol)))
527
528 (defun slime-fuzzy-process-event-in-completions-buffer ()
529 "Simply processes the event in the target buffer"
530 (interactive)
531 (with-current-buffer (slime-get-fuzzy-buffer)
532 (push last-input-event unread-command-events)))
533
534 (defun slime-fuzzy-select-and-process-event-in-target-buffer ()
535 "Selects the current completion, making sure that it is inserted
536 into the target buffer and processes the event in the target buffer."
537 (interactive)
538 ; (slime-log-event "Selecting and processing event in target buffer")
539 (when slime-fuzzy-target-buffer
540 (let ((buff slime-fuzzy-target-buffer))
541 (slime-fuzzy-select)
542 (with-current-buffer buff
543 (slime-fuzzy-disable-target-buffer-completions-mode)
544 (push last-input-event unread-command-events)))))
545
546 (defun slime-fuzzy-select/mouse (event)
547 "Handle a mouse-2 click on a completion choice as if point were
548 on the completion choice and the slime-fuzzy-select command was
549 run."
550 (interactive "e")
551 (with-current-buffer (window-buffer (posn-window (event-end event)))
552 (save-excursion
553 (goto-char (posn-point (event-end event)))
554 (when (get-text-property (point) 'mouse-face)
555 (slime-fuzzy-insert-from-point)
556 (slime-fuzzy-select)))))
557
558 (defun slime-fuzzy-done ()
559 "Cleans up after the completion process. This removes all hooks,
560 and attempts to restore the window configuration. If this fails,
561 it just burys the completions buffer and leaves the window
562 configuration alone."
563 (when slime-fuzzy-target-buffer
564 (set-buffer slime-fuzzy-target-buffer)
565 (slime-fuzzy-disable-target-buffer-completions-mode)
566 (if (slime-fuzzy-maybe-restore-window-configuration)
567 (bury-buffer (slime-get-fuzzy-buffer))
568 ;; We couldn't restore the windows, so just bury the fuzzy
569 ;; completions buffer and let something else fill it in.
570 (pop-to-buffer (slime-get-fuzzy-buffer))
571 (bury-buffer))
572 (if (slime-minibuffer-p slime-fuzzy-target-buffer)
573 (select-window (minibuffer-window))
574 (pop-to-buffer slime-fuzzy-target-buffer))
575 (goto-char slime-fuzzy-end)
576 (setq slime-fuzzy-target-buffer nil)
577 (remove-hook 'window-configuration-change-hook
578 'slime-fuzzy-window-configuration-change)))
579
580 (defun slime-fuzzy-maybe-restore-window-configuration ()
581 "Restores the saved window configuration if it has not been
582 nullified."
583 (when (boundp 'window-configuration-change-hook)
584 (remove-hook 'window-configuration-change-hook
585 'slime-fuzzy-window-configuration-change))
586 (if (not slime-fuzzy-saved-window-configuration)
587 nil
588 (set-window-configuration slime-fuzzy-saved-window-configuration)
589 (setq slime-fuzzy-saved-window-configuration nil)
590 t))
591
592 (defun slime-fuzzy-window-configuration-change ()
593 "Called on window-configuration-change-hook. Since the window
594 configuration was changed, we nullify our saved configuration."
595 (setq slime-fuzzy-saved-window-configuration nil))
596
597 (provide 'slime-fuzzy)

  ViewVC Help
Powered by ViewVC 1.1.5