unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#67182: 29.1; read-kbd-macro always return a vector
@ 2023-11-15  1:05 Jakub T. Jankiewicz
  2023-11-15 12:14 ` Eli Zaretskii
  0 siblings, 1 reply; 5+ messages in thread
From: Jakub T. Jankiewicz @ 2023-11-15  1:05 UTC (permalink / raw)
  To: 67182

This is the code I was always using in Emacs to send raw keys
to modes like ansi-term:

(defun raw (str)
  (interactive "sSend Raw Key: ")
  (term-send-raw-string (read-kbd-macro str)))

But this doesn't work anymore it throw an error [3] when calling:

(raw "C-c")

According to documentation `C-h f read-kbd-macro`
"The result will be a string if possible" but it seems that in new
GNU Emacs it's always a vector.

In GNU Emacs 29.1 (build 1, x86_64-redhat-linux-gnu, GTK+ Version
 3.24.38, cairo version 1.17.8) of 2023-09-24 built on
 e1d0f5fdfea948b9bb25e212c9c623e4
Windowing system distributor 'The X.Org Foundation', version 11.0.12014000
System Description: Fedora Linux 39 (Xfce)

Configured using:
 'configure --build=x86_64-redhat-linux-gnu
 --host=x86_64-redhat-linux-gnu --program-prefix=
 --disable-dependency-tracking --prefix=/usr --exec-prefix=/usr
 --bindir=/usr/bin --sbindir=/usr/sbin --sysconfdir=/etc
 --datadir=/usr/share --includedir=/usr/include --libdir=/usr/lib64
 --libexecdir=/usr/libexec --localstatedir=/var --runstatedir=/run
 --sharedstatedir=/var/lib --mandir=/usr/share/man
 --infodir=/usr/share/info --with-dbus --with-gif --with-jpeg --with-png
 --with-rsvg --with-tiff --with-xpm --with-x-toolkit=gtk3 --with-gpm=no
 --with-xwidgets --with-modules --with-harfbuzz --with-cairo --with-json
 --with-native-compilation=aot --with-tree-sitter --with-sqlite3
 --with-webp --with-xinput2 build_alias=x86_64-redhat-linux-gnu
 host_alias=x86_64-redhat-linux-gnu CC=gcc 'CFLAGS=-DMAIL_USE_LOCKF -O2
 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches
 -pipe -Wall -Werror=format-security
 -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS
 -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong
 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic
 -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection
 -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer '
 LDFLAGS=-Wl,-z,relro
 PKG_CONFIG_PATH=:/usr/lib64/pkgconfig:/usr/share/pkgconfig CXX=g++
 'CXXFLAGS=-O2 -flto=auto -ffat-lto-objects -fexceptions -g
 -grecord-gcc-switches -pipe -Wall -Werror=format-security
 -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS
 -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong
 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic
 -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection
 -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer ''

Configured features:
ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GSETTINGS HARFBUZZ JPEG JSON
LIBOTF LIBSELINUX LIBSYSTEMD LIBXML2 M17N_FLT MODULES NATIVE_COMP NOTIFY
INOTIFY PDUMPER PNG RSVG SECCOMP SOUND SQLITE3 THREADS TIFF
TOOLKIT_SCROLL_BARS TREE_SITTER WEBP X11 XDBE XIM XINPUT2 XPM XWIDGETS
GTK3 ZLIB

Important settings:
  value of $LC_ALL: C
  value of $LANG: pl_PL.utf8
  value of $XMODIFIERS: @im=none
  locale-coding-system: utf-8

Major mode: ELisp/d

Minor modes in effect:
  windmove-mode: t
  shell-dirtrack-mode: t
  whitespace-mode: t
  delete-selection-mode: t
  highlight-symbol-mode: t
  display-time-mode: t
  erc-autojoin-mode: t
  erc-scrolltobottom-mode: t
  minibuffer-depth-indicate-mode: t
  global-auto-revert-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  show-paren-mode: t
  mouse-wheel-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  column-number-mode: t
  line-number-mode: t
  transient-mark-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t

Load-path shadows:
/home/kuba/projects/emacs-modes/multiple-cursors.el/multiple-cursors hides
/home/kuba/projects/emacs-modes/multiple-cursors
/home/kuba/projects/emacs-modes/polymode/modes/poly-markdown hides
/home/kuba/projects/emacs-modes/poly-markdown
/home/kuba/projects/emacs-modes/expand-region.el/expand-region hides
/home/kuba/projects/emacs-modes/expand-region
/home/kuba/projects/emacs-modes/highlight-symbol.el/highlight-symbol hides
/home/kuba/projects/emacs-modes/highlight-symbol
/home/kuba/projects/emacs-modes/mark-multiple.el/mark-multiple hides
/home/kuba/projects/emacs-modes/mark-multiple
/home/kuba/projects/emacs-modes/web-mode/web-mode hides
/home/kuba/projects/emacs-modes/web-mode
/home/kuba/projects/emacs-modes/php-mode/php-mode hides
/home/kuba/projects/emacs-modes/php-mode
/home/kuba/projects/emacs-modes/clojure-mode hides
/home/kuba/.emacs.d/elpa/clojure-mode-20220418.2015/clojure-mode
/home/kuba/projects/emacs-modes/markdown-mode hides
/home/kuba/.emacs.d/elpa/markdown-mode-20181112.1529/markdown-mode
/home/kuba/projects/emacs-modes/typescript-mode hides
/home/kuba/.emacs.d/elpa/typescript-mode-20181018.553/typescript-mode
/home/kuba/projects/emacs-modes/json hides /usr/share/emacs/29.1/lisp/json
/home/kuba/projects/emacs-modes/csharp-mode hides
/usr/share/emacs/29.1/lisp/progmodes/csharp-mode
/home/kuba/projects/emacs-modes/linum hides
/usr/share/emacs/29.1/lisp/obsolete/linum

Features:
(shadow sort mail-extr emacsbug message yank-media rfc822 mml mml-sec
epa epg rfc6068 epg-config mm-decode mm-bodies mm-encode mail-parse
rfc2231 mailabbrev gmm-utils sendmail rfc2047 rfc2045 ietf-drums
windmove openai-chat shortdoc company-files company-oddmuse
company-keywords company-etags company-gtags company-dabbrev-code
company-dabbrev company-capf company-cmake company-xcode company-clang
company-semantic company-eclim company-template company-css company-nxml
company-bbdb make-mode tramp-cmds gambit cmuscheme scheme vc-hg vc-bzr
tramp-cache time-stamp tramp-sh tramp tramp-loaddefs trampver
tramp-integration files-x tramp-compat parse-time misearch multi-isearch
flyspell css-mode-expansions css-mode smie eww url-queue shr pixel-fill
kinsoku url-file svg mm-url gnus nnheader gnus-util range wid-edit
mm-util mail-prsvr color help-fns radix-tree cl-print debug backtrace
term shell ehelp whitespace cl-indent vc-git diff-mode vc-dispatcher
nodejs-repl tide tide-lv flycheck s typescript-mode delsel
highlight-chars highlight-symbol highlight-current-line time
multiple-cursors mc-hide-unmatched-lines-mode mc-separate-operations
rectangular-region-mode mc-mark-pop mc-mark-more mc-cycle-cursors
mc-edit-lines multiple-cursors-core rect bar-cursor repeat skeleton
erc-join erc-match tls gnutls puny erc-goodies erc iso8601 erc-backend
erc-networks erc-common erc-compat erc-loaddefs mb-depth ispell coverage
highlight htmlize js-comint expand-region text-mode-expansions
cc-mode-expansions the-org-mode-expansions js2-mode-expansions
js-mode-expansions web-mode-expansions html-mode-expansions
er-basic-expansions expand-region-core expand-region-custom
mark-more-like-this inline-string-rectangle mark-multiple yaml-mode
functions zencoding-mode notify whattf-dt html5-langs comp comp-cstr
cl-extra help-mode emmet-mode chatgpt spinner ht lv openai tblui
magit-popup dash tablist tablist-filter semantic/wisent/comp
semantic/wisent semantic/wisent/wisent semantic/util-modes semantic/util
semantic semantic/tag semantic/lex semantic/fw mode-local cedet dired
dired-loaddefs request mailheader mail-utils let-alist markdown-mode cl
autorevert filenotify web-mode disp-table company pcase edmacro kmacro
finder-inf prisma-mode po-mode po php-mode advice speedbar ezimage
dframe flymake-proc flymake compile warnings thingatpt add-log cc-langs
rjsx-mode sgml-mode facemenu dom js2-mode etags fileloop xref project js
c-ts-common treesit cc-mode cc-fonts cc-guess cc-menus cc-cmds cc-styles
cc-align cc-engine cc-vars cc-defs imenu eaf derived eaf-interleave
easy-mmode org-element org-persist xdg org-id org-refile avl-tree
generator org ob ob-tangle ob-ref ob-lob ob-table ob-exp org-macro
org-src ob-comint org-pcomplete pcomplete comint ansi-osc ansi-color
ring org-list org-footnote org-faces org-entities time-date noutline
outline icons ob-emacs-lisp ob-core ob-eval org-cycle org-table ol rx
org-fold org-fold-core org-keys oc org-loaddefs find-func cal-menu
calendar cal-loaddefs org-version org-compat org-macs format-spec
eaf-mindmap bookmark text-property-search pp dbus xml chatgpt-autoloads
ht-autoloads lv-autoloads openai-autoloads request-autoloads
tblui-autoloads tablist-autoloads info magit-popup-autoloads package
browse-url url url-proxy url-privacy url-expand url-methods url-history
url-cookie generate-lisp-file url-domsuf url-util mailcap url-handlers
url-parse auth-source cl-seq eieio eieio-core cl-macs password-cache
json subr-x map byte-opt gv bytecomp byte-compile url-vars cl-loaddefs
cl-lib 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 xwidget-internal dbusbind inotify dynamic-setting
system-font-setting font-render-setting cairo move-toolbar gtk x-toolkit
xinput2 x multi-tty make-network-process native-compile emacs)

Memory information:
((conses 16 874709 431017)
 (symbols 48 43878 1)
 (strings 32 161534 11291)
 (string-bytes 1 5158452)
 (vectors 16 68327)
 (vector-slots 8 1567256 115522)
 (floats 8 382 471)
 (intervals 56 20425 807)
 (buffers 984 35))

--
Jakub T. Jankiewicz, Senior Front-End Developer
https://jcubic.pl/me
https://koduj.org





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#67182: 29.1; read-kbd-macro always return a vector
  2023-11-15  1:05 bug#67182: 29.1; read-kbd-macro always return a vector Jakub T. Jankiewicz
@ 2023-11-15 12:14 ` Eli Zaretskii
  2023-11-15 12:45   ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 5+ messages in thread
