From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Leo <sdl.web@gmail.com>
Cc: emacs-devel@gnu.org
Subject: Re: `completion-in-region'
Date: Sun, 11 Apr 2010 11:32:32 -0400 [thread overview]
Message-ID: <jwvk4sexbvp.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <xbaityrif8q4.fsf@cam.ac.uk> (Leo's message of "Sun, 11 Apr 2010 13:56:51 +0100")
>> completion-in-region-functions is indeed meant for situations where you
>> want to either completely replace the completion UI with some other one
>> (à la completion-ui.el), or where you want to let-bind some completion
>> variables. But indeed, it hasn't been used much yet, so maybe a better
>> interface would make sense.
> BTW, some modern text editors (such as textmate) have started offering
> fuzzy completion as default.
Interesting. Do you have any details of what is meant by "fuzzy"?
[ BTW, I expect fuzzy matching to be a completion-style rather than
a completion-ui. The IO part is the part that chooses which keys do
what, where/how to display the list of completions, etc... whereas
the completion-style controls what is the possible list of
completions given a completion-table and a user input. ]
>>> The above comments are based on my experience to write two
>>> completions: one for TeX: I want the completion to automatically
>>> include a 'close' string (i.e. {} for LaTeX macros etc.), I can write
>>> a function for completion-at-point-functions which returns '(beg end
>>> completion-function) and do the adding in completion-function but it
>>> is difficult to control the position of point so that it locates
>>> between {}.
>>
>> Could you expand on what problems you've encountered when trying to add
>> it in completion-function? You may want to check how I used
>> completion-table-with-terminator in pcomplete.el for that same kind
>> of situation.
> I was trying to return a list of (beg end collections) and let
> completion-in-region do the job. But in the end I did something like
> this:
> (defun TeX-completion-at-point ()
> (let ((list TeX-complete-list) entry)
> (while list
> (setq entry (car list)
> list (cdr list))
> (if (TeX-looking-at-backward (car entry) 250)
> (setq list nil)))
> ;; ignore the useless ispell completion
> (when (numberp (nth 1 entry))
> (when (looking-at "\\w")
> (forward-word 1))
> (TeX-complete-symbol)
> ;; try leaving point in between parenthesis
> (when (looking-back "\\s)" (line-beginning-position))
> (skip-syntax-backward ")"))
> ;; this is discouraged
> ;; return a function that does nothing
> 'ignore)))
I don't see where this adds a terminating }.
> I haven't used pcomplete before so I will look at it later on.
My suggestion doesn't have anything to do with pcomplete.el except for
the fact that it's one place where I've used c-t-with-terminator.
I.e. I'm suggesting you use completion-table-with-terminator and the
pcomplete.el is just telling you where you can see it in use.
But "grep completion-table-with-terminator lisp/**/*.el" will show you
a few other uses (in meta-mode and make-mode, for example).
>>> Another for snippet (similar to abbrev), complete the snippet (abbrev) and
>>> then expand if completion succeeds.
>> Hmm... I do not understand the above two lines. They seem to lack
>> context or something.
> I am re-designing snippet.el
> (http://www.emacswiki.org/emacs/SnippetMode) to tightly integrate with
> abbrev. Emacs has abbreviation feature for a very long time but it
> hasn't advanced much. 'snippet' is a substantial step forward. It was
> original introduced in textmate and becomes so popular that almost all
> text editors have it now.
There have been many Emacs packages to do such things. Emacs itself
comes with skeleton.el, tempo.el, expand.el, and probably some more.
I'm not really interested in adding yet another such package to Emacs.
OTOH I'd be interested in consolidating them so as to try and reduce the
urge of people to reinvent them yet again.
> The completion I was talking about was for function
> `snippet-completion-at-point' which completes abbrevs and do the
> expansion if the completed string is an abbrev name; the abbrev
> expansion is then processed by snippet-region.
I see. So what problems have you encountered in this context?
[ BTW, you may want to generalize it to abbrev-complete-at-point since
it's likely to be easy to generalize to any abbreviation table.
We could install this in abbrev.el. ]
Stefan
next prev parent reply other threads:[~2010-04-11 15:32 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-04-06 14:37 `completion-in-region' Leo
2010-04-09 3:05 ` `completion-in-region' Stefan Monnier
2010-04-11 12:56 ` `completion-in-region' Leo
2010-04-11 15:32 ` Stefan Monnier [this message]
2010-04-11 18:05 ` `completion-in-region' Drew Adams
2010-04-11 19:44 ` `completion-in-region' Stefan Monnier
2010-04-11 19:56 ` `completion-in-region' Drew Adams
2010-04-11 20:49 ` `completion-in-region' Stefan Monnier
2010-04-11 21:13 ` `completion-in-region' Drew Adams
2010-04-11 20:08 ` `completion-in-region' Lennart Borgman
2010-04-11 20:51 ` `completion-in-region' Stefan Monnier
2010-04-11 21:06 ` `completion-in-region' Lennart Borgman
2010-04-12 2:10 ` `completion-in-region' Stefan Monnier
2010-04-12 9:46 ` `completion-in-region' Lennart Borgman
2010-04-12 13:10 ` `completion-in-region' Stefan Monnier
2010-04-12 14:50 ` `completion-in-region' Davis Herring
2010-04-11 21:12 ` `completion-in-region' Drew Adams
2010-04-12 15:36 ` `completion-in-region' Leo
2010-04-12 18:10 ` `completion-in-region' Stefan Monnier
2010-04-12 15:51 ` `completion-in-region' Leo
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=jwvk4sexbvp.fsf-monnier+emacs@gnu.org \
--to=monnier@iro.umontreal.ca \
--cc=emacs-devel@gnu.org \
--cc=sdl.web@gmail.com \
/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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.