Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How about prettier colors in the headers view? #1355

Closed
Alexander-Miller opened this issue Jan 3, 2019 · 21 comments
Closed

How about prettier colors in the headers view? #1355

Alexander-Miller opened this issue Jan 3, 2019 · 21 comments
Labels

Comments

@Alexander-Miller
Copy link

I played around with other mail clients and one thing I really liked about notmuch is that every column has its own face, while in mu4e the entire line's face depends on the flags of the message. So I propose to bring the same behaviour to mu4e. The changes would be reasonably small, and you could still have the subject's face depend on the flags.

I've had success making the necessary changes to mu already, so if you'd like to go ahead with this I can clean my code up and provide a PR. Here's an example of what the headers could then look like. Imo it's much nicer to look at than a single color throughout.

If you want to see for yourself here's my code so far:

(defun mu4e~headers-line-apply-flag-face (msg line)
  line)
(defun mu4e~headers-field-apply-basic-properties (msg field val width)
  (case field
    (:subject
     (propertize 
      (concat 
       (mu4e~headers-thread-prefix (mu4e-message-field msg :thread))
       (truncate-string-to-width val 600))
      'face 
      (let ((flags (mu4e-message-field msg :flags)))
        (cond
         ((memq 'trashed flags) 'mu4e-trashed-face)
         ((memq 'draft flags) 'mu4e-draft-face)
         ((or (memq 'unread flags) (memq 'new flags))
          'mu4e-unread-face)
         ((memq 'flagged flags) 'mu4e-flagged-face)
         ((memq 'replied flags) 'mu4e-replied-face)
         ((memq 'passed flags) 'mu4e-forwarded-face)
         (t 'mu4e-header-face)))))
    (:thread-subject 
     (propertize 
      (mu4e~headers-thread-subject msg)
      'face 'font-lock-doc-face))
    ((:maildir :path :message-id) val)
    ((:to :from :cc :bcc) 
     (propertize
      (mu4e~headers-contact-str val)
      'face 'font-lock-function-name-face))
    (:from-or-to (mu4e~headers-from-or-to msg))
    (:date 
     (propertize
      (format-time-string mu4e-headers-date-format val)
      'face 'font-lock-string-face))
    (:mailing-list (mu4e~headers-mailing-list val))
    (:human-date 
     (propertize 
      (mu4e~headers-human-date msg)
	  'help-echo (format-time-string
				  mu4e-headers-long-date-format
				  (mu4e-msg-field msg :date))
      'face 'font-lock-string-face))
    (:flags 
     (propertize (mu4e~headers-flags-str val)
			     'help-echo (format "%S" val)
                 'face 'font-lock-type-face))
    (:tags 
     (propertize 
      (mapconcat 'identity val ", ")
      'face 'font-lock-builtin-face))
    (:size (mu4e-display-size val))
    (t (mu4e~headers-custom-field msg field))))
@djcb djcb added the rfe label Feb 19, 2019
@thriveth
Copy link

+1
This would be very nice to have! Good choice of colors for various columns can really help the eye along when looking around in the header view.

@thriveth
Copy link

@Alexander-Miller I just tested your code and OMG, it makes my header view so much more pleasing and also, I think, easier to navigate.

@dannyob
Copy link

dannyob commented Jun 20, 2020

@Alexander-Miller agreed! This looks great, Alexander!

@averter
Copy link

averter commented Jul 10, 2020

@Alexander-Miller and @djcb just to let you know that I've stopped seeing the colors display correctly from commit 3715bb0 and onwards. Has anyone else experienced the same?

@pkazmier
Copy link

pkazmier commented Oct 8, 2020

@averter did you solve the issue? I would like colored columns as well.

@averter
Copy link

averter commented Oct 8, 2020

@pkazmier unfortunately no. I was only able to backtrack from where the issue came from. This feature was really great to have/see while it was functioning.
By looking at the commit, it is clear that the functions defined by @Alexander-Miller were deleted (or substituted) by others: for example mu4e~headers-field-apply-basic-properties seems to be replaced by mu4e~headers-field-value. The arguments of some of the functions are different as well, so it is probably not just a case of simply changing the name of the functions.
Since @djcb flagged this as 'new feature' he probably intends to re-implement it in some way at some point.

@Alexander-Miller
Copy link
Author

it is clear that the functions defined by @Alexander-Miller were deleted (or substituted) by others

When did that happen? I am on v1.4.13 and my config still works just fine.

Since @djcb flagged this as 'new feature' he probably intends to re-implement it in some way at some point.

I would've been ready to make a proper PR, I was just wanted some feedback that such a change would be wanted in the first place.

@averter
Copy link

averter commented Oct 11, 2020

it is clear that the functions defined by @Alexander-Miller were deleted (or substituted) by others

When did that happen? I am on v1.4.13 and my config still works just fine.

That's why I asked if anyone else experienced the same (see my previous post). It happened in commit 3715bb0 on the master branch. If I switch branches everything looks ok.

Since @djcb flagged this as 'new feature' he probably intends to re-implement it in some way at some point.

I would've been ready to make a proper PR, I was just wanted some feedback that such a change would be wanted in the first place.

I think that everyone is in "thumbs up" mode for this change :-). For me, I just recently added this to my init file

(setq mu4e-headers-fields '((:human-date . 12)
			    (:flags . 6)
			    (:mailing-list . 10)
			    (:from-or-to . 22)
			    (:subject)))

and noticed that you don't allocate a color to :from-or-to field. Is there a way to also have this field colored? Thanks again for this feature.

@djcb
Copy link
Owner

djcb commented Oct 17, 2020

I wouldn't necessarily want my headers view to be more colorful, but surely don't want to stop other people from doing how. However, I've found the current methods significantly slow down the display.

@Alexander-Miller
Copy link
Author

I wouldn't necessarily want my headers view to be more colorful

It'd all be optional of course.

However, I've found the current methods significantly slow down the display.

How did you measure things? I tried putting a timer around (mu4e-headers-rerun-search) and continually refreshed a search that returned all the 474 mails I have. The version with my additions and default mu4e needed between 0.003s and 0.004s.

My guess is either I don't have enough messages or I am measuring the wrong thing, probably on account of something being asynchronous. Can you point me in the right direction for creating a proper benchmark?

and noticed that you don't allocate a color to :from-or-to field. Is there a way to also have this field colored?

Probably just another branch that needs to be added to the big case statement. I'll look into it.

@djcb
Copy link
Owner

djcb commented Oct 19, 2020

Ah, I judged it just by the time it took to fill my screen; but actually measuring would be better; however note that measuring mu4e-headers-rerun-search measures the sending of the search command to the mu backend; but what we'd be interested to know is the time it takes to render.

So perhaps a first step is adding something for that :) I'll take a look.

@averter
Copy link

averter commented Oct 21, 2020

I wouldn't necessarily want my headers view to be more colorful

It'd all be optional of course.

However, I've found the current methods significantly slow down the display.

How did you measure things? I tried putting a timer around (mu4e-headers-rerun-search) and continually refreshed a search that returned all the 474 mails I have. The version with my additions and default mu4e needed between 0.003s and 0.004s.

My guess is either I don't have enough messages or I am measuring the wrong thing, probably on account of something being asynchronous. Can you point me in the right direction for creating a proper benchmark?

and noticed that you don't allocate a color to :from-or-to field. Is there a way to also have this field colored?

Probably just another branch that needs to be added to the big case statement. I'll look into it.

Thanks for this. Incidentally, after a recent update the case statement stopped working/disappeared.

error in process filter: mu4e~headers-field-apply-basic-properties: Symbol’s function definition is void: case

I couldn't find much info about this command online. Thoughts?
Note: I am using GNU Emacs 26.3 on Linux Mint

@Alexander-Miller
Copy link
Author

case is deprecated, at least in Emacs 27. Not sure what you see in 26.

In 27 if you really want to use it you can manually load cl, and it'll be aliased to cl-case. The correct solution is to use the functions from cl-lib instead.

@averter
Copy link

averter commented Oct 21, 2020

Indeed, it seems to be deprecated also in E 26.3. There's no need to load cl manually though; just replacing case by cl-case makes everything work again. Thanks.

@FrostyX
Copy link

FrostyX commented Jan 1, 2021

When applying this patch, do you guys see unread emails highlighted somehow?

@OlMon
Copy link

OlMon commented Jul 28, 2021

This solution is not working anymore in 1.6.0
I found the following variable: mu4e-headers-field-properties-function
Can I achieve the same result with it? If yes can someone please provide a small example.

Cheers and Thanks for all the work!

@Alexander-Miller
Copy link
Author

I've pulled the new version of mu now, so I am working on an update.

This issue has been stuck for a while now - for understandable reasons, I'd be just as cautious about performance implications if something like this was proposed in treemacs - so I think it's in everyone's best interest if I publish this as an external package.

I'll come back to close this issue once I have something on melpa.

@Alexander-Miller
Copy link
Author

New code is now available at https://github.com/Alexander-Miller/mu4e-column-faces. Feedback is very much welcome.

Next step is getting published on melpa.

@djcb
Copy link
Owner

djcb commented Aug 2, 2021

Nice work!

Obligatory note that relying on ~ internal stuff is a bit dangerous, since it tends to change! At least for 1.6 it shouldn't change though.

Oh, (setq mu4e-headers-report-render-time t) might be useful to see the impact on the headers rendering time.

@Alexander-Miller
Copy link
Author

Obligatory note that relying on ~ internal stuff is a bit dangerous, since it tends to change!

The previous version worked for 2 years. I think that's an acceptable pace for me.

Oh, (setq mu4e-headers-report-render-time t) might be useful to see the impact on the headers rendering time.

Done that and refreshed a couple times. Here's the result with mu4e-column-faces:

[mu4e] Found 427 matching messages (rendering took 470.9 ms, 1.10 ms/msg)
[mu4e] Found 427 matching messages (rendering took 500.1 ms, 1.17 ms/msg)
[mu4e] Found 427 matching messages (rendering took 469.1 ms, 1.10 ms/msg)
[mu4e] Found 427 matching messages (rendering took 472.4 ms, 1.11 ms/msg)
[mu4e] Found 427 matching messages (rendering took 513.4 ms, 1.20 ms/msg)

and here's vanilla mu4e:

[mu4e] Found 427 matching messages (rendering took 471.2 ms, 1.10 ms/msg)
[mu4e] Found 427 matching messages (rendering took 491.3 ms, 1.15 ms/msg)
[mu4e] Found 427 matching messages (rendering took 470.8 ms, 1.10 ms/msg)
[mu4e] Found 427 matching messages (rendering took 508.7 ms, 1.19 ms/msg)
[mu4e] Found 427 matching messages (rendering took 469.8 ms, 1.10 ms/msg)

I am on Emacs 28, and native compilation (and maybe define-inline) seems to be a contributing factor, the timings become slightly worse when mu4e-column-faces code is interpreted and not inlined:

[mu4e] Found 427 matching messages (rendering took 506.2 ms, 1.19 ms/msg)
[mu4e] Found 427 matching messages (rendering took 508.9 ms, 1.19 ms/msg)
[mu4e] Found 427 matching messages (rendering took 518.6 ms, 1.21 ms/msg)
[mu4e] Found 427 matching messages (rendering took 475.0 ms, 1.11 ms/msg)
[mu4e] Found 427 matching messages (rendering took 530.3 ms, 1.24 ms/msg)

So all in all performance does not look to be a problem.

@Alexander-Miller
Copy link
Author

mu4e-column-faces is now available on Melpa 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

8 participants