[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[eev] Interactive e-scripts
From: |
rubikitch |
Subject: |
[eev] Interactive e-scripts |
Date: |
Sat, 14 Jan 2006 06:10:35 +0900 (JST) |
Hi,
I think it is very useful to get input from Emacs minibuffer in e-scripts.
Here is the usage. Type F9, F9...
(eevnow-at "emacs-read")
emacs-read --prompt=str:
emacs-read --prompt=str: --initial="init"
emacs-read --prompt=str: --default="default"
emacs-read --prompt=str: --initial="init" --default="default"
emacs-read --prompt=compl: abc def ghi
emacs-read --prompt=compl: --require-match abc def ghi
emacs-read --prompt=compl: --require-match abc def ghi --initial=a
tmpdir
touch a.txt b.txt c.tex d.jpg
emacs-read --prompt=file: --require-match *.txt
tmpdir-clean
#
# emacs-read
# (eevnow-bounded)
emacs-read () {
cat <<'%%%' | ruby - "$@"
require 'optparse'
def gnudoit(lisp)
system "gnudoit", lisp
end
class NilClass
def inspect
"nil"
end
end
class TrueClass
def inspect
"t"
end
end
@initial = @default = @require_match = nil
ARGV.options {|o|
o.on("--prompt=PROMPT"){|x| @prompt="#{x}: "}
o.on("--initial=INITIAL"){|x| @initial=x}
o.on("--default=DEFAULT"){|x| @default=x}
o.on("--require-match"){ @require_match = true }
o.parse!
}
if ARGV.empty?
# If no arguments(except options), use read-string.
# (find-efunctiondescr 'read-string)
gnudoit %Q((read-string address@hidden address@hidden nil address@hidden))
else
# If any arguments(except options), use completing-read.
# (find-efunctiondescr 'completing-read)
collection = ARGV.map{|x| %Q((#{x.inspect}))}.join
collection = "'(" + collection + ")" # '
gnudoit %Q((completing-read address@hidden #{collection} nil address@hidden
address@hidden nil address@hidden))
end
%%%
}
#
--
rubikitch
http://www.rubyist.net/~rubikitch/
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [eev] Interactive e-scripts,
rubikitch <=