Function: log-edit-set-header

log-edit-set-header is a byte-compiled function defined in log-edit.el.gz.

Signature

(log-edit-set-header HEADER VALUE &optional TOGGLE)

Documentation

Set the value of HEADER to VALUE in the current buffer.

If TOGGLE is non-nil, and the value of HEADER already is VALUE, clear it. Make sure there is an empty line after the headers. Return t if toggled on (or TOGGLE is nil), otherwise nil.

Source Code

;; Defined in /usr/src/emacs/lisp/vc/log-edit.el.gz
(defun log-edit-set-header (header value &optional toggle)
  "Set the value of HEADER to VALUE in the current buffer.
If TOGGLE is non-nil, and the value of HEADER already is VALUE,
clear it.  Make sure there is an empty line after the headers.
Return t if toggled on (or TOGGLE is nil), otherwise nil."
  (let ((val t)
        (line (log-edit--make-header-line header value)))
    (save-excursion
      (save-restriction
        (rfc822-goto-eoh)
        (narrow-to-region (point-min) (point))
        (goto-char (point-min))
        (if (re-search-forward (concat "^" header ":"
                                       log-edit-header-contents-regexp)
                               nil t)
            (if (setq val (not (and toggle (string= (match-string 1) value))))
                (replace-match line t t)
              (replace-match "" t t nil 1))
          (insert line)))
      (rfc822-goto-eoh)
      (delete-horizontal-space)
      (unless (looking-at "\n")
        (insert "\n")))
    val))