stumpwm-devel
[Top][All Lists]
Advanced

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

Re: [STUMP] [PATCH] Fixed problem with completion of `where-is' command,


From: Wojciech Meyer
Subject: Re: [STUMP] [PATCH] Fixed problem with completion of `where-is' command, now it also recognises not existent commands giving a proper message
Date: Mon, 21 Mar 2011 16:30:16 +0000

>
> Hi Wojciech,
>

Hi Ben,

Thank you for considering this patch!

>> +(defmacro with-command-completion (prompt initial-input cmd &body body)
>> +  "Prompt user with @var{prompt}, bind the command name into @{cmd}
>> +check for errors, commands existence then evaluate @{body}."
>> +  `(let ((cmd (completing-read (current-screen) ,prompt
>> +                               (all-commands) :initial-input (or 
>> initial-input ""))))
>> +     (unless ,cmd
>> +       (throw 'error :abort))
>> +     (when (and (plusp (length ,cmd))
>> +     (if (not (get-command-structure cmd))
>> +         (throw 'error (format nil "Command '~a' not found." cmd))
>> +       ,@body)))))
>
> Unless I've misunderstood what it's doing, this macro is missing some
> ,s - the current version depends on the names of the CMD and
> INITIAL-INPUT variables in the calling code.

Yes you are right I've spoted it after sending this code, sorry about this,
I can correct it. I am not a common lisper in fact :) (I do mostly O'Caml
these days).

>
> Also I believe the last bit could be simplified to:
>
>     (when (plusp (length ,cmd))
>       (if (get-command-structure ,cmd)
>           (progn ,@body)
>           (throw 'error (format nil "Command '~a' not found." ,cmd))))
>
> (the progn would be necessary if the body contained more than one
> clause).
>
> That said, this problem seems like a candidate for a
> define-stumpwm-type rather than a custom macro.  Is this infeasible
> for some reason?

Right, thanks for the hint I look at this stuff and rework it

>
> Ben
>

Thanks!!
Wojciech
> _______________________________________________
> Stumpwm-devel mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/stumpwm-devel
>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]