# HG changeset patch # User Kim F. Storm # Date 1149383655 0 # Node ID 07072bab2769d59a5e2f8b551c2306ba518deab7 # Parent 7b03434bdd7a9a331f7b5f4860f9cb665674115f (view-emacs-news): Rewrite to support new NEWS, NEWS.major, and NEWS.1-17 file naming. Add more intelligense, e.g. version 10 matches 1.10, and don't be confused by version 1.1 begin a prefix of 1.12 (etc). A numeric prefix arg also works. diff -r 7b03434bdd7a -r 07072bab2769 lisp/help.el --- a/lisp/help.el Sun Jun 04 01:11:51 2006 +0000 +++ b/lisp/help.el Sun Jun 04 01:14:15 2006 +0000 @@ -326,63 +326,76 @@ ;; run describe-prefix-bindings. (setq prefix-help-command 'describe-prefix-bindings) -(defun view-emacs-news (&optional arg) +(defun view-emacs-news (&optional version) "Display info on recent changes to Emacs. With argument, display info only for the selected version." (interactive "P") - (if (not arg) - (view-file (expand-file-name "NEWS" data-directory)) - (let* ((map (sort - (delete-dups - (apply - 'nconc - (mapcar - (lambda (file) - (with-temp-buffer - (insert-file-contents - (expand-file-name file data-directory)) - (let (res) - (while (re-search-forward - (if (string-match "^ONEWS\\.[0-9]+$" file) - "Changes in \\(?:Emacs\\|version\\)?[ \t]*\\([0-9]+\\(?:\\.[0-9]+\\)?\\)" - "^\* [^0-9\n]*\\([0-9]+\\.[0-9]+\\)") nil t) - (setq res (cons (list (match-string-no-properties 1) - file) res))) - res))) - (append '("NEWS" "ONEWS") - (directory-files data-directory nil - "^ONEWS\\.[0-9]+$" nil))))) - (lambda (a b) - (string< (car b) (car a))))) - (current (caar map)) - (version (completing-read - (format "Read NEWS for the version (default %s): " current) - (mapcar 'car map) nil nil nil nil current)) - (file (cadr (assoc version map))) - res) - (if (not file) - (error "No news is good news") - (view-file (expand-file-name file data-directory)) - (widen) - (goto-char (point-min)) - (when (re-search-forward - (concat (if (string-match "^ONEWS\\.[0-9]+$" file) - "Changes in \\(?:Emacs\\|version\\)?[ \t]*" - "^\* [^0-9\n]*") version) - nil t) - (beginning-of-line) - (narrow-to-region - (point) - (save-excursion - (while (and (setq res - (re-search-forward - (if (string-match "^ONEWS\\.[0-9]+$" file) - "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)))))))) + (unless version + (setq version emacs-major-version)) + (when (consp version) + (let* ((all-versions + (let (res) + (mapcar + (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) (lambda (a b) (string< b a))))) + (current (car all-versions)) + res) + (setq version (completing-read + (format "Read NEWS for the version (default %s): " 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))))) + (view-file (expand-file-name file data-directory)) + (widen) + (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))))))) + (defun view-todo (&optional arg) "Display the Emacs TODO list."