From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Visuwesh Newsgroups: gmane.emacs.bugs Subject: bug#64584: 29.0.91; skeleton: cannot pass `str' as argument to some functions Date: Tue, 12 Sep 2023 08:06:25 +0530 Message-ID: <87bke8kthy.fsf@gmail.com> References: <87y1jloyao.fsf@gmail.com> <87fs3klos4.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="25899"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 64584@debbugs.gnu.org To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Sep 12 04:37:09 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qftH3-0006ac-3c for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 12 Sep 2023 04:37:09 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qftGu-0006m6-Cb; Mon, 11 Sep 2023 22:37:00 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qftGs-0006lg-6J for bug-gnu-emacs@gnu.org; Mon, 11 Sep 2023 22:36:58 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qftGr-0004dr-UY for bug-gnu-emacs@gnu.org; Mon, 11 Sep 2023 22:36:57 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qftGv-0004Dx-Oo for bug-gnu-emacs@gnu.org; Mon, 11 Sep 2023 22:37:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Visuwesh Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 12 Sep 2023 02:37:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 64584 X-GNU-PR-Package: emacs Original-Received: via spool by 64584-submit@debbugs.gnu.org id=B64584.169448620616213 (code B ref 64584); Tue, 12 Sep 2023 02:37:01 +0000 Original-Received: (at 64584) by debbugs.gnu.org; 12 Sep 2023 02:36:46 +0000 Original-Received: from localhost ([127.0.0.1]:55540 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qftGg-0004DR-1T for submit@debbugs.gnu.org; Mon, 11 Sep 2023 22:36:46 -0400 Original-Received: from mail-pl1-x642.google.com ([2607:f8b0:4864:20::642]:48290) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qftGZ-0004D9-Sf for 64584@debbugs.gnu.org; Mon, 11 Sep 2023 22:36:44 -0400 Original-Received: by mail-pl1-x642.google.com with SMTP id d9443c01a7336-1c0c6d4d650so43143045ad.0 for <64584@debbugs.gnu.org>; Mon, 11 Sep 2023 19:36:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694486189; x=1695090989; darn=debbugs.gnu.org; h=content-transfer-encoding:mime-version:user-agent:message-id:date :references:in-reply-to:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=UFexwUmtLP7+cbkqiwuagcnjPryfFeWCLMksrwTT9/E=; b=E7FmZwNLhA4EbSBaUDLFdVq50uWT+Awu8qjzoeMGl4STZTU6l3PiZFdk3vhyeEeb08 icIvr1XOCvSUXBSojKMfF5xILGRXFpkyhxr6PqqKfE0xo67au/hmEUqZ1j/Luc1MXhvY ONsOqwu/hdZxF8Wh57GSuXnBGWEY7MnKv2RQI/1TeQHlzLqj787lWcCCT8XquBmHSoKY j0i+Hq00IwP/UgQgzDuQ7yk6LRYZXpRHsq/2qb28IZOd8d/DvXgSLbIjffH4LK7ZqVwE vfO+HyZ5jG4nTSuC8+rCfW97Uvlwc6mCPWFaOMzeNzHMnXodFl00J+DnEC2Ha117edee 9STw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694486189; x=1695090989; h=content-transfer-encoding:mime-version:user-agent:message-id:date :references:in-reply-to:subject:cc:to:from:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=UFexwUmtLP7+cbkqiwuagcnjPryfFeWCLMksrwTT9/E=; b=dtliRwgn4/qr8KALdC3DVqe8VNAFO4kxpuM9KImJopS8QLeFShtQJdiDv3oOaAbTDp XSSJ/9uB6HTJbQLbj9aerJca8EekItwq0udNttklykFBYmFPRBpX/ckZQoY5G1uhGqE7 e8tgY8LBQj7J+toW9LQSwMMAjSZ5mbUYT97VbBojIv8mWpsGcsu1vFafcjB1Hch+Uh7v 1c3/7jBCQ5Ndyintm/YOLXGjaQqj96u2IVo2Kj1yMv3RxCAqYsjmljxQTChVNH48OhE5 JNXkTpAgZui7N/l9mpS6T5nhayLeu98v4+y+Iz0pVAwaoCFl0anVVezvaskXEnvjkVKb +DhQ== X-Gm-Message-State: AOJu0YxZJYBjMr/9FXyAo63Esd+BQny0jAe08RlGmiAZKST/tfbhjjqG Dp1r6Jt2FKBXYpP9aroBpzs= X-Google-Smtp-Source: AGHT+IGKncI/T59X63WtEMvlhIbfL9g7TzGrMydSlY9fcXYF3vnchRGTnWhychBZcS8t83vDfhMruw== X-Received: by 2002:a17:903:445:b0:1bb:dbec:40ba with SMTP id iw5-20020a170903044500b001bbdbec40bamr11193061plb.16.1694486189135; Mon, 11 Sep 2023 19:36:29 -0700 (PDT) Original-Received: from localhost ([115.240.90.130]) by smtp.gmail.com with ESMTPSA id ja10-20020a170902efca00b001b9da8b4eb7sm7144420plb.35.2023.09.11.19.36.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Sep 2023 19:36:28 -0700 (PDT) In-Reply-To: (Stefan Monnier's message of "Mon, 11 Sep 2023 18:12:28 -0400") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:270130 Archived-At: [=E0=AE=A4=E0=AE=BF=E0=AE=99=E0=AF=8D=E0=AE=95=E0=AE=B3=E0=AF=8D =E0=AE=9A= =E0=AF=86=E0=AE=AA=E0=AF=8D=E0=AE=9F=E0=AE=AE=E0=AF=8D=E0=AE=AA=E0=AE=B0=E0= =AF=8D 11, 2023] Stefan Monnier wrote: >>> It should work if you can change your skeleton to something like: >>> >>> (define-skeleton test-skeleton "" >>> (file-relative-name (read-file-name "P: ")) >>> str >>> (shell-quote-argument str)) >>> >>> where that first use of `str` will convert it from something that "read >>> a string according to INTERACTOR" to the actual string. >> >> ... this inserts the directory twice. :-( > > Of course, it changes the behavior of your skeleton. > I assumed that your *real* skeleton does something else anyway, so > I showed what kind of change might help. > > To do what your above skeleton does, you simply can't use `str`. > You need something like: > > (define-skeleton test-skeleton "" > nil > (shell-quote-argument (file-relative-name (read-file-name "P: ")))) > > instead. Yes, of course. I end up having to do something like the let form below (defun vz/read-relative-filename (&optional prompt dir) (let ((file (read-file-name (or prompt "Filname: ") dir ""))) (if (equal file "") "" (file-relative-name file default-directory)))) (define-skeleton imagemagick-collage-images "Collage/montage multiple images using imagemagick." nil "montage " ((let ((file (vz/read-relative-filename "Image: "))) (if (equal file "") "" (shell-quote-argument file))) str " ") "-geometry 00 " "-tile " (skeleton-read "How many columns (horizontal)? ") "x" (skeleton-read "How many rows (vertical)? ") (shell-quote-argument (vz/read-relative-filename "Out: "))) I was hoping I could avoid doing this. I wanted to ask you why the eval form used by skeleton errors but now I realise that str is a list when it is eval'ed in the example I gave in the OP; I was thinking of eval as some kind of macroexpansion instead. I disturbed you all for nothing, sorry. I can do (define-skeleton test "" (read-file-name "p: ") (shell-quote-argument (eval str))) instead and that works without the error. I do wonder if the eval can be avoided but this bug can be closed regardless. >> 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. >> 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. > > > Stefan Thanks for your patience and help.