aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKim F. Storm2006-06-04 01:14:15 +0000
committerKim F. Storm2006-06-04 01:14:15 +0000
commite38cc268e2d391191b6a81b9b72f4cd1491faafa (patch)
tree03c5d67458cd31857fb85f45f5c6267bd4312b99
parent32a877bb6756a0f41ea919c60b846320763e7c64 (diff)
downloademacs-e38cc268e2d391191b6a81b9b72f4cd1491faafa.tar.gz
emacs-e38cc268e2d391191b6a81b9b72f4cd1491faafa.zip
(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.
-rw-r--r--lisp/help.el121
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."
326;; run describe-prefix-bindings. 326;; run describe-prefix-bindings.
327(setq prefix-help-command 'describe-prefix-bindings) 327(setq prefix-help-command 'describe-prefix-bindings)
328 328
329(defun view-emacs-news (&optional arg) 329(defun view-emacs-news (&optional version)
330 "Display info on recent changes to Emacs. 330 "Display info on recent changes to Emacs.
331With argument, display info only for the selected version." 331With argument, display info only for the selected version."
332 (interactive "P") 332 (interactive "P")
333 (if (not arg) 333 (unless version
334 (view-file (expand-file-name "NEWS" data-directory)) 334 (setq version emacs-major-version))
335 (let* ((map (sort 335 (when (consp version)
336 (delete-dups 336 (let* ((all-versions
337 (apply 337 (let (res)
338 'nconc 338 (mapcar
339 (mapcar 339 (lambda (file)
340 (lambda (file) 340 (with-temp-buffer
341 (with-temp-buffer 341 (insert-file-contents
342 (insert-file-contents 342 (expand-file-name file data-directory))
343 (expand-file-name file data-directory)) 343 (while (re-search-forward
344 (let (res) 344 (if (member file '("NEWS.18" "NEWS.1-17"))
345 (while (re-search-forward 345 "Changes in \\(?:Emacs\\|version\\)?[ \t]*\\([0-9]+\\(?:\\.[0-9]+\\)?\\)"
346 (if (string-match "^ONEWS\\.[0-9]+$" file) 346 "^\* [^0-9\n]*\\([0-9]+\\.[0-9]+\\)") nil t)
347 "Changes in \\(?:Emacs\\|version\\)?[ \t]*\\([0-9]+\\(?:\\.[0-9]+\\)?\\)" 347 (setq res (cons (match-string-no-properties 1) res)))))
348 "^\* [^0-9\n]*\\([0-9]+\\.[0-9]+\\)") nil t) 348 (cons "NEWS"
349 (setq res (cons (list (match-string-no-properties 1) 349 (directory-files data-directory nil
350 file) res))) 350 "^NEWS\\.[0-9][-0-9]*$" nil)))
351 res))) 351 (sort (delete-dups res) (lambda (a b) (string< b a)))))
352 (append '("NEWS" "ONEWS") 352 (current (car all-versions))
353 (directory-files data-directory nil 353 res)
354 "^ONEWS\\.[0-9]+$" nil))))) 354 (setq version (completing-read
355 (lambda (a b) 355 (format "Read NEWS for the version (default %s): " current)
356 (string< (car b) (car a))))) 356 all-versions nil nil nil nil current))
357 (current (caar map)) 357 (if (integerp (string-to-number version))
358 (version (completing-read 358 (setq version (string-to-number version))
359 (format "Read NEWS for the version (default %s): " current) 359 (unless (or (member version all-versions)
360 (mapcar 'car map) nil nil nil nil current)) 360 (<= (string-to-number version) (string-to-number current)))
361 (file (cadr (assoc version map))) 361 (error "No news about version %s" version)))))
362 res) 362 (when (integerp version)
363 (if (not file) 363 (cond ((<= version 12)
364 (error "No news is good news") 364 (setq version (format "1.%d" version)))
365 (view-file (expand-file-name file data-directory)) 365 ((<= version 18)
366 (widen) 366 (setq version (format "%d" version)))
367 (goto-char (point-min)) 367 ((> version emacs-major-version)
368 (when (re-search-forward 368 (error "No news about emacs %d (yet)" version))))
369 (concat (if (string-match "^ONEWS\\.[0-9]+$" file) 369 (let* ((vn (if (stringp version)
370 "Changes in \\(?:Emacs\\|version\\)?[ \t]*" 370 (string-to-number version)
371 "^\* [^0-9\n]*") version) 371 version))
372 nil t) 372 (file (cond
373 (beginning-of-line) 373 ((>= vn emacs-major-version) "NEWS")
374 (narrow-to-region 374 ((< vn 18) "NEWS.1-17")
375 (point) 375 (t (format "NEWS.%d" vn)))))
376 (save-excursion 376 (view-file (expand-file-name file data-directory))
377 (while (and (setq res 377 (widen)
378 (re-search-forward 378 (goto-char (point-min))
379 (if (string-match "^ONEWS\\.[0-9]+$" file) 379 (when (stringp version)
380 "Changes in \\(?:Emacs\\|version\\)?[ \t]*\\([0-9]+\\(?:\\.[0-9]+\\)?\\)" 380 (when (re-search-forward
381 "^\* [^0-9\n]*\\([0-9]+\\.[0-9]+\\)") nil t)) 381 (concat (if (< vn 19)
382 (equal (match-string-no-properties 1) version))) 382 "Changes in Emacs[ \t]*"
383 (or res (goto-char (point-max))) 383 "^\* [^0-9\n]*") version "$")
384 (beginning-of-line) 384 nil t)
385 (point)))))))) 385 (beginning-of-line)
386 (narrow-to-region
387 (point)
388 (save-excursion
389 (while (and (setq res
390 (re-search-forward
391 (if (< vn 19)
392 "Changes in \\(?:Emacs\\|version\\)?[ \t]*\\([0-9]+\\(?:\\.[0-9]+\\)?\\)"
393 "^\* [^0-9\n]*\\([0-9]+\\.[0-9]+\\)") nil t))
394 (equal (match-string-no-properties 1) version)))
395 (or res (goto-char (point-max)))
396 (beginning-of-line)
397 (point)))))))
398
386 399
387(defun view-todo (&optional arg) 400(defun view-todo (&optional arg)
388 "Display the Emacs TODO list." 401 "Display the Emacs TODO list."