[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: completion-ui.el question: my vimpulse-show-completion-menu function

From: Toby Cubitt
Subject: Re: completion-ui.el question: my vimpulse-show-completion-menu function always gives me an empty menu
Date: Wed, 14 Mar 2007 12:36:10 +0800
User-agent: Thunderbird (Windows/20070221)


I'm not surprised it doesn't work, because you're using completion-UI in completely the wrong way. (Excusable, since documentation is currently fairly non-existent :-) Instead, set 'completion-function' to a function that returns a list of possible completions, and leave completion-UI to do its job.

Your comment 2. is along the right lines: menu completion shouldn't be implemented in the vimpulse code base, or indeed in the code base of any other completion package. It should indeed be in something like the hippie-expand package. But that's precisely what completion-UI is! All the hippie-expand features, plus tooltips, menu-completion, auto-completion, hotkey completion etc. etc. Completion-UI is supposed to supersede hippie-expand, at least for in-buffer completion. So using completion-UI and hippie-expand at the same time is unlikely to work very well.

As an Elisp coder, you're not supposed to invoke *any* completion interface explicitly, as you've tried to do. Deciding which combination of user-interfaces to use is the user's business, not the package writer's. Maybe some users want to use menu completion, but others prefer to see a list in the echo area, whilst still others just want a tooltip to popup after a delay, etc. etc. Completion-UI offloads those choices onto the user, which is where they should be.

I hope that makes things a bit clearer. I fully appreciate that using completion-UI will be confusing until it's properly documented, although the commentary at the beginning of completion-ui.el does tersely explain how it should be used. (Setting 'completion-function' really is all there is to it, I promise!)


Jason Spiro wrote:
Hi all,

I am trying to get menu completion working for Alessandro Piras'
vimpulse.el, available on EmacsWiki.  (Menu completion is an
ultra-nice feature.  Instead of having to press M-/ over and over
until you get what you want, you get a drop-down menu listing the
completion options.  To see what menu completion looks like in Vim,

If you have Toby Cubitt's predictive completion from installed (incidentally, it's a very
cool package), I would appreciate if you could run this code so you
can answer my question 1 below:

;; Begin code {{{

(require 'completion-ui)

;; Note: This code has an additional bug in addition to the problem I
;; am asking about in this mailing list message:
;; When called with a MAXNUM of nil, this func sometimes fails.  (Seems
;; to work the first time, then fail all times after, in such cases.
;; To fix, call with a normal MAXNUM.)
(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)
   (insert-string prefix)
   (hippie-expand nil)
   (unless (string-equal (current-message) "No expansion found")
     (while (and
             (not (string-equal
                   "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))

(defun vimpulse-show-completion-menu ()
 (setq-default completion-function
 (setq completion-function 'vimpulse-try-hippie-expand-listed-functions)
 ;; is this always necessary?  Am I even ever supposed to call it?
 (completion-setup-overlay 'prefix)

;; }}} End code

1. Whenever I start typing a word then run
vimpulse-show-completion-menu I get an empty menu.  Why?  (Am I using
completion-show-menu wrong?  It errors on me if I don't call
completion-setup-overlay first, so I call it first.  Should I?  In
general, what is the proper way to use completion-show-menu?  It's not
perfectly documented.

2. Should menu completion really be part of vimpulse.el, or should I
try to get it into the hippie-expand source base?  Or, alternatively,
would someone like to take over maintainership of my attempt to get
menu completion working in Emacs?

Thanks in advance,

P.S. I am using GNU Emacs (i486-pc-linux-gnu, GTK+ Version
2.10.3) of 2006-09-19 on rothera, modified by Debian.  That's 6 months
old.  I am using predictive 0.16.2; I downloaded it today.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]