Skip to content

Commit

Permalink
Add DIY section about org-modern-label
Browse files Browse the repository at this point in the history
  • Loading branch information
protesilaos committed Sep 22, 2022
1 parent ad1b709 commit 79bb143
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions README.org
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,47 @@ code that uses ~ef-themes-with-colors~.
This section documents how the user can further tweak the Ef themes to
their liking.

** Style font of =org-modern= elements
:PROPERTIES:
:CUSTOM_ID: h:32e3b7b2-3b53-4ec2-bd4e-fa24235e447d
:END:

[ Part of {{{development-version}}} ]

The =org-modern= package uses faces and text properties to make Org
buffers more aesthetically pleasing. It affects tables, timestamps,
lists, headings, and more. To achieve a uniform look, the package
defines a face that applies to all of those restyled elements. The face
is ~org-modern-label~.

Depending on the user's font configurations, some elements may not line
up properly. The Ef themes used to prevent that phenomenon by expressly
disabling all attributes of the ~org-modern-label~. However, that only
works for users who do not tinker with their packages, as it has the
adverse effect of impacting the user option ~org-modern-label-border~.

As such, the Ef themes no longer touch the ~org-modern-label~. Users
who want the old behaviour, are advised to include the following snipet
in their init file. They can add it, for example, after the call to
load their theme of choice ([[#h:75d74aea-d17f-497f-a3b8-f0bf4c372de0][Loading a theme]]).

#+begin_src emacs-lisp
;; Revert to previous style of ef-themes version 0.5.0. This makes,
;; e.g., timestamps align in tables since they have the same typographic
;; attributes as the default typeface.
(set-face-attribute 'org-modern-label nil
:inherit 'unspecified
:height 'unspecified
:weight 'unspecified
:width 'unspecified
:underline 'unspecified
:box 'unspecified)
#+end_src

Alignment in tables will also depend on the use of proportionately
spaced fonts. Enable the relevant option to work with those without any
further trouble ([[#h:621d3bb9-5967-4f97-b253-7470bba9168c][Enable mixed fonts]]).

** The general approach to advanced DIY changes
:PROPERTIES:
:CUSTOM_ID: h:ec0adf54-c037-4c53-81b8-7eab2303794d
Expand Down

5 comments on commit 79bb143

@protesilaos
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@minad Do you think this is okay? I will include it in the change log as well.

@minad
Copy link

@minad minad commented on 79bb143 Sep 22, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resetting the face is fine from the side of the user, if the user doesn't like the adjusted size of the labels. See also the docstring of org-modern-label. You could mention face-spec-reset-face as an alternative and put it in a with-eval-after-load block for org-modern. You should also recommend to set org-modern-label-border to nil to disable the "label effect", used to emulate the look from Rougier's svg-tag-mode.

What you write about alignment is not correct. The problem is that org-modern doesn't only modify the faces, but it also adds display properties. This affects for example TODO status keywords, which will get a space to the left an right of the keyword, see https://github.com/minad/org-modern/blob/828cf100c62fc9dfb50152c192ac3a968c1b54bc/org-modern.el#L360-L362. Also timestamps with date and time are affected, see https://github.com/minad/org-modern/blob/828cf100c62fc9dfb50152c192ac3a968c1b54bc/org-modern.el#L407-L408. This already destroys alignment, even if you reset the faces. You can observe the alignment issues with text as follows:

# alignment broken (also the stars often break alignment for faces which are not 100% fixed pitch)
* TODO heading
* next heading
- some item

# alignment broken
<2022-09-22 Thu 10:00>
|2022-09-22 Thu 10:00|

# alignment stays intact
<2022-09-22 Thu>
|2022-09-22 Thu|

Preserving fixed pitch alignment isn't a goal of org-modern, but we could discuss introducing a user option org-modern-preserve-alignment if we can still make the end result look pretty. In your case it seems that the main problem is table alignment for clock tables and not alignment in general? In the end the only way to solve the table issues is to use pixel-perfect alignment (minad/org-modern#5). But for now I would just recommend to disable styling all elements which should not break alignment, e.g., org-modern-timestamp=nil.

@protesilaos
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello Daniel and thanks for the detailed explanation!

In your case it seems that the main problem is table alignment for clock tables and not alignment in general?

Yes. This is the only area I identified where someone may notice a major difference when they update to the new version of the themes. I will phrase it better.

But for now I would just recommend to disable styling all elements which should not break alignment, e.g., org-modern-timestamp=nil.

So you mean this without touching the org-modern-label, right? It should work for the case I noticed.

@minad
Copy link

@minad minad commented on 79bb143 Sep 22, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So you mean this without touching the org-modern-label, right? It should work for the case I noticed.

Yes. You can leave the label face alone if all you care is the alignment of timestamps in tables. To fix that it is better to just disable org-modern-timetamp=nil. Maybe it is even possible to do this via some file-local variables such that files without clock tables still get timestamp formatting, in case you like that.

@protesilaos
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!. The simplest solution will do. It is just to inform users in advance before they come asking for it. I will update the document now. The new version will be done tomorrow, most likely.

Please sign in to comment.