unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Antoine Levitt <antoine.levitt@gmail.com>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: emacs-devel@gnu.org
Subject: Re: ERC completion
Date: Mon, 02 May 2011 17:19:00 +0200	[thread overview]
Message-ID: <87d3k1ceqj.fsf@gmail.com> (raw)
In-Reply-To: <jwvmxj5duan.fsf-monnier+emacs@gnu.org> (Stefan Monnier's message of "Mon, 02 May 2011 12:02:08 -0300")

02/05/11 17:02, Stefan Monnier
>> Nowadays, I have in my .emacs the following, which actually works fine
>> but which I now realize is utterly wrong :)
>
>> (setq tab-always-indent 'complete)
>> (defun my-dabbrev-expand ()
>>   (when (and (not (bolp))
>> 	     (looking-at "\\_>"))
>>     (dabbrev-expand nil)))
>> (defun my-dabbrev-expand-and-nil ()
>>   (my-dabbrev-expand)
>>   nil)
>
> Why my-dabbrev-expand-and-nil?

Because I'm dumb. :) (that was for some old code I don't use anymore)

>
>> (setq completion-at-point-functions '(my-dabbrev-expand-and-nil))
>
> `setq' on a hook is almost always the wrong thing to do.
> Either use `setq-default' here if you really intend to throw away the
> default global completion functions, or otherwise use something like:
>
> (add-hook 'completion-at-point-functions 'my-dabbrev-expand 'append)

That was mostly for tests.

>
>> I seem to recall talks of priority for completions. Couldn't that be
>> used here? That way, I'd set completion-at-point-functions to something
>> that returns the list of dabbrev expands with a low priority, and every
>> other completion would take precedence over it.
>
> By placing it at the end of the hook, you're giving it the lowest
> priority.

Cool! Then all that'd be needed is to write a dabbrev-completions
function that'd return all completions, as found by dabbrev, and set it
at the end of the hook. Then erc nick completions would take precedence,
and life would be good again.

This doesn't seem to be trivial, as dabbrev relies on an internal state
(for instance, calling dabbrev--find-all-expansions twice results in a
different result each time), and there seems to be more issues -
http://www.emacswiki.org/emacs/CompletionUI#toc6 says that it doesn't
get the ordering right, for instance. But surely dabbrev would be a
worthy addition to the completion framework (unless everybody uses
something else of which I'm not aware?)



  reply	other threads:[~2011-05-02 15:19 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-27 18:58 ERC completion Antoine Levitt
2011-04-28  0:18 ` Stefan Monnier
2011-04-28 10:44   ` Antoine Levitt
2011-04-28 19:34     ` Stefan Monnier
2011-04-28 19:48       ` Antoine Levitt
2011-04-29  0:50         ` Stefan Monnier
2011-04-29  7:43           ` Antoine Levitt
2011-04-29 15:20             ` Stefan Monnier
2011-04-29 20:50               ` Antoine Levitt
2011-05-02 15:02                 ` Stefan Monnier
2011-05-02 15:19                   ` Antoine Levitt [this message]
2011-05-02 18:04                     ` Stefan Monnier
2011-05-02 21:29                       ` Antoine Levitt
2011-05-03  0:47                         ` Stefan Monnier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87d3k1ceqj.fsf@gmail.com \
    --to=antoine.levitt@gmail.com \
    --cc=emacs-devel@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).