Function: help-fns--first-release

help-fns--first-release is a byte-compiled function defined in help-fns.el.gz.

Signature

(help-fns--first-release SYMBOL)

Documentation

Return the likely first release that defined SYMBOL, or nil.

Source Code

;; Defined in /usr/src/emacs/lisp/help-fns.el.gz
(defun help-fns--first-release (symbol)
  "Return the likely first release that defined SYMBOL, or nil."
  ;; Code below relies on the etc/NEWS* files.
  ;; FIXME: Maybe we should also use the */ChangeLog* files when available.
  ;; FIXME: Maybe we should also look for announcements of the addition
  ;; of the *packages* in which the function is defined.
  (let* ((re (help-fns--first-release-regexp symbol))
         (news (directory-files data-directory t "\\`NEWS\\(\\'\\|\\.\\)"))
         (case-fold-search nil)
         (place nil)
         (first nil))
    (with-temp-buffer
      (dolist (f news)
        (erase-buffer)
        (insert-file-contents f)
        (goto-char (point-min))
        ;; Failed git merges can leave empty files that look like NEWS
        ;; in etc.  Don't error here.
        (when (search-forward "\n*" nil t)
          (while (re-search-forward re nil t)
            (let ((pos (match-beginning 0)))
              (save-excursion
                ;; Almost all entries are of the form "* ... in Emacs NN.MM."
                ;; but there are also a few in the form "* Emacs NN.MM is a bug
                ;; fix release ...".
                (if (not (re-search-backward
                          "^\\* \\(?:.* \\)?Emacs \\([0-9.]+[0-9]\\)"
                          nil t))
                    (message "Ref to %S found in non-versioned section in %S"
                             symbol (file-name-nondirectory f))
                  (let ((version (match-string 1)))
                    (when (or (null first) (version< version first))
                      (setq place (list f pos))
                      (setq first version))))))))))
    (when first
      (make-text-button first nil 'type 'help-news 'help-args place))))