From cd257205edd1b5044a061c83da433ea7cbb89cbb Mon Sep 17 00:00:00 2001 From: Tom Willemse Date: Sun, 28 Aug 2016 01:18:52 +0200 Subject: [PATCH] Make sermon usable with visual-line-mode --- emacs/.emacs.d/vendor-lisp/sermon/sermon.el | 93 +++++++++++++-------- 1 file changed, 58 insertions(+), 35 deletions(-) diff --git a/emacs/.emacs.d/vendor-lisp/sermon/sermon.el b/emacs/.emacs.d/vendor-lisp/sermon/sermon.el index 6e8eacc..f2efcde 100644 --- a/emacs/.emacs.d/vendor-lisp/sermon/sermon.el +++ b/emacs/.emacs.d/vendor-lisp/sermon/sermon.el @@ -59,67 +59,90 @@ (defvar sermon-original-format-server-nick-change nil "The original value of `circe-format-server-nick-change'.") +(defun sermon--fill-string () + (make-string (+ sermon-longest-nick 3) ?\s)) + (defun sermon--update-longest-nick (keywords) (let* ((nick (plist-get keywords :nick)) (len (length nick))) (when (> len sermon-longest-nick) (setq sermon-longest-nick len) - (setq-local lui-fill-type (make-string (+ len 3) ?\s))))) + (when lui-fill-type + (setq-local lui-fill-type (sermon--fill-string)))))) (defun sermon-say-formatter (&rest keywords) (sermon--update-longest-nick keywords) - (lui-format (format "{nick:%ds} {body}" sermon-longest-nick) - keywords)) + (propertize + (lui-format (format "{nick:%ds} {body}" sermon-longest-nick) + keywords) + 'wrap-prefix (sermon--fill-string))) (defun sermon-self-say-formatter (&rest keywords) - (format (format "%%%ds %%s" sermon-longest-nick) - ">" (plist-get keywords :body))) + (propertize (format (format "%%%ds %%s" sermon-longest-nick) + ">" (plist-get keywords :body)) + 'wrap-prefix (sermon--fill-string))) (defun sermon-action-formatter (&rest keywords) - (lui-format - (format "{intro:%ds} {nick} {body}" sermon-longest-nick) - (plist-put keywords :intro "*"))) + (propertize + (lui-format + (format "{intro:%ds} {nick} {body}" sermon-longest-nick) + (plist-put keywords :intro "*")) + 'wrap-prefix (sermon--fill-string))) (defun sermon-server-message-formatter (&rest keywords) - (lui-format - (format "{intro:%ds} {body}" sermon-longest-nick) - (plist-put keywords :intro "***"))) + (propertize + (lui-format + (format "{intro:%ds} {body}" sermon-longest-nick) + (plist-put keywords :intro "***")) + 'wrap-prefix (sermon--fill-string))) (defun sermon-server-join-in-channel-formatter (&rest keywords) - (lui-format - (format "{intro:%ds} Join: {nick} ({userinfo}) joined {channel}" - sermon-longest-nick) - (plist-put keywords :intro ">>>"))) + (propertize + (lui-format + (format "{intro:%ds} Join: {nick} ({userinfo}) joined {channel}" + sermon-longest-nick) + (plist-put keywords :intro ">>>")) + 'wrap-prefix (sermon--fill-string))) (defun sermon-server-join-formatter (&rest keywords) - (lui-format - (format "{intro:%ds} Join: {nick} ({userinfo})" - sermon-longest-nick) - (plist-put keywords :intro ">>>"))) + (propertize + (lui-format + (format "{intro:%ds} Join: {nick} ({userinfo})" + sermon-longest-nick) + (plist-put keywords :intro ">>>")) + 'wrap-prefix (sermon--fill-string))) (defun sermon-server-quit-formatter (&rest keywords) - (lui-format - (format "{intro:%ds} Quit: {nick} ({userhost}) left IRC: {reason}" - sermon-longest-nick) - (plist-put keywords :intro "<<<"))) + (propertize + (lui-format + (format "{intro:%ds} Quit: {nick} ({userhost}) left IRC: {reason}" + sermon-longest-nick) + (plist-put keywords :intro "<<<")) + 'wrap-prefix (sermon--fill-string))) (defun sermon-server-quit-channel-formatter (&rest keywords) - (lui-format - (format "{intro:%ds} Quit: {nick} ({userhost}) left {channel}: {reason}" - sermon-longest-nick) - (plist-put keywords :intro "<<<"))) + (propertize + (lui-format + (format "{intro:%ds} Quit: {nick} ({userhost}) left {channel}: {reason}" + sermon-longest-nick) + (plist-put keywords :intro "<<<")) + 'wrap-prefix (sermon--fill-string))) (defun sermon-server-part-formatter (&rest keywords) - (lui-format - (format "{intro:%ds} Part: {nick} ({userhost}) left {channel}: {reason}" - sermon-longest-nick) - (plist-put keywords :intro "***"))) + (propertize + (lui-format + (format "{intro:%ds} Part: {nick} ({userhost}) left {channel}: {reason}" + sermon-longest-nick) + (plist-put keywords :intro "***")) + 'wrap-prefix (sermon--fill-string))) (defun sermon-server-nick-change-formatter (&rest keywords) - (lui-format - (format "{intro:%ds} Nick change: {old-nick} ({userhost}) is now know as {new-nick}" - sermon-longest-nick) - (plist-put keywords :intro "***"))) + (propertize + (lui-format + (format "{intro:%ds} Nick change: {old-nick} ({userhost}) is now know as {new-nick}" + sermon-longest-nick) + (plist-put keywords :intro "***")) + 'wrap-prefix (sermon--fill-string))) ;;;###autoload (defun enable-sermon ()