Niluge-KiWi / erc-view-log

erc-view-log is an emacs mode for viewing ERC logs
15 stars 4 forks source link

No fontlocking #1

Open impaktor opened 10 years ago

impaktor commented 10 years ago

Hi! Happy to see this mode, unfortunately, the only effect it has on my erc-logs is setting them as read only. No fontlocking.

Niluge-KiWi commented 10 years ago

Do you have the mode keyboard shortcuts working though? ("g" for reload, "n" and "p" for next and previous own nickname mention).

I only tested this mode with my own log syntax, it's probably broken if you change the timestamp format or other things. It can be fixed by tweaking the regexps here: https://github.com/Niluge-KiWi/erc-view-log/blob/master/erc-view-log.el#L56-L83

impaktor commented 10 years ago

n,p,g keys don't work for me.

alezost in #erc@irc.freenode.net suggested this, which works a bit better:

(defun erc-view-log-get-keywords ()
  "Returns the font-lock-defaults."
      (list
       ;; own message line
       `(,(format "^\\(%s\\)\\(<\\)\\(%s\\)\\(>\\)[ \t]\\(%s\\)$" erc-view-log-timestamp-regexp (erc-log-get-my-nick-regexp) erc-view-log-message-regexp)
     (1 'erc-timestamp-face)
     (2 'erc-default-face)
     (3 'erc-my-nick-face)
     (4 'erc-default-face)
     (5 'erc-input-face) ;; own message
     )
       ;; standard message line
       `(,(format "^\\(%s\\)\\(<\\)\\(%s\\)\\(>\\)[ \t]\\(%s\\)$" erc-view-log-timestamp-regexp erc-view-log-nickname-regexp erc-view-log-message-regexp)
     (1 'erc-timestamp-face)
     (2 'erc-default-face)
     (3 (erc-log-nick-get-face (match-string 3)))
     (4 'erc-default-face)
     (5 'erc-default-face) ;; other message
     )
       ;; current nicks line
       `(,(format "\\(%s\\)\\(%s\\)" erc-view-log-timestamp-regexp erc-view-log-current-nick-regexp)
     (1 'erc-timestamp-face)
     (2 'erc-current-nick-face)
     )
       ;; notice line
       `(,(format "\\(%s\\)\\(%s\\)" erc-view-log-timestamp-regexp erc-view-log-notice-regexp)
     (1 'erc-timestamp-face)
     (2 'erc-notice-face)
     )
       ;; action line
       `(,(format "\\(%s\\)\\(%s\\)" erc-view-log-timestamp-regexp erc-view-log-action-regexp)
     (1 'erc-timestamp-face)
     (2 'erc-action-face)
     )
       ;; command line
       `(,(format "\\(%s\\)\\(%s\\) \\(/.*\\)" erc-view-log-timestamp-regexp erc-view-log-prompt-regexp)
     (1 'erc-timestamp-face)
     (2 'erc-prompt-face)
     (3 'erc-command-indicator-face)
     )
       ))
Niluge-KiWi commented 10 years ago

If you have a working version for you please send me a pull request, I'll look at this and test it on my setup, if it works I'll happily merge it!

alezost commented 10 years ago

Actually i didn't suggest that, i just wanted to say that with spaces in every regexp after ^\\(%s\\) (https://github.com/Niluge-KiWi/erc-view-log/blob/master/erc-view-log.el#L104 and other lines), i don't have highlighting at all. If i remove those spaces, a log is highlighted but it's an ugly jumble of colors.

Tested with default settings (in "emacs -q") - no highlighting.

Emacs 24.3.1, ERC 5.3.

alezost commented 10 years ago

For me erc-log looks like this:

[Mon Jan 20 2014]
*** Topic for #heaven: Heaven is here  [09:31]
*** #heaven: topic set by angel 0-0-0 17:51:32
*** Users on #heaven: man1 man2 man3 man4 man5 man6 man7 man8 man9 man10
    man11 woman1 woman2 woman3 animal @ChanGod
*** #heaven URL: http://heaven.hell
*** #heaven modes: +n
*** #heaven was created on 0-0-0 0:00:00
<man1> man2: hey mate, what do you think about "foo"?  [09:42]
<man2> man1: i think "bar" is better
<man3> ok, now i'm going to write a long message that will be split into
       several lines, and i don't know what it should be about, probably
       about "foo" and "bar"  [09:45]

Niluge-KiWi, is it the same for you?

If I understand correctly, regexps from erc-view-log-get-keywords match something really different.

alezost commented 10 years ago

In every regexp, erc-view-log-timestamp-regexp is placed in the beginning: you probably use erc-insert-timestamp-left for erc-insert-timestamp-function (default value is erc-insert-timestamp-left-and-right). That can explain some problems with highlighting.

alezost commented 10 years ago

Ok, i've noticed a line that explains weirdness with multiple lines: https://github.com/Niluge-KiWi/erc-view-log/blob/master/erc-view-log.el#L20. That's why i didn't see that regexps match auto-filled lines.

I think it would be a big work to make the package highlight logs with any erc configuration.

Niluge-KiWi commented 10 years ago

Ok so indeed we have clearly different log formats. My erc config is here: https://github.com/Niluge-KiWi/dotfiles/blob/master/.emacs.d/erc.el

I use erc-insert-timestamp-left and no erc-fill-mode.

It's relatively easy to handle timestamp at the right, you just have to change the regexp order in erc-view-log-get-keywords, and update erc-view-log-timestamp-regexp.

For the fill mode, we would need to handle multi-line font lock, it seems possible, but I've never tried it and wont since I personally don't need it. But I accept patches!

alezost commented 10 years ago

It's relatively easy to handle timestamp at the right, you just have to change the regexp order in erc-view-log-get-keywords, and update erc-view-log-timestamp-regexp.

Surely, but that means a user with default settings can't use your package without additional hacking. I'm going to modify regexps so that they will match both left and right timestamps. (I've done it actually, i just need some time until i publish the results).

As for matching multiline messages, i also thought it's possible at first, but then i faced a problem that i can't solve.

Niluge-KiWi commented 10 years ago

I have no problem with a default configuration of erc-view-logs that works with the default configuration of erc-mode, as long as I can easily customize it for my needs. The many defvar were there for that, I just kept as default values the values that worked for me.

There is no need for a unique regexp than can work with both modes (left & right timestamps): it can be a "if" that reads the erc-mode variable. If you already have it, it's ok though.

On Tue, Jan 21, 2014 at 2:04 PM, Alex Kost notifications@github.com wrote:

It's relatively easy to handle timestamp at the right, you just have to change the regexp order in erc-view-log-get-keywords, and update erc-view-log-timestamp-regexp.

Surely, but that means a user with default settings can't use your package without additional hacking. I'm going to modify regexps so that they will match both left and right timestamps. (I've done it actually, i just need some time until i publish the results).

As for matching multiline messages, i also thought it's possible at first, but then i faced a problem that i can't solve.

— Reply to this email directly or view it on GitHubhttps://github.com/Niluge-KiWi/erc-view-log/issues/1#issuecomment-32882962 .

alezost commented 10 years ago

I have no problem with a default configuration of erc-view-logs that works with the default configuration of erc-mode, as long as I can easily customize it for my needs. The many defvar were there for that, I just kept as default values the values that worked for me.

My point is: to make erc-view-log-mode work you need to set erc-insert-timestamp-function to erc-insert-timestamp-left or to modify erc-view-log-get-keywords function which is not obvious. Otherwise there is no highlighting at all. And as many people use the default right position for timestamp (i believe at least), they may think the mode is not working.

There is no need for a unique regexp than can work with both modes (left & right timestamps): it can be a "if" that reads the erc-mode variable. If you already have it, it's ok though.

Yes, i know, but what if a man lived with right timestamps for some time and then he decided to switch to another configuration. That's why i thought it would be better to have regexps matching both variants.

Anyway, I have opened a pull request (https://github.com/Niluge-KiWi/erc-view-log/pull/2), so a potential discussion may move there.

Niluge-KiWi commented 10 years ago

On Tue, Jan 21, 2014 at 10:13 PM, Alex Kost notifications@github.comwrote:

I have no problem with a default configuration of erc-view-logs that works with the default configuration of erc-mode, as long as I can easily customize it for my needs. The many defvar were there for that, I just kept as default values the values that worked for me.

My point is: to make erc-view-log-mode work you need to set erc-insert-timestamp-function to erc-insert-timestamp-left or to modify erc-view-log-get-keywords function which is not obvious. Otherwise there is no highlighting at all. And as many people use the default right position for timestamp (i believe at least), they may think the mode is not working.

I understand your point, I think we have the same ideas here: let's make it work with the default erc configuration, and configurable enough so that it may work with other erc configs too, with some customization.

There is no need for a unique regexp than can work with both modes (left & right timestamps): it can be a "if" that reads the erc-mode variable. If you already have it, it's ok though.

Yes, i know, but what if a man lived with right timestamps for some time and then he decided to switch to another configuration. That's why i thought it would be better to have regexps matching both variants.

Oh ok, I hadn't thought of that. However does it highlight both timestamps if someone wrote a message with timestamp-left and that ends with something resembling a timestamp-right?

Anyway, I have opened a pull request (https://github.com/Niluge-KiWi/erc-view-log/pull/2), so a potential discussion may move there.

I'll check that in details soon, thanks.

elevengu commented 10 years ago

I've always wanted this, so I might take a look at it myself if I get the time.