Function: ansi-color--ensure-context

ansi-color--ensure-context is a byte-compiled function defined in ansi-color.el.gz.

Signature

(ansi-color--ensure-context CONTEXT-SYM POSITION)

Documentation

Return CONTEXT-SYM's value as a valid context.

If it is nil, set CONTEXT-SYM's value to a new context and return it. Context is a list of the form as described in ansi-color-context if POSITION is nil, or ansi-color-context-region if POSITION is non-nil.

If CONTEXT-SYM's value is already non-nil, return it. If its marker doesn't point anywhere yet, position it before character number POSITION, if non-nil.

Source Code

;; Defined in /usr/src/emacs/lisp/ansi-color.el.gz
(defun ansi-color--ensure-context (context-sym position)
  "Return CONTEXT-SYM's value as a valid context.
If it is nil, set CONTEXT-SYM's value to a new context and return
it. Context is a list of the form as described in
`ansi-color-context' if POSITION is nil, or
`ansi-color-context-region' if POSITION is non-nil.

If CONTEXT-SYM's value is already non-nil, return it. If its
marker doesn't point anywhere yet, position it before character
number POSITION, if non-nil."
  (let ((context (symbol-value context-sym)))
    (if context
        (if position
            (let ((marker (cadr context)))
              (unless (marker-position marker)
                (set-marker marker position))
              context)
          context)
      (set context-sym
           (list (list (make-bool-vector 8 nil)
                       nil nil)
                 (if position
                     (copy-marker position)
                   ""))))))