Open OdinZhang opened 3 years ago
Did you consider if your font supports that ligation? If you're on Emacs 27.1 you may get crash bugs also.
I chose to use composite now and it works well now. Maybe there's some bug in this package.
I'm seeing the same thing. That is, Emacs (27.1 on Linux) hangs (but doesn't crash) if I open a C-, C++- or Java-file when I have the following configuration:
(add-to-list 'load-path "~/elisp/ligature")
(require 'ligature)
(ligature-set-ligatures 'prog-mode '("/*"))
(global-ligature-mode t)
(This is approximately the smallest reproducible example I could make. Font doesn't seem to matter.)
I've tried running Emacs in GDB, but it's hard to see exactly what's going on. I could try building Emacs with -O0
and have another look.
My actual configuration is the following, and it works fine if I leave /*
out:
(use-package ligature
:config
(ligature-set-ligatures
'prog-mode
'(".=" ".-" ":=" "=:=" "==" "!=" "===" "!==" "=/=" "<<-"
"<--" "<-" "<->" "->" "-->" "->>" "<=<" "<<=" "<==" "<=>"
"=>" "==>" "=>>" ">=>" ">>=" ">>-" ">-" "-<" "-<<" "=<<"
"<~~" "<~" "~>" "~~>" "<<<" "<<" "<=" "<>" ">="
">>" ">>>" "<|" "<|>" "|>" "<$" "<$>" "$>" "<+" "<+>"
"+>" "<*" "<*>" "*>" "{-" "-}" "//" "///"
"/**" "**/" "*/" "</" "<!--" "www" "-->" "/>"
"0xA" "0xB" "0xC" "0xD" "0xE" "0xF" "0x0" "0x1" "0x2"
"0x3" "0x4" "0x5" "0x6" "0x7" "0x8" "0x9"
";;" ";;;" "::" ":::" "!!" "!!!" "??" "%%" "%%%"
"&&" "&&&" "||" "|||" ".." "..." "..<" "--" "---"
"++" "+++" "**" "***" "~-" "-~" "=~" "~@" "^=" "?=" "~="
"/=" "/==" "|=" "||=" "##" "###" "####" "#{" "#[" "#("
"#?" "#_" "#_(" "#!"))
(global-ligature-mode t)))
(I'm using Fira Code, but as mentioned, font doesn't seem to matter.)
I tried building Emacs 27.1.90 also now, same issue.
(But Emacs from the master branch as of commit ac102bb966f7944babbd8594684550905eecca0a
works fine. I guess maybe it's git bisect
-time. :grin: )
Hm. It will also affect the upcoming Emacs 27 minor release? That's a shame. I figured it would've been cherry picked into the branch.
There's a particular commit that fixes it, I think, but I have not actually verified this: fe903c5ab7354b97f80ecf1b01ca3ff1027be446
.
I had a look at emacs-27.1.91
now. It also doesn't seem to include that commit.
(I tried building it, also. Same problem.)
Do you mind M-x report-emacs-bug
? I believe that is probably a genuine oversight on their part not to cherry pick it into that branch.
Yeah, I've sent a bug report. (Also verified that the commit you mentioned fixes the issue when applied to the emacs-27 branch.)
@skrytebane, thanks for raising it. Shame it was too late to get it merged in.
I think I can confirm this (or a variant of this bug) also for emacs 27.2 (Kubuntu 20.04 snap install). In my case elpy, php-mode, and c-mode are affected (rustic/ rust-mode and the basic python mode are not). When opening such a file (or activating the affected modes directly), emacs hangs and cannot be closed (doesn't react to C-g or Esc, but multiple clicks on the close button work). On my machine I also see a constant flickering and a half rendered scroll bar in the middle of the frame.
I am not sure if this is the same error or just something similar. If it is, then this fix is not contained in 27.2, and I guess my options are compiling using the newest version or waiting for emacs-28, right?
@HenningTimm I don't think this change will be in a 27.x release, so you need to build Emacs from master to get it. Or you can build the 27.x branch with fe903c5ab7354b97f80ecf1b01ca3ff1027be446
cherry-picked onto it. I seem to recall that I tried it and it seemed to work. See the bug thread I linked to above.
(By the way, I'm running Emacs compiled from master now, and it seems to mostly work fine, even with native compilation enabled.)
EDIT: I should clarify that I'm not using ligature.el at the moment, so I don't actually know how that works now. (Because I have some hosts with only Emacs 26 or 27, and didn't want to bother with version-specific configurations.)
Oh, and what you describe seems like the same error I saw, yes.
Thank you @skrytebane as far as I can see this works!
For others who want to follow along: Assuming all prerequisites to compile EMACS are present, I did roughly the following:
# clone emacs repo
git clone https://git.savannah.gnu.org/git/emacs.git
cd emacs
# check out emacs-27 branch
git checkout emacs-27
# create a new branch based on this one for the cherry-picked commit
# this hopefully avoids conflicts when updating to newer versions
# you can easily skip this step
git checkout -b emacs-27-ligature
# Apply the fix for ligature.el
git cherry-pick -x fe903c5ab7354b97f80ecf1b01ca3ff1027be446
# build EMACS
./configure
make
# Verify it works
./src/emacs foo.py
Et voila (an example with python/ elpy since it was affected by the same bug. I verified that it also works for c-mode):
If have not done any long term testing yet, but if anythings crops up I will post an update.
@HenningTimm's instructions weren't quite right - there's no "configure" file in the repository so you need autoconf and then run "make" in the top-level directory to create it. See the INSTALL.REPO file for further details.
I can't use c-mode when I use this package, my configure is:
When I wan't to add
"\\"
into that list, there will be an error My Emacs is 27.1 on Windows