reddit / emacs

Is it just me or do language modes have a lot of jankiness in Emacs?

PrayForGains · 2022-11-04 17:48
I'm a big Emacs fan and have loved using it for years but can't help but think there's a lot of jankiness in various language modes. Syntax highlighting in general is slow. Tree Sitter is an interesting potential replacement and I got it working with some languages but I got lost trying to install a language manually - ex vue tree sitter. Indentation can be unexpected. For example, say you are a PHP developer and you decide to try Emacs. The first thing you'd do is install some sort of PHP support, right? So you'd likely go to php-mode. * [This is how php-mode highlights and indents my code by default](https://imgur.com/iZQZnb6). * On VS Code, [here is how it indents and formats the same code](https://imgur.com/FaJlpo2) almost out of the box. Just had to install the PHP formatter. Just works. * So then on your Emacs PHP journey you'd try to look for a better mode so you'd install web-mode and be happy because it formats it as expected. But I've experienced situations where web-mode would format in an unexpected way or syntax highlighting bugs out so I'd have to re-run M-x web-mode. I seem to experience this a lot. A language mode that's just has the janky kind of feel. I also wish there was more of a standard in how things were done. As an example, several language modes define their own variable for tab width. I do understand this is a project that's been around since the 80s so cruft is to be expected. EDIT: My love of Emacs is like a toxic relationship. I'm over here complaining thinking my life will be better with the other text editors. Then the next day, I'm deep into editing my Emacs config, falling in love all over again realizing Emacs is the only one for me. <3
takeonrules · 2022-11-04 18:36
In the specific case of PHP, that file looks like a mix of PHP and HTML. I know there's a multi-major-mode tool. The issue I see is that PHP mode looks to PHP specific declarations and doesn't delve into the HTML aspect.
KaranasToll · 2022-11-04 19:40
Correct. Php mode focuses on not mixing php and html which is the more modern suggested way. Multi major modes can be fun, but very difficult to get to work correctly, especially for indentation. OP, if you really want this to work, php mode will need soecial treatment like js-mode for jsx or something like this: https://github.com/moderninterpreters/markup/blob/master/lisp-markup.el which is a minor mode for writing html in lisp files.
peatfreak · 2022-11-04 21:18
Yep, it's like this everywhere in Emacs. It's certainly been like this ever since I started I started using it in the late 1990's, I think version 19.34 was the first one I used. Nothing in Emacs really works properly or integrates with the other modes, and you just end up getting used to it and ignoring the shit that doesn't work right. The problem is that it takes an enormous amount of mental effort just to keep track of what you have to to ignore. I thought it was clear 20 years ago that the cognitive load of trying to maintain all these bundled modes in an integrated way was well beyond the combined capabilities of the maintainers even back then. Now it's a lot worse. The problem is that there really is nothing much better. Every few years I try to escape but I always come crawling back. The thing is, it's got a really beautiful core of a robust portable text editor that can handle large files safely. It can do multilingual stuff well. Vim is worse, VSCode and Atom are same old same old, they all grow until they become Emacs. This is why editor wars never end.
SteamingBeer · 2022-11-04 23:36
Tree sitter, no?
bspwm_js · 2022-11-05 02:04
Maybe if commercial emacs be a thing and implement folding we do not need these modes.
nnreddit-user · 2022-11-05 02:31
Word brother. One massive advantage commercial-emacs has over GNU is effectively unlimited man-hours. So long as I don't get hit by a bus, it's going to happen. Currently working on an lsp client -- then world domination.
bspwm_js · 2022-11-05 02:38
Thanks for your work in commercial emacs and i see that work is massive for support all neovim-treesitter parsing. But i failed to install it with tree-sitter on 2 machine one uses manjaro and another using mac m1 😞.
peatfreak · 2022-11-05 10:49
Commercial Emacs is an unethical grudge project that gives us the worst of both worlds. The suggestion that the maintainers aren't doing enough is insulting. I've been following Emacs development since the late 1990's and I've seen many sleazy projects like this come and go.
bspwm_js · 2022-11-05 10:53
Are you seeing how nvim moving fast or the issues that emacs have we need proper syntax highlight less funnky modes that just slow the app, emacs came with alot of packages and you need more to be a thing.
xombul · 2022-11-05 11:58
Neovim is not a commercial vim, it was bootstrapped with fundings sure, but it’s not a commercial product. And they still don’t have org-mode ^^ But, yes, Emacs have some quirks I would like to see resolved. Better defaults and keybindings, out of the box top 20~50 language syntax/indent support, out of the box Unicode/Symbols/Emoji support, no native compile warning messages popping at startup, better async support, etc…
gammarray · 2022-11-05 12:04
I’ve never experienced slow syntax highlighting in Emacs. It’s either on or off. Indent is something you can customize per mode. Tree Sitter is so new that it’s not widely supported. LSP or Eglot will probably provide a better experience. Web dev in general isn’t supported as well as say C or Clojure. Emacs is open source all the way, so you’ll find a better experience where more contributions have been made. Vue in particular is a tough one. Supporting multiple languages in a single file isn’t easy, especially because they may very (JS vs TS, SCSS vs Stylus, etc). There’s polymode and mmm which could be used (with non-trivial configuration) to achieve support or you could take the route that I did and write a little Elise that checks what part of the document you’re in and switches to the appropriate mode automatically. And yeah, web-mode is better than php-mode. It’s just a thing you learn on the Emacs journey. I hope yours isn’t too challenging. There’s a lot to gain from the fully customizable nature of Emacs, but sometimes you have to be willing to crack open the source code and think creatively about you personal configuration to achieve your goals.
bspwm_js · 2022-11-05 12:08
I think commercial not mean anything just for fsf do not bother me i will do what i want with emacs. So i think commercial emacs not having any funding and i do not have a problem to support the project i really want that the project looks amazing if i could using it.
peatfreak · 2022-11-05 12:47
>fsf do not bother me i will do what i want with emacs Except you still feel entitled to pull the latest changes from mainline GNU Emacs on an hourly schedule and integrate them into your own grubby project. The hypocrisy is appalling. "I'm going to take all your code and disrespect your licensing conventions but don't you dare bother me!"
bspwm_js · 2022-11-05 12:56
It is open-source world if gnu-emacs maintainer goes slow development and do not merge alot things to emacs becuase we need it stable yes i will take merges from source and my patches to new repo like neovim did with vim.
bspwm_js · 2022-11-05 12:57
You have missed some point with open-source i could modified the source code as i could and as i need.
peatfreak · 2022-11-05 13:06
Would tree sitter make web development easier (where you have multiple languages in a single file)?
gammarray · 2022-11-05 14:07
Likely, but getting it to work in something like a Vue component might prove to be challenging. I’m still using LSP.
xombul · 2022-11-05 14:07
Yes sure, you can, but I’m not convinced it will take less efforts to create/fork a new Emacs than to resolve the problems in the current GNU Emacs.
peatfreak · 2022-11-05 15:04
How's that installation going?
oantolin · 2022-11-05 16:38
For what it's worth I've never had any trouble with any programming major mode in Emacs, but of course this is highly dependent on which modes we're talking about. I've never used PHP, for example, so I've never tried php-mode. I can tell you that modes for C, Ruby, Python, Go, Ocaml, Haskell, Scheme, Common Lisp, Clojure, Pascal, C#, Lua, Fortran and several others I'm forgetting have all worked fine for me, with no bizarre indentation nor slow syntax highlighting. (In fact I switched from Vim to Emacs because of the speed of syntax highlighting: in Vim the syntax highlighting for LaTeX is so slow that there is a [section of the manual about it](https://vimhelp.org/syntax.txt.html#tex-slow).)
ForkInBrain · 2022-11-05 17:30
I wouldn't say Commerical Emacs is unethical, just a misguided effort. The "Commerical Emacs" program doesn't infringe on the GPL nor does it compromise anybody's "four freedoms" (https://www.gnu.org/philosophy/free-sw.en.html). In fact, the GPL exists precisely to *permit* such things, so exercising that permissions cannot be unethical. I will say this: the amount of effort put behind running the core Emacs project is significant, sustainable, and if anything gaining momentum. As for these kinds of forks, I've seen it over the years too. Most often the good ideas from these forks get re-implemented and folded back into Emacs, often in a better way.
peatfreak · 2022-11-05 18:46
I agree. But it takes experience and maturity to understand this. It's a far greater achievement to cooperate with experienced developers on a decades-long successful project than it is to ride their coat-tails and make your own even-jankier distribution.
peatfreak · 2022-11-05 18:48
>out of the box top 20~50 language syntax/indent support, out of the box Unicode/Symbols/Emoji support I don't understand what you mean by these. What would you like?
peatfreak · 2022-11-05 20:47
Not only that, but RMS has been proven right time and time again. Too many developers criticize him for being out of touch but he's forgotten more about programming than I'll ever know.
Thaodan · 2022-11-06 11:10
I'd take RMS out of this. RMS as a person is another can of works regarding how he acts as a person.
peatfreak · 2022-11-06 11:35
I'm not talking about his personal deficits, I'm talking about his software and IP work.
xombul · 2022-11-06 12:31
I mean, out of the box reasonable defaults. My current Emacs config file is 2252 lines long, adding support to file types, projectile, lsp, magit, company, … and to address various points. As an example for emoji support I have : (set-fontset-font t ‘emoji (font-spec :family (cond ((member “Noto Color Emoji” (font-family-list)) “Noto Color Emoji”) ((member “Noto Emoji” (font-family-list)) “Noto Emoji”)))) Without that, no emoji support, I would expect Emacs to look for emoji fonts by default, not having to type config like that. For Unicode : (set-charset-priority 'unicode) (set-default-coding-systems 'utf-8) (set-terminal-coding- system 'utf-8) (set -keyboard-coding-system 'utf-8) (set-selection-coding-system 'utf-8) (prefer -coding-system 'utf-8) (setq locale-coding-system 'utf-8) (set default-process-coding-system '(utf-8-unix . utf-8-unix)) About the syntax highlighting and indentation, no support for golang or rust and many more “modern” languages by default. Golang was created 12 years ago and is really popular today. Also IMHO, electric-pair-mode should be activated by default for programming languages, it’s a common feature in other editors/IDE. To sum up, Emacs is the best but only after taking hours, months, years… to learn elisp and customize the configuration.
Thaodan · 2022-11-08 10:39
His work is related to his personal attitude, a lot of the things he does come from his knowledge or his ignorance. Like ask him about Melpa.