Re: Byte compilation error.

Teika Kazura <teika lavabit com> writes:
> On Sat, 29 May 2010 09:06:42 -0500, Jeremy Hankins wrote:

>> The unfinished part has nothing to do with prompt.jl; I can apply
>> that anytime we decide it's time.  In fact, the sawfish that I run
>> myself has this patch applied and has for months.  The problem is
>> that it breaks backward-compatibility since it changes the way the
>> prompt code is called.
> We're not in hurry at all, but if you could do it, I'd appreciate it
> deeply. Is it easy for you to write a rough documentation on the
> usage? If it's supplied, then it's easy to update existent codes, so
> there'll be no problem.

Hmm..  Currently there is no documentation for prompt, only the source.
I've been meaning to write up some more thorough docs on using the
prompt module, maybe in the form of a tutorial.  But here's very rough
documentation of the changes:

In the past prompt has worked by allowing a variety of helper functions
and variables to be over-ridden by let statements at the time that
prompt is called.  With my changes in place these things are not passed
implicitly via let statements, but passed explicitly in the call to
prompt.  Here's an example from prompt-extras.jl that I think captures
all the changes: the prompt-for-file function presented as a diff
against the old way of doing things.

+(define filename-history (prompt-make-history))
 (define (prompt-for-file #!optional title existing start default)
   "Prompt for a file, if EXISTING is t only files which exist are
 allowed to be entered."
@@ -90,14 +100,17 @@ allowed to be entered."
   (setq start (if (stringp start)
                  (expand-file-name start)
                (file-name-as-directory default-directory)))
-  (let* ((prompt-completion-fun prompt-complete-filename)
-        (prompt-validation-fun (and existing prompt-validate-filename))
-        (prompt-abbrev-fun prompt-abbreviate-filename)
-        (str (prompt title start)))
+  (let ((str (prompt #:title title
+                     #:start start
+                     #:completion-fun prompt-complete-filename
+                     #:validation-fun (and existing prompt-validate-filename)
+                     #:abbrev-fun prompt-abbreviate-filename
+                     #:history filename-history)))
     (when (and (string= str "") default)
       (setq str default))

The prompt-make-history function is new; it creates a data structure
suitable for holding prompt history.  By creating a new history value
specifically for prompt-for-file the prompt history for files is kept
separately from, e.g., the history of prompts for sawfish commands.
It's a fluid rather than a special variable (in C terms, it's more like
a pointer than a global variable), so the reference must be passed to
prompt when prompt is called.  There is a default history defined in
prompt.jl so it's not necessary to supply a new history if you don't
want to.

The other big difference is the let*/let statement.  The
prompt-complete-filename, prompt-validate-filename, and
prompt-abbreviate-filename are helper functions defined elsewhere in
prompt-extras.jl, they haven't changed.  But in the new version they're
passed explicitly to prompt, along with title (the message prompting for
input, e.g., "Enter filename:"), start (any initial text, e.g., "~/")
and history (which holds the history of filename input).

Jeremy Hankins <nowan nowan org>

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]