Subject: 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

From: Lynn Winebarger <[email-masked]>
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.  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))
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)
+
 (defcustom makefile-mode-hook nil
   "Normal hook run by `makefile-mode'."
   :type 'hook)
@@ -823,12 +832,8 @@ makefile-mode
    at the beginning of a line in Makefile mode."
   (add-hook 'completion-at-point-functions
             #'makefile-completions-at-point nil t)
-  (add-hook 'write-file-functions
-	    'makefile-warn-suspicious-lines nil t)
-  (add-hook 'write-file-functions
-	    'makefile-warn-continuations nil t)
-  (add-hook 'write-file-functions
-	    'makefile-cleanup-continuations nil t)
+  (dolist (h makefile-write-check-hooks)
+    (add-hook 'write-file-functions h nil t))
   (make-local-variable 'makefile-target-table)
   (make-local-variable 'makefile-macro-table)
   (make-local-variable 'makefile-has-prereqs)