From a0dba8f86a2ace7e800a9dc8f814767625a509af Mon Sep 17 00:00:00 2001 From: Matus Goljer Date: Wed, 10 May 2023 13:24:09 +0200 Subject: [PATCH] feat: add hook run after data is rendered in the result buffer This can be used for custom window alignment routines based on the number of rows or some additional text insertion in the buffer. --- lsp-mssql.el | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lsp-mssql.el b/lsp-mssql.el index 7db031b..b9bd74f 100644 --- a/lsp-mssql.el +++ b/lsp-mssql.el @@ -262,6 +262,11 @@ PARAMS the params." (goto-char (1+ start)) (delete-char -1)))) +(defvar lsp-mssql-after-render-table-hook nil + "Hook called after data is rendered in the result buffer. + +When the hook is called, the point is at the end of the buffer.") + (defun lsp-mssql--result-set-complete (workspace params) "Result set complete handler. WORKSPACE is the active workspace. @@ -343,7 +348,8 @@ PARAMS the params." (insert (lsp-mssql--render-table result)) (org-table-align) (forward-line 1) - (render-load-more))) + (render-load-more) + (run-hooks 'lsp-mssql-after-render-table-hook))) :mode 'detached)))) 'keymap (-doto (make-sparse-keymap) (define-key [M-return] 'push-button) @@ -352,7 +358,8 @@ PARAMS the params." (insert "\n\n") (goto-char (marker-position marker)) (org-table-align) - (display-buffer (current-buffer)))) + (display-buffer (current-buffer)) + (run-hooks 'lsp-mssql-after-render-table-hook))) :mode 'detached)))))) (defun lsp-mssql--batch-complete (_workspace _params)