Live data from Hacker News

How to open a file in Emacs: a story about Lisp, technology, and human progress

murilopereira.com

41–50 of 97 posts

Re: How to open a file in Emacs: a story about Lisp, technology, and human progress

#41
This is a great post showing effective performance analysis.

It's worth noting that Emacs's built-in way to find files (project-find-file) in a project does not suffer these performance issues. Try it, C-x p f.

* project-find-file doesn't call expand-file-name for all 70k files (each of which involves a network roundtrip).

* project-find-file will use "git ls-files" (see project--vc-list-files) rather than find (or expecting the user to install and enable fd)

* project-find-file uses completing-read, which wouldn't by default call Ivy/Ivy prescient.

I can see how the author has ended up here: projectile predates the built-in project support, so it must only seem natural to use projectile as a base, and apply performance fixes on top.

Emacs's built in functionality tends to work better with other Emacs functionality, hence why project-find-file works well with TRAMP.

It's worth trimming your config occasionally, and rebasing onto built-in functionality.

The author's fast-project-find-file has a more responsive UI, however. It'd be great to have that in core.

Re: How to open a file in Emacs: a story about Lisp, technology, and human progress

#42
The author quickly moves on after finding that expand-file-name is the issue and routes around the problem. The last time we hear from it is when it is patched out. But what is really going on?

The problem is that many parts of Emacs and libraries built on top of them have not been made fully TRAMP aware. There is an abstraction boundary that is being crossed, assumptions are being violated, etc. because all paths are treated equally, despite the fact that most parts of Emacs can identify that a path is remote (or could be remote).

