Closed roblem closed 3 years ago
Partly addresses #115
The syntax highlighting that you get in org-msg is coming from htmlize
, which uses the coloring from your emacs screen, down to the background color. Hard-coding a background color in the package would be problematic for some themes—consider a user with a dark theme that uses light foreground for fonts, where this would result in light text on a light background.
Of course you can customize this in your own config! Just edit org-msg-default-style
. The colors look great with your emacs theme (I presume a light one) per that screenshot. I've got a few tweaks to the package myself.
Thanks. I completely understand that it wouldn't work with some background colors. Since I am using Leuven (a white background) my customization works great IMO. BTW, I tried several other themes without my customizations and when exporting using C-c C-e from org-msg, default background for src blocks is always white (which surprised me) and at times this made light colored fontified src text very hard to read. It just depends on the theme whether things work.
So is the recommended way of customizing things by editing org-msg-default-style in org-msg.el and re-byte compiling it?
default background for src blocks is always white
Are you sure you're running the original code? I see my emacs background color in src blocks when looking at html emails in gmail.
So is the recommended way of customizing things by editing org-msg-default-style in org-msg.el and re-byte compiling it?
You should be able setq
that variable in your emacs config which will override that variable, and leave the package as-is (so you don't need to maintain your own version). I'm not certain if the fact that it's defined as a constant will affect this, per the defconst
docs:
Define SYMBOL as a constant variable.
This declares that neither programs nor users should ever change the
value. This constancy is not actually enforced by Emacs Lisp, but
SYMBOL is marked as a special variable so that it is never lexically
bound.
Are you sure you're running the original code?
Yes. I just setup a minimal environment and had to install everything from melpa. Screenshot of the email compose buffer (to see theme):
leuven
with preview
tango dark
with preview
so src backgrounds are always white for me.
You should be able setq that variable in your emacs config which will override that variable
Unfortunately, I have been unable to make this work. I have tried things like
(setq org-msg-default-style
(let* ((font-family '(font-family . "\"Arial\""))
(font-size '(font-size . "10pt"))
....
or
(with-eval-after-load "org-msg" ;; or org-msg-mode
(setq org-msg-default-style
(let* ((font-family '(font-family . "\"Arial\""))
(font-size '(font-size . "10pt"))
(font `(,font-family ,font-size))
(line-height '(line-height . "10pt"))
...
and the changes never have an effect on the output. The only way I have been able to make it work is to edit org-msg.el and byte compile it.
I still couldn't tell you about the background color of src blocks (looks quite different for me) but looking at the next sexp in the source showed how to customize the style and this worked in a test:
(setq org-msg-enforce-css
(let* ((font-family '(font-family . "\"Arial\""))
(font-size '(font-size . "10pt"))
...
So is the recommended way of customizing things by editing
org-msg-default-style
in org-msg.el and re-byte compiling it?
No, as @obar mentioned, the right way is to use the org-msg-enforce-css
variable. org-msg-default-style
is the default style and is a constant you should not touch. Even though I am sure plenty of user are modifying but as @obar emphasizes, it creates a maintenance burden to these users . This default style should work well is most cases as it dynamically gets the information from your current theme so that the output always looks similar to what it looks like in your Emacs.
By default, org-msg-enforce-css
contains org-msg-default-style
but you can change that by either redefining entirely this customization variable or by running some emacs-lisp code to perform some automatic changes such as update all the face-background
and face-foreground
colors to fit your preferences.
Also, I suppose that if your background color is not adapting automatically between themes this is because you have not re-evaluate the org-msg-default-style
constant and org-msg-enforce-css
variable between these theme changes.
as @obar mentioned, the right way is to use the
org-msg-enforce-css
variable.
Actually I screwed it up at first :) At any rate, @roblem are you good to close #115 and #116?
Yes thanks for all the help.
This default style should work well is most cases as it dynamically gets the information from your current theme so that the output always looks similar to what it looks like in your Emacs.
To follow up on this: I believe a recent update to emacs in Fedora now allows org-msg to pull the font-faces from emacs so
org-msg-enforce-css
for code block tweaks
This does a few things
The upside is that it looks pretty good:![org-msg-change](https://user-images.githubusercontent.com/1871086/121560245-9f43a080-ca17-11eb-98ba-bcf2bac25099.png)
There are two downsides: