unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* BibTeX completion via completion-in-region
@ 2009-12-05  4:56 Roland Winkler
  2009-12-05 16:08 ` Stefan Monnier
  0 siblings, 1 reply; 6+ messages in thread
From: Roland Winkler @ 2009-12-05  4:56 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

Hi Stefan

I noticed that you updated the completion code of BibTeX mode.
Three things:

- Suppose I want to complete the BibTeX string "AB".
  So I hit TAB while point is past the "AB".
  This gives me a buffer displaying possible completions, for example,
  "ABC" and "ABD".
  Then I select "ABC".
  This will insert the complete string "ABC" so that I get the
  awkward result "ABABC".
  I do not know whether this is related to the fact that
  completion-ignore-case is t in that case.
  (Maybe this is a known problem. There are some comments of that
  kind in minibuffer.el.)

- You greatly shortened the code of bibtex-complete-internal by
  calling completion-in-region. The code calling
  bibtex-complete-internal assumes that this function returns the
  completion. This still seems to work, though completion-in-region
  has no documented return value. So I suggest to make the
  completion the documented return value of completion-in-region.

- The return value of bibtex-complete-internal is used by
  bibtex-complete-string-cleanup which displays the expansion of the
  BibTeX string. Yet now this message can be hidden by the `Sole
  completion' message issued by minibuffer-complete. Here I am
  actually not sure what would be the best solution. I like the
  message that tells me the expansion of the BibTeX string (I cannot
  and will never be able to remember their meanings...). But I also
  understand that a "Sole completion' message can be helpful. And I
  know for sure that I am annoyed when one of these message is
  delayed by the other.

If you prefer, I can submit proper bug reports for these things.

Roland




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: BibTeX completion via completion-in-region
  2009-12-05  4:56 BibTeX completion via completion-in-region Roland Winkler
@ 2009-12-05 16:08 ` Stefan Monnier
  2009-12-05 17:45   ` Roland Winkler
  2009-12-06  0:14   ` Roland Winkler
  0 siblings, 2 replies; 6+ messages in thread
From: Stefan Monnier @ 2009-12-05 16:08 UTC (permalink / raw)
  To: Roland Winkler; +Cc: emacs-devel

>>>>> "Roland" == Roland Winkler <Roland.Winkler@physik.uni-erlangen.de> > - Suppose I want to complete the BibTeX string "AB".
>   So I hit TAB while point is past the "AB".
>   This gives me a buffer displaying possible completions, for example,
>   "ABC" and "ABD".
>   Then I select "ABC".
>   This will insert the complete string "ABC" so that I get the
>   awkward result "ABABC".
>   I do not know whether this is related to the fact that
>   completion-ignore-case is t in that case.
>   (Maybe this is a known problem. There are some comments of that
>   kind in minibuffer.el.)

That would be a bug, indeed.  Please report it.

> - You greatly shortened the code of bibtex-complete-internal by
>   calling completion-in-region. The code calling
>   bibtex-complete-internal assumes that this function returns the
>   completion. This still seems to work, though completion-in-region
>   has no documented return value. So I suggest to make the
>   completion the documented return value of completion-in-region.

As you can see in the code, it doesn't return the completion, but yes,
we should document that it returns a boolean.  I'll take care of it, no
need for a bug-report.

> - The return value of bibtex-complete-internal is used by
>   bibtex-complete-string-cleanup which displays the expansion of the
>   BibTeX string. Yet now this message can be hidden by the `Sole
>   completion' message issued by minibuffer-complete. Here I am
>   actually not sure what would be the best solution. I like the
>   message that tells me the expansion of the BibTeX string (I cannot
>   and will never be able to remember their meanings...). But I also
>   understand that a "Sole completion' message can be helpful. And I
>   know for sure that I am annoyed when one of these message is
>   delayed by the other.

That's a problem, indeed.  Please bug-report it.


        Stefan






^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: BibTeX completion via completion-in-region
  2009-12-05 16:08 ` Stefan Monnier
@ 2009-12-05 17:45   ` Roland Winkler
  2009-12-05 18:44     ` Stefan Monnier
  2009-12-06  0:14   ` Roland Winkler
  1 sibling, 1 reply; 6+ messages in thread
From: Roland Winkler @ 2009-12-05 17:45 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

On Sat Dec 5 2009 Stefan Monnier wrote:
> > - You greatly shortened the code of bibtex-complete-internal by
> >   calling completion-in-region. The code calling
> >   bibtex-complete-internal assumes that this function returns the
> >   completion. This still seems to work, though completion-in-region
> >   has no documented return value. So I suggest to make the
> >   completion the documented return value of completion-in-region.
> 
> As you can see in the code, it doesn't return the completion, but yes,
> we should document that it returns a boolean.  I'll take care of it, no
> need for a bug-report.

Yet then I am still confused about what is now the proper way to
hook into the completion mechanism if one wants to perform some
post-completion processing based on the actual value of the
completion that was selected by the user.

The old BibTeX code achieved this goal in two steps, by hooking into
choose-completion-string-functions plus using the return value of
bibtex-complete-internal. (Unfortunately, I cannot recall all
details anymore under which circumstances one or the other step was
needed.) Now bibtex-complete-internal does not return the completion
anymore (because of completion-in-region) so that this step doesn't
work anymore in the old way. Is this step really not needed anymore
(and should be removed from the code)? Is it sufficient now that the
post-completion procesing is done inside choose-completion-string-functions?

For the other things, I'll submit bug reports.

Roland




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: BibTeX completion via completion-in-region
  2009-12-05 17:45   ` Roland Winkler
@ 2009-12-05 18:44     ` Stefan Monnier
  2009-12-05 19:23       ` Roland Winkler
  0 siblings, 1 reply; 6+ messages in thread
From: Stefan Monnier @ 2009-12-05 18:44 UTC (permalink / raw)
  To: Roland Winkler; +Cc: emacs-devel

> The old BibTeX code achieved this goal in two steps, by hooking into
> choose-completion-string-functions plus using the return value of
> bibtex-complete-internal. (Unfortunately, I cannot recall all
> details anymore under which circumstances one or the other step was
> needed.) Now bibtex-complete-internal does not return the completion
> anymore (because of completion-in-region) so that this step doesn't
> work anymore in the old way. Is this step really not needed anymore
> (and should be removed from the code)? Is it sufficient now that the
> post-completion procesing is done inside choose-completion-string-functions?

Check bibtex-complete-internal again, it ends with:

    (when (completion-in-region beg end completions)
      (buffer-substring beg (point)))))

it's not perfect, but should work for now.
Bibtex-mode's completion (as well as a few others) show the need for
some kind of "completion-hook" that gets run when a completion is
performed (e.g. via TAB or via choosing something in the *Completions*
buffer), so this should/will be added at some point in the future.
Currently, I'm mostly going through all the packages and making them use
completion-in-region to try and see what needs to be added (like this
completion-hook).


        Stefan




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: BibTeX completion via completion-in-region
  2009-12-05 18:44     ` Stefan Monnier
@ 2009-12-05 19:23       ` Roland Winkler
  0 siblings, 0 replies; 6+ messages in thread
From: Roland Winkler @ 2009-12-05 19:23 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

On Sat Dec 5 2009 Stefan Monnier wrote:
> Check bibtex-complete-internal again, it ends with:
> 
>     (when (completion-in-region beg end completions)
>       (buffer-substring beg (point)))))
> 
> it's not perfect, but should work for now.

I see. I did not really look at the new code. Now I understand why
it appears to work as it used to.

Roland




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: BibTeX completion via completion-in-region
  2009-12-05 16:08 ` Stefan Monnier
  2009-12-05 17:45   ` Roland Winkler
@ 2009-12-06  0:14   ` Roland Winkler
  1 sibling, 0 replies; 6+ messages in thread
From: Roland Winkler @ 2009-12-06  0:14 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

On Sat Dec 5 2009 Stefan Monnier wrote:
> >>>>> "Roland" == Roland Winkler <Roland.Winkler@physik.uni-erlangen.de> > -
> Suppose
> I want to complete the BibTeX string "AB".
> >   So I hit TAB while point is past the "AB".
> >   This gives me a buffer displaying possible completions, for example,
> >   "ABC" and "ABD".
> >   Then I select "ABC".
> >   This will insert the complete string "ABC" so that I get the
> >   awkward result "ABABC".
> >   I do not know whether this is related to the fact that
> >   completion-ignore-case is t in that case.
> >   (Maybe this is a known problem. There are some comments of that
> >   kind in minibuffer.el.)
> 
> That would be a bug, indeed.  Please report it.

Stefan, just to let you know:

Whatever this was (possibly an inconsitent state while I was trying
various things), I cannot reproduce it anymore.

Roland




^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2009-12-06  0:14 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-12-05  4:56 BibTeX completion via completion-in-region Roland Winkler
2009-12-05 16:08 ` Stefan Monnier
2009-12-05 17:45   ` Roland Winkler
2009-12-05 18:44     ` Stefan Monnier
2009-12-05 19:23       ` Roland Winkler
2009-12-06  0:14   ` Roland Winkler

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).