emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: master 9ade7ea: Fix Eldoc problem when loading on Emacs 26.3


From: João Távora
Subject: Re: master 9ade7ea: Fix Eldoc problem when loading on Emacs 26.3
Date: Sat, 11 Jul 2020 09:06:24 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

Stefan Monnier <monnier@iro.umontreal.ca> writes:

>> all, a much safer bet.  I've even thought about dropping the whole
>> "rename function to strategy" idea completely, which was just a cosmetic
>> way to escape the awful mind-bending confusion between "e-d-function"
>> singular and "e-d-functions" plural.
>
> The reason why I was happy to see you use a different name is to make it
> possible for eldoc--supported-p to distinguish the case where something
> changed the -strategy var (which shouldn't affect
> eldoc--supported-p) from the case where something changed
> the -function var.

Yes, I know that now, and I don't oppose it.  I just don't feel
capacitated enough to separated the two things without mixing myself up
:-).  I drafted up this patch yesterday, but it's got this problem I
mentioned.  Maybe you can fix it.  In the meantime, I'm going to go with
the alias.

João

commit c40761d683dcf70fe7f404b675a3a2631edfeaf0
Author: João Távora <joaotavora@gmail.com>
Date:   Fri Jul 10 19:11:01 2020 +0100

    Adjust Eldoc backward compatibility of eldoc-documentation-function
    
    Making a variable alias doesn't work because that variable is
    preloaded and localized.  So just keep the
    eldoc-documentation-function, make it obsolete, and let it be used
    instead of strategy if it is found to be non-nil (either locally or
    globally).
    
    * lisp/emacs-lisp/eldoc.el (eldoc--eval-expression-setup): Set
    eldoc-documentation-function to nil.
    (eldoc-documentation-function): Reinstate variable.
    (eldoc--documentation-strategy): New helper function.
    (eldoc--invoke-strategy): Use eldoc--documentation-strategy.
    (eldoc--supported-p): Reowkr
    (Version): Bump to 1.5.0
    eldoc--supported-p

diff --git a/lisp/emacs-lisp/eldoc.el b/lisp/emacs-lisp/eldoc.el
index 7964c4c45a..29007807aa 100644
--- a/lisp/emacs-lisp/eldoc.el
+++ b/lisp/emacs-lisp/eldoc.el
@@ -5,7 +5,7 @@
 ;; Author: Noah Friedman <friedman@splode.com>
 ;; Keywords: extensions
 ;; Created: 1995-10-06
-;; Version: 1.4.0
+;; Version: 1.5.0
 ;; Package-Requires: ((emacs "26.3"))
 
 ;; This is a GNU ELPA :core package.  Avoid functionality that is not
@@ -233,7 +233,8 @@ eldoc--eval-expression-setup
             #'elisp-eldoc-var-docstring nil t)
   (add-hook 'eldoc-documentation-functions
             #'elisp-eldoc-funcall nil t)
-  (setq eldoc-documentation-strategy 'eldoc-documentation-default)
+  (setq-local eldoc-documentation-function nil)
+  (setq-local eldoc-documentation-strategy 'eldoc-documentation-default)
   (eldoc-mode +1))
 
 ;;;###autoload
@@ -535,8 +536,11 @@ eldoc-documentation-enthusiast
                         (if (stringp str) (funcall callback str))
                         nil))))
                         
-(define-obsolete-variable-alias 'eldoc-documentation-function
-  'eldoc-documentation-strategy "eldoc-1.1.0")
+(make-obsolete-variable
+ 'eldoc-documentation-function
+ "use `eldoc-documentation-strategy' instead." "eldoc-1.5.0")
+
+(defvar eldoc-documentation-function nil)
 
 (defcustom eldoc-documentation-strategy #'eldoc-documentation-default
   "How to collect and organize results of `eldoc-documentation-functions'.
@@ -584,9 +588,14 @@ eldoc-documentation-strategy
                 (function :tag "Other function"))
   :version "28.1")
 
+(defun eldoc--documentation-strategy ()
+  "Return the actual "
+  (or (bound-and-true-p eldoc-documentation-function)
+      eldoc-documentation-strategy))
+
 (defun eldoc--supported-p ()
   "Non-nil if an ElDoc function is set for this buffer."
-  (and (not (memq eldoc-documentation-strategy '(nil ignore)))
+  (and (not (memq (eldoc--documentation-strategy) '(nil ignore)))
        (or eldoc-documentation-functions
            ;; The old API had major modes set `eldoc-documentation-function'
            ;; to provide eldoc support.  It's impossible now to determine
@@ -596,7 +605,8 @@ eldoc--supported-p
            ;; `eldoc-documentation-functions' (as in the new API).
            ;; But at least if it's set buffer-locally it's a good hint that
            ;; there's some eldoc support in the current buffer.
-           (local-variable-p 'eldoc-documentation-strategy))))
+           (local-variable-p 'eldoc-documentation-strategy)
+           (local-variable-p 'eldoc-documentation-function))))
 
 (defvar eldoc--enthusiasm-curbing-timer nil
   "Timer used by the `eldoc-documentation-enthusiast' strategy.
@@ -703,7 +713,7 @@ eldoc--invoke-strategy
                        (display-doc)
                        t))))))
             (let* ((eldoc--make-callback #'make-callback)
-                   (res (funcall eldoc-documentation-strategy)))
+                   (res (funcall (eldoc--documentation-strategy))))
               ;; Observe the old and the new protocol:
               (cond (;; Old protocol: got string, output immediately;
                      (stringp res) (register-doc 0 res nil) (display-doc))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]