Does dabbrev work?

41 views
Skip to first unread message

F.S.

unread,
Oct 1, 2012, 1:32:08 AM10/1/12
to leo-e...@googlegroups.com
The answer seems to be no based on the exchange here:

Just want to be sure that my understanding is correct.

Edward K. Ream

unread,
Oct 2, 2012, 11:53:14 AM10/2/12
to leo-e...@googlegroups.com
Rev 5472 makes dabbrev-completion and dabbrev-expands work as I
expect. These are totally cool commands! I welcome any suggestions
for improvement. It looks like Leo should have default bindings for
these in leoSettings.leo.

Edward

F.S.

unread,
Oct 2, 2012, 12:54:58 PM10/2/12
to leo-e...@googlegroups.com
Very cool! Default bindings a la Emacs -- as suggested in the source code nodes! -- would be great. I've copied them out of the (@ignored) emacs key bindings and put them in myLeoSettings.

Edward K. Ream

unread,
Oct 2, 2012, 1:24:41 PM10/2/12
to leo-e...@googlegroups.com
On Tue, Oct 2, 2012 at 11:54 AM, F.S. <speec...@gmail.com> wrote:
> Very cool! Default bindings a la Emacs -- as suggested in the source code
> nodes! -- would be great. I've copied them out of the (@ignored) emacs key
> bindings and put them in myLeoSettings.

Done at rev 5474.

I am considering a small change to dynamic-expands. Presently, this
is equivalent to dynamic-completion if there is only one completion
available: the single completion is inserted directly.

But I think it is better always to put up the completion list even if
it contains only one item. That way <backspace><tab> may show more
completions.

What do you think?

Edward

F.S.

unread,
Oct 2, 2012, 2:47:57 PM10/2/12
to leo-e...@googlegroups.com
In Emacs M-/ (dabbrev-expand) just expands to the first choice. You then cycle through the choices by repeating M-/. If you go too far you can cycle back with C-/. C-M-/ (dabbrev-completion) expands to the longest common prefix.
With 5473 I seem to already get the behavior you are talking about: that on M-/ I get a completion list. I agree that getting a list is nice, esp if <backspace><tab> show more choices (in 5473 they don't seem to).

I think there are a few use cases here:
1) I know exactly what I want but I just don't want to type it again (I may be lazy or I don't want to create a typo) so give it to me with as few key strokes as possible
2) I am not quite sure so let me see the choices
3) None of the choices is what I need so let me go back and show me some more choices

Maybe a combination of behavior is the best. With M-/ and C-/ one just cycles through the choices (auto inserted), which takes care of 1). 
With C-M-/ (dabbrev-completion) one gets the longest prefix auto inserted and a list of choices. Now it would be truly great that if we can easily just <backspace><tab> to see potentially more choices. But how do you interface with both? For 2) one desires to type just one more letter so as to make a choice in the choice list. For 3) we need to go back but may need backspace quite a bit to get back to before where we started (the only place where we can get new choices) -- can that be achieved with a single backspace instead?

For example suppose I have abcdefg and abwxyz. I type abc, C-M-/ and abcdefg is the sole completion. I may not want it but it would be nice to not have to backspace all the way to b to see the other choice. In other word if I backspace at all it is understood that I want to go before where I started (before where the auto insertion takes place). That would be neat!

F.S.

unread,
Oct 2, 2012, 3:06:00 PM10/2/12
to leo-e...@googlegroups.com
When no choice is available I get an exception:
exception executing command
Traceback (most recent call last):
  File "C:\Users\Public\Documents\leo-editor\trunk\leo\core\leoCommands.py", line 561, in doCommand
    val = command(event)
  File "C:\Users\Public\Documents\leo-editor\trunk\leo\core\leoEditCommands.py", line 576, in dynamicExpansion
    prefix = reduce(g.longestCommonPrefix,aList)
TypeError: reduce() of empty sequence with no initial value

This exception should be caught or guarded against with a gentler message of, say, "no completion found".

Edward K. Ream

unread,
Oct 2, 2012, 3:40:58 PM10/2/12
to leo-e...@googlegroups.com
On Tue, Oct 2, 2012 at 2:06 PM, F.S. <speec...@gmail.com> wrote:
> When no choice is available I get an exception:

I think I fixed this at rev 5475.

EKR

Edward K. Ream

unread,
Oct 2, 2012, 5:57:19 PM10/2/12
to leo-e...@googlegroups.com
On Tuesday, October 2, 2012 1:47:57 PM UTC-5, F.S. wrote:

> In other word if I backspace at all it is understood that I want to go before where I started (before where the auto insertion takes place). That would be neat!

I agree that backspace could be improved.  I'm not sure exactly what would be best.  I'll investigate.

EKR
Reply all
Reply to author
Forward
0 new messages