-
Notifications
You must be signed in to change notification settings - Fork 1
/
fuel-popup.el
53 lines (40 loc) · 1.58 KB
/
fuel-popup.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
;;; fuel-popup.el -- popup windows -*- lexical-binding: t -*-
;; Copyright (C) 2008 Jose Antonio Ortega Ruiz
;; See https://factorcode.org/license.txt for BSD license.
;; Author: Jose Antonio Ortega Ruiz <[email protected]>
;; Keywords: languages, fuel, factor
;; Start date: Sun Dec 21, 2008 14:37
;;; Comentary:
;; A minor mode to pop up windows and restore configurations
;; afterwards.
;;; Code:
(defvar-local fuel-popup--created-window nil)
(defvar-local fuel-popup--selected-window nil)
(defun fuel-popup--display (&optional buffer display-only)
(when buffer (set-buffer buffer))
(let ((selected-window (selected-window))
(buffer (current-buffer)))
(unless (eq selected-window (get-buffer-window buffer))
(let ((windows))
(walk-windows (lambda (w) (push w windows)) nil t)
(prog1 (if display-only
(display-buffer buffer)
(pop-to-buffer buffer))
(setq-local fuel-popup--created-window
(unless (memq (selected-window) windows) (selected-window)))
(setq-local fuel-popup--selected-window selected-window))))))
(defun fuel-popup--quit ()
(interactive)
(let ((selected fuel-popup--selected-window)
(created fuel-popup--created-window))
(bury-buffer)
(when (eq created (selected-window)) (delete-window created))
(when (window-live-p selected) (select-window selected))))
;;;###autoload
(define-minor-mode fuel-popup-mode
"Mode for displaying read only stuff"
nil nil
'(("q" . fuel-popup--quit))
(setq buffer-read-only t))
(provide 'fuel-popup)
;;; fuel-popup.el ends here