yard-mode.el icon indicating copy to clipboard operation
yard-mode.el copied to clipboard

yard-eldoc-message as eldoc-documentation-function not work.

Open stardiviner opened this issue 9 years ago • 4 comments

I found use yard-eldoc-message as eldoc-documentation-function will not display eldoc from robe-eldoc. It does not show anything at all.

stardiviner avatar Mar 09 '16 05:03 stardiviner

This previously came up in #3, and at the time the best I could come up with was to allow opting out of yard-mode's eldoc support: https://github.com/pd/yard-mode.el/commit/aa303f6f1c348cbee1dbab3be2ad04b0aaa590cf

Both modes are setting the eldoc-documentation-function, and depending on the order in which you initialize the minor modes, one of them wins. You probably want robe-mode to win since it's ... actually useful in most of a buffer. PRs / protips welcome for a means of making them co-exist, but I don't use robe and barely use ruby these days.

pd avatar Mar 09 '16 13:03 pd

Actually, here's a quick hack that will display the yard eldoc only when in a yard comment, and fall back to robe's eldoc if the function is available. This seems to work for me if and only if yard-mode is enabled after robe-mode. Depending on hook ordering isn't a great idea, but I see no way around it. It's a bit unfortunate that the standard pattern for installing an eldoc function is to just forcibly overwrite it, eh?

Try eval-defun on this, ensure eldoc-documentation-function is yard-eldoc-message, and lemme know if eldoc is now working in both contexts:

(defun yard-eldoc-message ()
  (cond
   ((yard-in-comment-p)
    (let ((tag (yard-tag-at-point)))
      (when tag (yard-tag-syntax tag))))

   ((functionp 'robe-eldoc)
    (robe-eldoc))))

pd avatar Mar 09 '16 14:03 pd

Thanks, this workaround is great for me.

stardiviner avatar Mar 09 '16 14:03 stardiviner

If yard-turn-on used add-function (in recent enough version of Emacs) instead of setq, you wouldn't need to hardcode robe-eldoc as the function to fall back to.

Since about a year ago, eldoc-documentation-function defaults to ignore to facilitate this usage, although you'd probably need to do a null check anyway.

And I could do similar wrapping in robe-mode, to handle the case when it's enabled after yard-mode.

dgutov avatar Mar 09 '16 15:03 dgutov