Subject: bug#38775: (kbd "C-x ( ... C-x )") gulps "C-x (" and "C-x )"

From: Kritixi Lithos <[email-masked]>
Date: Sat, 28 Dec 2019 17:12:40 +0200

From `emacs -Q`, I write `(kbd "C-x ( C-d C-x )")` in the buffer, then
evaluate it using `C-M-x`, which gives "^D" instead of the expected
"^X(^D^X)". This can be seen more clearly by calling `key-description`
with the result from `kbd`, resulting in "C-d" instead of the expected
original string "C-x ( C-d C-x )". (Thanks to thblt from #emacs for this
minimal example).

The original problem was found when trying to call emacs keystrokes on
an input file (with the goal of achieving something like vim with the
`-c` flag) like so,
`emacs -Q --insert input.txt --eval '(command-execute(kbd"C-x ( C-d M-0
C-x )"))'`
Running this removes only 1 character from the input file instead of
every character being deleted as expected.

Another instance of this bug is https://emacs.stackexchange.com/q/33395
(thanks again to thblt for finding this).

These results were as tested on GNU Emacs 26.3.

In GNU Emacs 26.3 (build 1, x86_64-apple-darwin19.0.0)
of 2019-10-01 built on Catalina.local
Recent messages:
For information about GNU Emacs and the GNU system, type C-h C-a.
Making completion list... [2 times]

Configured using:
'configure --disable-dependency-tracking --disable-silent-rules
--enable-locallisppath=/usr/local/share/emacs/site-lisp
--infodir=/usr/local/Cellar/emacs/26.3/share/info/emacs
--prefix=/usr/local/Cellar/emacs/26.3 --with-gnutls --without-x
--with-xml2 --without-dbus --with-modules --without-ns
--without-imagemagick'

Configured features:
NOTIFY ACL GNUTLS LIBXML2 ZLIB MODULES THREADS

Important settings:
  value of $LC_ALL: en_US.UTF-8
  value of $LC_CTYPE: 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
  electric-indent-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug message rmc puny seq byte-opt gv
bytecomp byte-compile cconv cl-loaddefs cl-lib dired dired-loaddefs
format-spec rfc822 mml easymenu mml-sec password-cache epa derived epg
epg-config gnus-util rmail tool-bar rmail-loaddefs mm-decode mm-bodies
mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail
regexp-opt rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils
term/screen term/xterm xterm time-date elec-pair mule-util tooltip eldoc
electric uniquify ediff-hook vc-hooks lisp-float-type tabulated-list
replace newcomment text-mode elisp-mode lisp-mode prog-mode register
page menu-bar rfn-eshadow isearch timer select mouse jit-lock font-lock
syntax facemenu font-core term/tty-colors frame cl-generic 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 charscript charprop
case-table epa-hook jka-cmpr-hook help simple abbrev obarray minibuffer
cl-preloaded nadvice loaddefs button faces cus-face macroexp files
text-properties overlay sha1 md5 base64 format env code-pages mule
custom widget hashtable-print-readable backquote threads kqueue
multi-tty make-network-process emacs)

Memory information:
((conses 16 93401 5763)
(symbols 48 19401 1)
(miscs 40 35 71)
(strings 32 27575 976)
(string-bytes 1 742301)
(vectors 16 11803)
(vector-slots 8 448648 7552)
(floats 8 49 254)
(intervals 56 209 13)
(buffers 992 12))