From: Eli Zaretskii @ 2023-11-15 12:14 UTC (permalink / raw)
  To: Jakub T. Jankiewicz, Stefan Monnier; +Cc: 67182

> Date: Wed, 15 Nov 2023 02:05:35 +0100
> From: "Jakub T. Jankiewicz" <jcubic@jcubic.pl>
> 
> This is the code I was always using in Emacs to send raw keys
> to modes like ansi-term:
> 
> (defun raw (str)
>   (interactive "sSend Raw Key: ")
>   (term-send-raw-string (read-kbd-macro str)))
> 
> But this doesn't work anymore it throw an error [3] when calling:
> 
> (raw "C-c")
> 
> According to documentation `C-h f read-kbd-macro`
> "The result will be a string if possible" but it seems that in new
> GNU Emacs it's always a vector.

Thanks.

Stefan, this is due to your change in edmacro-parse-keys as part of
commit 87789330, whose log message says nothing about
edmacro-parse-keys.  Did you really intend to make that
backward-incompatible change?  If so, why?





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#67182: 29.1; read-kbd-macro always return a vector
  2023-11-15 12:14 ` Eli Zaretskii
@ 2023-11-15 12:45   ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2023-11-15 13:20     ` Jakub T. Jankiewicz
  0 siblings, 1 reply; 5+ messages in thread
From: Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-11-15 12:45 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Jakub T. Jankiewicz, 67182

>> This is the code I was always using in Emacs to send raw keys
>> to modes like ansi-term:
>> 
>> (defun raw (str)
>>   (interactive "sSend Raw Key: ")
>>   (term-send-raw-string (read-kbd-macro str)))
>> 
>> But this doesn't work anymore it throw an error [3] when calling:
>> 
>> (raw "C-c")

The above code already threw the same error when you call

    (raw "C-<mouse-1>")
or
    (raw "M-a")
or
    (raw "é")

:-(

Maybe it should be something like

    (defun raw (str)
      (interactive "sSend Raw Key: ")
      (let ((keys (kbd str))
            (string (condition-case err
                        (concat "" keys)
                      (wrong-type-argument
                       (let ((elem (nth 2 err)))
                         (error "%s is not a character"
                                (if (numberp elem)
                                    (prin1-char elem)
                                  elem)))))))
        (term-send-raw-string string)))

?

>> According to documentation `C-h f read-kbd-macro`
>> "The result will be a string if possible" but it seems that in new
>> GNU Emacs it's always a vector.
> Stefan, this is due to your change in edmacro-parse-keys as part of
> commit 87789330, whose log message says nothing about
> edmacro-parse-keys.  Did you really intend to make that
> backward-incompatible change?  If so, why?

Yes.  I want to eliminate the use of strings that stand for a sequence
of events because it does nothing more than leave latent bugs and create
confusion (between the strings used as input to `read-kbd-macro` and the
strings that used to be output by `read-kbd-macro`), while increasing
the complexity of the rest of the code which has to handle both vectors
and strings.


        Stefan






^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#67182: 29.1; read-kbd-macro always return a vector
  2023-11-15 12:45   ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2023-11-15 13:20     ` Jakub T. Jankiewicz
  2023-11-18  9:54       ` Eli Zaretskii
  0 siblings, 1 reply; 5+ messages in thread
From: Jakub T. Jankiewicz @ 2023-11-15 13:20 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: Eli Zaretskii, 67182

Then maybe the documentation for the function should be updated and in
changelog there is should a note about this breaking change.

On Wed, 15 Nov 2023 07:45:16 -0500
Stefan Monnier <monnier@iro.umontreal.ca> wrote:

> >> This is the code I was always using in Emacs to send raw keys
> >> to modes like ansi-term:
> >> 
> >> (defun raw (str)
> >>   (interactive "sSend Raw Key: ")
> >>   (term-send-raw-string (read-kbd-macro str)))
> >> 
> >> But this doesn't work anymore it throw an error [3] when calling:
> >> 
> >> (raw "C-c")  
> 
> The above code already threw the same error when you call
> 
>     (raw "C-<mouse-1>")
> or
>     (raw "M-a")
> or
>     (raw "é")
> 
> :-(
> 
> Maybe it should be something like
> 
>     (defun raw (str)
>       (interactive "sSend Raw Key: ")
>       (let ((keys (kbd str))
>             (string (condition-case err
>                         (concat "" keys)
>                       (wrong-type-argument
>                        (let ((elem (nth 2 err)))
>                          (error "%s is not a character"
>                                 (if (numberp elem)
>                                     (prin1-char elem)
>                                   elem)))))))
>         (term-send-raw-string string)))
> 
> ?
> 
> >> According to documentation `C-h f read-kbd-macro`
> >> "The result will be a string if possible" but it seems that in new
> >> GNU Emacs it's always a vector.  
> > Stefan, this is due to your change in edmacro-parse-keys as part of
> > commit 87789330, whose log message says nothing about
> > edmacro-parse-keys.  Did you really intend to make that
> > backward-incompatible change?  If so, why?  
> 
> Yes.  I want to eliminate the use of strings that stand for a sequence
> of events because it does nothing more than leave latent bugs and create
> confusion (between the strings used as input to `read-kbd-macro` and the
> strings that used to be output by `read-kbd-macro`), while increasing
> the complexity of the rest of the code which has to handle both vectors
> and strings.
> 
> 
>         Stefan
> 

--
Jakub T. Jankiewicz, Senior Front-End Developer
https://jcubic.pl/me
https://koduj.org





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#67182: 29.1; read-kbd-macro always return a vector
  2023-11-15 13:20     ` Jakub T. Jankiewicz
@ 2023-11-18  9:54       ` Eli Zaretskii
  0 siblings, 0 replies; 5+ messages in thread
From: Eli Zaretskii @ 2023-11-18  9:54 UTC (permalink / raw)
  To: Jakub T. Jankiewicz; +Cc: monnier, 67182-done

> Date: Wed, 15 Nov 2023 14:20:55 +0100
> From: "Jakub T. Jankiewicz" <jcubic@jcubic.pl>
> Cc: Eli Zaretskii <eliz@gnu.org>, 67182@debbugs.gnu.org
> 
> Then maybe the documentation for the function should be updated and in
> changelog there is should a note about this breaking change.

Done on the emacs-29 branch, and closing the bug.





^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-11-18  9:54 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-15  1:05 bug#67182: 29.1; read-kbd-macro always return a vector Jakub T. Jankiewicz
2023-11-15 12:14 ` Eli Zaretskii
2023-11-15 12:45   ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-11-15 13:20     ` Jakub T. Jankiewicz
2023-11-18  9:54       ` Eli Zaretskii

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).