Add buffer and frame hooks

This commit is contained in:
Yuan Fu 2019-08-13 13:44:28 +08:00
parent 93f89087b8
commit 4c88ceecc6
No known key found for this signature in database
GPG Key ID: 56E19BC57664A442
2 changed files with 14 additions and 1 deletions

View File

@ -23,6 +23,9 @@ It is also available on [[https://melpa.org/#/eldoc-box][MELPA]]
** Face ** Face
- =eldoc-box-border= :: Adjust =:background= of this face for border color. - =eldoc-box-border= :: Adjust =:background= of this face for border color.
- =eldoc-box-body= :: Default face used by childframe. I suggest to use a nice Sans Serif font such as Source Sans Pro, and a lighter or darker background. - =eldoc-box-body= :: Default face used by childframe. I suggest to use a nice Sans Serif font such as Source Sans Pro, and a lighter or darker background.
** Hooks
- =eldoc-box-buffer-hook= :: Hook run after buffer for doc is setup.Run inside the new buffer.
- =eldoc-box-frame-hook= :: Hook run after doc frame is setup but just before it is made visible.Each function runs inside the child frame and receives the main frame as argument.
** Variable ** Variable
- =eldoc-box-max-pixel-width= & =eldoc-box-max-pixel-height= :: Set them according to the screen resolution of your machine. - =eldoc-box-max-pixel-width= & =eldoc-box-max-pixel-height= :: Set them according to the screen resolution of your machine.
- =eldoc-box-only-multi-line= :: Set this to non-nil and eldoc-box only display multi-line message in childframe. One line messages are left in minibuffer. - =eldoc-box-only-multi-line= :: Set this to non-nil and eldoc-box only display multi-line message in childframe. One line messages are left in minibuffer.

View File

@ -116,6 +116,14 @@ It will be passes with two arguments: WIDTH and HEIGHT of the childframe.")
(defvar eldoc-box-fringe-use-same-bg t (defvar eldoc-box-fringe-use-same-bg t
"T means fringe's background color is set to as same as that of default.") "T means fringe's background color is set to as same as that of default.")
(defvar eldoc-box-buffer-hook nil
"Hook run after buffer for doc is setup.
Run inside the new buffer.")
(defvar eldoc-box-frame-hook nil
"Hook run after doc frame is setup but just before it is made visible.
Each function runs inside the new frame and receives the main frame as argument.")
;;;;; Function ;;;;; Function
(defvar eldoc-box--frame nil ;; A backstage variable (defvar eldoc-box--frame nil ;; A backstage variable
"The frame to display doc.") "The frame to display doc.")
@ -186,7 +194,8 @@ You can use C-g to hide the doc."
(setq eldoc-box-hover-mode t) (setq eldoc-box-hover-mode t)
(erase-buffer) (erase-buffer)
(insert str) (insert str)
(goto-char (point-min))) (goto-char (point-min))
(run-hook-with-args 'eldoc-box-buffer-hook))
(eldoc-box--get-frame doc-buffer)))) (eldoc-box--get-frame doc-buffer))))
@ -307,6 +316,7 @@ Checkout `lsp-ui-doc--make-frame', `lsp-ui-doc--move-frame'."
;; set size ;; set size
(eldoc-box--update-childframe-geometry frame window) (eldoc-box--update-childframe-geometry frame window)
(setq eldoc-box--frame frame) (setq eldoc-box--frame frame)
(run-hook-with-args 'eldoc-box-frame-hook main-frame)
(make-frame-visible frame))) (make-frame-visible frame)))