; Turn off a mode with -1, not zero

* lisp/xwidget.el (xwidget-webkit-isearch-exit):
* lisp/whitespace.el (whitespace-toggle-options)
(global-whitespace-toggle-options):
* lisp/url/url-handlers.el (url-handler-regexp)
(url-handlers-set-buffer-mode):
* lisp/textmodes/refill.el (refill-mode):
* lisp/strokes.el (strokes-update-window-configuration):
* lisp/so-long.el (so-long-revert-function-longlines-mode)
(turn-off-so-long-minor-mode, so-long-disable)
(so-long-unload-function):
* lisp/progmodes/verilog-mode.el (verilog-save-font-no-change-functions)
(verilog-scan-debug):
* lisp/progmodes/flymake.el (flymake-mode-off):
* lisp/progmodes/cperl-mode.el (cperl-setup-tmp-buf):
* lisp/progmodes/cc-mode.el (c-setup-doc-comment-style):
* lisp/autorevert.el (auto-revert-tail-mode):
* lisp/proced.el (proced-mode):
* lisp/play/gametree.el (gametree-mode):
* lisp/obsolete/tpu-edt.el (tpu-toggle-overwrite-mode):
* lisp/obsolete/longlines.el (longlines-mode)
(longlines-mode-off, longlines-before-revert-hook):
* lisp/obsolete/idlw-shell.el (idlwave-shell-toggle-electric-debug-mode)
(idlwave-shell-electric-debug-all-off):
* lisp/nxml/rng-valid.el (rng-do-some-validation):
* lisp/nxml/rng-nxml.el (rng-nxml-mode-init):
* lisp/net/dictionary.el (global-dictionary-tooltip-mode):
* lisp/mouse.el (mouse-appearance-menu):
* lisp/mh-e/mh-folder.el (mh-set-scan-mode):
* lisp/menu-bar.el (menu-bar--toggle-truncate-long-lines)
(menu-bar--wrap-long-lines-window-edge):
* lisp/ldefs-boot.el (global-dictionary-tooltip-mode):
* lisp/iimage.el (turn-off-iimage-mode):
* lisp/fringe.el (fringe-mode-initialize):
* lisp/face-remap.el (buffer-face-set, buffer-face-toggle):
* lisp/erc/erc-spelling.el (spelling):
* lisp/epa-hook.el (epa-file-find-file-hook):
* lisp/editorconfig.el (editorconfig-after-apply-functions):
* lisp/desktop.el (desktop-save-mode-off, desktop-create-buffer):
* lisp/calc/calc-menu.el (calc-modes-menu):
* lisp/autorevert.el (auto-revert-tail-mode): Prefer -1 to zero
when turning off a mode.  (Bug#81569)
This commit is contained in:
Eli Zaretskii 2026-08-16 11:56:16 +03:00
parent 5b4d9683f0
commit 1cc4babde2
32 changed files with 54 additions and 54 deletions

View file

@ -457,12 +457,12 @@ Use `auto-revert-mode' for changes other than appends!"
:group 'find-file :lighter auto-revert-tail-mode-text
(when auto-revert-tail-mode
(unless buffer-file-name
(auto-revert-tail-mode 0)
(auto-revert-tail-mode -1)
(error "This buffer is not visiting a file"))
(if (and (buffer-modified-p)
(zerop auto-revert-tail-pos) ; library was loaded only after finding file
(not (y-or-n-p "Buffer is modified, so tail offset may be wrong. Proceed? ")))
(auto-revert-tail-mode 0)
(auto-revert-tail-mode -1)
;; a-r-tail-pos stores the size of the file at the time of the
;; last revert. After this package loads, it adds a
;; find-file-hook to set this variable every time a file is
@ -480,7 +480,7 @@ Perform a full revert? ")
;; Use this (not just revert-buffer) for point-preservation.
(auto-revert-buffer (current-buffer)))
;; else we might reappend our own end when we save
(add-hook 'before-save-hook (lambda () (auto-revert-tail-mode 0)) nil t)
(add-hook 'before-save-hook (lambda () (auto-revert-tail-mode -1)) nil t)
(or (local-variable-p 'auto-revert-tail-pos) ; don't lose prior position
(setq-local auto-revert-tail-pos
(file-attribute-size

View file

@ -1512,7 +1512,7 @@
["Scalar mode"
(progn
(require 'calc-mode)
(calc-matrix-mode 0))
(calc-matrix-mode -1))
:style radio
:selected (eq calc-matrix-mode 'scalar)
:help "Variables are assumed to be scalars"])

View file

@ -193,7 +193,7 @@ For further details, see info node `(emacs)Saving Emacs Sessions'."
(defun desktop-save-mode-off ()
"Disable `desktop-save-mode'. Provided for use in hooks."
(desktop-save-mode 0))
(desktop-save-mode -1))
(defcustom desktop-save 'ask-if-new
"Specifies whether the desktop should be saved when it is killed.
@ -1615,7 +1615,7 @@ and try to load that."
(cond ((equal '(t) desktop-buffer-minor-modes) ; backwards compatible
(auto-fill-mode 1))
((equal '(nil) desktop-buffer-minor-modes) ; backwards compatible
(auto-fill-mode 0))
(auto-fill-mode -1))
(t
(dolist (minor-mode desktop-buffer-minor-modes)
;; Give minor mode module a chance to add a handler.
@ -1772,7 +1772,7 @@ If there are no buffers left to create, kill the timer."
(let ((key "--no-desktop"))
(when (member key command-line-args)
(setq command-line-args (delete key command-line-args))
(desktop-save-mode 0)))
(desktop-save-mode -1)))
(when desktop-save-mode
(desktop-read)
(setq inhibit-startup-screen t))))

View file

@ -89,7 +89,7 @@ show line numbers on the left:
\\='(lambda (props)
(let ((show-line-num (gethash \\='emacs_linum props)))
(cond ((equal show-line-num \"true\") (linum-mode 1))
((equal show-line-num \"false\") (linum-mode 0))))))
((equal show-line-num \"false\") (linum-mode -1))))))
This hook will be run even when there are no matching sections in
\".editorconfig\", or no \".editorconfig\" file was found at all."

View file

@ -86,7 +86,7 @@ interface, update `file-name-handler-alist'."
(if (and buffer-file-name
(string-match epa-file-name-regexp buffer-file-name)
epa-file-inhibit-auto-save)
(auto-save-mode 0)))
(auto-save-mode -1)))
(defun epa-file-name-p (file)
"Say whether FILE is handled by `epa-file'."

View file

@ -49,7 +49,7 @@
((remove-hook 'erc-connect-pre-hook #'erc-spelling-init)
(dolist (buffer (erc-buffer-list))
(remove-hook 'flyspell-incorrect-hook #'erc-spelling--flyspell-check t)
(with-current-buffer buffer (flyspell-mode 0)))))
(with-current-buffer buffer (flyspell-mode -1)))))
(defcustom erc-spelling-dictionaries nil
"An alist mapping buffer names to dictionaries.

View file

@ -591,7 +591,7 @@ local, and sets it to FACE."
(while (and (consp specs) (null (cdr specs)))
(setq specs (car specs)))
(if (null specs)
(buffer-face-mode 0)
(buffer-face-mode -1)
(setq-local buffer-face-mode-face specs)
(buffer-face-mode t)))
@ -619,7 +619,7 @@ buffer local, and set it to SPECS."
(setq specs (car specs)))
(if (or (null specs)
(and buffer-face-mode (equal buffer-face-mode-face specs)))
(buffer-face-mode 0)
(buffer-face-mode -1)
(setq-local buffer-face-mode-face specs)
(buffer-face-mode t)))

View file

@ -140,7 +140,7 @@ See `fringe-mode' for possible values and their effect."
(if (equal fringe-mode '(nil . nil))
(setq fringe-mode nil))
(if (equal fringe-mode '(0 . 0))
(setq fringe-mode 0)))
(setq fringe-mode -1)))
;; Otherwise impose the user-specified value of fringe-mode.
(custom-initialize-reset symbol value))))

View file

@ -96,7 +96,7 @@ Examples of image filename patterns to match:
(defun turn-off-iimage-mode ()
"Unconditionally turn off iimage mode."
(interactive)
(iimage-mode 0))
(iimage-mode -1))
(defun iimage-modification-hook (beg end)
"Remove display property if a display region BEG..END is modified."

View file

@ -7880,7 +7880,7 @@ active it will overwrite that mode for the current buffer.
Internally it provides a default for the `dictionary-tooltip-mode'.
It can be overwritten for each buffer using `dictionary-tooltip-mode'.
Note: (global-dictionary-tooltip-mode 0) will not disable the mode
Note: (global-dictionary-tooltip-mode -1) will not disable the mode
any buffer where (dictionary-tooltip-mode 1) has been called.
(fn &optional ARG)" t)

View file

@ -1432,14 +1432,14 @@ mail status in mode line"))
(defun menu-bar--toggle-truncate-long-lines ()
"Toggle long lines mode."
(interactive)
(if visual-line-mode (visual-line-mode 0))
(if visual-line-mode (visual-line-mode -1))
(setq word-wrap nil)
(toggle-truncate-lines 1))
(defun menu-bar--wrap-long-lines-window-edge ()
"Wrap long lines at window edge."
(interactive)
(if visual-line-mode (visual-line-mode 0))
(if visual-line-mode (visual-line-mode -1))
(setq word-wrap nil)
(if truncate-lines (toggle-truncate-lines -1)))

View file

@ -1672,7 +1672,7 @@ after the commands are processed."
"Display the scan listing buffer, but do not show a message."
(if (get-buffer mh-show-buffer)
(delete-windows-on mh-show-buffer))
(mh-showing-mode 0)
(mh-showing-mode -1)
(force-mode-line-update)
(if mh-recenter-summary-flag
(mh-recenter nil)))

View file

@ -3236,8 +3236,8 @@ choose a font."
((eq choice 'text-scale-decrease)
(text-scale-increase -1))
((eq choice 'face-remap-reset-base)
(text-scale-mode 0)
(buffer-face-mode 0))
(text-scale-mode -1)
(buffer-face-mode -1))
(choice
;; Either choice == 'x-select-font, or choice is a
;; symbol whose name is a font.

View file

@ -1498,7 +1498,7 @@ active it will overwrite that mode for the current buffer."
Internally it provides a default for the `dictionary-tooltip-mode'.
It can be overwritten for each buffer using `dictionary-tooltip-mode'.
Note: (global-dictionary-tooltip-mode 0) will not disable the mode
Note: (global-dictionary-tooltip-mode -1) will not disable the mode
any buffer where (dictionary-tooltip-mode 1) has been called."
(interactive "P")
(require 'tooltip)

View file

@ -113,7 +113,7 @@ Validation will be enabled if `rng-nxml-auto-validate-flag' is non-nil."
(add-hook 'completion-at-point-functions #'rng-completion-at-point nil t)
(add-hook 'nxml-in-mixed-content-hook #'rng-in-mixed-content-p nil t))
(t
(rng-validate-mode 0)
(rng-validate-mode -1)
(remove-hook 'completion-at-point-functions #'rng-completion-at-point t)
(remove-hook 'nxml-in-mixed-content-hook #'rng-in-mixed-content-p t))))

View file

@ -450,13 +450,13 @@ The schema is set like `rng-auto-set-schema'."
;; will get mysteriously stuck at a single place
(rng-compile-error
(message "Incorrect schema. %s" (nth 1 err))
(rng-validate-mode 0)
(rng-validate-mode -1)
nil)
(error
(message "Internal error in rng-validate-mode triggered at buffer position %d. %s"
(point)
(error-message-string err))
(rng-validate-mode 0)
(rng-validate-mode -1)
nil)))))
(defun rng-validate-prepare ()

View file

@ -4118,7 +4118,7 @@ Otherwise, just expand the file name."
(if idlwave-shell-electric-debug-mode
(progn ;; Turn it off, and make sure it stays off.
(setq idlwave-shell-suppress-electric-debug t)
(idlwave-shell-electric-debug-mode 0))
(idlwave-shell-electric-debug-mode -1))
(setq idlwave-shell-suppress-electric-debug nil)
(idlwave-shell-electric-debug-mode t)))
@ -4170,7 +4170,7 @@ Shell debugging commands are available as single key sequences."
(when (and (derived-mode-p 'idlwave-mode)
buffer-file-name
idlwave-shell-electric-debug-mode)
(idlwave-shell-electric-debug-mode 0))))))
(idlwave-shell-electric-debug-mode -1))))))
(setq idlwave-shell-electric-debug-buffers nil))
;; Show the help text

View file

@ -168,7 +168,7 @@ newlines are indicated with a symbol."
(add-hook 'after-change-functions #'longlines-after-change-function nil t)
(add-hook 'post-command-hook #'longlines-post-command-function nil t)
(when longlines-auto-wrap
(auto-fill-mode 0)))
(auto-fill-mode -1)))
;; Turn off longlines mode
(setq buffer-file-format (delete 'longlines buffer-file-format))
(if longlines-showing
@ -202,7 +202,7 @@ newlines are indicated with a symbol."
"Turn off longlines mode.
This function exists to be called by `change-major-mode-hook' when the
major mode changes."
(longlines-mode 0))
(longlines-mode -1))
;;; Showing the effect of hard newlines in the buffer
@ -475,7 +475,7 @@ This is called by `window-configuration-change-hook'."
(defun longlines-before-revert-hook ()
(add-hook 'after-revert-hook #'longlines-after-revert-hook nil t)
(longlines-mode 0))
(longlines-mode -1))
(defun longlines-after-revert-hook ()
(remove-hook 'after-revert-hook #'longlines-after-revert-hook t)

View file

@ -881,7 +881,7 @@ if no region is selected."
(interactive)
(cond (overwrite-mode
(tpu-local-set-key "\177" tpu-saved-delete-func)
(overwrite-mode 0))
(overwrite-mode -1))
(t
(setq tpu-saved-delete-func (local-key-binding "\177"))
(tpu-local-set-key "\177" 'picture-backward-clear-column)

View file

@ -601,7 +601,7 @@ Useful to postal and email chess (and, it is hoped, also checkers, go,
shogi, etc.) players, it is a slightly modified version of Outline mode.
\\{gametree-mode-map}"
(auto-fill-mode 0)
(auto-fill-mode -1)
(add-hook 'write-contents-functions 'gametree-save-and-hack-layout nil t))
(provide 'gametree)

View file

@ -896,8 +896,8 @@ normal hook `proced-post-display-hook'.
\\{proced-mode-map}"
:interactive nil
(abbrev-mode 0)
(auto-fill-mode 0)
(abbrev-mode -1)
(auto-fill-mode -1)
(setq buffer-read-only t
truncate-lines t
header-line-format '(:eval (proced-header-line)))

View file

@ -2437,7 +2437,7 @@ Called in PHASE `after-insertion', see `antlr-options-alists'."
(or (null new-language)
(eq new-language antlr-language)
(let ((font-lock (and (boundp 'font-lock-mode) font-lock-mode)))
(if font-lock (font-lock-mode 0))
(if font-lock (font-lock-mode -1))
(funcall major-mode) ; TODO: do differently?
(and font-lock (null font-lock-mode) (font-lock-mode 1)))))))

View file

@ -772,7 +772,7 @@ that requires a literal mode spec at compile time."
(when (and (featurep 'font-lock)
(symbol-value 'font-lock-mode))
;; Force font lock mode to reinitialize itself.
(font-lock-mode 0)
(font-lock-mode -1)
(font-lock-mode 1)))
;; Buffer local variables defining the region to be fontified by a font lock

View file

@ -7411,7 +7411,7 @@ by CPerl."
(set-buffer (get-buffer-create cperl-tmp-buffer))
(set-syntax-table cperl-mode-syntax-table)
(buffer-disable-undo)
(auto-fill-mode 0)
(auto-fill-mode -1)
(if cperl-use-syntax-table-text-property-for-tags
(progn
;; Do not introduce variable if not needed, we check it!

View file

@ -1595,7 +1595,7 @@ Do it only if `flymake-no-changes-timeout' is non-nil."
;;;###autoload
(defun flymake-mode-off ()
"Turn Flymake mode off."
(flymake-mode 0))
(flymake-mode -1))
(make-obsolete 'flymake-mode-on 'flymake-mode "26.1")
(make-obsolete 'flymake-mode-off 'flymake-mode "26.1")

View file

@ -3552,7 +3552,7 @@ For insignificant changes, see instead `verilog-save-buffer-state'."
(let* ((verilog-save-font-mod-hooked (- (point-max) (point-min)))
;; Significant speed savings with no font-lock properties
(fontlocked (when font-lock-mode
(font-lock-mode 0)
(font-lock-mode -1)
t)))
(run-hook-with-args 'before-change-functions (point-min) (point-max))
(unwind-protect
@ -3668,7 +3668,7 @@ either is ok to parse as a non-comment, or `verilog-insert' was used."
(defun verilog-scan-debug ()
"For debugging, show with display face results of `verilog-scan'."
(font-lock-mode 0)
(font-lock-mode -1)
;;(if dbg (setq dbg (concat dbg "verilog-scan-debug\n")))
(save-excursion
(goto-char (point-min))

View file

@ -274,7 +274,7 @@
;; Refer to M-: (info "(emacs) Specifying File Variables") RET
;;
;; If so-long itself causes problems, disable the automated behavior with
;; M-- M-x global-so-long-mode, or M-: (global-so-long-mode 0)
;; M-- M-x global-so-long-mode, or M-: (global-so-long-mode -1)
;; * Example configuration
;; -----------------------
@ -1325,7 +1325,7 @@ This is the default `so-long-predicate' function in Emacs versions < 28.1.
(if state
(unless (equal (cadr state) longlines-mode)
(longlines-mode (if (cadr state) 1 0)))
(longlines-mode 0))))
(longlines-mode -1))))
(defun turn-on-so-long-minor-mode ()
"Enable minor mode `so-long-minor-mode'."
@ -1333,7 +1333,7 @@ This is the default `so-long-predicate' function in Emacs versions < 28.1.
(defun turn-off-so-long-minor-mode ()
"Disable minor mode `so-long-minor-mode'."
(so-long-minor-mode 0))
(so-long-minor-mode -1))
;;;###autoload
(define-minor-mode so-long-minor-mode
@ -1908,9 +1908,9 @@ Equivalent to calling (global-so-long-mode 1)"
(defun so-long-disable ()
"Disable the `so-long' library's functionality.
Equivalent to calling (global-so-long-mode 0)"
Equivalent to calling (global-so-long-mode -1)"
(interactive)
(global-so-long-mode 0))
(global-so-long-mode -1))
(make-obsolete 'so-long-enable 'global-so-long-mode "so-long 1.0")
(make-obsolete 'so-long-disable 'global-so-long-mode "so-long 1.0")
@ -1990,7 +1990,7 @@ or call the function `global-so-long-mode'.")
"Handler for `unload-feature'."
(condition-case err
(progn
(global-so-long-mode 0)
(global-so-long-mode -1)
;; Process existing buffers.
(dolist (buf (buffer-list))
(with-current-buffer buf

View file

@ -1060,9 +1060,9 @@ This is based on the last time `strokes-window-configuration' was updated."
(set-window-buffer current-window strokes-buffer-name)
(delete-other-windows)
(fundamental-mode)
(auto-save-mode 0)
(font-lock-mode 0)
(abbrev-mode 0)
(auto-save-mode -1)
(font-lock-mode -1)
(abbrev-mode -1)
(buffer-disable-undo (current-buffer))
(setq truncate-lines nil)
(strokes-fill-current-buffer-with-whitespace)

View file

@ -243,7 +243,7 @@ For true \"word wrap\" behavior, use `visual-line-mode' instead."
'(refill-adjust-ignorable-overlay))
(overlay-put refill-ignorable-overlay 'insert-behind-hooks
'(refill-adjust-ignorable-overlay))
(auto-fill-mode 0))
(auto-fill-mode -1))
(remove-hook 'after-change-functions #'refill-after-change-function t)
(remove-hook 'post-command-hook #'refill-post-command-function t)
(kill-local-variable 'backward-delete-char-untabify-method)))

View file

@ -136,7 +136,7 @@ at this)."
:version "25.1"
:set (lambda (symbol value)
(let ((enable url-handler-mode))
(url-handler-mode 0)
(url-handler-mode -1)
(set-default symbol value)
(if enable
(url-handler-mode)))))
@ -419,7 +419,7 @@ if it had been inserted from a file named URL."
"Set correct modes for the current buffer if visiting a remote file."
(and buffer-file-name
(string-match-p url-handler-regexp buffer-file-name)
(auto-save-mode 0)))
(auto-save-mode -1)))
(provide 'url-handlers)

View file

@ -1267,7 +1267,7 @@ See `whitespace-style' and `indent-tabs-mode' for documentation."
(interactive (whitespace-interactive-char t))
(let ((whitespace-style
(whitespace-toggle-list t arg whitespace-active-style)))
(whitespace-mode 0)
(whitespace-mode -1)
(whitespace-mode 1)))
@ -1353,7 +1353,7 @@ See `whitespace-style' and `indent-tabs-mode' for documentation."
(let ((whitespace-style
(whitespace-toggle-list nil arg whitespace-toggle-style)))
(setq whitespace-toggle-style whitespace-style)
(global-whitespace-mode 0)
(global-whitespace-mode -1)
(global-whitespace-mode 1)))

View file

@ -1109,7 +1109,7 @@ With argument, add COUNT copies of CHAR."
(defun xwidget-webkit-isearch-exit ()
"Exit incremental search of a WebKit buffer."
(interactive)
(xwidget-webkit-isearch-mode 0))
(xwidget-webkit-isearch-mode -1))
(defvar-keymap xwidget-webkit-isearch-mode-map
:doc "The keymap used inside `xwidget-webkit-isearch-mode'."