Function: allout-add-resumptions

allout-add-resumptions is a byte-compiled function defined in allout.el.gz.

Signature

(allout-add-resumptions &rest PAIRS)

Documentation

Set name/value PAIRS.

Old settings are preserved for later resumption using allout-do-resumptions.

The new values are set as a buffer local. On resumption, the prior buffer scope of the variable is restored along with its value. If it was a void buffer-local value, then it is left as nil on resumption.

The pairs are lists whose car is the name of the variable and car of the cdr is the new value: (some-var some-value). The pairs can actually be triples, where the third element qualifies the disposition of the setting, as described further below.

If the optional third element is the symbol extend, then the new value created by consing the second element of the pair onto the front of the existing value.

If the optional third element is the symbol append, then the new value is extended from the existing one by appending a list containing the second element of the pair onto the end of the existing value.

Extension, and resumptions in general, should not be used for hook functions -- use the local mode of add-hook for that, instead.

The settings are stored on allout-mode-prior-settings.

Probably introduced at or before Emacs version 22.1.

Source Code

;; Defined in /usr/src/emacs/lisp/allout.el.gz
;;;_   > allout-add-resumptions (&rest pairs)
(defun allout-add-resumptions (&rest pairs)
  "Set name/value PAIRS.

Old settings are preserved for later resumption using `allout-do-resumptions'.

The new values are set as a buffer local.  On resumption, the prior buffer
scope of the variable is restored along with its value.  If it was a void
buffer-local value, then it is left as nil on resumption.

The pairs are lists whose car is the name of the variable and car of the
cdr is the new value: `(some-var some-value)'.  The pairs can actually be
triples, where the third element qualifies the disposition of the setting,
as described further below.

If the optional third element is the symbol `extend', then the new value
created by `cons'ing the second element of the pair onto the front of the
existing value.

If the optional third element is the symbol `append', then the new value is
extended from the existing one by `append'ing a list containing the second
element of the pair onto the end of the existing value.

Extension, and resumptions in general, should not be used for hook
functions -- use the `local' mode of `add-hook' for that, instead.

The settings are stored on `allout-mode-prior-settings'."
  (while pairs
    (let* ((pair (pop pairs))
           (name (car pair))
           (value (cadr pair))
           (qualifier (if (> (length pair) 2)
                          (caddr pair)))
           prior-value)
      (if (not (symbolp name))
          (error "Pair's name, %S, must be a symbol, not %s"
                 name (type-of name)))
      (setq prior-value (condition-case nil
                            (symbol-value name)
                          (void-variable nil)))
      (when (not (assoc name allout-mode-prior-settings))
        ;; Not already added as a resumption, create the prior setting entry.
        (if (local-variable-p name (current-buffer))
            ;; is already local variable -- preserve the prior value:
            (push (list name prior-value) allout-mode-prior-settings)
          ;; wasn't local variable, indicate so for resumption by killing
          ;; local value, and make it local:
          (push (list name) allout-mode-prior-settings)
          (make-local-variable name)))
      (if qualifier
          (cond ((eq qualifier 'extend)
                 (if (not (listp prior-value))
                     (error "Extension of non-list prior value attempted")
                   (set name (cons value prior-value))))
                ((eq qualifier 'append)
                 (if (not (listp prior-value))
                     (error "Appending of non-list prior value attempted")
                   (set name (append prior-value (list value)))))
                (t (error "Unrecognized setting qualifier `%s' encountered"
                          qualifier)))
        (set name value)))))