Function: rmail-set-attribute-1

rmail-set-attribute-1 is a byte-compiled function defined in rmail.el.gz.

Signature

(rmail-set-attribute-1 ATTR STATE)

Documentation

Subroutine of rmail-set-attribute.

Set Rmail attribute ATTR to STATE in rmail-attribute-header, creating the header if necessary. Returns non-nil if a significant attribute change was made.

Source Code

;; Defined in /usr/src/emacs/lisp/mail/rmail.el.gz
(defun rmail-set-attribute-1 (attr state)
  "Subroutine of `rmail-set-attribute'.
Set Rmail attribute ATTR to STATE in `rmail-attribute-header',
creating the header if necessary.  Returns non-nil if a
significant attribute change was made."
  (let ((limit (search-forward "\n\n" nil t))
        (value (rmail-get-attr-value attr state))
        (inhibit-read-only t)
        altered)
    (goto-char (point-min))
    (if (search-forward (concat rmail-attribute-header ": ") limit t)
        ;; If this message already records attributes, just change the
        ;; value for this one.
        (let ((missing (- (+ (point) attr) (line-end-position))))
          ;; Position point at this attribute, adding attributes if necessary.
          (if (> missing 0)
              (progn
                (end-of-line)
                (insert-char ?- missing)
                (backward-char 1))
            (forward-char attr))
          ;; Change this attribute.
          (when (/= value (char-after))
            (setq altered t)
            (delete-char 1)
            (insert value)))
      ;; Otherwise add a header line to record the attributes and set
      ;; all but this one to no.
      (let ((header-value (copy-sequence "--------")))
        (aset header-value attr value)
        (goto-char (if limit (1- limit) (point-max)))
        (setq altered (/= value ?-))
        (insert rmail-attribute-header ": " header-value "\n")))
    altered))