2015-05-19 06:28:02 +00:00
|
|
|
|
;;; corelv.el --- Other echo area
|
2015-02-20 05:27:08 +00:00
|
|
|
|
|
|
|
|
|
;; Copyright (C) 2015 Free Software Foundation, Inc.
|
|
|
|
|
|
|
|
|
|
;; Author: Oleh Krehel
|
|
|
|
|
|
|
|
|
|
;; This file is part of GNU Emacs.
|
|
|
|
|
|
|
|
|
|
;; GNU Emacs is free software: you can redistribute it and/or modify
|
|
|
|
|
;; it under the terms of the GNU General Public License as published by
|
|
|
|
|
;; the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
;; (at your option) any later version.
|
|
|
|
|
|
|
|
|
|
;; GNU Emacs is distributed in the hope that it will be useful,
|
|
|
|
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
;; GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
;; You should have received a copy of the GNU General Public License
|
|
|
|
|
;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
|
|
;;; Commentary:
|
|
|
|
|
;;
|
2015-05-19 06:28:02 +00:00
|
|
|
|
;; This package provides `corelv-message' intended to be used in place of
|
2015-02-20 05:27:08 +00:00
|
|
|
|
;; `message' when semi-permanent hints are needed, in order to not
|
|
|
|
|
;; interfere with Echo Area.
|
|
|
|
|
;;
|
|
|
|
|
;; "Я тихо-тихо пiдглядаю,
|
|
|
|
|
;; І тiшуся собi, як бачу то,
|
|
|
|
|
;; Шо страшить i не пiдпускає,
|
|
|
|
|
;; А iншi п’ють тебе, як воду пiсок."
|
|
|
|
|
;; -- Андрій Кузьменко, L.V.
|
|
|
|
|
|
|
|
|
|
;;; Code:
|
|
|
|
|
|
2015-10-19 03:31:57 +00:00
|
|
|
|
(defgroup corelv nil
|
|
|
|
|
"The other echo area."
|
|
|
|
|
:group 'minibuffer
|
|
|
|
|
:group 'hydra)
|
|
|
|
|
|
|
|
|
|
(defcustom corelv-use-separator nil
|
|
|
|
|
"Whether to draw a line between the LV window and the Echo Area."
|
|
|
|
|
:group 'corelv
|
|
|
|
|
:type 'boolean)
|
|
|
|
|
|
|
|
|
|
(defface corelv-separator
|
|
|
|
|
'((((class color) (background light)) :background "grey80")
|
|
|
|
|
(((class color) (background dark)) :background "grey30"))
|
|
|
|
|
"Face used to draw line between the corelv window and the echo area.
|
|
|
|
|
This is only used if option `corelv-use-separator' is non-nil.
|
|
|
|
|
Only the background color is significant."
|
|
|
|
|
:group 'corelv)
|
|
|
|
|
|
2015-05-19 06:28:02 +00:00
|
|
|
|
(defvar corelv-wnd nil
|
2015-02-20 05:27:08 +00:00
|
|
|
|
"Holds the current LV window.")
|
|
|
|
|
|
2015-05-19 06:28:02 +00:00
|
|
|
|
(defun corelv-window ()
|
2015-02-20 05:27:08 +00:00
|
|
|
|
"Ensure that LV window is live and return it."
|
2015-05-19 06:28:02 +00:00
|
|
|
|
(if (window-live-p corelv-wnd)
|
|
|
|
|
corelv-wnd
|
2015-02-20 05:27:08 +00:00
|
|
|
|
(let ((ori (selected-window))
|
|
|
|
|
buf)
|
2015-05-19 06:28:02 +00:00
|
|
|
|
(prog1 (setq corelv-wnd
|
2015-02-20 05:27:08 +00:00
|
|
|
|
(select-window
|
2015-10-19 03:31:57 +00:00
|
|
|
|
(let ((ignore-window-parameters t))
|
|
|
|
|
(split-window
|
|
|
|
|
(frame-root-window) -1 'below))))
|
2015-02-20 05:27:08 +00:00
|
|
|
|
(if (setq buf (get-buffer "*LV*"))
|
|
|
|
|
(switch-to-buffer buf)
|
|
|
|
|
(switch-to-buffer "*LV*")
|
2015-10-19 03:31:57 +00:00
|
|
|
|
(set-window-hscroll corelv-wnd 0)
|
|
|
|
|
(setq window-size-fixed t)
|
2015-02-20 05:27:08 +00:00
|
|
|
|
(setq mode-line-format nil)
|
|
|
|
|
(setq cursor-type nil)
|
2015-10-19 03:31:57 +00:00
|
|
|
|
(set-window-dedicated-p corelv-wnd t)
|
|
|
|
|
(set-window-parameter corelv-wnd 'no-other-window t))
|
2015-02-20 05:27:08 +00:00
|
|
|
|
(select-window ori)))))
|
|
|
|
|
|
2015-10-19 03:31:57 +00:00
|
|
|
|
(defvar golden-ratio-mode)
|
|
|
|
|
|
|
|
|
|
(defvar corelv-force-update nil
|
|
|
|
|
"When non-nil, `corelv-message' will refresh even for the same string.")
|
|
|
|
|
|
2015-05-19 06:28:02 +00:00
|
|
|
|
(defun corelv-message (format-string &rest args)
|
2015-02-20 05:27:08 +00:00
|
|
|
|
"Set LV window contents to (`format' FORMAT-STRING ARGS)."
|
2015-10-19 03:31:57 +00:00
|
|
|
|
(let* ((str (apply #'format format-string args))
|
|
|
|
|
(n-lines (cl-count ?\n str))
|
|
|
|
|
deactivate-mark
|
|
|
|
|
golden-ratio-mode)
|
|
|
|
|
(with-selected-window (corelv-window)
|
|
|
|
|
(unless (and (string= (buffer-string) str)
|
|
|
|
|
(null corelv-force-update))
|
|
|
|
|
(delete-region (point-min) (point-max))
|
|
|
|
|
(insert str)
|
|
|
|
|
(when (and (window-system) corelv-use-separator)
|
|
|
|
|
(unless (looking-back "\n" nil)
|
|
|
|
|
(insert "\n"))
|
|
|
|
|
(insert
|
|
|
|
|
(propertize "__" 'face 'corelv-separator 'display '(space :height (1)))
|
|
|
|
|
(propertize "\n" 'face 'corelv-separator 'line-height t)))
|
|
|
|
|
(setq-local window-min-height n-lines)
|
|
|
|
|
(setq truncate-lines (> n-lines 1))
|
|
|
|
|
(let ((window-resize-pixelwise t)
|
|
|
|
|
(window-size-fixed nil))
|
|
|
|
|
(fit-window-to-buffer nil nil 1)))
|
|
|
|
|
(goto-char (point-min)))))
|
|
|
|
|
|
|
|
|
|
(defun corelv-delete-window ()
|
|
|
|
|
"Delete LV window and kill its buffer."
|
|
|
|
|
(when (window-live-p corelv-wnd)
|
|
|
|
|
(let ((buf (window-buffer corelv-wnd)))
|
|
|
|
|
(delete-window corelv-wnd)
|
|
|
|
|
(kill-buffer buf))))
|
2015-02-20 05:27:08 +00:00
|
|
|
|
|
2015-05-19 06:28:02 +00:00
|
|
|
|
(provide 'corelv)
|
2015-02-20 05:27:08 +00:00
|
|
|
|
|
2015-05-19 06:28:02 +00:00
|
|
|
|
;;; corelv.el ends here
|