jorgenschaefer / elpy

Emacs Python Development Environment
GNU General Public License v3.0
1.9k stars 260 forks source link

error in process filter: Symbol’s function definition is void: eldoc-docstring-format-sym-doc #1823

Closed Blade6570 closed 4 years ago

Blade6570 commented 4 years ago

Summary

Hi, thanks for this great package. Whenever I start editing any python code, I come across this error. I can globally switch off the eldoc-mode which solves the problem but I am looking to fix this instead of avoiding. Previously this error was not there and suddenly appeared after I update the emacs. I checked all the *.el files from elpy but could not find eldoc-docstring-format-sym-doc function definition.

Steps to reproduce

Update the emacs to the latest emacs-snapshot

My configuration

OS

Ubuntu 18.04.4 LTS x86_64

Result of (elpy-config)

Emacs.............: 28.0.50 Elpy..............: 1.32.0 Virtualenv........: None Interactive Python: ipython 7.16.1 (/home/soumya/anaconda3/bin/ipython) RPC virtualenv....: anaconda3 (/home/soumya/anaconda3) Python...........: python 3.7.6 (/home/soumya/anaconda3/bin/python) Jedi.............: 0.17.1 (0.17.2 available) Rope.............: 0.17.0 Autopep8.........: 1.5.3 Yapf.............: Not found (0.30.0 available) Black............: Not found (19.10b0 available) Syntax checker....: flake8 `(/home/soumya/anaconda3/bin/flake8)

Elpy configuration in my init.el

(elpy-enable) (setq elpy-rpc-virtualenv-path 'current)

Blade6570 commented 4 years ago

Hi, I realized that this is not the problem of elpy in any way (for the moment). I was using bleeding-edge so in the recent updates, they have changed the eldoc significantly.

Thanks

ghost commented 4 years ago

Can we re-open this? It's a problem that is going to need to be solved. As a temporary workaround you can modify elpy.el at lines 3144 and 3154. There is a fallback to use 'format' for older versions of Emacs. If you update the two places to just use format, you'll stop getting the error messages. Not sure exactly what functionality is lost by doing this though, could be that it doesn't highlight the current arg in the docstring.

Change this: (eldoc-message (if (version<= emacs-version "25") (format "%s%s" prefix args) (eldoc-docstring-format-sym-doc prefix args nil)))

To this: (eldoc-message (format "%s%s" prefix args))

In both places.

Blade6570 commented 4 years ago

Yes, anyway it needs to be addressed. So let me keep this open for others to look in to.

vinimmelo commented 4 years ago

Can we re-open this? It's a problem that is going to need to be solved. As a temporary workaround you can modify elpy.el at lines 3144 and 3154. There is a fallback to use 'format' for older versions of Emacs. If you update the two places to just use format, you'll stop getting the error messages. Not sure exactly what functionality is lost by doing this though, could be that it doesn't highlight the current arg in the docstring.

Change this: (eldoc-message (if (version<= emacs-version "25") (format "%s%s" prefix args) (eldoc-docstring-format-sym-doc prefix args nil)))

To this: (eldoc-message (format "%s%s" prefix args))

In both places.

So much better now after this changes, thanks for the solution, I am using the latest emacs version and Python development was really slow down after this problem.

fhaun commented 4 years ago

This problem is currently discussed on emacs devel. Maybe they bring back this function.

https://lists.gnu.org/archive/html/emacs-devel/2020-07/msg00584.html

joaotavora commented 4 years ago

This problem is currently discussed on emacs devel. Maybe they bring back this function.

That's possible, and I've provided a patch that does it, but I'm against it, as it is going backwards. It's easier to hoist the function into elpy.el if one wants a quick and dirty solution. The better solution is to change elpy-eldoc-documentation to work with the new and the old ElDoc protocol. I did that in the 86aa703 commit I pointed to: but I DIDN'T test it, so you must do that if you're interested.

Beyond that stopgap commit there is more in the ElDoc redesign which would simplify and enhance Elpy, such as removing the need for Flymake-specific code and enabling Elpy to serve different bits of Python-related documentation independently. If the Elpy maintainers are interested, I can assist in doing that.

ghost commented 4 years ago

@joaotavora Thanks for the details João. Is there some kind of planning doc available that describes this ElDoc refresh project? Curious to know what all of the changes are and the motivation behind this. Searching around the web, I see references to elpy-eldoc-documentation in more than one project. I suspect the blast radius of these non-backwards compatible changes is larger than just Elpy.

joaotavora commented 4 years ago

Is there some kind of planning doc available that describes this ElDoc refresh project?

The "ElDoc refresh project" started before I touched this: Emacs development on the master branch is a continuous thing. The most ambitious change on my part was support for asynchronous sources in a variable introduced earlier for Emacs 28 called eldoc-documentation-functions. This commit by Mark Oteiza introduces the variable. And you can read the rationale for my change in this commit message.

Together, these changes mean that clients such as ElPy don't have to worry about calling eldoc-message directly "when the time is right" and users can easily compose docs from various sources, synchronous or asynchronous, much like Elpy tries to do with the Flymake diagnostics when it finds them. I recommend reading the docstrings of eldoc-documentation-functions and eldoc-documentation-strategy. Be sure to M-x report-emacs-bug if you think something is missing.

But this part was carefully planned to be backward compatible. The backward incompatible part was a more mundane oversight: I deleted some functions which have long been considered to be ElDoc implementation details. eldoc-message is one of those, as is eldoc-docstring-format-sym-doc, a string-formatting helper. I put up an alias for the former, which generates a benign obsoletion warning. The latter I simply deleted, believing (mistakenly) that no-one used it.

I suspect the blast radius of these non-backwards compatible changes is larger than just Elpy.

Are you sure you meant to write elpy-eldoc-documentation? If so, then all that needs to be done is fix it and then its users won't experience any "blast". There are various ways of doing that. There is the way I'm proposing, which opens up Elpy to the future of ElDoc. Alternatively, the easiest way by far is to copy-paste eldoc-docstring-format-sym-doc into elpy.el, call it elpy--docstring-format-sym-doc itself, and call that from elpy-eldoc-documentation. There are also other more ambitious ways, such as having ElPy depend on the new ElDoc even for Emacs versions < 28, by pulling eldoc.el in as a dependency from GNU Elpa.

I also invite you to continue the discussion in the emacs-devel. You can follow the thread that your colleague posted in https://github.com/jorgenschaefer/elpy/issues/1823#issuecomment-663866043.

Or did you mean eldoc-docstring-format-sym-doc? In that case I don't see many more users other than Elpy. Some personal configuration here and there. Am I mistaken?

ghost commented 4 years ago

Are you sure you meant to write elpy-eldoc-documentation

Yes, good catch. I meant to write eldoc-docstring-format-sym-doc. I repeated my searches today and cannot find example references. I must have been searching for something else before. In either case, thanks for the full explanation. I'll subscribe to the mailing list. Thank you for the suggestion!

galaunay commented 4 years ago

Hopefully, PR #1825 from @joaotavora should fix this. Please let me know here if it doesn't.