From 2a24db2ba6f4ff446bf2d062fe5e7a2bd1e1e923 Mon Sep 17 00:00:00 2001 From: Trust me I am a doctor Date: Tue, 9 Mar 2021 01:41:26 +0000 Subject: [PATCH] Add functions to neutralize/restore feebleline Feebleline is not the only package to use extensively the echo area. visual-regexp also does and have conflicts with feebleline. Theses functions, deactivate feebleline without altering the mode state. They can patch conflicts used in hooks like : (add-hook 'vr/initialize-hook #'initialize-without-feebleline) (add-hook 'vr/end-hook #'end-with-feebleline) See https://github.com/benma/visual-regexp.el/pull/60 --- feebleline.el | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/feebleline.el b/feebleline.el index 039d327..58aee66 100644 --- a/feebleline.el +++ b/feebleline.el @@ -100,6 +100,12 @@ (defvar feebleline--mode-line-format-previous) (defvar feebleline-last-error-shown nil) +(defvar pils--feebleline-transient nil + "Store the transient state of `feebleline-mode', +Used by `initialize-without-feebleline' and `end-with-feebleline', +which can temporarly neutralize feebleline so another function may +take control of the echo area.") + (defface feebleline-git-face '((t :foreground "#444444")) "Example face for git branch." :group 'feebleline) @@ -154,6 +160,24 @@ "Macro for adding B to the feebleline mode-line, at the beginning." `(add-to-list 'feebleline-msg-functions ,@b nil (lambda (x y) nil))) +(defun initialize-without-feebleline () + "Neutralise `feebleline-mode', meant to be used in a hook, + before a conflictual command." + (when feebleline-mode + (setq feebleline-transient-state t) + (cancel-timer feebleline--msg-timer) + (remove-hook 'focus-in-hook 'feebleline--insert-ignore-errors))) + +(defun end-with-feebleline () + "Restore `feebleline-mode', meant to be used in a hook, +after a conflictual command." + (when feebleline-mode + (setq feebleline-transient-state nil) + (setq feebleline--msg-timer + (run-with-timer 0 feebleline-timer-interval + 'feebleline--insert-ignore-errors)) + (add-hook 'focus-in-hook 'feebleline--insert-ignore-errors))) + ;; (feebleline-append-msg-function '((lambda () "end") :pre "//")) ;; (feebleline-append-msg-function '(magit-get-current-branch :post "<-- branch lolz")) ;; (feebleline-prepend-msg-function '((lambda () "-") :face hey-i-want-some-new-fae))