Add hydra lv.el to display micro-state in a window
This commit is contained in:
parent
9ad7ce5236
commit
0a5442e44a
|
@ -10,6 +10,7 @@
|
|||
;; This file is not part of GNU Emacs.
|
||||
;;
|
||||
;;; License: GPLv3
|
||||
(require 'lv)
|
||||
|
||||
(defun spacemacs//defface-micro-state-faces ()
|
||||
"Define faces for micro-states."
|
||||
|
@ -71,9 +72,10 @@ Available PROPS:
|
|||
`(defun ,func ()
|
||||
,(format "%s micro-state." (symbol-name name))
|
||||
(interactive)
|
||||
(let ((doc ,@doc)) (when doc
|
||||
(echo (spacemacs//micro-state-propertize-doc
|
||||
(concat ,(symbol-name name) ": " doc)))))
|
||||
(let ((doc ,@doc))
|
||||
(when doc
|
||||
(lv-message (spacemacs//micro-state-propertize-doc
|
||||
(concat ,(symbol-name name) ": " doc)))))
|
||||
,@on-enter
|
||||
(,(if (version< emacs-version "24.4")
|
||||
'set-temporary-overlay-map
|
||||
|
@ -102,16 +104,16 @@ Available PROPS:
|
|||
"Auto-generated function"
|
||||
(interactive)
|
||||
(when ',wrapped
|
||||
(call-interactively ',wrapped))
|
||||
(let ((bdoc ,@binding-doc)
|
||||
(defdoc ,@default-doc))
|
||||
(if bdoc
|
||||
(echo (spacemacs//micro-state-propertize-doc
|
||||
(concat ,(symbol-name name) ": " bdoc)))
|
||||
(when defdoc
|
||||
(echo (spacemacs//micro-state-propertize-doc
|
||||
(concat ,(symbol-name name) ": "
|
||||
defdoc))))))))))
|
||||
(call-interactively ',wrapped)
|
||||
(let ((bdoc ,@binding-doc)
|
||||
(defdoc ,@default-doc))
|
||||
(if bdoc
|
||||
(lv-message (spacemacs//micro-state-propertize-doc
|
||||
(concat ,(symbol-name name) ": " bdoc)))
|
||||
(when defdoc
|
||||
(lv-message (spacemacs//micro-state-propertize-doc
|
||||
(concat ,(symbol-name name) ": "
|
||||
defdoc)))))))))))
|
||||
(append (list (car binding) wrapper-func) binding)))
|
||||
|
||||
(defun spacemacs//micro-state-fill-map-sexps (wrappers)
|
||||
|
@ -132,7 +134,10 @@ micro-state."
|
|||
(spacemacs//micro-state-stay? ',name x))
|
||||
',wrappers)
|
||||
:initial-value nil)
|
||||
't ,@on-exit nil)))))
|
||||
't
|
||||
,@on-exit
|
||||
(spacemacs//micro-state-close-window)
|
||||
nil)))))
|
||||
|
||||
(defun spacemacs//micro-state-stay? (name wrapper)
|
||||
"Return non nil if WRAPPER does not leave the micro-state."
|
||||
|
@ -167,4 +172,11 @@ micro-state."
|
|||
(concat head pkey tail))
|
||||
doc))
|
||||
|
||||
(defun spacemacs//micro-state-close-window ()
|
||||
"Close micro-state help window."
|
||||
(when (window-live-p lv-wnd)
|
||||
(let ((buf (window-buffer lv-wnd)))
|
||||
(delete-window lv-wnd)
|
||||
(kill-buffer buf))))
|
||||
|
||||
(provide 'core-micro-state)
|
||||
|
|
|
@ -0,0 +1,73 @@
|
|||
;;; lv.el --- Other echo area
|
||||
|
||||
;; 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:
|
||||
;;
|
||||
;; This package provides `lv-message' intended to be used in place of
|
||||
;; `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:
|
||||
|
||||
(defvar lv-wnd nil
|
||||
"Holds the current LV window.")
|
||||
|
||||
(defun lv-window ()
|
||||
"Ensure that LV window is live and return it."
|
||||
(if (window-live-p lv-wnd)
|
||||
lv-wnd
|
||||
(let ((ori (selected-window))
|
||||
buf)
|
||||
(prog1 (setq lv-wnd
|
||||
(select-window
|
||||
(split-window
|
||||
(frame-root-window) -1 'below)))
|
||||
(if (setq buf (get-buffer "*LV*"))
|
||||
(switch-to-buffer buf)
|
||||
(switch-to-buffer "*LV*")
|
||||
(setq truncate-lines nil)
|
||||
(setq mode-line-format nil)
|
||||
(setq cursor-type nil)
|
||||
(set-window-dedicated-p lv-wnd t))
|
||||
(select-window ori)))))
|
||||
|
||||
(defun lv-message (format-string &rest args)
|
||||
"Set LV window contents to (`format' FORMAT-STRING ARGS)."
|
||||
(let ((ori (selected-window))
|
||||
(str (apply #'format format-string args))
|
||||
deactivate-mark)
|
||||
(select-window (lv-window))
|
||||
(unless (string= (buffer-string) str)
|
||||
(delete-region (point-min) (point-max))
|
||||
(insert str)
|
||||
(fit-window-to-buffer nil (count-lines (point-min) (point-max)) 1))
|
||||
(goto-char (point-max))
|
||||
(select-window ori)))
|
||||
|
||||
(provide 'lv)
|
||||
|
||||
;;; lv.el ends here
|
|
@ -1101,6 +1101,7 @@ which require an initialization must be listed explicitly in the list.")
|
|||
(add-to-list 'golden-ratio-inhibit-functions
|
||||
'spacemacs/no-golden-ratio-guide-key)
|
||||
(add-to-list 'golden-ratio-exclude-buffer-names " *NeoTree*")
|
||||
(add-to-list 'golden-ratio-exclude-buffer-names "*LV*")
|
||||
|
||||
(spacemacs|diminish golden-ratio-mode " ⊞" " G"))))
|
||||
|
||||
|
|
Loading…
Reference in New Issue