Function: view-emacs-news
view-emacs-news is an interactive and byte-compiled function defined
in help.el.gz.
Signature
(view-emacs-news &optional VERSION)
Documentation
Display info on recent changes to Emacs.
With argument, display info only for the selected version.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/help.el.gz
(defun view-emacs-news (&optional version)
"Display info on recent changes to Emacs.
With argument, display info only for the selected version."
(interactive "P")
(unless version
(setq version emacs-major-version))
(when (consp version)
(let* ((all-versions
(let (res)
(mapc
(lambda (file)
(with-temp-buffer
(insert-file-contents
(expand-file-name file data-directory))
(while (re-search-forward
(if (member file '("NEWS.18" "NEWS.1-17"))
"Changes in \\(?:Emacs\\|version\\)?[ \t]*\\([0-9]+\\(?:\\.[0-9]+\\)?\\)"
"^\\* [^0-9\n]*\\([0-9]+\\.[0-9]+\\)") nil t)
(setq res (cons (match-string-no-properties 1) res)))))
(cons "NEWS"
(directory-files data-directory nil
"\\`NEWS\\.[0-9][-0-9]*\\'" nil)))
(sort (delete-dups res) #'string>)))
(current (car all-versions)))
(setq version (completing-read
(format-prompt "Read NEWS for the version" current)
all-versions nil nil nil nil current))
(if (integerp (string-to-number version))
(setq version (string-to-number version))
(unless (or (member version all-versions)
(<= (string-to-number version) (string-to-number current)))
(error "No news about version %s" version)))))
(when (integerp version)
(cond ((<= version 12)
(setq version (format "1.%d" version)))
((<= version 18)
(setq version (format "%d" version)))
((> version emacs-major-version)
(error "No news about Emacs %d (yet)" version))))
(let* ((vn (if (stringp version)
(string-to-number version)
version))
(file (cond
((>= vn emacs-major-version) "NEWS")
((< vn 18) "NEWS.1-17")
(t (format "NEWS.%d" vn))))
res)
(find-file (expand-file-name file data-directory))
(widen) ; In case we already are visiting that NEWS file
(emacs-news-view-mode)
(goto-char (point-min))
(when (stringp version)
(when (re-search-forward
(concat (if (< vn 19)
"Changes in Emacs[ \t]*"
"^\\* [^0-9\n]*") version "$")
nil t)
(beginning-of-line)
(narrow-to-region
(point)
(save-excursion
(while (and (setq res
(re-search-forward
(if (< vn 19)
"Changes in \\(?:Emacs\\|version\\)?[ \t]*\\([0-9]+\\(?:\\.[0-9]+\\)?\\)"
"^\\* [^0-9\n]*\\([0-9]+\\.[0-9]+\\)") nil t))
(equal (match-string-no-properties 1) version)))
(or res (goto-char (point-max)))
(beginning-of-line)
(point)))))))