[implementations-list] Re: vimpulse
Hi Fabian, I was looking at the viper source code to see how to add the '<,'> functionality to ex commands. It turns out it's quite boring to add it. Viper does not recognize the '< and '> marks, and the characters recognized as mark identifiers are hard coded in the ex command parser. I could easily change the parser to let it recognize '< '>, but that would be yet another viper function redefinition. I also think I'd have to change it in other places, like in the ' command, and god knows where else (as there are also other functions that check if the character is a valid mark, and it seems viper uses some sort of registers (the same code used for "a "b etc) to store markers. To avoid another redefinition, I can do 2 things: - put the line numbers that identify the current visual selection automatically after ":" - this would work almost the same, but then you would have to remember the line numbers if you want to issue a second command on the visual selection after it is turned off - use two marks, for example y and z, instead of < and >, and automatically put 'y,'z after the : when : is issued in visual mode. By the way, I'm forwarding this mail to the mailing list, so to hear other opinions too. I also invite you to subscribe to the mailing list, and direct your feature/fix requests there :) Cheers, Alessandro 2009/6/30 Fabian Braennstroem <[email protected]>
Hi Alessandro,
Alessandro Piras wrote:
thanks for the suggestions! :) ex support is still bad in vimpulse, the code is at least 2 years old, and we didn't work much on it, but that will be on the schedule :)
Sounds nice! I am quite happy, that I saw the new start ... somehow, I was afraid, that it will stay at the current status (which was quite good) .
Best Regards! Fabian
Ciao,
Alessandro
2009/6/29 Fabian Braennstroem <[email protected] <mailto: [email protected]>>
Hi Alessandro,
thanks a lot! That is really great! One or two more suggestions I got, is the adjustment of the search using: set ignorecase set smartcase
in vim and running commands on the visual region like:
:'<,'>s/test/TEST/
in vim :-)
Best Regards! Fabian
Alessandro Piras wrote:
Hi Fabian, unluckily, the emacs commands <do-something>-region don't work at all with the new visual selection, at least for the moment. I'll try to explain why. The region is the area between the mark and the point. there are quite a lot of functions that can be used to identify those two ends, I really don't know why. I tried at first to override region-beginning and region-end, and some command worked, and some didn't. I tried to override point and mark, and some other function worked, and some didn't. suffice is to say, there's no clean method to make those commands work automatically. There basically are 3 options: a) Move the mark and the point at the exit of visual mode, so to highlight the region. I really don't like this method at all b) Provide an explicit command to exit visual selection mode and activate the region, so you can use the region-related commands c) instead of using region-related commands, like comment-region and uncomment-region, you provide your own commands that operate on the visual selection (implemented using the region commands, possibly).
I'll give you a quick solution using the method 3, as it's the one that I would use in that case :)
(define-key viper-vi-global-user-map (kbd "\\\]") 'my-vimpulse-comment-region) (define-key viper-vi-global-user-map (kbd "\\,") 'my-vimpulse-uncomment-region)
(defun my-vimpulse-comment-region () (interactive) (comment-region (vimpulse-get-vs-start) (vimpulse-get-vs-end)) (vimpulse-visual-mode nil))
(defun my-vimpulse-uncomment-region () (interactive) (uncomment-region (vimpulse-get-vs-start) (vimpulse-get-vs-end)) (vimpulse-visual-mode nil))
You can go further than this. As most (maybe all?) emacs region related commands have the syntax (command region-begin region-end), it's possible to convert commands in a more abstract way: (defmacro vimpulse-region-command (function) `(lambda () (interactive) (,function (vimpulse-get-vs-start) (vimpulse-get-vs-end)) (vimpulse-visual-mode nil))) (define-key vimpulse-vi-global-user-map "\\\]" (vimpulse-region-command comment-region)) (define-key vimpulse-vi-global-user-map "\\," (vimpulse-region-command uncomment-region))
As this macro seems to be of general interest, I'll add it to vimpulse's helper functions :) Thanks for your feedback! Alessandro
2009/6/28 Fabian Braennstroem <[email protected] <mailto:[email protected]> <mailto:[email protected] <mailto:[email protected]>>>
Hi Alessandro,
I just saw the new vimpulse release and that you took the maintaining :-) This is really great! I had to test the new release right away and like the new visual behavior. Right now, I got a short comment about the visual mode. I use quite a lot the command 'comment-region' to place comment characters in the first column of the whole visual region. This works with the new visual mode as well, but unfortunately it seems to behave in the old release style, which means that the last marked line does not get commented out!?
(define-key viper-vi-global-user-map (kbd "\\\]") 'comment-region) (define-key viper-vi-global-user-map (kbd "\\,") 'uncomment-region)
Do you have a hint, how to fix this?
Thanks in advance! Fabian
participants (1)
-
Alessandro Piras