all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Michal Nazarewicz <mpn@google.com>
To: Stefan Monnier <monnier@IRO.UMontreal.CA>
Cc: 19338@debbugs.gnu.org
Subject: bug#19338: [PATCHv2 2/2] eldoc: convert `eldoc-documentation-function' into a defcustom
Date: Thu, 11 Dec 2014 17:02:32 +0100	[thread overview]
Message-ID: <1418313752-13536-2-git-send-email-mpn@google.com> (raw)
In-Reply-To: <1418313752-13536-1-git-send-email-mpn@google.com>

From: Michal Nazarewicz <mina86@mina86.com>

* lisp/emacs-lisp/eldoc.el (eldoc-documentation-function): Change from
defvar to defcustom with `describe-char-eldoc' function as one of the
suggested values.  Describe how major modes should use `add-function' to
alter value of the defcustom.

* lisp/hexl.el (hexl-mode): Set `eldoc-documentation-function' using
`add-function' so the default value is always used.
* lisp/ielm.el (inferior-emacs-lisp-mode): Set
`eldoc-documentation-function' using `add-function' so the default
value is always used.
* lisp/progmodes/cfengine.el (cfengine3-mode): Set
`eldoc-documentation-function' using `add-function' so the default
value is always used.
* lisp/progmodes/elisp-mode (emacs-lisp-mode): Set
`eldoc-documentation-function' using `add-function' so the default
value is always used.
* lisp/progmodes/octave.el (octave-mode): Set
`eldoc-documentation-function' using `add-function' so the default
value is always used.
* lisp/progmodes/python.el (python-mode): Set
`eldoc-documentation-function' using `add-function' so the default
value is always used.
* lisp/simple.el (read--expression): Set `eldoc-documentation-function'
using `add-function' so the default value is always used.
---
 lisp/emacs-lisp/eldoc.el     | 15 ++++++++++++---
 lisp/hexl.el                 |  4 ++--
 lisp/ielm.el                 |  6 +++---
 lisp/progmodes/cfengine.el   |  3 ++-
 lisp/progmodes/elisp-mode.el |  4 ++--
 lisp/progmodes/octave.el     |  3 ++-
 lisp/progmodes/python.el     |  4 ++--
 lisp/simple.el               |  4 ++--
 8 files changed, 27 insertions(+), 16 deletions(-)

