Skip to content

feat(ligatures): use ligature.el for Emacs28+ #5082

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

Merged
merged 1 commit into from
Sep 12, 2023

Conversation

gagbo
Copy link
Member

@gagbo gagbo commented May 23, 2021

As discussed briefly on Discord + Discourse, use https://github.com/mickeynp/ligature.el to handle the composition table for ligatures if using Emacs28+ with Harfbuzz.

This gives an easier API to handle per-user/per-mode configuration (potentially dealing with #4922 ), and all potential fixes can be targeted upstream instead of maintaining the code here (See #5053 ).

All example configuration values is coming from suggestions in upstream package, not much has been changed to enable discussion :

  • Should we keep the "all-prog-mode" defvar as is ?
  • Should extra ligatures go in their :lang modules ? (If so, this PR will not make it, better have other contributions to their respective modules)
  • Should the defvar keep track of all the ligatures available for each font, in a +fira/+iosevka... way ? (If so, this PR will not make the per font change, but I'll try to find a minimal set for the defvar)
  • Should there be a "all-text-mode" defvar as well ? (looking at you, markdown-mode and org-mode)
    Currently the decision is "no", and instead let users customize ligatures in text-modes with set-ligatures!
  • Should there be a "t" defvar as well ?
    Currently done, with a nil default value

PS: thanks @mickeynp for that package, it's been a good relief when we found out about it

@gagbo gagbo requested a review from hlissner as a code owner May 23, 2021 09:36
@hlissner hlissner marked this pull request as draft May 23, 2021 13:49
@hlissner hlissner added is:tweak Code changes that affects user-facing behavior module:ui/ligatures Pertains to Doom's :ui ligatures module labels May 23, 2021
@gagbo
Copy link
Member Author

gagbo commented May 23, 2021

Added ligature.el manipulation in set-ligatures! function so that users keep a single entrypoint.

As discussed, it’s pretty hard to handle inheritance of derived modes, so I think the best way to do it is to allow users to override the only configuration that writes to "high priority" modes through +ligatures-all-modes-list and +ligatures-prog-mode-list and then only use set-ligatures! if they want.

@gagbo gagbo force-pushed the feat/ligature.el branch from abf9442 to b0b3c43 Compare May 26, 2021 09:52
@gagbo
Copy link
Member Author

gagbo commented May 26, 2021

Maybe the defvar could be a plist or an alist, so that instead of having multiple variable for t, prog-mode, text-mode etc., we’d have a single list on which we could mapcar ligature-set-ligatures (car elt) (cdr elt).

Not sure if that’s the better API, but I guess it unclutters the namespace

@gagbo gagbo marked this pull request as ready for review May 26, 2021 09:59
@gagbo gagbo force-pushed the feat/ligature.el branch from b0b3c43 to 3cab75b Compare May 27, 2021 07:58
hlissner added a commit that referenced this pull request Jun 6, 2021
To fix ligatures, at least until I get around to merging #5082
@github-actions

This comment has been minimized.

@github-actions github-actions bot added the stale No response, forgotten, or abandoned label Aug 1, 2021
@hlissner hlissner added status:confirmed Issue was verified, or request approved. Waiting for a working solution. and removed stale No response, forgotten, or abandoned labels Aug 1, 2021
@gagbo gagbo force-pushed the feat/ligature.el branch from 3cab75b to 27f2ecc Compare August 1, 2021 08:22
peterhoeg pushed a commit to peterhoeg/doomemacs that referenced this pull request Aug 2, 2021
To fix ligatures, at least until I get around to merging doomemacs#5082
@gagbo gagbo force-pushed the feat/ligature.el branch 2 times, most recently from c70c38b to 82cc04a Compare August 2, 2021 19:11
@gagbo
Copy link
Member Author

gagbo commented Sep 30, 2021

(pong ; don't stale me bot)

I don't remember the blocker, it was something around the API of set-ligatures! that didn't integrate ligatures.el and prettify-symbols-mode seamlessly enough, but I don't remember what

@gagbo gagbo changed the base branch from develop to master January 13, 2022 21:59
@hlissner hlissner changed the title feat(:ui ligatures): use ligature.el for Emacs28+ feat(ligatures): use ligature.el for Emacs28+ Aug 3, 2022
@hlissner hlissner removed the status:confirmed Issue was verified, or request approved. Waiting for a working solution. label Aug 3, 2022
@hlissner hlissner added this to the modules v22.08 milestone Aug 3, 2022
@gagbo gagbo force-pushed the feat/ligature.el branch 3 times, most recently from 0d84fc6 to cc45900 Compare August 29, 2022 09:25
@gagbo gagbo force-pushed the feat/ligature.el branch from fd2cf5a to 8b3fa1d Compare March 23, 2023 07:58
@gagbo gagbo force-pushed the feat/ligature.el branch from 8b3fa1d to 9147983 Compare May 11, 2023 22:41
@gagbo gagbo force-pushed the feat/ligature.el branch 2 times, most recently from b176d34 to 9cc7c3e Compare July 26, 2023 05:55
@gagbo gagbo force-pushed the feat/ligature.el branch from 9cc7c3e to 0baa044 Compare August 9, 2023 09:11
@gagbo gagbo force-pushed the feat/ligature.el branch from 0baa044 to ff32dd9 Compare August 27, 2023 12:38
@gagbo gagbo force-pushed the feat/ligature.el branch 2 times, most recently from 5f647f4 to 63cb3d6 Compare September 9, 2023 15:35
@hlissner hlissner added ! Introduces, suggests, or requires a backwards-incompatible change is:refactor Code changes with little/no effect on user-facing behavior and removed is:tweak Code changes that affects user-facing behavior labels Sep 10, 2023
hlissner
hlissner previously approved these changes Sep 10, 2023
Copy link
Member

@hlissner hlissner left a comment

Choose a reason for hiding this comment

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

Looks good! Just a few minor changes and I think it's good to go.

Copy link
Member

@hlissner hlissner left a comment

Choose a reason for hiding this comment

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

Ah, forgot one other request: could you reword 63cb3d6 and dd0ebe0 to include a BREAKING CHANGE: in their body? Mainly to comment on what will break and how to work around it (if at all).

Include ligature.el in a new set-font-ligatures! function, so that
"normal" (read: "font-based") ligatures can
also be controlled on a per-major mode basis from a user function
in configuration.

This commit also drops support for Emacs 27 to reduce the maintenance
burden.

BREAKING CHANGE: font ligatures for Harfbuzz/Coretext composition
table-based ligations are no longer controlled with
`+ligatures-composition-alist`, but is handled with
`+ligatures-prog-mode-list` and `+ligatures-all-modes-list` for most
common cases. See the README for the mode-specific methods

BREAKING CHANGE: the `:ui ligatures` module will not work anymore
with Emacs 27 or older. Also, there is no need to keep patched fonts
(for Fira, Hasklig, Iosevka) if you use the module. Update Emacs if
you want to keep using ligatures, or disable the module (`doom doctor`
will tell you if your current version of Emacs stopped working with
the module)
@gagbo
Copy link
Member Author

gagbo commented Sep 12, 2023

Ah, forgot one other request: could you reword 63cb3d6 and dd0ebe0 to include a BREAKING CHANGE: in their body? Mainly to comment on what will break and how to work around it (if at all).

I just squashed everything, I mostly left the commits like that to remember and revert parts of it if necessary. I don't think it makes a lot of sense to let this be multiple commits on master.

@hlissner hlissner merged commit 46d7404 into doomemacs:master Sep 12, 2023
@hlissner
Copy link
Member

LGTM! Thanks again for your help!

hlissner added a commit that referenced this pull request Sep 17, 2023
Old lexical variable reference caused an error.

Ref: #7433
Amend: #5082
Amend: 46d7404
peterhoeg pushed a commit to peterhoeg/doomemacs that referenced this pull request Sep 17, 2023
Old lexical variable reference caused an error.

Ref: doomemacs#7433
Amend: doomemacs#5082
Amend: 46d7404
kenranunderscore pushed a commit to kenranunderscore/doomemacs that referenced this pull request Oct 16, 2023
Old lexical variable reference caused an error.

Ref: doomemacs#7433
Amend: doomemacs#5082
Amend: 46d7404
Zetagon pushed a commit to Zetagon/doom-emacs that referenced this pull request Oct 17, 2023
Old lexical variable reference caused an error.

Ref: doomemacs#7433
Amend: doomemacs#5082
Amend: 46d7404
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
! Introduces, suggests, or requires a backwards-incompatible change is:refactor Code changes with little/no effect on user-facing behavior module:ui/ligatures Pertains to Doom's :ui ligatures module
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants