Use windows-1252 encoding for stdin/stdout on Windows
[factor/jcg.git] / misc / fuel / fuel-popup.el
blobb8a967d3b027252e23c85174ae46c678a021c49e
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
10 ;;; Comentary:
12 ;; A minor mode to pop up windows and restore configurations
13 ;; afterwards.
15 ;;; Code:
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))
28 (let ((windows))
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)
34 selected-window))))))
36 (defun fuel-popup--quit ()
37 (interactive)
38 (let ((selected fuel-popup--selected-window)
39 (created fuel-popup--created-window))
40 (bury-buffer)
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"
46 nil nil
47 '(("q" . fuel-popup--quit))
48 (setq buffer-read-only t))
50 (defmacro fuel-popup--define (fun name mode)
51 `(defun ,fun ()
52 (or (get-buffer ,name)
53 (with-current-buffer (get-buffer-create ,name)
54 (funcall ,mode)
55 (fuel-popup-mode)
56 (current-buffer)))))
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))
63 ,@body)))
65 (put 'fuel--with-popup 'lisp-indent-function 1)
68 (provide 'fuel-popup)
69 ;;; fuel-popup.el ends here