diff options
author | Lars Ingebrigtsen <larsi@gnus.org> | 2022-02-13 16:29:26 +0100 |
---|---|---|
committer | Lars Ingebrigtsen <larsi@gnus.org> | 2022-02-13 16:29:26 +0100 |
commit | 997dd86a9f6a253e4542d65b17dfec6af2f4e8fd (patch) | |
tree | 446bf645ed4c341bf4fd237fbdd3812897c20562 /lisp | |
parent | 68b32732140606a1eddce82f50733c549a40900a (diff) | |
download | emacs-997dd86a9f6a253e4542d65b17dfec6af2f4e8fd.tar.gz emacs-997dd86a9f6a253e4542d65b17dfec6af2f4e8fd.tar.bz2 emacs-997dd86a9f6a253e4542d65b17dfec6af2f4e8fd.zip |
Add a new macro `setopt'
* doc/emacs/custom.texi (Examining): Mention it.
(Init Syntax): Ditto.
* doc/emacs/windows.texi (Window Choice): Adjust example.
* doc/lispref/windows.texi (Choosing Window Options): Adjust examples.
* doc/lispref/variables.texi (Setting Variables): Document setopt.
* doc/misc/eudc.texi (Emacs-only Configuration): Adjust examples.
* lisp/cus-edit.el (setopt): New macro.
Diffstat (limited to 'lisp')
-rw-r--r-- | lisp/cus-edit.el | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/lisp/cus-edit.el b/lisp/cus-edit.el index ff70f6724a8..bb7ffc1eae5 100644 --- a/lisp/cus-edit.el +++ b/lisp/cus-edit.el @@ -1045,6 +1045,29 @@ If given a prefix (or a COMMENT argument), also prompt for a comment." value) ;;;###autoload +(defmacro setopt (&rest pairs) + "Set VARIABLE/VALUE pairs, and return the final VALUE. +This is like `setq', but is meant for user options instead of +plain variables. This means that `setopt' will execute any +Customize form associated with VARIABLE. + +If VARIABLE has a `custom-set' property, that is used for setting +VARIABLE, otherwise `set-default' is used. + +\(fn [VARIABLE VALUE]...)" + (declare (debug setq)) + (unless (zerop (mod (length pairs) 2)) + (error "PAIRS must have an even number of variable/value members")) + (let ((expr nil)) + (while pairs + (unless (symbolp (car pairs)) + (error "Attempting to set a non-symbol: %s" (car pairs))) + (push `(customize-set-variable ',(car pairs) ,(cadr pairs)) + expr) + (setq pairs (cddr pairs))) + (macroexp-progn (nreverse expr)))) + +;;;###autoload (defun customize-save-variable (variable value &optional comment) "Set the default for VARIABLE to VALUE, and save it for future sessions. Return VALUE. |