unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: SAKURAI Masashi <m.sakurai@kiwanami.net>
To: emacs-devel@gnu.org
Subject: Re: dropdown-list.el
Date: Sun, 22 May 2011 15:13:35 +0900	[thread overview]
Message-ID: <20110522061336.266B513C50D@vps1.kiwanami.net> (raw)
In-Reply-To: <87zkmgolrh.fsf@stupidchicken.com>

[-- Attachment #1: Type: text/plain, Size: 1923 bytes --]

At Fri, 20 May 2011 22:00:50 -0400,
Chong Yidong wrote:
> :
> It might be worth putting dropdown-list.el in Emacs core.  The code is
> not up to Emacs standards, but it is a relatively small library, and so
> should not be hard to clean up.  Has anyone taken a look at this before?
> Opinions welcome.

How about popup.el?
It was posted to gnu-emacs-sources on 7 March 2011 by Matsuyama san.
https://github.com/m2ym/popup-el/tree/v0.4

I compared three functions:
- dropdown-list (dropdown-list.el)
- popup-menu    (mouse.el)
- popup-menu*   (popup.el).

I attached the sample code in which the menus select from a string
list and insert a string.


* dropdown-list (dropdown-list.el)

The code is very short (about 260 lines) and easy to use.  Because the menu is drawn by
overlay texts, one can use this function in the terminal.

I think the library is too simple for general purposes. 
Particularly, this library can not treat many items well.

* popup-menu (mouse.el)

This function is included in the current Emacs. The menu is drawn by
the GUI menu, so one can not use in the terminal. The construction of
menu items is the same as the usual menu keymaps. But I think it is
little difficult to use for the quick selecting for transient menu
items.

* popup-menu* (popup.el)

The menu is also drawn by overlay texts, so one can use it in the terminal.
The code is not short (about 1000 lines), but it has many functions
and customization points for the general purposes.
It has following functions:

- one can scroll the menu in the case of many items
- incremental search and narrowing
- one can construct a cascading menu
- a menu item can display the summary and documentation 
  like completion menus in the Eclipse and Visual Studio.

The library popup.el is used by auto-complete (http://cx4a.org/software/auto-complete/).



I hope this article is helpful for discussion.

--
SAKURAI, Masashi (family, given)


[-- Attachment #2: popup-test.el --]
[-- Type: application/octet-stream, Size: 1384 bytes --]

;;; Simple popup menu comparing

(require 'dropdown-list)
(require 'popup)

(defvar ddtest-list 
  '("Dictaphone"
    "Dictaphone's"
    "dicta"
    "dicta's"
    "dictate"
    "dictated"
    "dictates"
    "dictating"
    "dictation"
    "dictation's"
    "dictations"
    "dictator"
    "dictator's"
    "dictatorial"
    "dictators"
    "dictatorship"
    "dictatorship's"
    "dictatorships"
    "diction"
    "diction's"
    "dictionaries"
    "dictionary"
    "dictionary's"
    "dictum"
    "dictum's"
    "dictums"))

(defun ddtest-show-dropdown-list ()
  (interactive)
  (let ((num (dropdown-list ddtest-list)))
    (and num (insert (nth num ddtest-list)))))

(defun ddtest-show-x-popup-menu ()
  (interactive)
  (let* ((menu-map (make-sparse-keymap "Popup Test")) val)
    (mapc (lambda (x) 
            (lexical-let ((x x))
              (define-key menu-map 
                (vector (intern x))
                (cons x (lambda () (interactive) (insert x))))))
          ddtest-list)
    (popup-menu menu-map)))

(defun ddtest-show-popup-menu ()
  (interactive)
  (let ((val (popup-menu*
              (mapcar (lambda (x) 
                        (popup-make-item x :value x))
                      ddtest-list)
              :scroll-bar t)))
    (and val (insert val))))

;; Do it.

;; (ddtest-show-dropdown-list)
;; (ddtest-show-x-popup-menu)
;; (ddtest-show-popup-menu)

  parent reply	other threads:[~2011-05-22  6:13 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-21  2:00 dropdown-list.el Chong Yidong
2011-05-21  9:38 ` dropdown-list.el Lennart Borgman
2011-05-22  6:13 ` SAKURAI Masashi [this message]
2011-05-22 11:48   ` dropdown-list.el Lennart Borgman
2011-05-22 12:28     ` dropdown-list.el Leo
2011-05-22 13:39       ` dropdown-list.el Lennart Borgman

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=20110522061336.266B513C50D@vps1.kiwanami.net \
    --to=m.sakurai@kiwanami.net \
    --cc=emacs-devel@gnu.org \
    /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 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).