Gnus development mailing list
 help / color / mirror / Atom feed
From: asjo@koldfront.dk (Adam Sjøgren)
To: ding@gnus.org
Cc: Stefan Monnier <monnier@iro.umontreal.ca>
Subject: Re: gcc tab completion strangeness
Date: Sun, 30 Jan 2011 14:49:06 +0100	[thread overview]
Message-ID: <87sjwa5wod.fsf@topper.koldfront.dk> (raw)
In-Reply-To: <87ipxwwg22.fsf@topper.koldfront.dk>

On Mon, 10 Jan 2011 23:27:01 +0100, Adam wrote:

> I thought it was just me as well when I saw it when completing in To:.

> git bisect says:

>   9464be87c026c732bc4a0b15e533cef2cf55f1a4 is the first bad commit
>   commit 9464be87c026c732bc4a0b15e533cef2cf55f1a4
>   Author: Stefan Monnier <monnier@iro.umontreal.ca>
>   Date:   Tue Dec 7 04:05:42 2010 +0000

>       message.el: Use completion-at-point.
>        (message-completion-function): New fun, extracted from message-tab.
>        (message-mode): Use it for completion-at-point-functions.
>        (message-tab): Use it and completion-at-point.

I have been edebugging this a little. The problem seems to be that
message-expand-name returns nil even when it completed something.

Here is the message-tab function:

    (defun message-tab ()
      "Complete names according to `message-completion-alist'.
    Execute function specified by `message-tab-body-function' when not in
    those headers."
      (interactive)
      (cond
       ((if (and (boundp 'completion-fail-discreetly)
                 (fboundp 'completion-at-point))
            (let ((completion-fail-discreetly t)) (completion-at-point))
          (funcall (or (message-completion-function) #'ignore)))
        ;; Completion was performed; nothing else to do.
        nil)
       (message-tab-body-function (funcall message-tab-body-function))
       (t (funcall (or (lookup-key text-mode-map "\t")
                       (lookup-key global-map "\t")
                       'indent-relative)))))

When I step through it, I hit (completion-at-point), and the To: line
gets completed, but the "cond" doesn't end there because
completion-at-point returns nil, and so it also tries the last two cond
clauses; the last one inserting the unwanted whitespace.

If I make the "if" take the "else" part, I get the completion in the To:
line and then the funcall returns nil, and the "cond" continues to the
two other clauses.

It looks like it boils down to message-expand-name returning nil because
bbdb-complete-name does. So, how to fix that...

This is the ugly, simple workaround:

--- a/lisp/message.el
+++ b/lisp/message.el
@@ -7911,7 +7911,8 @@ those headers."
         (eudc-expand-inline))
        ((and (memq 'bbdb message-expand-name-databases)
              (fboundp 'bbdb-complete-name))
-        (bbdb-complete-name))
+         (bbdb-complete-name)
+         t)
        (t
         (expand-abbrev))))

but then expand-abbrew won't be called when bbdb is available but fails...

Here is an attempt to return nil/t according to whether
bbdb-complete-name suceeded:

--- a/lisp/message.el
+++ b/lisp/message.el
@@ -7911,7 +7911,10 @@ those headers."
         (eudc-expand-inline))
        ((and (memq 'bbdb message-expand-name-databases)
              (fboundp 'bbdb-complete-name))
-        (bbdb-complete-name))
+         (let ((bbdb-complete-did-succeed nil)
+               (bbdb-complete-name-hooks '(lambda () (setq bbdb-complete-did-succeed t))))
+           (bbdb-complete-name)
+           bbdb-complete-did-succeed))
        (t
         (expand-abbrev))))

I looks quite ugly.

But it calls expand-abbrev if bbdb-complete-name doesn't complete.

And then the annoying whitespace is added.

Hm.


  Best regards,

    Adam

-- 
 "My ethicator machine must've had a built-in moral           Adam Sjøgren
  compromise spectral release phantasmatron!"            asjo@koldfront.dk




  reply	other threads:[~2011-01-30 13:49 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-10 18:58 Peter Münster
2011-01-10 20:42 ` Tassilo Horn
2011-01-10 20:58   ` Eric Abrahamsen
2011-01-10 22:27     ` Adam Sjøgren
2011-01-30 13:49       ` Adam Sjøgren [this message]
2011-01-31  2:18         ` Lars Ingebrigtsen
2011-01-31 21:47           ` Adam Sjøgren
     [not found]         ` <jwvlj21azom.fsf-monnier+emacs@gnu.org>
2011-01-31 19:44           ` Adam Sjøgren
2011-01-31 21:14             ` Stefan Monnier
2011-01-31 21:42               ` Adam Sjøgren
2011-02-01 14:09                 ` Stefan Monnier
2011-02-01  1:24               ` Lars Ingebrigtsen
2011-02-01 15:54                 ` Stefan Monnier
2011-01-11  8:26 ` Gijs Hillenius

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

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

  git send-email \
    --in-reply-to=87sjwa5wod.fsf@topper.koldfront.dk \
    --to=asjo@koldfront.dk \
    --cc=ding@gnus.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.
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 NNTP newsgroup(s).