3

On my machine, Emacs takes a long file when creating buffers: when opening the files or directories, or when starting M-x shell. The pause is 10-15 seconds and is really annoying.

This problem seems to appear when I have about 150+ buffers open (most of them are files and directories on my machine; there are ~5 cmd-backed shell buffers; no remote files).

I have global-auto-revert-mode running on, but the problem persists even with it turned off.

I have this thing, found somewhere on StackOverflow, in .emacs, but it doesn't help:

(setq w32-get-true-file-attributes nil)

My environment: Emacs 23.2.1, Windows 7. Do you have any suggestions on what I can try?

Martin Geisler
  • 72,968
  • 25
  • 171
  • 229
Arry
  • 895
  • 1
  • 7
  • 20
  • 150+ buffers open? I'm experiencing a 10-15 second pause trying to comment on that. – harpo Jan 12 '12 at 15:52
  • # of simultaneous open buffers directly reflect one's Emacs-fu. Mine is not very strong. – event_jr Jan 12 '12 at 15:58
  • Having many buffers open is advantageous, because then you can quickly switch to any buffer with iswitchb (or something else) without having to open it first. Some people opens all possible files in their projects when starting emacs, so they don't have to deal with file opening later. – Tom Jan 12 '12 at 16:01
  • @harpo: You could take a longer pause -- I've got 703 open buffers right now... – Lindydancer Jan 12 '12 at 16:44
  • Yes, I knew I would regret that. – harpo Jan 12 '12 at 17:10

4 Answers4

7

I had the same problem and tracked it down to the vc-find-file-hook

Adding this line to ~/.emacs fixed the problem for me

(remove-hook 'find-file-hooks 'vc-find-file-hook)

See also:

Git slows down Emacs to Death - How to Fix this?

Community
  • 1
  • 1
Jason Furtney
  • 181
  • 1
  • 4
1

I have had the same problem, It would open files fast in some parts of the file system, and slow (with a 10-15 second delay) on other parts. I suspected that this could be due to some suboptimal way to open files in Windows 7, so I turned on Compability mode (XP) on the emacs.exe file. This fixed the problem.

This is of course a workaround, I suspect the real problem is the way emacs operates on files. Hopefully this will be fixed some time in the future.

daramarak
  • 6,115
  • 1
  • 31
  • 50
1

You may want to check the value of find-file-hook to see what packages are hooked onto file opening and maybe try removing them one by one to see if one of them is the culprit.

Tom
  • 7,515
  • 7
  • 38
  • 54
  • Thank you for the suggestion, but this isn't the reason. I cleared `find-file-hook` and went for half a day, still with the delays. (Besides, the same delays are present when opening directories and running shell, which don't use `find-file-hook`.) – Arry Jan 16 '12 at 09:09
0

Nearly the same as for Jason Furtney except that in my case:

(remove-hook 'find-file-hooks 'vc-refresh-state)

Did the job.

In fact git status on windows seems to be SLOOOOOOWWWW. So if you don't need to have information on your git status' file this will speed this up a lot.

For instance my M-x org-agenda + a doesn't take ages like before.

Avy
  • 1
  • 1