all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@IRO.UMontreal.CA>
To: emacs-devel@gnu.org
Subject: History info in C-h f
Date: Fri, 28 Sep 2018 15:11:18 -0400	[thread overview]
Message-ID: <jwvmus1wija.fsf-monnier+emacs@gnu.org> (raw)

Not sure if we should install this, especially since it's far from
reliable, but I've just whipped up the code below and figured some of
you might like it.

With this hack (which can go into your ~/.emacs), `C-h f defmacro`
dutifully informs you that `defmacro` was added to Emacs-1.2 (at least,
if you're on `master` and have upgraded very recently), whereas `C-h
f advice-add` informs you that it was only introduced in Emacs-24.4.


        Stefan


diff --git a/lisp/help-fns.el b/lisp/help-fns.el
index e15c96e6a3..a6c92103e6 100644
--- a/lisp/help-fns.el
+++ b/lisp/help-fns.el
@@ -574,6 +574,37 @@ help-fns--interactive-only
                          (t "."))
                    "\n")))))
 
+(add-hook 'help-fns-describe-function-functions #'help-fns--first-release)
+(defun help-fns--first-release (function)
+  "Try and find the first release that defined this function."
+  ;; Code below relies on the etc/NEWS* files.
+  ;; FIXME: Maybe we should also use the */ChangeLog* files when available.
+  ;; FIXME: Maybe we should also look for announcements of the addition
+  ;; of the *packages* in which the function is defined.
+  (when (symbolp function)
+    (let* ((name (symbol-name function))
+           (re (concat "\\_<" (regexp-quote name) "\\_>"))
+           (news (directory-files data-directory t "\\`NEWS.[1-9]"))
+           (first nil))
+      (with-temp-buffer
+        (dolist (f news)
+          (erase-buffer)
+          (insert-file-contents f)
+          (goto-char (point-min))
+          (search-forward "\n*")
+          (while (re-search-forward re nil t)
+            (save-excursion
+              (if (not (re-search-backward "^\\*.*in Emacs \\([0-9.]+\\)"
+                                           nil t))
+                  (error "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))))))))
+      (when first
+        (insert (format "\nIntroduced at or before Emacs version %s.\n"
+                        first))))))
+
 (defun help-fns-short-filename (filename)
   (let* ((abbrev (abbreviate-file-name filename))
          (short abbrev))



             reply	other threads:[~2018-09-28 19:11 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-28 19:11 Stefan Monnier [this message]
2018-09-29  8:15 ` History info in C-h f Michael Albinus
2018-09-29 15:18 ` John Shahid
2018-09-29 15:30   ` Elias Mårtenson
2018-09-29 18:01   ` Stefan Monnier
2018-11-12  0:30 ` Drew Adams

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwvmus1wija.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.