Package: emacs;
Reported by: Joost Kremers <joostkremers <at> fastmail.fm>
Date: Sun, 28 Sep 2025 08:53:01 UTC
Severity: normal
Found in version 30.2
To reply to this bug, email your comments to 79527 AT debbugs.gnu.org.
Toggle the display of automated, internal messages from the tracker.
View this report as an mbox folder, status mbox, maintainer mbox
bug-gnu-emacs <at> gnu.org:bug#79527; Package emacs.
(Sun, 28 Sep 2025 08:53:01 GMT) Full text and rfc822 format available.Joost Kremers <joostkremers <at> fastmail.fm>:bug-gnu-emacs <at> gnu.org.
(Sun, 28 Sep 2025 08:53:02 GMT) Full text and rfc822 format available.Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
From: Joost Kremers <joostkremers <at> fastmail.fm> To: bug-gnu-emacs <at> gnu.org Subject: 30.2; Cannot evaluate variable in literate-scratch-mode Date: Sun, 28 Sep 2025 10:52:13 +0200
In literate-scratch-mode (a GNU Elpa package), when I try to evaluate a variable (e.g., `major-mode`) with `C-x C-e` or `C-j`, I get the following error: ``` Debugger entered--Lisp error: (void-variable ajor-mode) (progn ajor-mode) eval((progn ajor-mode) t) elisp--eval-last-sexp(t) #f(compiled-function () #<bytecode 0xf49b74d6449a>)() eval-last-sexp(t) eval-print-last-sexp(nil) funcall-interactively(eval-print-last-sexp nil) command-execute(eval-print-last-sexp) ``` For some reason, the first character of the symbol is chopped off. This is with Emacs 30.2 and the latest version of `literate-scratch-mode` from GNU Elpa. Recipe: - Start Emacs with `emacs -Q -L ~/.emacs.d/elpa/literate-scratch-2.2/` (or wherever the package is installed). - `M-: (require 'literate-scratch)` - `M-x literate-scratch-mode` (in the *scratch* buffer, obviously). - Type `major-mode` and press `C-x C-e` or `C-j`. PS: if this isn't the right place to report bugs with GNU Elpa packages, please let me know. TIA Joost Kremers In GNU Emacs 30.2 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.50, cairo version 1.18.4) System Description: Arch Linux Configured using: 'configure --with-pgtk --sysconfdir=/etc --prefix=/usr --libexecdir=/usr/lib --localstatedir=/var --disable-build-details --with-cairo --with-harfbuzz --with-libsystemd --with-modules --with-native-compilation=aot --with-tree-sitter 'CFLAGS=-march=x86-64 -mtune=generic -O2 -pipe -fno-plt -fexceptions -Wp,-D_FORTIFY_SOURCE=3 -Wformat -Werror=format-security -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -g -ffile-prefix-map=/build/emacs/src=/usr/src/debug/emacs -flto=auto' 'LDFLAGS=-Wl,-O1 -Wl,--sort-common -Wl,--as-needed -Wl,-z,relro -Wl,-z,now -Wl,-z,pack-relative-relocs -flto=auto' 'CXXFLAGS=-march=x86-64 -mtune=generic -O2 -pipe -fno-plt -fexceptions -Wp,-D_FORTIFY_SOURCE=3 -Wformat -Werror=format-security -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -Wp,-D_GLIBCXX_ASSERTIONS -g -ffile-prefix-map=/build/emacs/src=/usr/src/debug/emacs -flto=auto'' Configured features: ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG LCMS2 LIBOTF LIBSYSTEMD LIBXML2 MODULES NATIVE_COMP NOTIFY INOTIFY PDUMPER PGTK PNG RSVG SECCOMP SOUND SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS TREE_SITTER WEBP XIM GTK3 ZLIB Important settings: value of $LANG: en_GB.UTF-8 value of $XMODIFIERS: @im=ibus locale-coding-system: utf-8-unix Major mode: mu4e:main Minor modes in effect: magit-auto-revert-mode: t mu4e-search-minor-mode: t mu4e-update-minor-mode: t mu4e-context-minor-mode: t mu4e-modeline-mode: t flycheck-indicator-mode: t global-flycheck-eglot-mode: t minions-mode: t doom-modeline-mode: t which-key-mode: t ultra-scroll-mode: t pixel-scroll-precision-mode: t nerd-icons-completion-mode: t marginalia-mode: t prescient-persist-mode: t vertico-multiform-mode: t vertico-mode: t eros-mode: t hexl-follow-ascii: t global-diff-hl-mode: t global-git-commit-mode: t global-treesit-auto-mode: t breadcrumb-mode: t corfu-popupinfo-mode: t global-corfu-mode: t corfu-mode: t csv-field-index-mode: t override-global-mode: t server-mode: t repeat-mode: t winner-mode: t electric-pair-mode: t recentf-mode: t delete-selection-mode: t tooltip-mode: t global-eldoc-mode: t show-paren-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 minibuffer-regexp-mode: t buffer-read-only: 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 auto-save-visited-mode: t overwrite-mode: overwrite-mode-binary Load-path shadows: ~/.emacs.d/lisp/custom hides /usr/share/emacs/30.2/lisp/custom /home/joost/.emacs.d/elpa/transient-20250922.1438/transient hides /usr/share/emacs/30.2/lisp/transient /home/joost/.emacs.d/elpa/which-key-20240620.2145/which-key hides /usr/share/emacs/30.2/lisp/which-key /home/joost/.emacs.d/elpa/eglot-1.18/eglot hides /usr/share/emacs/30.2/lisp/progmodes/eglot /home/joost/.emacs.d/elpa/eldoc-1.16.0/eldoc hides /usr/share/emacs/30.2/lisp/emacs-lisp/eldoc /home/joost/.emacs.d/elpa/track-changes-1.4/track-changes hides /usr/share/emacs/30.2/lisp/emacs-lisp/track-changes Features: (shadow emacsbug guess-language smiley gnus-cite mail-extr textsec uni-scripts idna-mapping ucs-normalize uni-confusable textsec-check display-line-numbers tramp-cache time-stamp tramp-sh shortdoc unfill gptel-transient org-agenda org-ebib ebib-settings ebib ebib-reading-list ebib-notes ebib-filters ebib-keywords ebib-utils ebib-db parsebib magit-bookmark magit-submodule magit-blame magit-stash magit-reflog magit-bisect magit-push magit-pull magit-fetch magit-clone magit-remote magit-commit magit-sequence magit-notes magit-worktree magit-tag magit-merge magit-branch magit-reset magit-files magit-refs magit-status magit magit-repos magit-apply magit-wip magit-log which-func magit-diff smerge-mode magit-core magit-autorevert magit-margin magit-transient disproject mu4e-settings gnus-dired mu4e mu4e-org org-settings org-clock ob-sqlite ob-sql ob-shell ob-clojure ob-js ob-python ol-w3m org-tempo ol-rmail ol-mhe ol-irc ol-info ol-gnus nnselect ol-eww eww mm-url ol-doi org-link-doi ol-docview doc-view jka-compr ol-bibtex ol-bbdb cus-start org-element org-persist org-id org-refile org-element-ast inline avl-tree org ob ob-tangle ob-ref ob-lob ob-table ob-exp org-macro org-src sh-script smie executable ob-comint org-pcomplete org-list org-footnote org-faces org-entities org-version ob-emacs-lisp org-table ol org-keys oc org-loaddefs mu4e-notification mu4e-main smtpmail mu4e-view mu4e-mime-parts cal-menu calendar cal-loaddefs mu4e-headers mu4e-thread mu4e-actions mu4e-compose mu4e-draft gnus-msg gnus-art mm-uu mml2015 mm-view mml-smime smime dig gnus-sum gnus-group gnus-undo gnus-start gnus-dbus gnus-cloud nnimap nnmail mail-source utf7 nnoo gnus-spec gnus-int gnus-range gnus-win gnus nnheader range mu4e-search mu4e-lists mu4e-bookmarks mu4e-mark mu4e-labels mu4e-message shr pixel-fill kinsoku svg flow-fill mu4e-contacts mu4e-update mu4e-folders mu4e-context mu4e-query-items mu4e-server mu4e-modeline mu4e-vars mu4e-helpers mu4e-config mu4e-window mu4e-obsolete ace-window avy cl-print visual-wrap misearch multi-isearch vertico-sort help-fns radix-tree vc-git consult semel scope display-fill-column-indicator goggles flyspell flycheck-indicator sideline-flycheck flycheck-ledger flycheck-eglot flycheck-eldev flycheck noutline outline jk-input-methods quail eldoc-box solarized-light-theme solarized-theme solarized solarized-faces gptel-gemini gptel gptel-request gptel-openai go-translate gt-text-utility gt-extensions gt-taker-buffer-prompt gt-taker-fresh-words gt-render-posframe gt-render-overlay gt-render-kill-ring gt-render-insert gt-render-buffer gt-faces gt-render-alert gt-engine-echo gt-engine-libre gt-engine-chatgpt gt-engine-youdao gt-engine-osxdict gt-engine-stardict gt-engine-deepl gt-engine-google-rpc gt-engine-google gt-engine-bing gt-core pdd gnutls socks url-http url-auth url-gw nsm wgrep-ag wgrep grep uniline-transient uniline-core csv2ledger vterm bookmark term disp-table ehelp vterm-module term/xterm xterm ielm minions doom-modeline doom-modeline-segments doom-modeline-env doom-modeline-core shrink-path f which-key ultra-scroll pixel-scroll cua-base iimage image+ image-file image-converter nerd-icons-completion marginalia corfu-prescient prescient char-fold orderless vertico-multiform vertico linenote js-comint js c-ts-common cc-mode cc-fonts cc-guess cc-menus cc-cmds cc-styles cc-align cc-engine cc-vars cc-defs python-pytest edebug eros macrostep checkdoc lisp-mnt paredit dape hexl gdb-mi bindat gud eglot external-completion jsonrpc flymake diff ert debug backtrace find-func ag vc-svn compile find-dired boxquote diff-hl log-view vc-dir ewoc vc vc-dispatcher git-commit log-edit message yank-media puny rfc822 mml mml-sec epa epg rfc6068 epg-config gnus-util text-property-search mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader pcvs-util add-log magit-process with-editor magit-mode benchmark magit-git magit-base magit-section cursor-sensor crm llama cond-let autorevert filenotify aggressive-indent sendmail rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils nswbuff yaml-mode yaml treesit-auto typo reader derived render-core reftex reftex-loaddefs reftex-vars sqlup-mode sql view breadcrumb pulse color imenu sideline ht mule-util tab-jump-out corg ob-core org-cycle org-fold org-fold-core org-compat ob-eval org-macs s tramp trampver tramp-integration tramp-message tramp-compat shell parse-time tramp-loaddefs mixed-pitch face-remap biblio biblio-download biblio-dissemin biblio-ieee biblio-hal biblio-dblp biblio-crossref biblio-arxiv timezone biblio-doi biblio-core let-alist url-queue url-file ido hl-line bibtex iso8601 time-date posframe cape corfu-popupinfo corfu finder-inf nerd-icons nerd-icons-faces nerd-icons-data nerd-icons-data-mdicon nerd-icons-data-flicon nerd-icons-data-codicon nerd-icons-data-devicon nerd-icons-data-sucicon nerd-icons-data-wicon nerd-icons-data-faicon nerd-icons-data-powerline nerd-icons-data-octicon nerd-icons-data-pomicon nerd-icons-data-ipsicon ialign align ispell image-dired image-dired-tags image-dired-external image-dired-util xdg image-mode exif dired dired-loaddefs ediff ediff-merg ediff-mult ediff-wind ediff-diff ediff-help ediff-init ediff-util whitespace literate-scratch jk-functions csv-mode sort dash eshell esh-cmd esh-ext esh-opt esh-proc esh-io esh-arg pcomplete esh-module esh-module-loaddefs esh-util notifications dbus xml use-package use-package-ensure use-package-delight use-package-diminish use-package-bind-key use-package-core bind-key server repeat winner elec-pair recentf tree-widget delsel help-at-pt cus-edit cus-load wid-edit apheleia-autoloads async-autoloads auctex-autoloads tex-site avy-autoloads biblio-autoloads boxquote-autoloads breadcrumb-autoloads cape-autoloads clojure-mode-autoloads combobulate-autoloads combobulate-go combobulate-json combobulate-yaml combobulate-css combobulate-js-ts combobulate-python combobulate-html combobulate-toml combobulate-cursor multiple-cursors mc-separate-operations rectangular-region-mode mc-mark-pop mc-edit-lines mc-hide-unmatched-lines-mode mc-mark-more sgml-mode facemenu dom thingatpt mc-cycle-cursors multiple-cursors-core advice comp comp-cstr cl-extra help-mode warnings comp-run comp-common rect combobulate-query savehist xref files-x scheme combobulate-ui transient pp format-spec edmacro kmacro combobulate-display combobulate-ztree combobulate-envelope combobulate-manipulation python rx project compat comint ansi-osc ring ansi-color combobulate-procedure combobulate-navigation combobulate-misc combobulate-setup tempo combobulate-interface combobulate-settings diff-mode track-changes easy-mmode treesit generator combobulate-rules consult-denote-autoloads consult-flycheck-autoloads corfu-prescient-autoloads corfu-autoloads corg-autoloads csv-mode-autoloads dape-autoloads denote-autoloads devdocs-browser-autoloads diff-hl-autoloads disproject-autoloads dockerfile-mode-autoloads doom-modeline-autoloads eglot-booster-autoloads eglot-java-autoloads eldoc-box-autoloads embark-consult-autoloads consult-autoloads embark-autoloads eros-autoloads expand-region-autoloads flycheck-clj-kondo-autoloads flycheck-eglot-autoloads flycheck-eldev-autoloads fringe-helper-autoloads go-translate-autoloads goggles-autoloads gptel-autoloads guess-language-autoloads highlight-indent-guides-autoloads ialign-autoloads js-comint-autoloads js2-mode-autoloads json-navigator-autoloads jsonian-autoloads kivy-mode-autoloads kotlin-ts-mode-autoloads ledger-mode-autoloads literate-scratch-autoloads lte-autoloads edit-indirect-autoloads macrostep-autoloads magit-autoloads magit-section-autoloads llama-autoloads cond-let-autoloads marginalia-autoloads markdown-mode-autoloads minions-autoloads multiple-cursors-autoloads nerd-icons-completion-autoloads nerd-icons-corfu-autoloads nerd-icons-dired-autoloads nerd-icons-autoloads numpydoc-autoloads nushell-ts-mode-autoloads orderless-autoloads org-gcal-autoloads oauth2-auto-autoloads elnode-autoloads db-autoloads fakir-autoloads creole-autoloads kv-autoloads noflet-autoloads alert-autoloads log4e-autoloads gntp-autoloads aio-autoloads org-modern-autoloads paredit-autoloads parse-csv-autoloads pasvortilo-autoloads pdd-autoloads pdf-tools-autoloads persist-autoloads posframe-autoloads prescient-autoloads python-pytest-autoloads reader-autoloads request-deferred-autoloads request-autoloads deferred-autoloads semel-autoloads f-autoloads sideline-eglot-autoloads eglot-autoloads eldoc-autoloads sideline-flycheck-autoloads flycheck-autoloads sideline-autoloads ht-autoloads sly-overlay-autoloads sly-autoloads solarized-theme-autoloads sqlup-mode-autoloads tab-jump-out-autoloads tablist-autoloads tempel-autoloads track-changes-autoloads transient-autoloads treesit-auto-autoloads treesit-fold-autoloads typo-autoloads ultra-scroll-autoloads uniline-autoloads hydra-autoloads lv-autoloads vertico-autoloads vterm-autoloads vundo-autoloads web-autoloads dash-autoloads websocket-autoloads which-key-autoloads info with-editor-autoloads yaml-autoloads yaml-mode-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 icons password-cache json subr-x map byte-opt gv bytecomp byte-compile url-vars cl-loaddefs cl-lib pcase rmc iso-transl tooltip cconv eldoc paren electric uniquify ediff-hook vc-hooks lisp-float-type elisp-mode mwheel term/pgtk-win pgtk-win term/common-win touch-screen pgtk-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 cairo gtk pgtk lcms2 multi-tty move-toolbar make-network-process native-compile emacs) Memory information: ((conses 16 1389994 341425) (symbols 48 69797 112) (strings 32 385265 15100) (string-bytes 1 11893793) (vectors 16 160358) (vector-slots 8 2636756 217565) (floats 8 1371 7040) (intervals 56 14432 2450) (buffers 992 37)) -- Joost Kremers Life has its moments
bug-gnu-emacs <at> gnu.org:bug#79527; Package emacs.
(Sun, 28 Sep 2025 09:48:01 GMT) Full text and rfc822 format available.Message #8 received at 79527 <at> debbugs.gnu.org (full text, mbox):
From: Stephen Berman <stephen.berman <at> gmx.net> To: Joost Kremers <joostkremers <at> fastmail.fm> Cc: 79527 <at> debbugs.gnu.org Subject: Re: bug#79527: 30.2; Cannot evaluate variable in literate-scratch-mode Date: Sun, 28 Sep 2025 11:47:35 +0200
On Sun, 28 Sep 2025 10:52:13 +0200 Joost Kremers <joostkremers <at> fastmail.fm> wrote: > In literate-scratch-mode (a GNU Elpa package), when I try to evaluate a > variable (e.g., `major-mode`) with `C-x C-e` or `C-j`, I get the following > error: > > ``` > Debugger entered--Lisp error: (void-variable ajor-mode) > (progn ajor-mode) > eval((progn ajor-mode) t) > elisp--eval-last-sexp(t) > #f(compiled-function () #<bytecode 0xf49b74d6449a>)() > eval-last-sexp(t) > eval-print-last-sexp(nil) > funcall-interactively(eval-print-last-sexp nil) > command-execute(eval-print-last-sexp) > ``` > > For some reason, the first character of the symbol is chopped off. > > This is with Emacs 30.2 and the latest version of `literate-scratch-mode` > from GNU Elpa. > > Recipe: > > - Start Emacs with `emacs -Q -L ~/.emacs.d/elpa/literate-scratch-2.2/` (or > wherever the package is installed). > - `M-: (require 'literate-scratch)` > - `M-x literate-scratch-mode` (in the *scratch* buffer, obviously). > - Type `major-mode` and press `C-x C-e` or `C-j`. If you point on the first "m" of `major-mode' and type `C-u C-x =', you'll see near the bottom of the *Help* buffer that the character has the `syntax-table' property (11), which means the comment-start syntax class; when you enable literate-scratch-mode, this property is added by `literate-scratch--put-comment-start', called from `literate-scratch--propertize', which is the local value of `syntax-propertize-function' set when literate-scratch-mode is enabled. So "m" marks the line as a comment and "ajor-mode" is handled as Lisp code, here a variable that hasn't been defined. It looks like literate-scratch-mode treats plain text not beginning with an open parenthesis as a comment (but I haven't examined the code in detail). Steve Berman
bug-gnu-emacs <at> gnu.org:bug#79527; Package emacs.
(Sun, 28 Sep 2025 10:37:01 GMT) Full text and rfc822 format available.Message #11 received at 79527 <at> debbugs.gnu.org (full text, mbox):
From: Joost Kremers <joostkremers <at> fastmail.fm> To: Stephen Berman <stephen.berman <at> gmx.net> Cc: 79527 <at> debbugs.gnu.org, spwhitton <at> spwhitton.name Subject: Re: bug#79527: 30.2; Cannot evaluate variable in literate-scratch-mode Date: Sun, 28 Sep 2025 12:35:54 +0200
On Sun, Sep 28 2025, Stephen Berman wrote: > If you point on the first "m" of `major-mode' and type `C-u C-x =', > you'll see near the bottom of the *Help* buffer that the character has > the `syntax-table' property (11), which means the comment-start syntax > class; when you enable literate-scratch-mode, this property is added by > `literate-scratch--put-comment-start', called from > `literate-scratch--propertize', which is the local value of > `syntax-propertize-function' set when literate-scratch-mode is enabled. > So "m" marks the line as a comment and "ajor-mode" is handled as Lisp > code, here a variable that hasn't been defined. Thanks for the analysis, I hadn't thought of trying `C-u C-x =` or of looking at the fontification... > It looks like literate-scratch-mode treats plain text not beginning with > an open parenthesis as a comment (but I haven't examined the code in > detail). Yes, that's basically what literate-scratch-mode is about: being able to mix plain text with lisp code in the *scratch* buffer without it being marked as an error or confusing things like paredit. So I guess the question becomes: is this something that can be fixed, or is it an unfortunate side-effect of the implementation that cannot be mitigated? [Cc:-ing Sean Whitton, in case he's not on this list.] -- Joost Kremers Life has its moments
bug-gnu-emacs <at> gnu.org:bug#79527; Package emacs.
(Sun, 28 Sep 2025 17:20:02 GMT) Full text and rfc822 format available.Message #14 received at 79527 <at> debbugs.gnu.org (full text, mbox):
From: Sean Whitton <spwhitton <at> spwhitton.name> To: Joost Kremers <joostkremers <at> fastmail.fm>, Stefan Monnier <monnier <at> iro.umontreal.ca> Cc: Stephen Berman <stephen.berman <at> gmx.net>, 79527 <at> debbugs.gnu.org Subject: Re: bug#79527: 30.2; Cannot evaluate variable in literate-scratch-mode Date: Sun, 28 Sep 2025 18:19:20 +0100
Hello, On Sun 28 Sep 2025 at 12:35pm +02, Joost Kremers wrote: > On Sun, Sep 28 2025, Stephen Berman wrote: >> If you point on the first "m" of `major-mode' and type `C-u C-x =', >> you'll see near the bottom of the *Help* buffer that the character has >> the `syntax-table' property (11), which means the comment-start syntax >> class; when you enable literate-scratch-mode, this property is added by >> `literate-scratch--put-comment-start', called from >> `literate-scratch--propertize', which is the local value of >> `syntax-propertize-function' set when literate-scratch-mode is enabled. >> So "m" marks the line as a comment and "ajor-mode" is handled as Lisp >> code, here a variable that hasn't been defined. > > Thanks for the analysis, I hadn't thought of trying `C-u C-x =` or of > looking at the fontification... > >> It looks like literate-scratch-mode treats plain text not beginning with >> an open parenthesis as a comment (but I haven't examined the code in >> detail). > > Yes, that's basically what literate-scratch-mode is about: being able to > mix plain text with lisp code in the *scratch* buffer without it being > marked as an error or confusing things like paredit. > > So I guess the question becomes: is this something that can be fixed, or is > it an unfortunate side-effect of the implementation that cannot be > mitigated? This is an interesting problem. Thanks for reporting it. Although the first character of the line is indeed marked as a comment starter, that should mean that the syntax of the following characters is comment, too, not Lisp. So if something is handling "ajor-mode" as Lisp code, it's doing the wrong thing. It should handle the whole of "major-mode" as a comment. Then maybe C-j can't/shouldn't operate on names of symbols embedded in comments, but that would be a different problem. So it seems like this reveals a bug in elisp--preceding-sexp, which is what selects "ajor-mode" for evaluation. We might be able to fix the problem there. Adding Stefan, who wrote that function. > [Cc:-ing Sean Whitton, in case he's not on this list.] I'm here, but it's good to CC people anyway so make sure they see it. -- Sean Whitton
bug-gnu-emacs <at> gnu.org:bug#79527; Package emacs.
(Sun, 28 Sep 2025 17:45:02 GMT) Full text and rfc822 format available.Message #17 received at 79527 <at> debbugs.gnu.org (full text, mbox):
From: Stephen Berman <stephen.berman <at> gmx.net> To: Sean Whitton <spwhitton <at> spwhitton.name> Cc: Joost Kremers <joostkremers <at> fastmail.fm>, 79527 <at> debbugs.gnu.org, Stefan Monnier <monnier <at> iro.umontreal.ca> Subject: Re: bug#79527: 30.2; Cannot evaluate variable in literate-scratch-mode Date: Sun, 28 Sep 2025 19:43:49 +0200
On Sun, 28 Sep 2025 18:19:20 +0100 Sean Whitton <spwhitton <at> spwhitton.name> wrote: > Hello, > > On Sun 28 Sep 2025 at 12:35pm +02, Joost Kremers wrote: > >> On Sun, Sep 28 2025, Stephen Berman wrote: >>> If you point on the first "m" of `major-mode' and type `C-u C-x =', >>> you'll see near the bottom of the *Help* buffer that the character has >>> the `syntax-table' property (11), which means the comment-start syntax >>> class; when you enable literate-scratch-mode, this property is added by >>> `literate-scratch--put-comment-start', called from >>> `literate-scratch--propertize', which is the local value of >>> `syntax-propertize-function' set when literate-scratch-mode is enabled. >>> So "m" marks the line as a comment and "ajor-mode" is handled as Lisp >>> code, here a variable that hasn't been defined. >> >> Thanks for the analysis, I hadn't thought of trying `C-u C-x =` or of >> looking at the fontification... >> >>> It looks like literate-scratch-mode treats plain text not beginning with >>> an open parenthesis as a comment (but I haven't examined the code in >>> detail). >> >> Yes, that's basically what literate-scratch-mode is about: being able to >> mix plain text with lisp code in the *scratch* buffer without it being >> marked as an error or confusing things like paredit. >> >> So I guess the question becomes: is this something that can be fixed, or is >> it an unfortunate side-effect of the implementation that cannot be >> mitigated? > > This is an interesting problem. Thanks for reporting it. > > Although the first character of the line is indeed marked as a comment > starter, that should mean that the syntax of the following characters is > comment, too, not Lisp. So if something is handling "ajor-mode" as Lisp > code, it's doing the wrong thing. It should handle the whole of > "major-mode" as a comment. Then maybe C-j can't/shouldn't operate on > names of symbols embedded in comments, but that would be a different > problem. > > So it seems like this reveals a bug in elisp--preceding-sexp, which is > what selects "ajor-mode" for evaluation. We might be able to fix the > problem there. Adding Stefan, who wrote that function. With emacs -Q, I see that typing the line `;;major-mode' (without the quotes) in *scratch* and then at the end of that line typing `C-x C-e' displays `lisp-interaction-mode' in the echo area, but typing `C-j' at the end of that line raises a Lisp error: (end-of-file #<buffer *scratch*>) on calling `elisp--preceding-sexp'. Steve Berman
bug-gnu-emacs <at> gnu.org:bug#79527; Package emacs.
(Mon, 29 Sep 2025 19:06:02 GMT) Full text and rfc822 format available.Message #20 received at 79527 <at> debbugs.gnu.org (full text, mbox):
From: Stefan Monnier <monnier <at> iro.umontreal.ca> To: Joost Kremers <joostkremers <at> fastmail.fm> Cc: Stephen Berman <stephen.berman <at> gmx.net>, 79527 <at> debbugs.gnu.org, spwhitton <at> spwhitton.name Subject: Re: bug#79527: 30.2; Cannot evaluate variable in literate-scratch-mode Date: Mon, 29 Sep 2025 15:04:58 -0400
> So I guess the question becomes: is this something that can be fixed,
> or is it an unfortunate side-effect of the implementation that cannot
> be mitigated?
It could be mitigated in various different ways, but yes it's an
unfortunate side-effect of the implementation, and any mitigation is
bound to be "hackish" (come with its set of downsides).
> With emacs -Q, I see that typing the line `;;major-mode' (without the
> quotes) in *scratch* and then at the end of that line typing `C-x C-e'
> displays `lisp-interaction-mode' in the echo area, but typing `C-j' at
> the end of that line raises a Lisp error: (end-of-file #<buffer
> *scratch*>) on calling `elisp--preceding-sexp'.
`eval-last-sexp` is a command meant to be usable anywhere rather than
only in ELisp buffers (e.g. can be used to run ELisp snippets in the
middle of an email message, or inside a string/comment, ...).
Maybe `eval-last-sexp` should be changed to ignore `syntax-table` text
properties, but then in elisp-mode buffers it would not benefit from the
refinement of `elisp-mode-syntax-propertize`.
As for `C-j`, it's a binding specific to `lisp-interaction-mode`.
If `literate-scratch-mode` uses the exact same command for `C-j` and
that command gets confused by `literate-scratch-mode`, then the problem
is on the side of `literate-scratch-mode`. This said, it's not clear what
it *should* do when used on a non-code line, so it doesn't look like
a very serious problem. Maybe the best fix would be to recognize that
it's a comment and signal a clear "C-j in a comment doesn't make
sense" error.
Stefan
bug-gnu-emacs <at> gnu.org:bug#79527; Package emacs.
(Tue, 07 Oct 2025 15:55:01 GMT) Full text and rfc822 format available.Message #23 received at 79527 <at> debbugs.gnu.org (full text, mbox):
From: Sean Whitton <spwhitton <at> spwhitton.name> To: Joost Kremers <joostkremers <at> fastmail.fm> Cc: Stephen Berman <stephen.berman <at> gmx.net>, Stefan Monnier <monnier <at> iro.umontreal.ca>, 79527 <at> debbugs.gnu.org Subject: Re: bug#79527: 30.2; Cannot evaluate variable in literate-scratch-mode Date: Tue, 07 Oct 2025 16:54:16 +0100
Hello, On Mon 29 Sep 2025 at 03:04pm -04, Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" wrote: >> So I guess the question becomes: is this something that can be fixed, >> or is it an unfortunate side-effect of the implementation that cannot >> be mitigated? > > It could be mitigated in various different ways, but yes it's an > unfortunate side-effect of the implementation, and any mitigation is > bound to be "hackish" (come with its set of downsides). > >> With emacs -Q, I see that typing the line `;;major-mode' (without the >> quotes) in *scratch* and then at the end of that line typing `C-x C-e' >> displays `lisp-interaction-mode' in the echo area, but typing `C-j' at >> the end of that line raises a Lisp error: (end-of-file #<buffer >> *scratch*>) on calling `elisp--preceding-sexp'. > > `eval-last-sexp` is a command meant to be usable anywhere rather than > only in ELisp buffers (e.g. can be used to run ELisp snippets in the > middle of an email message, or inside a string/comment, ...). > Maybe `eval-last-sexp` should be changed to ignore `syntax-table` text > properties, but then in elisp-mode buffers it would not benefit from the > refinement of `elisp-mode-syntax-propertize`. > > As for `C-j`, it's a binding specific to `lisp-interaction-mode`. > If `literate-scratch-mode` uses the exact same command for `C-j` and > that command gets confused by `literate-scratch-mode`, then the problem > is on the side of `literate-scratch-mode`. This said, it's not clear what > it *should* do when used on a non-code line, so it doesn't look like > a very serious problem. Maybe the best fix would be to recognize that > it's a comment and signal a clear "C-j in a comment doesn't make > sense" error. Thanks Stefan. I'll have a look at elisp--preceding-sexp to see if there is a way to change it that doesn't have downsides, though you're probably right that there isn't. If not I'll look into changing C-j, either the lisp-interaction-mode binding, or giving it a separate binding in literate-scratch-mode. Joost, I won't work on this immediately, so patches welcome if you're interested. -- Sean Whitton
bug-gnu-emacs <at> gnu.org:bug#79527; Package emacs.
(Tue, 07 Oct 2025 18:25:01 GMT) Full text and rfc822 format available.Message #26 received at 79527 <at> debbugs.gnu.org (full text, mbox):
From: Joost Kremers <joostkremers <at> fastmail.fm> To: Sean Whitton <spwhitton <at> spwhitton.name> Cc: Stephen Berman <stephen.berman <at> gmx.net>, Stefan Monnier <monnier <at> iro.umontreal.ca>, 79527 <at> debbugs.gnu.org Subject: Re: bug#79527: 30.2; Cannot evaluate variable in literate-scratch-mode Date: Tue, 07 Oct 2025 20:24:25 +0200
> Joost, I won't work on this immediately, so patches welcome if you're > interested. If I find some time, I might take a look. No promises, though. -- Joost Kremers Life has its moments
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.