From: Toby Cubitt <t.s.cubitt.98@cantab.net>
To: Jason Spiro <jasonspiro4@gmail.com>
Cc: help-gnu-emacs@gnu.org
Subject: Re: Fwd: completion-ui.el question: my vimpulse-show-completion-menu function always gives me an empty menu
Date: Fri, 13 Apr 2007 10:50:29 +0200 [thread overview]
Message-ID: <461F4455.3080209@dr-qubit.org> (raw)
In-Reply-To: <c241693f0704130131t3478d3bckf8b70b0ab60d957a@mail.gmail.com>
Jason Spiro wrote:
> 2007/4/13, Toby Cubitt <tsc25@cantab.net> wrote:
>> (defun vimpulse-try-hippie-expand-listed-functions
>> (prefix &optional maxnum)
>> ; (interactive "*MString to expand:
>> ;nMaximum number of expansions, or nil for unlimited: ")
>> (setq expansions nil)
>> (with-temp-buffer
>> (insert-string prefix)
>> (hippie-expand nil)
>> (unless (string-equal (current-message) "No expansion found")
>> (while (and
>> (not (string-equal
>> (current-message)
>> "No further expansions found"))
>> (if maxnum (not (= (length expansions) maxnum))))
>> ;; Hippie-expand was designed to be run interactively. If
>> ;; this-command and last-command are equal, it assumes it's
>> ;; being called as a "repeated use" (additional call without
>> ;; moving the point) and searches for additional expansions
>> ;; with the same prefix. So, make this-command and
>> ;; last-command equal.
>> (setq this-command last-command)
>> (hippie-expand nil)
>> (add-to-list 'expansions (buffer-string))
>> (buffer-string)
>> ))
>> expansions))
> This is almost OK. Completion-UI expects the completion-function to
> return a list of completion strings *without* the prefix. So you need
> to change "expansions" in the last line to:
> (mapcar (lambda (str) (substring str 1)) expansions)
Sorry, this isn't quite correct. It should of course be:
(mapcar (lambda (str) (substring str (length prefix))) expansions)
>> How exactly does this multiple-word completion work? I don't follow.
>
> For example, type: The quick brown fox jumped over the lazy dog. My
> favorite foM-/ SPC M-/ SPC M-/ SPC M-/ SPC M-/ SPC M-/
>
> It should write: The quick brown fox jumped over the lazy dog. My
> favorite fox jumped over the lazy dog"
I see. This relies on the fact that the first dabbrev expansion is the
one that is closest in the buffer. If you're completion function (or
rather, hippie-expand's) returned the completions in this order, you
could get the same behaviour using completion-UI. My personal favourite
is to enable 'completion-use-dynamic', so that you don't even need to
type the M-/ equivalent (M-TAB).
Toby
prev parent reply other threads:[~2007-04-13 8:50 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-04-12 23:16 completion-ui.el question: my vimpulse-show-completion-menu function always gives me an empty menu Jason Spiro
[not found] ` <c241693f0704121619i14d16188j2cdb3e5c6baf6860@mail.gmail.com>
2007-04-13 8:00 ` Fwd: " Toby Cubitt
2007-04-13 8:31 ` Jason Spiro
2007-04-13 8:50 ` Toby Cubitt [this message]
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=461F4455.3080209@dr-qubit.org \
--to=t.s.cubitt.98@cantab.net \
--cc=help-gnu-emacs@gnu.org \
--cc=jasonspiro4@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.