bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#64584: 29.0.91; skeleton: cannot pass `str' as argument to some func


From: Visuwesh
Subject: bug#64584: 29.0.91; skeleton: cannot pass `str' as argument to some functions
Date: Tue, 12 Sep 2023 17:54:12 +0530
User-agent: Gnus/5.13 (Gnus v5.13)

[திங்கள் செப்டம்பர் 11, 2023] Stefan Monnier wrote:

>>>> AFAIU, using 'str should prevent the insertion of the value but that
>>>> signals the same error.
>>> Sorry, I don't know what you mean by that.
>> I meant this part in skeleton-insert's docstring
>>
>>     Quoted Lisp expressions are evaluated for their side-effects.
>
> Ah, I see.  Yes, using
>
>     'str
>
> should basically have no effect.

Yes, but here it basically does nothing unfortunately.  I am not sure if

    'str

should have the side effect of setting that variable.

>>>> I tried (progn str (shell-quote-argument str))
>>>> instead but the same error again.
>>> Of course: any use `str` within an actual expression (as opposed to
>>> using it as a skeleton element) will work reliably only if that occurs
>>> after a use of `str` as a skeleton element.
>> Thanks for your patience and help.
>
> We should try and improve the docs to clarify this confusing situation.
> If you have suggestions for how/where we could make changes that would
> have effectively discouraged you from trying to use `str` in that way,
> I'd be happy to hear them.

Unfortunately, I don't really remember what motivated me to end up with
such a skeleton.  I usually have the problems I face written as a
comment but this time I didn't.  Looking at the skeletons I have, ISTM
that I want the skeleton to "end" whenever I give the empty string as
the value for `str'.  In fact, I have a macro defined

    (defmacro vz/snippet-when (form &rest body)
      "Evaluate BODY if FORM returns non-nil or non-empty string."
      (declare (indent 1) (debug (form body)))
      `(let ((str ,form))
         (if (and str (equal str ""))
             ""
           ,@body)))

and have skeleton bodies such as

    (define-skeleton imagemagick-collage-images
      "Collage/montage multiple images using imagemagick."
      nil
      "montage "
      ((vz/snippet-when (vz/snippet-read-relative-filename "Image: ")
         (shell-quote-argument str))
       str " ")
      "-geometry +0+0 "
      "-tile " (skeleton-read "How many columns (horizontal)? ") "x"
      (skeleton-read "How many rows (vertical)? ")
      (shell-quote-argument (vz/snippet-read-relative-filename "Out: ")))

using it.





reply via email to

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