emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ERC completion


From: Stefan Monnier
Subject: Re: ERC completion
Date: Fri, 29 Apr 2011 12:20:35 -0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)

> Can't you just wrap the new framework as a function that completes and
> returns nil if it did not do anything, and use this for
> erc-complete-functions?

You can replace erc-pcompletions-at-point with erc-pcomplete on
erc-complete-functions to get back the old behavior, and if you want to
use the standard UI for it, we could create a new erc-pcomplete-std
which calls erc-pcompletions-at-point and passes the result to
completion-in-region, but that would not be compatible for example with
completion-help-at-point.

Think about the problem: completion-help-at-point should be able to show
either the completions at point for nicks or for dabbrev depending on
the situation.

> In any cases the change breaks erc-complete-functions. Maybe this
> should be resolved in a general way before converting ERC (and maybe
> others that use a similar way of customizing completions) to the new
> completion framework.

In foo-completion-functions, where you have a list of possible
completions and use the first that works, there are two different cases:
- a completion function can decide based on context that it does not
  apply at this point and we should hence try the next
  completion function.
- a completion function may think that we may indeed be completing one
  of the things for which it was designed, but it happens to find no
  valid completion, and then decides that maybe we should then try the
  next completion function.

The first is what is supported by completion-at-point-functions, and the
second is what is supported by completion-table-in-turn.
comint-dynamic-complete-functions and erc-complete-functions support
a combination of the two (AFAICT this was not so much a conscious design
decision as just a natural way to write the simple code).

completion-at-point-functions happens to support the second as well, tho
deprecates it because it's incompatible with the underlying idea of
separating the completion data from the completion operations.

We could change erc-pcompletions-at-point to assume that
completion-in-region-functions is nil and to check that
`completion-try-completion' returns non-nil before returning the
completion data.  Or maybe this test should be done only in
ERC's pcomplete-default-completion-function.

[...time passes...]

I think the basic problem is that we need here to combine various
"default completion" alternatives (nicks, from erc-pcomplete, and
dabbrev), i.e. completion functions which are valid everywhere.
Maybe completion-at-point-functions should provide special support
for such things.

> Or just drop erc-complete-functions support and document a way of
> achieving the same effect under the new framework.

The problem is in the precise effect you're trying to achieve, rather
than in erc-complete-functions ;-)

>>> Also, while on the subject of ERC completions, it seems an extra space
>>> is appended after erc-pcomplete-nick-postfix, originating from the same
>>> commit.
>> Hmm... can you show me exactly what you've done, what was the result
>> with the code and what is the result with the new code?
> Just run emacs -Q, join any channel, and complete a username. Old code
> did
> "ERC> some_nick: "
> new code does
> "ERC> some_nick:  "

Ah, I see the problem: pcomplete-completions-at-point does not pay
attention to pcomplete-suffix-list (because it solves the problem that
pcomplete-suffix-list was meant to solve in a different way (relying on
the completion table's `boundaries' method instead).  Can you try the
patch below to see if it solves the problem?


        Stefan


=== modified file 'lisp/erc/erc-pcomplete.el'
--- lisp/erc/erc-pcomplete.el   2011-04-26 13:50:09 +0000
+++ lisp/erc/erc-pcomplete.el   2011-04-29 15:19:43 +0000
@@ -48,7 +48,7 @@
   "Programmable completion for ERC"
   :group 'erc)
 
-(defcustom erc-pcomplete-nick-postfix ": "
+(defcustom erc-pcomplete-nick-postfix ":"
   "*When `pcomplete' is used in the first word after the prompt,
 add this string to nicks completed."
   :group 'erc-pcomplete
@@ -93,8 +93,6 @@
        t)
   (set (make-local-variable 'pcomplete-use-paring)
        nil)
-  (set (make-local-variable 'pcomplete-suffix-list)
-       '(?  ?:))
   (set (make-local-variable 'pcomplete-parse-arguments-function)
        'pcomplete-parse-erc-arguments)
   (set (make-local-variable 'pcomplete-command-completion-function)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]