From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Kelly Dean Newsgroups: gmane.emacs.devel Subject: Re: [Old patch] Unify fn and var help to make learning elisp a little easier Date: Thu, 05 Feb 2015 03:59:59 +0000 Message-ID: References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: ger.gmane.org 1423108911 7364 80.91.229.3 (5 Feb 2015 04:01:51 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 5 Feb 2015 04:01:51 +0000 (UTC) Cc: emacs-devel@gnu.org To: Artur Malabarba Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Feb 05 05:01:47 2015 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1YJDdQ-0005Ri-R0 for ged-emacs-devel@m.gmane.org; Thu, 05 Feb 2015 05:01:44 +0100 Original-Received: from localhost ([::1]:39930 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YJDdP-0007nY-E5 for ged-emacs-devel@m.gmane.org; Wed, 04 Feb 2015 23:01:43 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:39304) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YJDdD-0007nT-V5 for emacs-devel@gnu.org; Wed, 04 Feb 2015 23:01:32 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YJDd9-0000OU-SP for emacs-devel@gnu.org; Wed, 04 Feb 2015 23:01:31 -0500 Original-Received: from relay6-d.mail.gandi.net ([2001:4b98:c:538::198]:43694) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YJDd9-0000OP-JW for emacs-devel@gnu.org; Wed, 04 Feb 2015 23:01:27 -0500 Original-Received: from mfilter40-d.gandi.net (mfilter40-d.gandi.net [217.70.178.171]) by relay6-d.mail.gandi.net (Postfix) with ESMTP id 946EBFB882; Thu, 5 Feb 2015 05:01:26 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at mfilter40-d.gandi.net Original-Received: from relay6-d.mail.gandi.net ([217.70.183.198]) by mfilter40-d.gandi.net (mfilter40-d.gandi.net [10.0.15.180]) (amavisd-new, port 10024) with ESMTP id ZtYkdgi17+3o; Thu, 5 Feb 2015 05:01:25 +0100 (CET) X-Originating-IP: 66.220.3.179 Original-Received: from localhost (gm179.geneticmail.com [66.220.3.179]) (Authenticated sender: kelly@prtime.org) by relay6-d.mail.gandi.net (Postfix) with ESMTPSA id C6949FB883; Thu, 5 Feb 2015 05:01:14 +0100 (CET) In-Reply-To: X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:4b98:c:538::198 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 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-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:182427 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Artur Malabarba wrote: > Not yet, but I haven't forgotten about it. It just didn't apply > cleanly and I haven't had time to look into it. > > Would you like to recreate the patch from current master? > > > Here's the apply output > > $ git apply descfunorvar.patch > error: patch failed: lisp/help.el:215 > error: lisp/help.el: patch does not apply That's just Git being stupid. The =C2=ABpatch=C2=BB program works fine. Updated patch attached below so even Git can handle it. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=descfunorvar-trunk.patch --- lisp/help-fns.el +++ lisp/help-fns.el @@ -930,6 +930,37 @@ ;;;###autoload +(defun describe-function-or-variable (symbol &optional buffer frame) + "Display the full documentation of the function or variable SYMBOL. +If SYMBOL is a variable and has a buffer-local value in BUFFER or FRAME +\(default to the current buffer and current frame), it is displayed along +with the global value." + (interactive + (let* ((v-or-f (variable-at-point)) + (found (symbolp v-or-f)) + (v-or-f (if found v-or-f (function-called-at-point))) + (found (or found v-or-f)) + (enable-recursive-minibuffers t) + val) + (setq val (completing-read (if found + (format + "Describe function or variable (default %s): " v-or-f) + "Describe function or variable: ") + obarray + (lambda (vv) + (or (fboundp vv) + (get vv 'variable-documentation) + (and (boundp vv) (not (keywordp vv))))) + t nil nil + (if found (symbol-name v-or-f)))) + (list (if (equal val "") + v-or-f (intern val))))) + (if (not (symbolp symbol)) (message "You didn't specify a function or variable") + (unless (buffer-live-p buffer) (setq buffer (current-buffer))) + (unless (frame-live-p frame) (setq frame (selected-frame))) + (help-xref-interned symbol buffer frame))) + +;;;###autoload (defun describe-syntax (&optional buffer) "Describe the syntax specifications in the syntax table of BUFFER. The descriptions are inserted in a help buffer, which is then displayed. --- lisp/help-mode.el +++ lisp/help-mode.el @@ -621,10 +621,13 @@ ;; Additional functions for (re-)creating types of help buffers. -(defun help-xref-interned (symbol) + +;;;###autoload +(defun help-xref-interned (symbol &optional buffer frame) "Follow a hyperlink which appeared to be an arbitrary interned SYMBOL. Both variable, function and face documentation are extracted into a single -help buffer." +help buffer. If SYMBOL is a variable, include buffer-local value for optional +BUFFER or FRAME." (with-current-buffer (help-buffer) ;; Push the previous item on the stack before clobbering the output buffer. (help-setup-xref nil nil) @@ -640,7 +643,7 @@ (get symbol 'variable-documentation)) ;; Don't record the current entry in the stack. (setq help-xref-stack-item nil) - (describe-variable symbol)))) + (describe-variable symbol buffer frame)))) (cond (sdoc ;; We now have a help buffer on the variable. --- lisp/help.el +++ lisp/help.el @@ -95,6 +95,7 @@ (define-key map "k" 'describe-key) (define-key map "l" 'view-lossage) (define-key map "m" 'describe-mode) + (define-key map "o" 'describe-function-or-variable) (define-key map "n" 'view-emacs-news) (define-key map "p" 'finder-by-keyword) (define-key map "P" 'describe-package) @@ -218,6 +219,7 @@ m Display documentation of current minor modes and current major mode, including their special commands. n Display news of recent Emacs changes. +o SYMBOL Display the given function or variable's documentation and value. p TOPIC Find packages matching a given topic keyword. P PACKAGE Describe the given Emacs Lisp package. r Display the Emacs manual in Info mode. --=-=-=--