]> code.delx.au - gnu-emacs-elpa/blob - packages/minibuffer-line/minibuffer-line.el
Merge commit '0cda39255827f283e7578cd469ae42daad9556a2' from js2-mode
[gnu-emacs-elpa] / packages / minibuffer-line / minibuffer-line.el
1 ;;; minibuffer-line.el --- Display status info in the minibuffer window -*- lexical-binding: t; -*-
2
3 ;; Copyright (C) 2015 Free Software Foundation, Inc.
4
5 ;; Author: Stefan Monnier <monnier@iro.umontreal.ca>
6 ;; Keywords:
7 ;; Version: 0.1
8
9 ;; This program is free software; you can redistribute it and/or modify
10 ;; it under the terms of the GNU General Public License as published by
11 ;; the Free Software Foundation, either version 3 of the License, or
12 ;; (at your option) any later version.
13
14 ;; This program is distributed in the hope that it will be useful,
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ;; GNU General Public License for more details.
18
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with this program. If not, see <http://www.gnu.org/licenses/>.
21
22 ;;; Commentary:
23
24 ;; This package lets you display various status information in the minibuffer
25 ;; window instead of the mode-line. Of course, this is only displayed when the
26 ;; minibuffer window is not already used for other things (e.g. a minibuffer or
27 ;; an each area message).
28 ;;
29 ;; The contents and aspect is controlled by the `minibuffer-line-format'
30 ;; variable and the `minibuffer-line' face. Their current default kind of
31 ;; sucks: suggestions for improvements welcome.
32
33 ;;; Code:
34
35 (defgroup minibuffer-line ()
36 "Use the idle minibuffer window to display status information."
37 :group 'mode-line)
38
39 (defcustom minibuffer-line-format
40 '("" (:eval system-name) " | " (:eval (format-time-string "%F %R")))
41 "Specification of the contents of the minibuffer-line.
42 Uses the same format as `mode-line-format'."
43 :type 'sexp)
44
45 (defface minibuffer-line
46 '((t :inherit mode-line-inactive))
47 "Face to use for the minibuffer-line.")
48
49 (defcustom minibuffer-line-refresh-interval 60
50 "The frequency at which the minibuffer-line is updated, in seconds."
51 :type 'integer)
52
53 (defconst minibuffer-line--buffer " *Minibuf-0*")
54
55 (defvar minibuffer-line--timer nil)
56
57 ;;;###autoload
58 (define-minor-mode minibuffer-line-mode
59 "Display status info in the minibuffer window."
60 :global t
61 (with-current-buffer minibuffer-line--buffer
62 (erase-buffer))
63 (when minibuffer-line--timer
64 (cancel-timer minibuffer-line--timer)
65 (setq minibuffer-line--timer nil))
66 (when minibuffer-line-mode
67 (setq minibuffer-line--timer
68 (run-with-timer t minibuffer-line-refresh-interval
69 #'minibuffer-line--update))
70 (minibuffer-line--update)))
71
72 (defun minibuffer-line--update ()
73 (with-current-buffer minibuffer-line--buffer
74 (erase-buffer)
75 (insert (format-mode-line minibuffer-line-format 'minibuffer-line))))
76
77 (provide 'minibuffer-line)
78 ;;; minibuffer-line.el ends here