unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Kelly Dean <kelly@prtime.org>
To: Artur Malabarba <bruce.connor.am@gmail.com>
Cc: emacs-devel@gnu.org
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	[thread overview]
Message-ID: <hINRNu5Ou3mqRKEUSB3U4Xmn8A3Ua57BMCBrKfiZU0y@local> (raw)
In-Reply-To: <CAAdUY-KQDpPe1sa+1r1Tb2Bvi5oJyyFMECxcNGm1j3oT=co-eg@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 490 bytes --]

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 «patch» program works fine.

Updated patch attached below so even Git can handle it.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: descfunorvar-trunk.patch --]
[-- Type: text/x-diff, Size: 3297 bytes --]

--- 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 @@
 
 \f
 ;; 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.

  reply	other threads:[~2015-02-05  3:59 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-20 23:06 [Old patch] Unify fn and var help to make learning elisp a little easier Kelly Dean
2015-01-20 23:17 ` Alexis
2015-01-21 14:37 ` Stefan Monnier
2015-01-28 10:25 ` Kelly Dean
2015-01-28 11:27   ` Artur Malabarba
2015-02-04  6:42     ` Kelly Dean
2015-02-04 12:05       ` Artur Malabarba
2015-02-05  3:59         ` Kelly Dean [this message]
2015-02-05 17:33           ` Artur Malabarba
2015-02-05 17:51             ` Dmitry Gutov
2015-02-06  5:23             ` Kelly Dean
2015-02-06  6:01               ` Dmitry Gutov
2015-02-06  8:47                 ` Artur Malabarba
2015-02-06 14:46                   ` Stefan Monnier
2015-01-30 20:05   ` Artur Malabarba
2015-01-30 20:14     ` Artur Malabarba
2015-01-30 20:45   ` patches: emacs-devel@ vs. debbugs.gnu.org Ivan Shmakov
  -- strict thread matches above, loose matches on Subject: below --
2015-01-21  4:59 [Old patch] Unify fn and var help to make learning elisp a little easier Brian Burns

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=hINRNu5Ou3mqRKEUSB3U4Xmn8A3Ua57BMCBrKfiZU0y@local \
    --to=kelly@prtime.org \
    --cc=bruce.connor.am@gmail.com \
    --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 public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).