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)"))
(stante-after tracking
(add-hook 'tracking-buffer-added-hook 'oni:update-mowedline-irclist)
(add-hook 'tracking-buffer-removed-hook 'oni:update-mowedline-irclist))
(add-hook 'tracking-buffer-added-hook 'oni:mowedline-buffer-added)
(add-hook 'tracking-buffer-removed-hook 'oni:mowedline-buffer-removed))
(stante-after type-break
(setq type-break-good-rest-interval (* 60 10))

View file

@ -24,6 +24,8 @@
;;; Code:
(require 's)
(require 'shorten)
(require 'tracking)
(require 'mowedline "~/projects/ext/mowedline/mowedline.el")
@ -31,17 +33,23 @@
(defvar oni:mowedline--shown-buffers nil)
;;;###autoload
(defun oni:update-mowedline-irclist ()
(let ((irclist
(with-temp-buffer
(insert (format-mode-line tracking-mode-line-buffers))
(buffer-substring-no-properties (point-min) (point-max)))))
(mowedline-update 'irclist irclist)))
(defun oni:mowedline-buffer-added ()
(setq oni:mowedline--shown-buffers
(cons (buffer-name) oni:mowedline--shown-buffers))
(let ((irclist (shorten-strings oni:mowedline--shown-buffers)))
(mowedline-update 'irclist (s-join "," (mapcar #'cdr 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
(defun oni:update-mailcount ()
"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)
;;; oni-mowedline.el ends here