- Subject: Re: dabbrev.sl
- From: Günter Milde <g.milde@xxxxxx>
- Date: Mon, 15 Mar 2004 10:15:39 +0100
Hi John,
excuse me for cc-ing to the list as well, I have 2 reasons for this:
- other users can bring in their opinion and wishes in a prerelease state
- I am afraid, previous mail from me to you got silently eaten up by
spam-preventing software.
On Sun, Mar 14, 2004 at 01:54:35AM -0500, John E. Davis wrote:
> Hi,
>
> I am currently testing your version 2.2 of dabbrev.sl for inclusion
> into the next release. I have a few questions:
>
> The function get_buflist takes a scope argument:
> % 0 = current_buffer,
> % 1 = visible_buffers, % including the current
> % 2 = open_buffers_of_same_mode,
> % 3 = open_buffers
> % 4 = other_visible_buffers, % excluding the current
> % 5 = other_open_buffers_of_same_mode,
> % 6 = other_open_buffers
>
> I do not understand some of these values, in particular 3, and 6.
> What is an "open_buffer", and why are there others?
In my wording, "open_buffers" means simply all buffers. You are right to
nag this, as saying "all buffers" is definitely more clear. (I suppose I
came to this term thinking of open files).
> My feeling is that scope should be a bitmapped value, but I have not
> thought too much about it.
I always find bitmapped flags harder to understand and handle than a simple
list.
I think, bitmapping might be advantageous for "orthogonal" (i.e.
independend) features. This could be used with dabbrev (but whether it is
really an advantage is not clear to me
bit 1 current buffer / all buffers
with bit 1 to TRUE there are 2 independent filters
bit 2 only visible buffers
bit 3 only buffers of same mode
> Also, instead of assigning get_buflist to a key, perhaps it would be
> better to have dabbrev take a prefix argument, e.g.,
>
> ESC 4 Ctrl-A
IMHO, this should not be instead but rather as a separate option.
I use the prefix argument rather seldom but can imagine it to be usefull
in some circumstances or for other users ==> implemented (in v 2.4)
> which would be equivalent to expansion with scope=4. It might even be
> useful to use a buffer-local variable for the scope, and default to using
> Dabbrev_Default_Buflist if such a variable does not work.
This is prepared in v 2.4 but not activated as it would need the function
get_blocal(name, default) from sl_utils (or need to emulate it). Simply
uncomment the lines
% buflist_scope = get_blocal("Dabbrev_Default_Buflist",
% Dabbrev_Default_Buflist;
when get_blocal is available by default...
> Finally, is there a way I can define a buffer that consists of a list
> of words and always have that buffer added to the list of completion
> buffers?
Yes, of course. One of the design-goals of the new dabbrev is
extensibility.
If you only want expansion from "*wordlist*", it is as simple as
% setkey("dabbrev(\"*wordlist*\")", "^A");
But your question was to add the wordlist. So you need to define and bind
a new function. The following example assumes the wordlist to be in a
buffer "*wordlist*" (of course it could also be an optional argument or
whatever):
define dabbrev_with_wordlist()
{
variable buflist = "*wordlist* ";
variable buflist_scope = prefix_argument(-1);
if (buflist_scope == -1)
buflist_scope = get_blocal("Dabbrev_Default_Buflist",
Dabbrev_Default_Buflist;
buflist += get_buflist(buflist_scope);
dabbrev(buflist);
}
The buflist-computation is done for the first expansion only, as
the function name starts with "dabbrev".
(c.f. the keypress check loop in dabbrev():
do
{
... % expand
% Check next keypress:
(type, fun) = get_key_binding();
}
while (andelse {type >= 0} % key bound ...
{is_substr(fun, _function_name) == 1}); % ... to "dabbrev.*"
)
I just did an update of the dabbrev mode at
http://jedmodes.sf.net/mode/dabbrev
The most recent version of dabbrev is now 2.4, with substantial enhancements
2.2.1 bugfix: invalid mark when buffer of last
expansion killed (P. Boekholt)
2.3 Dec 2003 prevent flooding the undo-buffer (using getkey for
subsequent invocations)
2.3.1 2003-12-05 replaced unget_keystring() with buffer_keystring()
2.4 2004-03-15 dabbrev() takes a prefix argument for the
buflist-scope (this is checked in dab_reset)
clearer documentation (open_buffers -> all buffers)
(hints by J. E. Davis)
Günter
--
G.Milde at web.de
[2004 date index]
[2004 thread index]
[Thread Prev] [Thread Next]
[Date Prev] [Date Next]