On Tue, 10 Apr 2007, Simon Strandgaard wrote:
problem: when text is selected and invoking this smart-home-command, then the selected text is erased.
Any ideas how to avoid this?
Use a macro to deselect the text then execute the command. I have a "Select Nothing" macro that is:
moveRightAndModifySelection: moveLeft:
(Record it by typing "shift-Right" then "Left".) This places the cursor at the beginning of the selection then clears the selection. Just record a macro with those strokes and the "Smart Home" command, save the macro, and bind it to the Home key.
(As an aside... I'm surprised I can't find a "clearSelection:" action. Anyone know of one that's better than this hack?)
It would, of course, be better to just move the cursor without modifying the selection. Unfortunately, the way commands are implemented there's no way to simply move the cursor without inserting text as a snippet. Any selection is going to be replaced by that insertion.
Which brings us to another problem with this command. Since it's actually doing an insert operation the buffer gets marked as modified, even if no other changes have been made. I'd love to have a way to simply move the cursor without the insert operation. Here's to a richer API in 2.0!