Skip to content

Commit

Permalink
Add functions to neutralize/restore feebleline
Browse files Browse the repository at this point in the history
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 benma/visual-regexp.el#60
  • Loading branch information
p1llule committed Mar 9, 2021
1 parent 71f2b02 commit 2a24db2
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions feebleline.el
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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))
Expand Down

0 comments on commit 2a24db2

Please sign in to comment.