From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: History info in C-h f Date: Fri, 28 Sep 2018 15:11:18 -0400 Message-ID: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1538161804 2849 195.159.176.226 (28 Sep 2018 19:10:04 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 28 Sep 2018 19:10:04 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Sep 28 21:10:00 2018 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1g5y9I-0000cV-7F for ged-emacs-devel@m.gmane.org; Fri, 28 Sep 2018 21:10:00 +0200 Original-Received: from localhost ([::1]:45499 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g5yBO-0006MV-Hj for ged-emacs-devel@m.gmane.org; Fri, 28 Sep 2018 15:12:10 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:52721) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g5yAk-0006MA-8A for emacs-devel@gnu.org; Fri, 28 Sep 2018 15:11:30 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g5yAh-0008S0-42 for emacs-devel@gnu.org; Fri, 28 Sep 2018 15:11:30 -0400 Original-Received: from pruche.dit.umontreal.ca ([132.204.246.22]:33268) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g5yAg-0008OS-VD for emacs-devel@gnu.org; Fri, 28 Sep 2018 15:11:27 -0400 Original-Received: from fmsmemgm.homelinux.net (lechon.iro.umontreal.ca [132.204.27.242]) by pruche.dit.umontreal.ca (8.14.7/8.14.1) with ESMTP id w8SJBITj022395; Fri, 28 Sep 2018 15:11:18 -0400 Original-Received: by fmsmemgm.homelinux.net (Postfix, from userid 20848) id 7BD67AE099; Fri, 28 Sep 2018 15:11:18 -0400 (EDT) X-NAI-Spam-Flag: NO X-NAI-Spam-Threshold: 5 X-NAI-Spam-Score: 0 X-NAI-Spam-Rules: 2 Rules triggered EDT_SA_DN_PASS=0, RV6384=0 X-NAI-Spam-Version: 2.3.0.9418 : core <6384> : inlines <6908> : streams <1799786> : uri <2720060> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 132.204.246.22 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:230115 Archived-At: 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))