1 ;;; fuel-popup.el -- popup windows
3 ;; Copyright (C) 2008 Jose Antonio Ortega Ruiz
4 ;; See http://factorcode.org/license.txt for BSD license.
6 ;; Author: Jose Antonio Ortega Ruiz <jao@gnu.org>
7 ;; Keywords: languages, fuel, factor
8 ;; Start date: Sun Dec 21, 2008 14:37
12 ;; A minor mode to pop up windows and restore configurations
17 (make-variable-buffer-local
18 (defvar fuel-popup--created-window nil
))
20 (make-variable-buffer-local
21 (defvar fuel-popup--selected-window nil
))
23 (defun fuel-popup--display (&optional buffer
)
24 (when buffer
(set-buffer buffer
))
25 (let ((selected-window (selected-window))
26 (buffer (current-buffer)))
27 (unless (eq selected-window
(get-buffer-window buffer
))
29 (walk-windows (lambda (w) (push w windows
)) nil t
)
30 (prog1 (pop-to-buffer buffer
)
31 (set (make-local-variable 'fuel-popup--created-window
)
32 (unless (memq (selected-window) windows
) (selected-window)))
33 (set (make-local-variable 'fuel-popup--selected-window
)
36 (defun fuel-popup--quit ()
38 (let ((selected fuel-popup--selected-window
)
39 (created fuel-popup--created-window
))
41 (when (eq created
(selected-window)) (delete-window created
))
42 (when (window-live-p selected
) (select-window selected
))))
44 (define-minor-mode fuel-popup-mode
45 "Mode for displaying read only stuff"
47 '(("q" . fuel-popup--quit
))
48 (setq buffer-read-only t
))
50 (defmacro fuel-popup--define
(fun name mode
)
52 (or (get-buffer ,name
)
53 (with-current-buffer (get-buffer-create ,name
)
58 (put 'fuel-popup--define
'lisp-indent-function
1)
60 (defmacro fuel--with-popup
(buffer &rest body
)
61 `(with-current-buffer ,buffer
62 (let ((inhibit-read-only t
))
65 (put 'fuel--with-popup
'lisp-indent-function
1)
69 ;;; fuel-popup.el ends here