(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.
This commit is contained in:
parent
32a877bb67
commit
e38cc268e2
1 changed files with 67 additions and 54 deletions
121
lisp/help.el
121
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."
|
||||
|
|
Loading…
Add table
Reference in a new issue