Function: setopt-local

setopt-local is an autoloaded macro defined in cus-edit.el.gz.

Signature

(setopt-local [VARIABLE VALUE]...)

Documentation

Set buffer local VARIABLE/VALUE pairs, and return the final VALUE.

This is like setq-local, but is meant for user options instead of plain variables. This means that setopt-local will execute any custom-set form associated with VARIABLE. Unlike setopt, setopt-local does not affect a user option's global value.

Note that setopt-local will emit a warning if the type of a VALUE does not match the type of the corresponding VARIABLE as declared by defcustom. (VARIABLE will be assigned the value even if it doesn't match the type.)

Signal an error if a custom-set form does not support the buffer-local argument.

View in manual

Probably introduced at or before Emacs version 31.1.

Source Code

;; Defined in /usr/src/emacs/lisp/cus-edit.el.gz
;;;###autoload
(defmacro setopt-local (&rest pairs)
  "Set buffer local VARIABLE/VALUE pairs, and return the final VALUE.
This is like `setq-local', but is meant for user options instead of
plain variables.  This means that `setopt-local' will execute any
`custom-set' form associated with VARIABLE.  Unlike `setopt',
`setopt-local' does not affect a user option's global value.

Note that `setopt-local' will emit a warning if the type of a VALUE does
not match the type of the corresponding VARIABLE as declared by
`defcustom'.  (VARIABLE will be assigned the value even if it doesn't
match the type.)

Signal an error if a `custom-set' form does not support the
`buffer-local' argument.

\(fn [VARIABLE VALUE]...)"
  (declare (debug setq))
  (unless (evenp (length pairs))
    (signal 'wrong-number-of-arguments (list 'setopt-local (length pairs))))
  (let ((expr nil))
    (while pairs
      (unless (symbolp (car pairs))
        (error "Attempting to set a non-symbol: %s" (car pairs)))
      (push `(setopt--set-local ',(car pairs) ,(cadr pairs))
            expr)
      (setq pairs (cddr pairs)))
    (macroexp-progn (nreverse expr))))