From 6c073d19b0a58ba659c6396e095f80dba70f219a Mon Sep 17 00:00:00 2001 From: Tom Willemse Date: Fri, 4 Mar 2016 12:18:00 +0100 Subject: [PATCH] Update tracked buffers to mowedline in realtime --- emacs/.emacs.d/init.el | 4 ++-- emacs/.emacs.d/site-lisp/oni-mowedline.el | 22 +++++++++++++++------- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/emacs/.emacs.d/init.el b/emacs/.emacs.d/init.el index d0c460a..7d4d1c6 100644 --- a/emacs/.emacs.d/init.el +++ b/emacs/.emacs.d/init.el @@ -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)) diff --git a/emacs/.emacs.d/site-lisp/oni-mowedline.el b/emacs/.emacs.d/site-lisp/oni-mowedline.el index 5b2772f..51e6ecb 100644 --- a/emacs/.emacs.d/site-lisp/oni-mowedline.el +++ b/emacs/.emacs.d/site-lisp/oni-mowedline.el @@ -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