Permalink
Browse files

Change completing-read and read-one-line to use &key arguments

This breaks backward compatibility!
  • Loading branch information...
1 parent 2494f6a commit c9a53e6ac8f4a50272f58ac128f1cb4d8c619ed6 Shawn Betts committed May 12, 2010
Showing with 6 additions and 6 deletions.
  1. +1 −1 command.lisp
  2. +4 −4 input.lisp
  3. +1 −1 sample-stumpwmrc.lisp
View
2 command.lisp
@@ -545,7 +545,7 @@ know lisp very well. One might put the following in one's rc file:
(defcommand colon (&optional initial-input) (:rest)
"Read a command from the user. @var{initial-text} is optional. When
supplied, the text will appear in the prompt."
- (let ((cmd (completing-read (current-screen) ": " (all-commands) (or initial-input ""))))
+ (let ((cmd (completing-read (current-screen) ": " (all-commands) :initial-input (or initial-input "") :require-match t)))
(unless cmd
(throw 'error :abort))
(when (plusp (length cmd))
View
8 input.lisp
@@ -180,7 +180,7 @@
(make-array (length initial-input) :element-type 'character :initial-contents initial-input
:adjustable t :fill-pointer t))
-(defun completing-read (screen prompt completions &optional (initial-input "") require-match)
+(defun completing-read (screen prompt completions &key (initial-input "") require-match)
"Read a line of input through stumpwm and return it with TAB
completion. completions can be a list, an fbound symbol, or a
function. if its an fbound symbol or a function then that function is
@@ -191,10 +191,10 @@ match with an element of the completions."
(let ((*input-completions* completions)
(*input-current-completions* nil)
(*input-current-completions-idx* nil))
- (let ((line (read-one-line screen prompt initial-input require-match)))
+ (let ((line (read-one-line screen prompt :initial-input initial-input :require-match require-match)))
(when line (string-trim " " line)))))
-(defun read-one-line (screen prompt &optional (initial-input "") require-match)
+(defun read-one-line (screen prompt &key (initial-input "") require-match)
"Read a line of input through stumpwm and return it. returns nil if the user aborted."
(let ((*input-last-command* nil)
(input (make-input-line :string (make-input-string initial-input)
@@ -217,7 +217,7 @@ match with an element of the completions."
(if (or (not require-match)
(match-input))
(return (input-line-string input))
- (draw-input-bucket screen prompt input "^B^01[No match]" t)))))))
+ (draw-input-bucket screen prompt input "[No match]" t)))))))
(setup-input-window screen prompt input)
(catch :abort
(unwind-protect
View
2 sample-stumpwmrc.lisp
@@ -10,7 +10,7 @@
;; prompt the user for an interactive command. The first arg is an
;; optional initial contents.
(defcommand colon1 (&optional (initial "")) (:rest)
- (let ((cmd (read-one-line (current-screen) ": " initial)))
+ (let ((cmd (read-one-line (current-screen) ": " :initial-input initial)))
(when cmd
(eval-command cmd t))))

0 comments on commit c9a53e6

Please sign in to comment.