Function: logview--toggle-option-locally

logview--toggle-option-locally is a natively compiled function defined in logview.el.

Signature

(logview--toggle-option-locally VARIABLE ARG &optional SHOW-MESSAGE MESSAGE-IF-TRUE MESSAGE-IF-FALSE CALLBACK)

Source Code

;; Defined in /nix/store/3zkn9hgpv447zb8nrg55d9x2ynmmrk40-emacs-packages-deps/share/emacs/site-lisp/elpa/logview-20260218.2013/logview.el
(defun logview--toggle-option-locally (variable arg &optional show-message message-if-true message-if-false callback)
  (let ((new-value (if (eq arg 'toggle)
                       (not (symbol-value variable))
                     (> (prefix-numeric-value arg) 0))))
    (unless (eq new-value (symbol-value variable))
      (set (make-local-variable variable) new-value)
      ;; The purpose of `callback' is to be invoked after updating the variable, but before showing the
      ;; message, as e.g. `isearch--momentary-message' sucks in that it effectively freezes Emacs.
      (when callback
        (funcall callback))
      (when show-message
        (let ((message (if (symbol-value variable) message-if-true message-if-false)))
          (if (and isearch-mode
                   ;; Private function, as always.  At least don't die if they rename it.
                   (fboundp 'isearch--momentary-message))
              (isearch--momentary-message message)
            (message message))))
      t)))