UPDATE: This solution is outdated, the code in the following node is much shorter and easier

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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.