]> git.eshelyaron.com Git - emacs.git/commitdiff
* lisp/help-fns.el: Make hyperlink for the "first release" info
authorStefan Monnier <monnier@iro.umontreal.ca>
Sun, 2 Jun 2019 15:52:41 +0000 (11:52 -0400)
committerStefan Monnier <monnier@iro.umontreal.ca>
Sun, 2 Jun 2019 15:52:41 +0000 (11:52 -0400)
* lisp/help-fns.el (help-fns--first-release): Return a "button".
(help-fns--mention-first-release): Preserve the string's text-properties.

* lisp/help-mode.el (help-news): New button type.

lisp/help-fns.el
lisp/help-mode.el

index de69168330d4fa913418693e1a7d20773d532bb6..47bbefbf010bc959d067e3202335f471aa704230 100644 (file)
@@ -592,6 +592,7 @@ FILE is the file where FUNCTION was probably defined."
   (let* ((name (symbol-name symbol))
          (re (concat "\\_<" (regexp-quote name) "\\_>"))
          (news (directory-files data-directory t "\\`NEWS.[1-9]"))
+         (place nil)
          (first nil))
     (with-temp-buffer
       (dolist (f news)
@@ -600,17 +601,20 @@ FILE is the file where FUNCTION was probably defined."
         (goto-char (point-min))
         (search-forward "\n*")
         (while (re-search-forward re nil t)
-          (save-excursion
-            ;; Almost all entries are of the form "* ... in Emacs NN.MM."
-            ;; but there are also a few in the form "* Emacs NN.MM is a bug
-            ;; fix release ...".
-            (if (not (re-search-backward "^\\*.* Emacs \\([0-9.]+[0-9]\\)"
-                                         nil t))
-                (message "Ref found in non-versioned section in %S"
-                         (file-name-nondirectory f))
-              (let ((version (match-string 1)))
-                (when (or (null first) (version< version first))
-                  (setq first version))))))))
+          (let ((pos (match-beginning 0)))
+            (save-excursion
+              ;; Almost all entries are of the form "* ... in Emacs NN.MM."
+              ;; but there are also a few in the form "* Emacs NN.MM is a bug
+              ;; fix release ...".
+              (if (not (re-search-backward "^\\*.* Emacs \\([0-9.]+[0-9]\\)"
+                                           nil t))
+                  (message "Ref found in non-versioned section in %S"
+                           (file-name-nondirectory f))
+                (let ((version (match-string 1)))
+                  (when (or (null first) (version< version first))
+                    (setq place (list f pos))
+                    (setq first version)))))))))
+    (make-text-button first nil 'type 'help-news 'help-args place)
     first))
 
 (add-hook 'help-fns-describe-function-functions
@@ -620,8 +624,9 @@ FILE is the file where FUNCTION was probably defined."
 (defun help-fns--mention-first-release (object)
   (let ((first (if (symbolp object) (help-fns--first-release object))))
     (when first
-      (princ (format "  Probably introduced at or before Emacs version %s.\n"
-                     first)))))
+      (with-current-buffer standard-output
+        (insert (format "  Probably introduced at or before Emacs version %s.\n"
+                        first))))))
 
 (defun help-fns-short-filename (filename)
   (let* ((abbrev (abbreviate-file-name filename))
index 6cc3f0d4f71a37668f91bc46d9b47d98e4b6a35b..dc2992cd4a5c19d49dc62d2c4b8a955eb480230d 100644 (file)
@@ -287,12 +287,12 @@ The format is (FUNCTION ARGS...).")
 
 (define-button-type 'help-theme-def
   :supertype 'help-xref
-  'help-function 'find-file
+  'help-function #'find-file
   'help-echo (purecopy "mouse-2, RET: visit theme file"))
 
 (define-button-type 'help-theme-edit
   :supertype 'help-xref
-  'help-function 'customize-create-theme
+  'help-function #'customize-create-theme
   'help-echo (purecopy "mouse-2, RET: edit this theme file"))
 
 (define-button-type 'help-dir-local-var-def
@@ -302,7 +302,13 @@ The format is (FUNCTION ARGS...).")
                   ;; local variable was defined.
                   (find-file file))
   'help-echo (purecopy "mouse-2, RET: open directory-local variables file"))
-
+(define-button-type 'help-news
+  :supertype 'help-xref
+  'help-function
+  (lambda (file pos)
+    (pop-to-buffer (find-file-noselect file))
+    (goto-char pos))
+  'help-echo (purecopy "mouse-2, RET: show corresponding NEWS announcement"))
 \f
 (defvar bookmark-make-record-function)