Make sermon usable with visual-line-mode
This commit is contained in:
parent
ced484c62a
commit
cd257205ed
1 changed files with 58 additions and 35 deletions
|
@ -59,67 +59,90 @@
|
||||||
(defvar sermon-original-format-server-nick-change nil
|
(defvar sermon-original-format-server-nick-change nil
|
||||||
"The original value of `circe-format-server-nick-change'.")
|
"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)
|
(defun sermon--update-longest-nick (keywords)
|
||||||
(let* ((nick (plist-get keywords :nick))
|
(let* ((nick (plist-get keywords :nick))
|
||||||
(len (length nick)))
|
(len (length nick)))
|
||||||
(when (> len sermon-longest-nick)
|
(when (> len sermon-longest-nick)
|
||||||
(setq sermon-longest-nick len)
|
(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)
|
(defun sermon-say-formatter (&rest keywords)
|
||||||
(sermon--update-longest-nick keywords)
|
(sermon--update-longest-nick keywords)
|
||||||
|
(propertize
|
||||||
(lui-format (format "{nick:%ds} {body}" sermon-longest-nick)
|
(lui-format (format "{nick:%ds} {body}" sermon-longest-nick)
|
||||||
keywords))
|
keywords)
|
||||||
|
'wrap-prefix (sermon--fill-string)))
|
||||||
|
|
||||||
(defun sermon-self-say-formatter (&rest keywords)
|
(defun sermon-self-say-formatter (&rest keywords)
|
||||||
(format (format "%%%ds %%s" sermon-longest-nick)
|
(propertize (format (format "%%%ds %%s" sermon-longest-nick)
|
||||||
">" (plist-get keywords :body)))
|
">" (plist-get keywords :body))
|
||||||
|
'wrap-prefix (sermon--fill-string)))
|
||||||
|
|
||||||
(defun sermon-action-formatter (&rest keywords)
|
(defun sermon-action-formatter (&rest keywords)
|
||||||
|
(propertize
|
||||||
(lui-format
|
(lui-format
|
||||||
(format "{intro:%ds} {nick} {body}" sermon-longest-nick)
|
(format "{intro:%ds} {nick} {body}" sermon-longest-nick)
|
||||||
(plist-put keywords :intro "*")))
|
(plist-put keywords :intro "*"))
|
||||||
|
'wrap-prefix (sermon--fill-string)))
|
||||||
|
|
||||||
(defun sermon-server-message-formatter (&rest keywords)
|
(defun sermon-server-message-formatter (&rest keywords)
|
||||||
|
(propertize
|
||||||
(lui-format
|
(lui-format
|
||||||
(format "{intro:%ds} {body}" sermon-longest-nick)
|
(format "{intro:%ds} {body}" sermon-longest-nick)
|
||||||
(plist-put keywords :intro "***")))
|
(plist-put keywords :intro "***"))
|
||||||
|
'wrap-prefix (sermon--fill-string)))
|
||||||
|
|
||||||
(defun sermon-server-join-in-channel-formatter (&rest keywords)
|
(defun sermon-server-join-in-channel-formatter (&rest keywords)
|
||||||
|
(propertize
|
||||||
(lui-format
|
(lui-format
|
||||||
(format "{intro:%ds} Join: {nick} ({userinfo}) joined {channel}"
|
(format "{intro:%ds} Join: {nick} ({userinfo}) joined {channel}"
|
||||||
sermon-longest-nick)
|
sermon-longest-nick)
|
||||||
(plist-put keywords :intro ">>>")))
|
(plist-put keywords :intro ">>>"))
|
||||||
|
'wrap-prefix (sermon--fill-string)))
|
||||||
|
|
||||||
(defun sermon-server-join-formatter (&rest keywords)
|
(defun sermon-server-join-formatter (&rest keywords)
|
||||||
|
(propertize
|
||||||
(lui-format
|
(lui-format
|
||||||
(format "{intro:%ds} Join: {nick} ({userinfo})"
|
(format "{intro:%ds} Join: {nick} ({userinfo})"
|
||||||
sermon-longest-nick)
|
sermon-longest-nick)
|
||||||
(plist-put keywords :intro ">>>")))
|
(plist-put keywords :intro ">>>"))
|
||||||
|
'wrap-prefix (sermon--fill-string)))
|
||||||
|
|
||||||
(defun sermon-server-quit-formatter (&rest keywords)
|
(defun sermon-server-quit-formatter (&rest keywords)
|
||||||
|
(propertize
|
||||||
(lui-format
|
(lui-format
|
||||||
(format "{intro:%ds} Quit: {nick} ({userhost}) left IRC: {reason}"
|
(format "{intro:%ds} Quit: {nick} ({userhost}) left IRC: {reason}"
|
||||||
sermon-longest-nick)
|
sermon-longest-nick)
|
||||||
(plist-put keywords :intro "<<<")))
|
(plist-put keywords :intro "<<<"))
|
||||||
|
'wrap-prefix (sermon--fill-string)))
|
||||||
|
|
||||||
(defun sermon-server-quit-channel-formatter (&rest keywords)
|
(defun sermon-server-quit-channel-formatter (&rest keywords)
|
||||||
|
(propertize
|
||||||
(lui-format
|
(lui-format
|
||||||
(format "{intro:%ds} Quit: {nick} ({userhost}) left {channel}: {reason}"
|
(format "{intro:%ds} Quit: {nick} ({userhost}) left {channel}: {reason}"
|
||||||
sermon-longest-nick)
|
sermon-longest-nick)
|
||||||
(plist-put keywords :intro "<<<")))
|
(plist-put keywords :intro "<<<"))
|
||||||
|
'wrap-prefix (sermon--fill-string)))
|
||||||
|
|
||||||
(defun sermon-server-part-formatter (&rest keywords)
|
(defun sermon-server-part-formatter (&rest keywords)
|
||||||
|
(propertize
|
||||||
(lui-format
|
(lui-format
|
||||||
(format "{intro:%ds} Part: {nick} ({userhost}) left {channel}: {reason}"
|
(format "{intro:%ds} Part: {nick} ({userhost}) left {channel}: {reason}"
|
||||||
sermon-longest-nick)
|
sermon-longest-nick)
|
||||||
(plist-put keywords :intro "***")))
|
(plist-put keywords :intro "***"))
|
||||||
|
'wrap-prefix (sermon--fill-string)))
|
||||||
|
|
||||||
(defun sermon-server-nick-change-formatter (&rest keywords)
|
(defun sermon-server-nick-change-formatter (&rest keywords)
|
||||||
|
(propertize
|
||||||
(lui-format
|
(lui-format
|
||||||
(format "{intro:%ds} Nick change: {old-nick} ({userhost}) is now know as {new-nick}"
|
(format "{intro:%ds} Nick change: {old-nick} ({userhost}) is now know as {new-nick}"
|
||||||
sermon-longest-nick)
|
sermon-longest-nick)
|
||||||
(plist-put keywords :intro "***")))
|
(plist-put keywords :intro "***"))
|
||||||
|
'wrap-prefix (sermon--fill-string)))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun enable-sermon ()
|
(defun enable-sermon ()
|
||||||
|
|
Loading…
Reference in a new issue