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

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

bug#64584: closed (29.0.91; skeleton: cannot pass `str' as argument to s


From: GNU bug Tracking System
Subject: bug#64584: closed (29.0.91; skeleton: cannot pass `str' as argument to some functions)
Date: Tue, 12 Sep 2023 14:52:02 +0000

Your message dated Tue, 12 Sep 2023 20:20:56 +0530
with message-id <87ttrzjvhr.fsf@gmail.com>
and subject line Re: bug#64584: 29.0.91; skeleton: cannot pass `str' as 
argument to some functions
has caused the debbugs.gnu.org bug report #64584,
regarding 29.0.91; skeleton: cannot pass `str' as argument to some functions
to be marked as done.

(If you believe you have received this mail in error, please contact
help-debbugs@gnu.org.)


-- 
64584: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=64584
GNU Bug Tracking System
Contact help-debbugs@gnu.org with problems
--- Begin Message --- Subject: 29.0.91; skeleton: cannot pass `str' as argument to some functions Date: Wed, 12 Jul 2023 22:35:35 +0530 User-agent: Gnus/5.13 (Gnus v5.13)
In a skeleton template, it is not possible to pass `str' as an argument
to some functions.  To reproduce:

    1. emacs -Q

    2. Evaluate the following skeletons:

    (define-skeleton test-skeleton ""
      (file-relative-name (read-file-name "P: "))
      (shell-quote-argument str))

    (define-skeleton test-skeleton-2 ""
      (file-relative-name (read-file-name "P: "))
      (identity str))

    3. M-x test-skeleton RET RET -- witness it signal an error

    4. M-x test-skeleton-2 RET RET -- witness it insert "./"

I was able to reduce the problem down to the follwing sexp by edebbuging
skeleton-internal-1 (specifically the last `t' case in the cond signals
the error):

    (dlet ((str `(setq str "test"))
           (e `(shell-quote-argument str)))
      (eval e))

In GNU Emacs 29.0.91 (build 11, x86_64-pc-linux-gnu, X toolkit, Xaw
 scroll bars) of 2023-07-12 built on astatine
Repository revision: 17c7915ab947ebeec6ea5ad3eb4cad1f24d5d4fc
Repository branch: emacs-29
Windowing system distributor 'The X.Org Foundation', version 11.0.12101007
System Description: Debian GNU/Linux trixie/sid

Configured using:
 'configure --with-sound=alsa --with-x-toolkit=lucid --with-json
 --without-xaw3d --without-gconf --without-libsystemd --without-cairo'

Configured features:
ACL DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG JSON
LIBOTF LIBSELINUX LIBXML2 MODULES NOTIFY INOTIFY PDUMPER PNG RSVG
SECCOMP SOUND SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS WEBP X11 XDBE XFT
XIM XINPUT2 XPM LUCID ZLIB

Important settings:
  value of $LC_MONETARY: ta_IN.UTF-8
  value of $LC_NUMERIC: ta_IN.UTF-8
  value of $LANG: en_GB.UTF-8
  locale-coding-system: utf-8-unix

Major mode: Lisp Interaction

Minor modes in effect:
  tooltip-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  show-paren-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  line-number-mode: t
  indent-tabs-mode: t
  transient-mark-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t

Load-path shadows:
None found.

Features:
(shadow sort help-mode emacsbug mail-extr message sendmail mailcap
yank-media puny dired dired-loaddefs rfc822 mml mml-sec password-cache
epa derived epg rfc6068 epg-config gnus-util text-property-search
time-date subr-x mm-decode mm-bodies mm-encode mail-parse rfc2231
rfc2047 rfc2045 mm-util ietf-drums mail-prsvr mailabbrev mail-utils
gmm-utils mailheader cl-loaddefs cl-lib skeleton rmc iso-transl tooltip
cconv eldoc paren electric uniquify ediff-hook vc-hooks lisp-float-type
elisp-mode mwheel term/x-win x-win term/common-win x-dnd tool-bar dnd
fontset image regexp-opt fringe tabulated-list replace newcomment
text-mode lisp-mode prog-mode register page tab-bar menu-bar rfn-eshadow
isearch easymenu timer select scroll-bar mouse jit-lock font-lock syntax
font-core term/tty-colors frame minibuffer nadvice seq simple cl-generic
indonesian philippine cham georgian utf-8-lang misc-lang vietnamese
tibetan thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek
romanian slovak czech european ethiopic indian cyrillic chinese
composite emoji-zwj charscript charprop case-table epa-hook
jka-cmpr-hook help abbrev obarray oclosure cl-preloaded button loaddefs
theme-loaddefs faces cus-face macroexp files window text-properties
overlay sha1 md5 base64 format env code-pages mule custom widget keymap
hashtable-print-readable backquote threads dbusbind inotify
dynamic-setting system-font-setting font-render-setting x-toolkit
xinput2 x multi-tty make-network-process emacs)

Memory information:
((conses 16 41879 11878)
 (symbols 48 5521 1)
 (strings 32 14721 2050)
 (string-bytes 1 393181)
 (vectors 16 10382)
 (vector-slots 8 158438 14259)
 (floats 8 44 14)
 (intervals 56 314 11)
 (buffers 976 13))



--- End Message ---
--- Begin Message --- Subject: Re: bug#64584: 29.0.91; skeleton: cannot pass `str' as argument to some functions Date: Tue, 12 Sep 2023 20:20:56 +0530 User-agent: Gnus/5.13 (Gnus v5.13)
[செவ்வாய் செப்டம்பர் 12, 2023] Stefan Monnier wrote:

>> Yes, but here it basically does nothing unfortunately.  I am not sure if
>>
>>     'str
>>
>> should have the side effect of setting that variable.
>
> The above skeleton expression means "eval the variable `str` and throw
> away the result".  The only effect it can have is to signal an error if
> the variable `str` is not bound.

Ah yes, of course.  I am still thinking in vague terms of macroexpansion
which is leading to all the misunderstandings.

>>     (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)))
>
> FWIW, this style of macro is usually called "anaphoric macro" and the
> convention is to use the identifier `it` rather than `str` in them.
> It would help avoid a confusion between skeleton's `str` and your
> macro's variable.

Oh yes, I called `it' first but changed it `str' "in anger".  So far, I
haven't been in the need of using both vz/snippet-when's `str' and
skeleton's `str' so I will let the sleeping dogs lie.

> [ And, yes, arguably, `define-skeleton` could be considered as an
>   anaphoric macro as well which should use `it` instead of `str`,
>   bringing back the confusion :-)  ]

I guess it wasn't chosen because there are other variables too (like
help, v1, v2, etc.).

I cannot think of any improvements to the documentation since the spawn
of this bug report is rooted in a lack of understanding of how skeleton
works.  There is nothing to fix here except my understanding so I'm
closing the bug report with this.  Thank you again for your time,
Stefan.


--- End Message ---

reply via email to

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