Skip to content

Instantly share code, notes, and snippets.

@TauPan
Last active November 12, 2021 15:04
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TauPan/6e14ba7059598e721c2874a8f0ac9207 to your computer and use it in GitHub Desktop.
Save TauPan/6e14ba7059598e721c2874a8f0ac9207 to your computer and use it in GitHub Desktop.
(setq weechat-timestamp-regex
"\\([0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\}\\)?[[:blank:]]?\\([0-9]\\{2\\}:[0-9]\\{2\\}:[0-9]\\{2\\}\\)")
(setq weechat-timestamp-prefix-regex
(format "^[[:blank:]]*%s"
weechat-timestamp-regex))
(setq weechat-info-line-regex
(format "%s[[:blank:]]+\\(<?-->?\\)[[:blank:]]+\\(.+\\)"
weechat-timestamp-prefix-regex))
(setq weechat-msg-line-regex
(format "%s[[:blank:]]+\\([^[:blank:]]+\\)[[:blank:]]+\\(.+\\)"
weechat-timestamp-prefix-regex))
(setq weechat-log-mode-keywords
`((,weechat-timestamp-regex 1 font-lock-function-name-face t t)
(,weechat-timestamp-regex 2 font-lock-function-name-face t t)
(,weechat-info-line-regex 3 font-lock-warning-face t t)
(,weechat-info-line-regex 4 font-lock-comment-face t t)
(,weechat-msg-line-regex 3 font-lock-keyword-face nil t)
(,weechat-msg-line-regex 4 bold nil t)))
(define-derived-mode weechat-log-mode fundamental-mode "weechat-log"
"major mode for viewing weechat logfiles"
(setq
font-lock-defaults '(weechat-log-mode-keywords t)))
(provide 'weechat-log-mode)
@TauPan
Copy link
Author

TauPan commented Nov 12, 2021

I've made some progress in the current revision but some lines do not match.

http://ergoemacs.org/emacs/elisp_font_lock_mode.html helped a lot here.

@TauPan
Copy link
Author

TauPan commented Nov 12, 2021

I've made some progress in the current revision but some lines do not match.

http://ergoemacs.org/emacs/elisp_font_lock_mode.html helped a lot here.

Looking better now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment