Function: verb-set-var

verb-set-var is an interactive and natively compiled function defined in verb.el.

Signature

(verb-set-var &optional VAR VALUE)

Documentation

Set new value for variable VAR previously set with verb-var.

When called interactively, prompt the user for a variable that has been set once with verb-var, and then prompt for VALUE. Otherwise, use string VAR and value VALUE.

When called with a non-nil prefix argument, copy the current variable value to the kill ring instead of setting it, and ignore VALUE.

Key Bindings

verb-command-map C-v

Source Code

;; Defined in /nix/store/8jnfn8w2mxcxbr2crbklcnija9m0zlkq-emacs-packages-deps/share/emacs/site-lisp/elpa/verb-20260818.1921/verb.el
(defun verb-set-var (&optional var value)
  "Set new value for variable VAR previously set with `verb-var'.
When called interactively, prompt the user for a variable that has
been set once with `verb-var', and then prompt for VALUE.  Otherwise,
use string VAR and value VALUE.

When called with a non-nil prefix argument, copy the current variable
value to the kill ring instead of setting it, and ignore VALUE."
  (interactive)
  (verb--ensure-verb-mode)
  (let* ((name (or (and (stringp var) var)
                   (and (symbolp var) var (symbol-name var))
                   (completing-read "Variable: "
                                    (mapcar (lambda (e)
                                              (symbol-name (car e)))
                                            verb--vars)
                                    nil nil nil
                                    'verb--set-var-hist)))
         (key (intern name))
         (val (or current-prefix-arg
                  value
                  (read-string (format "Set value for %s: " name))))
         (elem (assq key verb--vars)))
    (when (string-empty-p name)
      (user-error "%s" "Variable name can't be empty"))
    (if elem
        (if current-prefix-arg
            (progn
              (kill-new (format "%s" (cdr elem)))
              (message "Variable value copied to the kill ring"))
          (setcdr elem val))
      (if current-prefix-arg
          (user-error "%s" "Variable has no value set")
        (push (cons key val) verb--vars)))))