all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Michal Nazarewicz <mpn@google.com>
To: 19338@debbugs.gnu.org
Subject: bug#19338: [PATCH 1/3] eldoc: use default eldoc function if local one gives no results
Date: Wed, 10 Dec 2014 18:49:43 +0100	[thread overview]
Message-ID: <1418233785-18020-1-git-send-email-mpn@google.com> (raw)
In-Reply-To: <1418232280-16915-1-git-send-email-mpn@google.com>

From: Michal Nazarewicz <mina86@mina86.com>

* lisp/emacs-lisp/eldoc.el (eldoc-print-current-symbol-info): If
local `eldoc-documentation-function' returns no docstring and the
variable has a non-nil default value, try it as well.  This allows
setting up a global documentation function which will still be
used if given major mode has its own.
---
 etc/NEWS                 | 6 ++++--
 lisp/emacs-lisp/eldoc.el | 8 +++++++-
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/etc/NEWS b/etc/NEWS
index 407df82..50338cf 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -199,8 +199,10 @@ typing RET.
 result of the calculation into the current buffer.
 
 ** ElDoc
-*** New minor mode global-eldoc-mode
-*** eldoc-documentation-function now defaults to nil
+*** New minor mode `global-eldoc-mode'
+*** `eldoc-documentation-function' now defaults to nil
+*** Default value of `eldoc-documentation-function now' is consulted if
+local function does not return any documentation.
 
 ** eww
 
diff --git a/lisp/emacs-lisp/eldoc.el b/lisp/emacs-lisp/eldoc.el
index 6dddf5b..06ee164 100644
--- a/lisp/emacs-lisp/eldoc.el
+++ b/lisp/emacs-lisp/eldoc.el
@@ -345,7 +345,13 @@ This variable is expected to be set buffer-locally by modes that support ElDoc."
              (when eldoc-last-message
                (eldoc-message nil)
                nil))
-	 (eldoc-message (funcall eldoc-documentation-function)))))
+         (eldoc-message
+          (or (funcall eldoc-documentation-function)
+              ;; If local documentation function did not return anything, try
+              ;; global one.
+              (when (local-variable-p 'eldoc-documentation-function)
+                (let ((func (default-value 'eldoc-documentation-function)))
+                  (when func (funcall func)))))))))
 
 \f
 ;; When point is in a sexp, the function args are not reprinted in the echo
-- 
2.2.0.rc0.207.ga3a616c






  reply	other threads:[~2014-12-10 17:49 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-10 17:24 bug#19338: [PATCH 0/3] Implement an ElDoc function which describes char at point Michal Nazarewicz
2014-12-10 17:49 ` Michal Nazarewicz [this message]
2014-12-10 17:49   ` bug#19338: [PATCH 2/3] descr-text: add `describe-char-eldoc' describing character " Michal Nazarewicz
2014-12-10 17:49   ` bug#19338: [PATCH 3/3] eldoc: convert `eldoc-documentation-function' into a defcustom Michal Nazarewicz
2014-12-10 20:08     ` Stefan Monnier
2014-12-10 20:05   ` bug#19338: [PATCH 1/3] eldoc: use default eldoc function if local one gives no results Stefan Monnier
2014-12-10 21:46     ` Michal Nazarewicz
2014-12-11  2:38       ` Stefan Monnier
2014-12-11 16:02         ` bug#19338: [PATCHv2 1/2] descr-text: add `describe-char-eldoc' describing character at point Michal Nazarewicz
2014-12-11 16:02           ` bug#19338: [PATCHv2 2/2] eldoc: convert `eldoc-documentation-function' into a defcustom Michal Nazarewicz
2015-01-20 14:08             ` Michal Nazarewicz
2014-12-11 16:56           ` bug#19338: [PATCHv2 1/2] descr-text: add `describe-char-eldoc' describing character at point Leo Liu
2014-12-11 17:21             ` Michal Nazarewicz
2014-12-14 19:46           ` Eli Zaretskii
2014-12-14 20:40             ` bug#19338: [PATCHv3 " Michal Nazarewicz
2014-12-11 16:59         ` bug#19338: [PATCH 1/3] eldoc: use default eldoc function if local one gives no results Stefan Monnier

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=1418233785-18020-1-git-send-email-mpn@google.com \
    --to=mpn@google.com \
    --cc=19338@debbugs.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.