diff options
author | Kim F. Storm <storm@cua.dk> | 2006-06-04 01:14:15 +0000 |
---|---|---|
committer | Kim F. Storm <storm@cua.dk> | 2006-06-04 01:14:15 +0000 |
commit | e38cc268e2d391191b6a81b9b72f4cd1491faafa (patch) | |
tree | 03c5d67458cd31857fb85f45f5c6267bd4312b99 /lisp/help.el | |
parent | 32a877bb6756a0f41ea919c60b846320763e7c64 (diff) | |
download | emacs-e38cc268e2d391191b6a81b9b72f4cd1491faafa.tar.gz |
(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.
Diffstat (limited to 'lisp/help.el')
-rw-r--r-- | lisp/help.el | 121 |
1 files changed, 67 insertions, 54 deletions
diff --git a/lisp/help.el b/lisp/help.el index 5efd58dfaf5..d9a48a0a4cf 100644 --- a/lisp/help.el +++ b/lisp/help.el @@ -326,63 +326,76 @@ of the key sequence that ran this command." ;; 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." |