diff lisp/help.el @ 90428:a8190f7e546e

Merge from emacs--devo--0 Patches applied: * emacs--devo--0 (patch 285-296) - Update from CVS - Merge from gnus--rel--5.10 - Update from CVS: admin/FOR-RELEASE: Update refcard section. * gnus--rel--5.10 (patch 102-104) - Update from CVS Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-64
author Miles Bader <miles@gnu.org>
date Wed, 07 Jun 2006 18:05:10 +0000
parents e6bf73e43cf4 07072bab2769
children 138027c8c982
line wrap: on
line diff
--- a/lisp/help.el	Wed Jun 07 11:41:58 2006 +0000
+++ b/lisp/help.el	Wed Jun 07 18:05:10 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."
@@ -942,11 +955,11 @@
 
 (defcustom temp-buffer-max-height (lambda (buffer) (/ (- (frame-height) 2) 2))
   "Maximum height of a window displaying a temporary buffer.
-This is the maximum height (in text lines) which `resize-temp-buffer-window'
+This is effective only when Temp Buffer Resize mode is enabled.
+The value is the maximum height (in lines) which `resize-temp-buffer-window'
 will give to a window displaying a temporary buffer.
-It can also be a function which will be called with the object corresponding
-to the buffer to be displayed as argument and should return an integer
-positive number."
+It can also be a function to be called to choose the height for such a buffer.
+It gets one argumemt, the buffer, and should return a positive integer."
   :type '(choice integer function)
   :group 'help
   :version "20.4")