Tim Harper <[email protected]> writes:
On Sat, Jul 24, 2010 at 3:23 PM, Vegard Øye <[email protected]> wrote:
[...]
Fourth approach: stay with the delete-or-surround DWIM functions, but bind them in a separate, toggleable keymap rather than overwriting the basic bindings. Like this:
(define-minor-mode surround-mode)
(vimpulse-define-key 'surround-mode 'vi-state "d" vimpulse-delete-surround-or-delete) (vimpulse-define-key 'surround-mode 'vi-state "c" vimpulse-change-surround-or-change)
Then you can enable surround-mode in certain buffers as appropriate, or turn it into a global minor mode.
Approach 4 does seem pretty good (better than the current behavior of hijacking another keymap). What about option 5:
advise vimpulse-range to set the *vimpulse-surrounding* variable to nil before calling it advise vimpulse-delete with an around filter, if *vimpulse-surrounding* is non-nil, then call vimpulse-surround-delete, otherwise invoke as normal with ad-do-it
Sounds good. It would also still be possible to define a minor mode and enable/disable the advice cleanly (albeit not buffer-locally, but that's not a problem I guess). [...]
Drawbacks:
* We are depending on side-effect value from a previous function call. This adds complexity and can make things difficult to follow.
I'm not sure I understand -- how is that worse than your current *vimpulse-surrounding* ugliness where you always initialise it to nil and set it during the `vimpulse-range' call? Or are you speaking about precisely that? Štěpán