reddit / emacs

Emojis in Emacs 28 - Tables not aligned in Orgmode column-view

pragmat1c1 路 2022-05-03 12:44
I am using emojis in my org-files a lot (folder icon, task icon etc) in Emacs 28.1 (see below) Now obviously the length of one emoji is not calculated correctly, that's why `org-columns` creates a table with misaligned column lines. See attached screenshot. ​ https://preview.redd.it/3ko4iwvcb9x81.png?width=1092&format=png&auto=webp&s=d7a476ba767fbce144b89bee82b94b0ba3d2445d Apparently this has been addressed here as well: [https://lists.gnu.org/archive/html/emacs-devel/2021-12/msg02703.html](https://lists.gnu.org/archive/html/emacs-devel/2021-12/msg02703.html) But I don't see how to mitigate this? ## Emacs version (emacs-version) "GNU Emacs 28.1 (build 1, x86_64-apple-darwin21.4.0, NS appkit-2113.40 Version 12.3.1 (Build 21E258)) of 2022-04-20"
Bodertz 路 2022-05-03 13:55
It night be helpful if you were to share a short example of a table that has that issue so that people can copy it and test it on their machine. The image is useful too, but I can't copy the text out of it. `string-glyph-split` is apparently in emacs 29 (which isn't released yet). And I'm not sure if Org's tables would make use of that even if it were in Emacs 28. I'm also not sure if that's the issue you are facing. I know that mismatched fonts can sometimes cause that issue [1], so it may just be that rather than whatever issue `string-glyph-split` solves. If you aren't opposed to using a package from ELPA, perhaps `valign` can fix your problem. I haven't tried it, so I don't know if it would cause other issues for you. It's something you could try, though. https://github.com/casouri/valign [1] https://emacs.stackexchange.com/questions/63850/doom-emacs-how-to-align-chinese-characters-in-org-tables
pragmat1c1 路 2022-05-03 17:01
Thank you for the detailed reply. It's a very conventional org file, just with some emojis in them (for example this: 馃搧 or this 馃梽), as you can see in the screenshot. I just downloaded Emacs 29, but that was not able to show the column mode correctly. Finally, **valign** did not help either. I guess I'll have to look into the code of org-columns view and modify the code to fix the incorrect calculation of string length containing emojis.
Bodertz 路 2022-05-03 18:00
I don't use `org-columns`, so I don't know what it should look like, but things seem to mostly line up with this simple test: https://i.imgur.com/DDHRfww.png * 馃搧 Blah Folder ** DONE Contain files and such * 馃樅 I'm a cat ** TODO Do cat things *** TODO Find box and maybe sit in it or something I'm not really sure yet * 馃惗 Woof ** TODO Find squirrel * 馃ウ i'm broccoli ** TODO Become tree It becomes less aligned when zoomed in: https://i.imgur.com/Ml9toiZ.png I think the issue is that the font sizes don't match or something like that. Is it aligned in terminal emacs? If so, I think you should either try to find an emoji font that plays better with your regular font, or maybe try adapting code from this comment for emojis instead of Chinese characters: https://www.reddit.com/r/emacs/comments/gvtcej/how_to_get_japanese_characters_alignment_in_the/fsrrcoe/
pragmat1c1 路 2022-05-03 18:49
Terminal is the same. I have experimented a lot today, and apparently it's the emojis that cause trouble (their length cannot be determined predictably, hence the padding in tables / org-columns is screwed). Thanks for your help anyways.
Bodertz 路 2022-05-03 18:53
Is the example I provided with the cat and dog emojis also screwed on your machine?
SafeSweet715 路 2022-05-04 14:03
I had a similar problem with some fonts, but [casouri/valign](https://github.com/casouri/valign) solved it for me. Not sure about emoji, but valign might work.
pragmat1c1 路 2022-05-05 08:36
Valign is excellent, but my problem is with emojis, and those screw up tables in column view.
jwiegley 路 2022-08-23 22:46
This is a display issue in Emacs 28, and affecting more than just Org-mode. I haven't yet found the answer for current users.