diff --git a/lisp/emacs-lisp/eldoc.el b/lisp/emacs-lisp/eldoc.el
index 2ee3d23..2360954 100644
--- a/lisp/emacs-lisp/eldoc.el
+++ b/lisp/emacs-lisp/eldoc.el
@@ -323,8 +323,8 @@ Otherwise work like `message'."
 
 \f
 ;;;###autoload
-(defvar eldoc-documentation-function #'ignore
-  "Function to call to return doc string.
+(defcustom eldoc-documentation-function #'ignore
+  "Function to call to return doc string for ElDoc mode.
 The function of no args should return a one-line string for displaying
 doc about a function etc. appropriate to the context around point.
 It should return nil if there's no doc appropriate for the context.
@@ -336,7 +336,16 @@ the variables `eldoc-argument-case' and `eldoc-echo-area-use-multiline-p',
 and the face `eldoc-highlight-function-argument', if they are to have any
 effect.
 
-This variable is expected to be set buffer-locally by modes that support ElDoc.")
+Major modes should modify this variable using `add-function', for example:
+  (add-function :before-until (local 'eldoc-documentation-function)
+                #'foo-mode-eldoc-function)
+so that the global documentation function (i.e. the default value of the
+variable) is taken into account if the major mode specific function does not
+return any documentation."
+  :type '(radio (function-item describe-char-eldoc)
+                function
+                (const :tag "No documentation function" #'ignore))
+  :group 'eldoc)
 
 (defun eldoc-print-current-symbol-info ()
   ;; This is run from post-command-hook or some idle timer thing,
diff --git a/lisp/hexl.el b/lisp/hexl.el
index 5c23f49..e1b1f98 100644
--- a/lisp/hexl.el
+++ b/lisp/hexl.el
@@ -394,8 +394,8 @@ You can use \\[hexl-find-file] to visit a file in Hexl mode.
     (add-hook 'change-major-mode-hook 'hexl-maybe-dehexlify-buffer nil t)
 
     ;; Set a callback function for eldoc.
-    (hexl-mode--setq-local 'eldoc-documentation-function
-                           #'hexl-print-current-point-info)
+    (add-function :before-until (local 'eldoc-documentation-function)
+                  #'hexl-print-current-point-info)
     (eldoc-add-command-completions "hexl-")
     (eldoc-remove-command "hexl-save-buffer"
 			  "hexl-current-address")
diff --git a/lisp/ielm.el b/lisp/ielm.el
index 37e66cc..f776f13 100644
--- a/lisp/ielm.el
+++ b/lisp/ielm.el
@@ -380,7 +380,7 @@ nonempty, then flushes the buffer."
                      (*3 ***)
                      (active-process (ielm-process))
                      (old-standard-output standard-output)
-                     new-standard-output 
+                     new-standard-output
                      ielm-temp-buffer)
                 (set-match-data ielm-match-data)
                 (save-excursion
@@ -542,8 +542,8 @@ Customized bindings may be defined in `ielm-map', which currently contains:
   (set (make-local-variable 'completion-at-point-functions)
        '(comint-replace-by-expanded-history
          ielm-complete-filename elisp-completion-at-point))
-  (setq-local eldoc-documentation-function
-              #'elisp-eldoc-documentation-function)
+  (add-function :before-until (local 'eldoc-documentation-function)
+                #'elisp-eldoc-documentation-function)
   (set (make-local-variable 'ielm-prompt-internal) ielm-prompt)
   (set (make-local-variable 'comint-prompt-read-only) ielm-prompt-read-only)
   (setq comint-get-old-input 'ielm-get-old-input)
diff --git a/lisp/progmodes/cfengine.el b/lisp/progmodes/cfengine.el
index 53d5be9..42de44e 100644
--- a/lisp/progmodes/cfengine.el
+++ b/lisp/progmodes/cfengine.el
@@ -1350,7 +1350,8 @@ to the action header."
                  (when buffer-file-name
                    (shell-quote-argument buffer-file-name)))))
 
-  (setq-local eldoc-documentation-function #'cfengine3-documentation-function)
+  (add-function :before-until (local 'eldoc-documentation-function)
+                #'cfengine3-documentation-function)
 
   (add-hook 'completion-at-point-functions
             #'cfengine3-completion-function nil t)
diff --git a/lisp/progmodes/elisp-mode.el b/lisp/progmodes/elisp-mode.el
index ba70f90..3094dec 100644
--- a/lisp/progmodes/elisp-mode.el
+++ b/lisp/progmodes/elisp-mode.el
@@ -229,8 +229,8 @@ Blank lines separate paragraphs.  Semicolons start comments.
   :group 'lisp
   (lisp-mode-variables nil nil 'elisp)
   (setq imenu-case-fold-search nil)
-  (setq-local eldoc-documentation-function
-              #'elisp-eldoc-documentation-function)
+  (add-function :before-until (local 'eldoc-documentation-function)
+                #'elisp-eldoc-documentation-function)
   (add-hook 'completion-at-point-functions
             #'elisp-completion-at-point nil 'local))
 
diff --git a/lisp/progmodes/octave.el b/lisp/progmodes/octave.el
index 7d96363..90b1e44 100644
--- a/lisp/progmodes/octave.el
+++ b/lisp/progmodes/octave.el
@@ -601,7 +601,8 @@ Key bindings:
   (add-hook 'before-save-hook 'octave-sync-function-file-names nil t)
   (setq-local beginning-of-defun-function 'octave-beginning-of-defun)
   (and octave-font-lock-texinfo-comment (octave-font-lock-texinfo-comment))
-  (setq-local eldoc-documentation-function 'octave-eldoc-function)
+  (add-function :before-until (local 'eldoc-documentation-function)
+                'octave-eldoc-function)
 
   (easy-menu-add octave-mode-menu))
 
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index 63597d5..586109a 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -4378,8 +4378,8 @@ Arguments START and END narrow the buffer region to work on."
                                                  (current-column))))
          (^ '(- (1+ (current-indentation))))))
 
-  (set (make-local-variable 'eldoc-documentation-function)
-       #'python-eldoc-function)
+  (add-function :before-until (local 'eldoc-documentation-function)
+                #'python-eldoc-function)
 
   (add-to-list 'hs-special-modes-alist
                `(python-mode "^\\s-*\\(?:def\\|class\\)\\>" nil "#"
diff --git a/lisp/simple.el b/lisp/simple.el
index 9f44798..806581b 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -1407,8 +1407,8 @@ display the result of expression evaluation."
     (minibuffer-with-setup-hook
         (lambda ()
           ;; FIXME: call emacs-lisp-mode?
-          (setq-local eldoc-documentation-function
-                      #'elisp-eldoc-documentation-function)
+          (add-function :before-until (local 'eldoc-documentation-function)
+                        #'elisp-eldoc-documentation-function)
           (add-hook 'completion-at-point-functions
                     #'elisp-completion-at-point nil t)
           (run-hooks 'eval-expression-minibuffer-setup-hook))
-- 
2.2.0.rc0.207.ga3a616c






  reply	other threads:[~2014-12-11 16:02 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 ` bug#19338: [PATCH 1/3] eldoc: use default eldoc function if local one gives no results Michal Nazarewicz
2014-12-10 17:49   ` bug#19338: [PATCH 2/3] descr-text: add `describe-char-eldoc' describing character at point 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           ` Michal Nazarewicz [this message]
2015-01-20 14:08             ` bug#19338: [PATCHv2 2/2] eldoc: convert `eldoc-documentation-function' into a defcustom 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=1418313752-13536-2-git-send-email-mpn@google.com \
    --to=mpn@google.com \
    --cc=19338@debbugs.gnu.org \
    --cc=monnier@IRO.UMontreal.CA \
    /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.