5 ms·
I'm not really happy with the number of times I have recently had to resort to sending it SIGUSR2 to force it to stop whatever it's doing when I re-indent some
by srhtftw 3y ago
I'm not really happy with the number of times I have recently had to resort to sending it SIGUSR2 to force it to stop whatever it's doing when I re-indent some code in a file of Typescript. It happens about once a day. When it does I quickly save all my work and restart. I haven't looked too closely at it yet but from what I've seen in backtraces I suspect there's a bad pattern match situation in there somewhere, like what you might get from the exponential behavior of a poorly written regex.
I'm also not happy about the fact that I can no longer open large C++ files like https://github.com/ASDAlexander77/TypeScriptCompiler/blob/main/tsc/lib/TypeScript/MLIRGen.cpp https://github.com/ASDAlexander77/TypeScriptCompiler/blob/ma... in C++ mode without scrolling becoming so sluggish as to be unusable. I either have to disable C++ mode or open them in an older version.
It's good that emacs is getting some long needed attention, but I'm sad the latest version isn't as usable for me.
- G3rn0ti 3y ago> I'm also not happy about the fact that I can no longer open large C++ files Regex-based syntax highlighting is usually the culprit in these cases. There’s probably a new RegEx inside c++ mode that burns too many cpu cycles. You might want to try out the treesitter mode „c++—ts-mode“ that does the syntax highlighting based on a real static parser written in C: https://medium.com/really-learn-programming/setting-up-tree-sitter-in-emacs-29-x-a38a9d3a9f2b https://medium.com/really-learn-programming/setting-up-tree-... Disclaimer: I’m not a C++ dev so I have never tried that.
- srhtftw 3y ago> https://medium.com/really-learn-programming/setting-up-tree-sitter-in-emacs-29-x-a38a9d3a9f2b https://medium.com/really-learn-programming/setting-up-tree-... The author made this story available to Medium members only. Sign up to read this one for free. /sigh
- G3rn0ti 3y agoYeah, sorry, I was hastily looking for a tutorial. But I got "c++-ts-mode" working for me now, see my other comment below: https://news.ycombinator.com/item?id=37466899 https://news.ycombinator.com/item?id=37466899 I am still not a competent C++ programmer but this is how your basic tree sitter C++ mode is supposed too look with "C-h m": Minor modes enabled in this buffer: Auto-Save Flycheck Flyspell Font-Lock Yas The major mode is C++// mode defined in c-ts-mode.el: Major mode for editing C++, powered by tree-sitter. This mode is independent from the classic cc-mode.el based ‘c++-mode’, so configuration variables of that mode, like ‘c-basic-offset’, don’t affect this mode. To use tree-sitter C/C++ modes by default, evaluate (add-to-list 'major-mode-remap-alist '(c-mode . c-ts-mode)) (add-to-list 'major-mode-remap-alist '(c++-mode . c++-ts-mode)) (add-to-list 'major-mode-remap-alist '(c-or-c++-mode . c-or-c++-ts-mode))
- G3rn0ti 3y ago> when I re-indent some code in a file of Typescript What typescript mode are you using? Emacs 29.1 comes with "typescript-ts-mode" providing parser based syntax highlighting and navigation. Traditionally, re-indentation is implemented using regex based syntax tables, too, so you might enhance your experience by switching over to that newer mode.
- srhtftw 3y agoFor reference, here are my versions ________________ M-x emacs-version GNU Emacs 29.1 (build 1, x86_64-apple-darwin18.7.0, NS appkit-1671.60 Version 10.14.6 (Build 18G9323)) of 2023-07-30 ________________ M-x describe-mode (for C++) Minor modes enabled in this buffer: Font-Lock Tree-Sitter-Hl Tree-Sitter The major mode is C++//l mode defined in cc-mode.el: Major mode for editing C++ code. Using CC Mode version 5.35.2 ________________ M-x describe-mode (for ts) Minor modes enabled in this buffer: Font-Lock Tree-Sitter-Hl Tree-Sitter The major mode is TypeScript mode defined in typescript-mode.el: Major mode for editing typescript. ;;; typescript-mode.el --- Major mode for editing typescript ;; URL: http://github.com/ananthakumaran/typescript.el ;; Version: 0.4 ;; Keywords: typescript languages ;; Package-Requires: ((emacs "24.3")) ________________ os % uname -srm Darwin 19.6.0 x86_64 % sw_vers ProductName: Mac OS X ProductVersion: 10.15.7 BuildVersion: 19H15
- G3rn0ti 3y agoSorry, was AFK over the weekend. > Minor modes enabled in this buffer: Font-Lock Tree-Sitter-Hl Tree-Sitter > The major mode is TypeScript mode defined in typescript-mode.el: > Major mode for editing typescript. This actually indicates that you are in fact using some tree sitter extension for doing "font-locking". Do you happen to have installed "elisp-tree-sitter" in the past? Perhaps this setup has some bugs. Or your font-locking is still running regexes in your mix. This is how typescript mode looks for me using Emacs 29.1's built-in tree sitter support: Minor modes enabled in this buffer: Auto-Revert Auto-Save Company Eldoc Flycheck Flyspell Font-Lock Lsp-Headerline-Breadcrumb Lsp-Modeline-Workspace-Status Lsp-Ui-Doc Lsp-Ui Lsp-Ui-Sideline Yas The major mode is TypeScript mode defined in typescript-ts-mode.el: Major mode for editing TypeScript. (I am also running "lsp-mode.el" so there are more minor modes running than perhaps in your case.) So, I would remove any tree sitter extension you may have installed in the past. Then to activate the new "typescript-ts-mode" you need to do the following: 1. Clone this repository: https://github.com/casouri/tree-sitter-module/ https://github.com/casouri/tree-sitter-module/ 2. run "./build typescript" (you'll need build-essentials and a C++ compile but I gathered you are programming in C++, so) 3. Copy the resulting shared library "dist/libtree-sitter-typescript.so" into "~/.emacs.d/tree-sitter/". 4. Open a random typescript file and try "M-x typescript-ts-mode" which should not give you any error but nice syntax highlighting. 5. Of course, you'll need some tweaking to make it your default. Basically, you'll have to add "'typescript-ts-mode" to your "'auto-mode-list". You'll have to do the same for your C++ setup. U̶n̶f̶o̶r̶t̶u̶n̶a̶t̶e̶l̶y̶,̶ ̶t̶h̶e̶ ̶c̶o̶n̶v̶e̶n̶i̶e̶n̶c̶e̶ ̶"̶t̶r̶e̶e̶-̶s̶i̶t̶t̶e̶r̶-̶m̶o̶d̶u̶l̶e̶"̶ ̶b̶u̶i̶l̶d̶ ̶s̶c̶r̶i̶p̶t̶ ̶d̶o̶e̶s̶ ̶n̶o̶t̶ ̶s̶u̶p̶p̶o̶r̶t̶ ̶C̶+̶+̶ ̶o̶u̶t̶ ̶o̶f̶ ̶t̶h̶e̶ ̶b̶o̶x̶.̶ ̶B̶u̶t̶ ̶i̶t̶ ̶d̶o̶e̶s̶ ̶n̶o̶t̶ ̶l̶o̶o̶k̶ ̶c̶o̶m̶p̶l̶i̶c̶a̶t̶e̶d̶ ̶t̶o̶ ̶e̶x̶t̶e̶n̶d̶ ̶i̶t̶ ̶f̶o̶r̶ ̶y̶o̶u̶r̶ ̶p̶u̶r̶p̶o̶s̶e̶s̶.̶ Nonsense, it is supported: Just run "./build cpp". You also seem to need "./build c". This way, I was able to activate the new C++ treesitter mode. If you do not want to go ahead and migrate to built-in treesitter yet -- as you see it's still a bit fiddly to setup as it is brand new -- I would tackle your C++ performance problem first by using Emacs' profiler: 1. M-x profiler-start (select "CPU") 2. Open your C++ file slowing your Emacs down. 3. M-x profiler-stop 4. M-x profiler-report and see what it gives you. Perhaps post an issue with the Emacs maintainers and they can give a clue where your issue comes from. But usually something like this is caused by a run-a-way regex. Good luck!