librep patch: completion of special commands
- From: Timo Korvola <Timo Korvola iki fi>
- To: sawfish-list gnome org
- Subject: librep patch: completion of special commands
- Date: Wed, 26 Sep 2007 21:57:26 +0300
I wonder if librep development is completely dead? The librep mailing
list certainly appears to be. Anyway, I tinkered with rep.util.repl a
bit and added tab completion for interpreter special commands such as
,apropos and ,describe. Since the completion works on a word basis
and a comma can also stand for unquote, completion alternatives for
words beginning with a comma are chosen from all bound symbols and
special commands.
--
Timo Korvola <URL:http://www.iki.fi/tkorvola>
diff --git a/lisp/rep/util/repl.jl b/lisp/rep/util/repl.jl
index 4a5334c..19dfcbb 100644
--- a/lisp/rep/util/repl.jl
+++ b/lisp/rep/util/repl.jl
@@ -51,6 +51,12 @@
(define (repl-eval form)
(eval form (intern-structure (repl-struct (fluid current-repl)))))
+ (define (repl-boundp sym)
+ (condition-case nil
+ (progn (repl-eval sym)
+ t)
+ (void-value nil)))
+
;; returns t if repl should run again
(define (repl-iterate repl input)
(setq input (concat (repl-pending repl) input))
@@ -135,13 +141,13 @@
(write standard-output #\newline)))))
(define (completion-generator w)
- (apropos (concat #\^ (quote-regexp w))
- (lambda (x)
- (condition-case nil
- (progn
- (repl-eval x)
- t)
- (void-value nil)))))
+ (if (string-head-eq w ",")
+ ;; Either a special command or unquote.
+ (mapcar (lambda (x) (concat "," (symbol-name x)))
+ (apropos (concat #\^ (quote-regexp (substring w 1)))
+ (lambda (x) (or (repl-boundp x)
+ (assq x repl-commands)))))
+ (apropos (concat #\^ (quote-regexp w)) repl-boundp)))
(define (repl-completions repl word)
(let-fluids ((current-repl repl))
@@ -404,12 +410,7 @@ commands may be abbreviated to their unique leading characters.\n\n")
'apropos
(lambda (re)
(require 'rep.lang.doc)
- (let ((funs (apropos re (lambda (x)
- (condition-case nil
- (progn
- (repl-eval x)
- t)
- (void-value nil))))))
+ (let ((funs (apropos re repl-boundp)))
(mapc (lambda (x)
(describe-value (repl-eval x) x)) funs)))
"\"REGEXP\"")
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]