Fixing the underlying issue and providing latency aware variants of commands is not easy (you usually can't just run elisp on a remote machine), but when we get there Emacs will be even more powerful!

Here is an excerpt from some notes I made back in October.

Consider these cases.

I have 10k files that I want to move on a remote server. I have 10k files that I want to move on a local server.

Where do I put the for loop?

I want to put it so that I only have to call ssh once.

Similar issue with using find and subshells. If I have to invoke a subshell there is significant overhead.

Having even a little bit of knowledge about the latency of running a single command, or the knowledge that certain commands commute under loop reordering would make it much easier to produce efficient code, basically

  #+begin_src elisp
  (do-for-values value '(a b c d e f g)
    (please-do-this-on-the-remote #'command value))
  #+end_src
should be rewritten to

  #+begin_src elisp
  (please-do-this-on-the-remote
    (do-for-values value '(a b c d e f g)
      (command value)))
  #+end_src
However, this is only safe if the values are from the local and not the remote and are not functions that are dependent on local state (that doesn't really matter in strict languages though).

The best way to approach this might be to detect and warn before running. Or not, sometimes you do just want to be more efficient, and if you don't want the optimization then disable it some other way. The reason is because sometimes it is much easier to write the latency multiplying version, and the conversion to the latency efficient form is trivial for a computer but extremely easy to screw up for a human being.

EDIT: Hah. I though I recognized Richard's reply. It was to me.

Re: How to open a file in Emacs: a story about Lisp, technology, and human progress

#43

I always wonder how people evolve from fiddling with package configurations to using emacs at this level. My stunbling block is not so much knowing Elisp (I’m sure I can stumble through that) but just knowing the internal architecture and how emacs works overall. Has anyone come across a good guide for hacking emacs? I know there is the manual. Perhaps I just need to look at that again and get going.

Emacs Lisp Intro and Elisp reference manual, which come with Emacs.

Former is concise and more suited for configuration, latter is for package developers.

Re: How to open a file in Emacs: a story about Lisp, technology, and human progress

#44

This is a great post showing effective performance analysis. It's worth noting that Emacs's built-in way to find files (project-find-file) in a project does not suffer these performance issues. Try it, C-x p f. * project-find-file doesn't call expand-file-name for all 70k files (each of which involves a network roundtrip). * project-find-file will use "git ls-files" (see project--vc-list-files) rather than find (or e…

> * project-find-file uses completing-read, which wouldn't by default call Ivy/Ivy prescient.

Not by default, that's true, but for users that have installed ivy and activated ivy-mode, ivy does take over completing-read.

Re: How to open a file in Emacs: a story about Lisp, technology, and human progress

#45

This is a great post showing effective performance analysis. It's worth noting that Emacs's built-in way to find files (project-find-file) in a project does not suffer these performance issues. Try it, C-x p f. * project-find-file doesn't call expand-file-name for all 70k files (each of which involves a network roundtrip). * project-find-file will use "git ls-files" (see project--vc-list-files) rather than find (or e…

> It's worth noting that Emacs's built-in way to find files (project-find-file) in a project does not suffer these performance issues. Try it, C-x p f.

That is your personal key binding, project-find-file does not seem to have a default key binding. (This, by I which I mean telling people that some built-in command is bound to some key while forgetting that is in my configuration and not by default, has happened to me several times.)

Re: How to open a file in Emacs: a story about Lisp, technology, and human progress

#46

This is a great post showing effective performance analysis. It's worth noting that Emacs's built-in way to find files (project-find-file) in a project does not suffer these performance issues. Try it, C-x p f. * project-find-file doesn't call expand-file-name for all 70k files (each of which involves a network roundtrip). * project-find-file will use "git ls-files" (see project--vc-list-files) rather than find (or e…

> Emacs's built in functionality tends to work better with other Emacs functionality, hence why project-find-file works well with TRAMP.

I think it's more than that, there is a higher barrier to entry for code in Emacs than in third party packages. Given that it's not surprising if built-in code is higher quality than external packages on average.

Re: How to open a file in Emacs: a story about Lisp, technology, and human progress

#47

This is a great post showing effective performance analysis. It's worth noting that Emacs's built-in way to find files (project-find-file) in a project does not suffer these performance issues. Try it, C-x p f. * project-find-file doesn't call expand-file-name for all 70k files (each of which involves a network roundtrip). * project-find-file will use "git ls-files" (see project--vc-list-files) rather than find (or e…

> It's worth noting that Emacs's built-in way to find files (project-find-file) in a project does not suffer these performance issues. Try it, C-x p f. That is your personal key binding, project-find-file does not seem to have a default key binding. (This, by I which I mean telling people that some built-in command is bound to some key while forgetting that is in my configuration and not by default, has happened to m…

Actually it's a default key binding in the (yet unreleased) Emacs 28. project.el has a lot of nice improvements in the upcoming version of Emacs. (I imagine the grandparent comment author just checked the version tag in `C-h k C-x p f' to see when it was released, but currently on Emacs HEAD the keybinding doesn't have a proper version tag - that's a big, albeit minor)

Re: How to open a file in Emacs: a story about Lisp, technology, and human progress

#48

This is a great post showing effective performance analysis. It's worth noting that Emacs's built-in way to find files (project-find-file) in a project does not suffer these performance issues. Try it, C-x p f. * project-find-file doesn't call expand-file-name for all 70k files (each of which involves a network roundtrip). * project-find-file will use "git ls-files" (see project--vc-list-files) rather than find (or e…

> It's worth noting that Emacs's built-in way to find files (project-find-file) in a project does not suffer these performance issues. Try it, C-x p f. That is your personal key binding, project-find-file does not seem to have a default key binding. (This, by I which I mean telling people that some built-in command is bound to some key while forgetting that is in my configuration and not by default, has happened to m…

'C-x p f' is a binding for project-find-file in project 0.5.3: https://elpa.gnu.org/packages/project.html

Emacs 27 users can upgrade to this, or wait until Emacs 28.

Re: How to open a file in Emacs: a story about Lisp, technology, and human progress

#49
post #11
post #6

Earlier quoted context omitted.

In no way do I want to come off as rude with this comment, but to me what you are saying is not at all different from "when I was young I used to work out and eat healthy... a couple of decades later, I just fund it all so exhausting". Customizing your computer environment is good. Eating healthy is good. None of those need to end up in a "rabbit hole". Everyone can be tired of life and give up due to exhaustion, but…

Or you can, you know, just use VSCode, have fun coding what you actually want to code and use that spare time: a) learning Spanish to talk to that hot chick/dude b) traveling around the world c) doing whatever else you love to do besides coding

I hesitate to do this mostly because I'm confident Emacs will be around in two decades. I don't know about VSCode. At the same time I don't feel like investing in Emacs is a great use of time.

So I mostly just leave everything as it is.

Re: How to open a file in Emacs: a story about Lisp, technology, and human progress

#50

Earlier quoted context omitted.

You appear utterly convinced that VSCode will never demonstrate an obscure bug like the one discussed in TFA, or alternatively that if it does you'll be able to jump ship to some other tool. I don't share your confidence, and would prefer to know that such issues can be fixed with or without vendor participation.

That seems an ungenerous and quite broad interpretation of a fairly simple assertion. Even as much as I love Emacs, I would never fault someone for choosing a more productive tool now even if there’s a non-zero risk of something breaking in the future...because there’s always something that will break on any platform. Time spent being productive now is usually worth that risk.

The counter-point to that is that the world benefits more by someone choosing to actually fix whatever was wrong, rather than just switching platforms (or never choosing it in the first place because they came across the post on HN).

The claim in the comment I was responding to appeared to me to be "hmm, Emacs has a problem, VSCode probably doesn't, I would rather use VSCode". It didn't seem to me to be written with much awareness of what the actual problem in TFA really was, nor with any real knowledge that VSCode actually would be more productive. It seemed to me to be more like "Ewww! Emacs has a bug, someone fixed it with a lot of obscure stuff, no thanks, VSCode here I come".

I certainly respect that for many, VSCode will be a more productive platform when measured by the metrics that matter to them.

Post reply on HN