Update tracked buffers to mowedline in realtime

This commit is contained in:
Tom Willemse 2016-03-04 12:18:00 +01:00
parent 7ee6fd8ae5
commit 6c073d19b0
2 changed files with 17 additions and 9 deletions

View file

@ -431,8 +431,8 @@ MODE1 is enabled and vice-versa."
(setq time-stamp-format "%04y-%02m-%02d %02H:%02M:%02S (%u)")) (setq time-stamp-format "%04y-%02m-%02d %02H:%02M:%02S (%u)"))
(stante-after tracking (stante-after tracking
(add-hook 'tracking-buffer-added-hook 'oni:update-mowedline-irclist) (add-hook 'tracking-buffer-added-hook 'oni:mowedline-buffer-added)
(add-hook 'tracking-buffer-removed-hook 'oni:update-mowedline-irclist)) (add-hook 'tracking-buffer-removed-hook 'oni:mowedline-buffer-removed))
(stante-after type-break (stante-after type-break
(setq type-break-good-rest-interval (* 60 10)) (setq type-break-good-rest-interval (* 60 10))

View file

@ -24,6 +24,8 @@
;;; Code: ;;; Code:
(require 's)
(require 'shorten)
(require 'tracking) (require 'tracking)
(require 'mowedline "~/projects/ext/mowedline/mowedline.el") (require 'mowedline "~/projects/ext/mowedline/mowedline.el")
@ -31,17 +33,23 @@
(defvar oni:mowedline--shown-buffers nil) (defvar oni:mowedline--shown-buffers nil)
;;;###autoload ;;;###autoload
(defun oni:update-mowedline-irclist () (defun oni:mowedline-buffer-added ()
(let ((irclist (setq oni:mowedline--shown-buffers
(with-temp-buffer (cons (buffer-name) oni:mowedline--shown-buffers))
(insert (format-mode-line tracking-mode-line-buffers)) (let ((irclist (shorten-strings oni:mowedline--shown-buffers)))
(buffer-substring-no-properties (point-min) (point-max))))) (mowedline-update 'irclist (s-join "," (mapcar #'cdr irclist)))))
(mowedline-update 'irclist irclist)))
;;;###autoload
(defun oni:mowedline-buffer-removed ()
(setq oni:mowedline--shown-buffers
(delete (buffer-name) oni:mowedline--shown-buffers))
(let ((irclist (shorten-strings oni:mowedline--shown-buffers)))
(mowedline-update 'irclist (s-join "," (mapcar #'cdr irclist)))))
;;;###autoload ;;;###autoload
(defun oni:update-mailcount () (defun oni:update-mailcount ()
"Update the mailcount in the wm." "Update the mailcount in the wm."
(shell-command-to-string "new-mail-mowedline")) (shell-command-to-string "~/usr/bin/new-mail-mowedline"))
(provide 'oni-mowedline) (provide 'oni-mowedline)
;;; oni-mowedline.el ends here ;;; oni-mowedline.el ends here