👉 Support this work via GitHub Sponsors
Identify temporary diversions and automatically return to original point location.
Let’s say you want to select the current function and indent region, this leaves your point in an unintended location. You likely wanted your point in the location becore selecting the current function. Diverted helps identify those scenarios and brings point back to your intended location.
Notice how point is left at the top of the screen after pressing TAB to indent region.
Notice how point is left where it was prior to selecting the functoin and pressing TAB to indent region.
- Load package
(require 'diverted)
- Identify diversions and provide a breadcrumb to get back.
(add-to-list 'diverted-events (make-diverted-event :from 'er/expand-region :to 'indent-for-tab-command :breadcrumb (lambda () (diverted--pop-to-mark-command 2))))
- Enable `diverted-mode’
(diverted-mode +1)