2

When I use mouse-over on an Link (thanks to Tobias) it shows an Image and text. When I used display-local-help the image disappeared (perhaps due to lack of space in the message area). I want to start the mouse-over with any key. Therefore I need a function name.

enter image description here

1
  • If you have the answer then please consider accepting it. You can accept your own answer. That takes the question off the unanswered questions list.
    – Drew
    Dec 27 '18 at 3:59
0

Not a real solution, but does do some of what you want:

  (defun my/show-tooltip ()
    (interactive)
    (let
        ((tooltip-frame-parameters '((left . 100) (top . 200)))
         (text (get-text-property (point) 'help-echo)))
      (if (stringp text) (tooltip-show text))))

What's missing to be a real solution:

  • the help-echo property is not necessarily a string, it can also be a function or any expression. I expect this to be easily solvable. See the description of the help-echo property in the elisp manual.

  • I don't know how to get graphic coordinates from a buffer position (need to put them as left and top in tooltip-frame-parameters).

  • I have no idea if a display property on the string is honored by tooltip-show.

0

Many Thanks !! It works. I had used pos-tip-show. It also works with a button with tooltip-show. Here is the code for displaying a link with image and text. I simplified the example a bit so that it works without any additional functions. I wish you all a lot of fun! Andreas

 (defun display-local-help-als-tooltip (&optional arg)
  "Display of the tooltip with the keyboard instead of the mouse.
Template was display-local-help."
  (interactive "P")
  (let ((help (help-at-pt-kbd-string)))
    (if help
      (tooltip-show
        help )
      (if (not arg) (tooltip-show
        "No indication available at this point.") ))))

(defun wikipedia-tooltip (window object position)
  "Tooltip with image and text."
    (save-excursion
      (goto-char position)
       (let ((path (org-element-property :path (org-element-context)))(beg) (end) (text)(imgfile) (img) (s))
     ;;Here the image should be inserted dynamically.
     (setq imgfile (format "x:/Temp/milk.jpg")) ; path
     ;; The text is actually determined by a function.
     (setq text "Milk is very ...")
    (if (file-exists-p imgfile)
      ;; If a picture exists, show it with the text.
      (progn
      (setq img (create-image (expand-file-name imgfile)
                  'imagemagick nil :width 300))
      (concat (propertize " "
                  'display img) (format "\n%s" text)))
      ;; No picture available, then just show the text.
      text)
      )))

(defun wikipedia-link-face (path)
    '(:foreground "red" ))

(org-link-set-parameters "wikipedia"         
         :help-echo 'wikipedia-tooltip 
         :face 'wikipedia-link-face)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.