Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Block visual insert performance #685

Open
TheBB opened this issue Jul 8, 2016 · 2 comments
Open

Block visual insert performance #685

TheBB opened this issue Jul 8, 2016 · 2 comments

Comments

@TheBB
Copy link
Member

TheBB commented Jul 8, 2016

Originally reported by: Anonymous


There are issues with block visual insert performance. In particular, it seems (though I don't have direct proof) that hooks for things are being run many many times. That means that you can have certain things installed that while relatively heavy give reasonable performance in normal usage, but when combined with block visual end up causing a long delay because the hooks are being run many many times. An example of something like that is line numbering.

I encountered this issue in spacemacs, here's the link: syl20bnr/spacemacs#5423. With line numbering active, block inserting into a 100 rows could easily give a delay of a couple of seconds.

It seems like emacs perhaps provides ways to avoid running hooks during an automated sequence of edits: https://www.gnu.org/software/emacs/manual/html_node/elisp/Change-Hooks.html.

Is it reasonable to change how hooks are being run during block visual inserts?


@TheBB
Copy link
Member Author

TheBB commented Jul 17, 2016

Original comment by Frank Fischer (Bitbucket: lyro, GitHub: lyro):


Block visual insertion just repeats the insertion on the first line on all other line using the standard repeat system (i.e. it executes the "dot" command on the successive lines). If we disable certain hooks the result is hard to predict.

Actually I do not know what I should say. Yes, you can disable some hooks, but it's hard to detect which hooks should be disabled. You try to advice evil-cleanup-insert-state so that some hooks are disabled during the execution of this function (that functions actually runs the repeated insertion).

@jonwooding
Copy link

The performance issues on my system were mostly related to linum-mode. My initial solution was to patch evil-insert to check vcount and disable linum-mode then enabling linum-mode when evil returned to normal-state. This could be wrapped in some additional conditions if the user doesn't use linum-mode in every buffer.

;; in evil-commands.el, evil-insert()
(when (and vcount (> vcount 1)) 
   (linum-mode -1))

;; in .emacs
(evil-normal-state-entry-hook (lambda () (linum-mode t)))

Ultimately this solution is pretty hacky so I opted for something a bit cleaner.

;; in .emacs
(define-key evil-visual-state-map "I" 'string-insert-rectangle)

It's not really in the spirit of Evil, but I use block insertion a lot and was becoming quite annoyed with the performance issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants