GNU bug report logs - #78365
31.0.50; make-mode has no way to turn off confirmations before saving when it thinks there may be a syntax error

Previous Next

Package: emacs;

Reported by: Lynn Winebarger <owinebar <at> gmail.com>

Date: Sun, 11 May 2025 00:02:02 UTC

Severity: normal

Found in version 31.0.50

To reply to this bug, email your comments to 78365 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


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#78365; Package emacs. (Sun, 11 May 2025 00:02:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Lynn Winebarger <owinebar <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sun, 11 May 2025 00:02:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Lynn Winebarger <owinebar <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 31.0.50; make-mode has no way to turn off confirmations before saving
 when it thinks there may be a syntax error
Date: Sat, 10 May 2025 20:01:01 -0400
[Message part 1 (text/plain, inline)]
I've been hacking on Makefiles, and I habitually save while rewriting,
not just when I have a finished edit.  I may also have autosave turned
on.  There were annoying confirmation requests when that happened, and
if I did not notice (maybe due to autosave), the requests pile up and
once a later one has been answered, an earlier one reappears but either
can't accept the input or maybe there were a bunch of warnings queued
up.  Or maybe there was some kind of implicit loop, where confirming the
save after some timer ran out caused another confirmation request.  I
don't know.  But there's no customization to let the user decide whether
they want this intrusive behavior.

I have attached a patch to let the user set the list of hooks that will
be run when the buffer is written, with the default being the current
set that are used.  At least I can set it to nil.



In GNU Emacs 31.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version
3.24.43, cairo version 1.18.0)
Repository revision: 2bced74aa9735d9a9a5cb00aedfcac72d54f5d50
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12101011
System Description: openSUSE Leap 15.6

Configured using:
 'configure --enable-checking=yes,glyphs --enable-check-lisp-object-type
 'CFLAGS=-O0 -g3' --infodir=/usr/local/share/emacs/31/share/info
 --mandir=/usr/local/share/emacs/31/share/man
 --docdir=/usr/local/share/emacs/31/share/doc/emacs
 --localedir=/usr/local/share/emacs/31/share/locale --with-x --with-xim
 --with-sound --with-xpm --with-jpeg --with-tiff --with-gif --with-png
 --with-rsvg --with-imagemagick --with-dbus --with-gpm
 --with-x-toolkit=gtk3 --with-toolkit-scroll-bars --with-libotf
 --with-m17n-flt --with-cairo --disable-build-details --without-pop
 --with-mailutils --without-hesiod --with-gameuser=:games
 --with-kerberos --with-kerberos5 --with-file-notification=inotify
 --with-modules --with-tree-sitter -C'

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

Important settings:
  value of $LANG: en_US.utf8
  value of $XMODIFIERS: @im=ibus
  locale-coding-system: utf-8-unix

Major mode: Fundamental

Minor modes in effect:
  global-semanticdb-minor-mode: t
  global-semantic-idle-breadcrumbs-mode: t
  global-semantic-idle-completions-mode: t
  global-semantic-idle-scheduler-mode: t
  global-semantic-idle-local-symbol-highlight-mode: t
  global-semantic-idle-summary-mode: t
  global-semantic-highlight-func-mode: t
  global-semantic-stickyfunc-mode: t
  global-semantic-show-parser-state-mode: t
  global-semantic-highlight-edits-mode: t
  semantic-mode: t
  global-so-long-mode: t
  global-hl-line-mode: t
  hexl-follow-ascii: t
  windmove-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  show-paren-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  global-prettify-symbols-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  blink-cursor-mode: t
  minibuffer-regexp-mode: t
  buffer-read-only: t
  column-number-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 mail-extr emacsbug message yank-media puny dired
dired-loaddefs rfc822 mml mml-sec epa derived epg rfc6068 epg-config
gnus-util mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev
gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums mm-util
mail-prsvr mail-utils help-at-pt time-date semantic/db-mode
semantic/idle semantic/analyze semantic/sort semantic/scope
semantic/analyze/fcn semantic/db semantic/format semantic/tag-ls
semantic/find semantic/ctxt semantic/util-modes semantic/util semantic
semantic/tag semantic/lex semantic/fw ede/speedbar ede/files ede
cl-extra ede/detect ede/base ede/auto ede/source eieio-base
eieio-speedbar eieio-custom cedet delsel cus-load allout-widgets allout
smerge-mode ediff ediff-merg ediff-mult ediff-wind ediff-diff ediff-help
ediff-init ediff-util treesit-x transient format-spec edmacro kmacro
time html-ts-mode conf-mode emacs-authors-mode emacs-news-mode refer
nroff-mode table remember sgml-mode facemenu dom yaml-ts-mode underline
texinfo texinfo-loaddefs term disp-table ehelp tab-line tempo so-long
sqlite-mode skeleton scroll-lock rtree reveal pulse color profiler
proced pcmpl-x pcmpl-linux pcmpl-git vc-git files-x vc-dispatcher
noutline outline misc hi-lock ibuffer ibuffer-loaddefs hl-line hexl ffap
chart bindat avl-tree disass memory-report mode-local lisp-mnt edebug
ielm hippie-exp image-file image-converter autoconf autoconf-mode
c++-ts-mode c-ts-mode c-ts-common etags fileloop generator make-mode gud
inf-lisp shell pcomplete hideshow ruler-mode speedbar ezimage dframe
sqlite treesit windmove eglot tree-widget wid-edit external-completion
jsonrpc xref flymake thingatpt project diff diff-mode track-changes
easy-mmode ert pp ewoc debug backtrace help-mode find-func filenotify
warnings compile text-property-search comint ansi-osc ansi-color ring
pcase imenu ispell package browse-url xdg 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 info 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
touch-screen 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 lcms2 dynamic-setting system-font-setting
font-render-setting cairo gtk x-toolkit xinput2 x multi-tty move-toolbar
make-network-process tty-child-frames emacs)

Memory information:
((conses 16 224623 38463) (symbols 48 25118 0) (strings 32 69778 2204)
 (string-bytes 1 1825120) (vectors 16 44197)
 (vector-slots 8 443913 13792) (floats 8 215 2) (intervals 56 553 0)
 (buffers 992 14))
[make-mode.patch (text/x-patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#78365; Package emacs. (Sun, 11 May 2025 05:07:01 GMT) Full text and rfc822 format available.

Message #8 received at 78365 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Lynn Winebarger <owinebar <at> gmail.com>
Cc: 78365 <at> debbugs.gnu.org
Subject: Re: bug#78365: 31.0.50;
 make-mode has no way to turn off confirmations before saving when it
 thinks there may be a syntax error
Date: Sun, 11 May 2025 08:06:48 +0300
> From: Lynn Winebarger <owinebar <at> gmail.com>
> Date: Sat, 10 May 2025 20:01:01 -0400
> 
> I've been hacking on Makefiles, and I habitually save while rewriting,
> not just when I have a finished edit.  I may also have autosave turned
> on.  There were annoying confirmation requests when that happened, and
> if I did not notice (maybe due to autosave), the requests pile up and
> once a later one has been answered, an earlier one reappears but either
> can't accept the input or maybe there were a bunch of warnings queued
> up.

AFAIU, autosave is not supposed to run these hooks, so if that
happened to you, it's a bug.  Can you show a recipe for reproducing
this?

> Or maybe there was some kind of implicit loop, where confirming the
> save after some timer ran out caused another confirmation request.  I
> don't know.  But there's no customization to let the user decide whether
> they want this intrusive behavior.

It would be good to understand the problem and its causes before we
discuss the possible solutions.  Especially since your proposed
solution is quite a blunt weapon.  These functions are placed on
write-file-functions for a reason.

> diff --git a/lisp/progmodes/make-mode.el b/lisp/progmodes/make-mode.el
> index d5fdd063825..ec1ac4e9d4f 100644
> --- a/lisp/progmodes/make-mode.el
> +++ b/lisp/progmodes/make-mode.el
> @@ -188,6 +188,15 @@ makefile-cleanup-continuations
>  to MODIFY A FILE WITHOUT YOUR CONFIRMATION when \"it seems necessary\"."
>    :type 'boolean)
>  
> +(defcustom makefile-write-check-hooks
> +  '(makefile-warn-suspicious-lines
> +    makefile-warn-continuations
> +    makefile-cleanup-continuations)
> +  "List of functions to run when writing the buffer to a file.
> +The defaults on the list require confirmation to save when a
> +suspicious line or line continuation is detected."
> +  :type 'list)

The :version tag is missing.  Also, this kind of change warrants a
NEWS entry.

(But I'm still not sure this change is TRT for solving the problems
you described, for lack of details.)




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#78365; Package emacs. (Sun, 11 May 2025 11:35:01 GMT) Full text and rfc822 format available.

Message #11 received at 78365 <at> debbugs.gnu.org (full text, mbox):

From: Lynn Winebarger <owinebar <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 78365 <at> debbugs.gnu.org
Subject: Re: bug#78365: 31.0.50; make-mode has no way to turn off
 confirmations before saving when it thinks there may be a syntax error
Date: Sun, 11 May 2025 07:34:33 -0400
[Message part 1 (text/plain, inline)]
On Sun, May 11, 2025, 1:06 AM Eli Zaretskii <eliz <at> gnu.org> wrote:

> > From: Lynn Winebarger <owinebar <at> gmail.com>
> > Date: Sat, 10 May 2025 20:01:01 -0400
> >
> > I've been hacking on Makefiles, and I habitually save while rewriting,
> > not just when I have a finished edit.  I may also have autosave turned
> > on.  There were annoying confirmation requests when that happened, and
> > if I did not notice (maybe due to autosave), the requests pile up and
> > once a later one has been answered, an earlier one reappears but either
> > can't accept the input or maybe there were a bunch of warnings queued
> > up.
>
> AFAIU, autosave is not supposed to run these hooks, so if that
> happened to you, it's a bug.  Can you show a recipe for reproducing
> this?
>

I've been editing in one frame with info manuals open in other frames on
other monitors.  So I would type <C-x s> in the Makefile buffer with a
"suspicious line" far away from the point I was editing, then go to the
manual, then return focus to the original buffer, edit a little more, type
<C-x s>, consult manual, back to original buffer, ... several times before
noticing the request for confirmation.  Then I would type y, the file will
be written, but another confirmation prompt is immediately displayed, but
it may or may not be able to accept my response, even after I switch focus
back to the minibuffer.  I don't know if that was correlated to my typing
multiple "y"'s in the buffer before I realized answering the first
confirmation put me back in the buffer, even though the subsequent prompt
displayed immediately after I responded to the first (that seems like a
completely independent problem from the lack of configurability).



> > Or maybe there was some kind of implicit loop, where confirming the
> > save after some timer ran out caused another confirmation request.  I
> > don't know.  But there's no customization to let the user decide whether
> > they want this intrusive behavior.
>
> It would be good to understand the problem and its causes before we
> discuss the possible solutions.  Especially since your proposed
> solution is quite a blunt weapon.  These functions are placed on
> write-file-functions for a reason.
>

I did not anticipate this behavior has been in place 20+ years (just looked
at the blame).  I understand a Makefile may be regarded as a previous
component of a build system rather than a programming language, but this
intrusive approach is unlike any other programming language mode I recall
using in emacs.  I understand why it might be the default, but for that to
not even be configurable was jarring.

So, I thought this had to be a recent addition I was just pushing back on,
as I am manually setting this hook to nil as a stop-gap now, for every
buffer I am using to actively develop a Makefile.  I didn't object to it
being the default behavior.

Another approach would be to have a customization variable to treat
Makefiles as precious or not by default.  Then have a Boolean buffer local
variable initialized to that setting that is consulted by those functions,
and a command to flip that treatment in a particular buffer, so they can be
freely hacked upon before they are actually in use.  For extra credit,
commands that are use to build a project might detect the Makefile is open
and set the flag to t while the build is running to prevent a race.



> > diff --git a/lisp/progmodes/make-mode.el b/lisp/progmodes/make-mode.el
> > index d5fdd063825..ec1ac4e9d4f 100644
> > --- a/lisp/progmodes/make-mode.el
> > +++ b/lisp/progmodes/make-mode.el
> > @@ -188,6 +188,15 @@ makefile-cleanup-continuations
> >  to MODIFY A FILE WITHOUT YOUR CONFIRMATION when \"it seems necessary\"."
> >    :type 'boolean)
> >
> > +(defcustom makefile-write-check-hooks
> > +  '(makefile-warn-suspicious-lines
> > +    makefile-warn-continuations
> > +    makefile-cleanup-continuations)
> > +  "List of functions to run when writing the buffer to a file.
> > +The defaults on the list require confirmation to save when a
> > +suspicious line or line continuation is detected."
> > +  :type 'list)
>
> The :version tag is missing.  Also, this kind of change warrants a
> NEWS entry.
>
> (But I'm still not sure this change is TRT for solving the problems
> you described, for lack of details.)
>

Yes, once I saw this behavior has been standard for 20+ years, I'd agree.

Lynn
[Message part 2 (text/html, inline)]

This bug report was last modified 3 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.