Hi
cperl-mode has an autohelp-feature to display a short description for the perl construct under the cursor point after some delay (variable "cperl-lazy-help-time")
after M-x cperl-toggle-autohelp or C-c C-h a (i.e. c=major-mode h=help a=auto)
Now putting the cursor on code will show a message on the bottom line. For instance
for my $i (1..10) ^^ ^^
will show
my VAR or my (VAR1,...) Introduces a lexical variable ($VAR, @ARR, or %HASH).
or
.. Range (list context); flip/flop (scalar context) operator.
the following code will alter this behaviour to have a tooltip popping up in place
(require 'pos-tip) (add-hook 'cperl-mode-hook (lambda () (cperl-toggle-autohelp) (setq cperl-lazy-help-time 2) (defun cperl-describe-perl-symbol (val) "Display the documentation of symbol at point, a Perl operat +or." (let ((enable-recursive-minibuffers t) args-file regexp) (cond ((string-match "^[&*][a-zA-Z_]" val) (setq val (concat (substring val 0 1) "NAME"))) ((string-match "^[$@]\\([a-zA-Z_:0-9]+\\)[ \t]*\\[" val) (setq val (concat "@" (substring val 1 (match-end 1))))) ((string-match "^[$@]\\([a-zA-Z_:0-9]+\\)[ \t]*{" val) (setq val (concat "%" (substring val 1 (match-end 1))))) ((and (string= val "x") (string-match "^x=" val)) (setq val "x=")) ((string-match "^\\$[\C-a-\C-z]" val) (setq val (concat "$^" (char-to-string (+ ?A -1 (aref va +l 1)))))) ((string-match "^CORE::" val) (setq val "CORE::")) ((string-match "^SUPER::" val) (setq val "SUPER::")) ((and (string= "<" val) (string-match "^<\\$?[a-zA-Z0-9_: +]+>" val)) (setq val "<NAME>"))) (setq regexp (concat "^" "\\([^a-zA-Z0-9_:]+[ \t]+\\)?" (regexp-quote val) "\\([ \t([/]\\|$\\)")) ;; get the buffer with the documentation text (cperl-switch-to-doc-buffer) ;; lookup in the doc (goto-char (point-min)) (let ((case-fold-search nil)) (list (if (re-search-forward regexp (point-max) t) (save-excursion (beginning-of-line 1) (let ((lnstart (point))) (end-of-line) (pos-tip-show (buffer-substring lnstart (point))))) (if cperl-message-on-help-error (message "No definition for %s" val))))))) ))
Now this messages will appear in a yellow frame at cursor position much like alt-texts in HTML browsers do.
--------
UPDATE: Demonstration move the mouse over my or ..
for
my $i (1
..
10) {...}
---------
You will have to download pos-tip.el and put it in your load path! (because tooltip-show uses the mouse and not the cursor position)
Please note:
1. This solution is still rather clumsy because I still need to completely redefine "cperl-describe-perl-symbol", I'm working on an approach to just locally override "message" with "pos-tip-show" within a wrapper.
2. Some of these help texts are rather outdated and seem to stem from perl4 times, maybe someone can point me to more modern sources for those short descriptions.
This demonstrates the possibilities to dynamically give emacs a more "modern" looking help interface.
It's easily possible to bind perldoc lookups an mouse or key actions to be displayed "in-place" as tooltips!
Cheers Rolf
In reply to [emacs] Autohelp as tooltip at cursorposition by LanX
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |