unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* ElDoc Tooltips
@ 2010-02-09 11:53 Nordlöw
  2010-02-09 14:02 ` Richard Riley
  2010-02-10  6:55 ` Kevin Rodgers
  0 siblings, 2 replies; 3+ messages in thread
From: Nordlöw @ 2010-02-09 11:53 UTC (permalink / raw)
  To: help-gnu-emacs

Has anybody provided a tweak to ElDoc to make it display its prototype
hint using a tooltip near (usually under) the cursor instead of a
minibuffer-message?

/Nordlöw


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: ElDoc Tooltips
  2010-02-09 11:53 ElDoc Tooltips Nordlöw
@ 2010-02-09 14:02 ` Richard Riley
  2010-02-10  6:55 ` Kevin Rodgers
  1 sibling, 0 replies; 3+ messages in thread
From: Richard Riley @ 2010-02-09 14:02 UTC (permalink / raw)
  To: help-gnu-emacs

Nordlöw <per.nordlow@gmail.com> writes:

> Has anybody provided a tweak to ElDoc to make it display its prototype
> hint using a tooltip near (usually under) the cursor instead of a
> minibuffer-message?
>
> /Nordlöw
>

I was hoping for something similar and actually started a little while
ago to look at using company-mode's display for this but got
distracted. One thing I did knock up ages ago when trying to learn elisp
was to make eldoc actually tell me something that helped. This shows the
help for a symbol under the point in a dedicated buffer. If you hide it,
toggle twice to make it reappear. POssibly the "eldoc" advice and the main
context help function could form the basis (when rewritten no doubt ;))
for a "proper" tooltip in an overlay perhaps?

,----
|   (defun rgr/context-buffer()
|     (get-buffer-create "*Help*"))
|   
|   (defun rgr/toggle-context-help()
|     "Turn on or off the context help. Note that if ON and you hide the help buffer then you need to manually reshow it. A double toggle will make it reappear"
|     (interactive)
|     (with-current-buffer (rgr/context-buffer)
|       (unless (local-variable-p 'context-help) (set (make-local-variable 'context-help) t))
|       (if (setq context-help (not context-help))
|           (progn
|             (if (not (get-buffer-window (help-buffer)))
|                 (display-buffer (help-buffer)))))
|       (message "Context help %s" (if context-help "ON" "OFF"))))
|   
|   (global-set-key (kbd "C-c h") 'rgr/toggle-context-help)
| 
|   (defun rgr/context-help()
|     " Display function or variable at point in the *Help* buffer if it is visible. Default behaviour can be turned off by setting the buffer local context-help to false"
|     (interactive)
|     
|     (let((helptext nil)( rgr-symbol (symbol-at-point)))(with-current-buffer (rgr/context-buffer)
|       (unless (local-variable-p 'context-help) (set (make-local-variable 'context-help) t))
|       (if (and context-help (get-buffer-window (help-buffer)) rgr-symbol )
|           (if (fboundp  rgr-symbol) (describe-function rgr-symbol) 
|             (if (boundp  rgr-symbol) (describe-variable rgr-symbol))))))
|         )
|   
|    (defadvice eldoc-print-current-symbol-info
|      (around eldoc-show-c-tag activate)
|      (cond 
|           ((eq major-mode 'emacs-lisp-mode)(rgr/context-help) ad-do-it)
|           ((eq major-mode 'lisp-interaction-mode)(rgr/context-help) ad-do-it)
|           ((eq major-mode 'apropos-mode)(rgr/context-help) ad-do-it)
|           (t ad-do-it)))
|   
|   
`----






^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: ElDoc Tooltips
  2010-02-09 11:53 ElDoc Tooltips Nordlöw
  2010-02-09 14:02 ` Richard Riley
@ 2010-02-10  6:55 ` Kevin Rodgers
  1 sibling, 0 replies; 3+ messages in thread
From: Kevin Rodgers @ 2010-02-10  6:55 UTC (permalink / raw)
  To: help-gnu-emacs

Nordlöw wrote:
> Has anybody provided a tweak to ElDoc to make it display its prototype
> hint using a tooltip near (usually under) the cursor instead of a
> minibuffer-message?

Here's a start.  Its main deficiency is that it only works in unmodified
buffers, so it would be helpful if someone could show how to adapt it so
that the help-echo property were set via font lock.

(defun eldoc-tooltips ()
   "Put the `help-echo' text property on symbols with 
`eldoc-get-fnsym-args-string'."
   (let ((buffer-modified-p (buffer-modified-p)))
     (save-excursion
       (goto-char (point-min))
       (let (symbol help-echo)
	(while (re-search-forward "[(']" nil t)
	  (when (and (setq symbol (eldoc-current-symbol))
		     (setq help-echo (eldoc-get-fnsym-args-string symbol)))
	    (put-text-property (1- (point))
			       (save-excursion (forward-sexp 1) (point))
			       'help-echo
			       help-echo)))))
     (restore-buffer-modified-p buffer-modified-p)))

(add-hook 'emacs-lisp-mode-hook 'eldoc-tooltips)

-- 
Kevin Rodgers
Denver, Colorado, USA





^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-02-10  6:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-02-09 11:53 ElDoc Tooltips Nordlöw
2010-02-09 14:02 ` Richard Riley
2010-02-10  6:55 ` Kevin Rodgers

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).