|
Warning: this is an htmlized version!
The original is here, and the conversion rules are here. |
;
; Copyright (c) 2004-2007 by Keith M. Knowles.
; Confidential, unpublished property of Keith M. Knowles.
; All rights reserved.
;
;
; Program: Mini-Menu.
; Module: menu.el -- mini-menu facility.
; Version: 1
; Author: Keith M. Knowles.
; Date: Dec 2004
;
;
; Changes:
;
; 07/07/28 kmk Changed option letter format to [x] from x:. Also,
; return an ordinal, rather than the member.
; 06/04/27 kmk Fixed the menu overflow case by truncation.
; 04/12/28 kmk Initial version.
;
;
; Notes:
;
;
;
; Description:
;
; Pop up a "mini-menu" in the mini-buffer and return the user selection.
;
( defun mini-menu ( list )
"Pop-up mini-menu"
( interactive )
; Assemble a menu.
;
( let
( ( menu nil )
( letter "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890" ) )
( dolist ( menu-item list nil )
( if ( = ( string-to-char menu-item ) ?\" )
( setq menu-item ( substring menu-item 1 -1 ) )
)
( if ( not ( string-equal letter "" ) )
( progn
( setq menu ( concat menu "[" ( substring letter 0 1 ) "] " menu-item " " ) )
( setq letter ( substring letter 1 -1 ) )
)
)
)
( setq menu ( concat menu "? " ) )
( setq answer ( read-char menu ) )
( setq
answer
( cond
( ( and ( >= answer ?a ) ( <= answer ?z ) )
;( elt list ( - answer ?a ) )
( - answer ?a )
)
( ( and ( >= answer ?A ) ( <= answer ?Z ) )
;( elt list ( + ( - answer ?A ) 26 ) )
( + ( - answer ?A ) 26 )
)
( ( and ( >= answer ?0 ) ( <= answer ?9 ) )
;( elt list ( + ( - answer ?0 ) 52 ) )
( + ( - answer ?0 ) 52 )
)
( t nil )
)
)
)
)