0

Org-modes radio targets are useful for automatically adding definitions to terms used in a text. You can define a term within triple angled brackets, like in this definition line:

<<<my term>>> my definition of 'my term'

and all occurrences of the term "my term" in the text will be converted to hyperlinks that links to their definition line. For instance if the term was"Emacs", the definition line could look like this:

<<<Emacs>>> a useful text editor

But clicking such radio targeted links in a text will move you to its definition line, somewhere else in the text. After reading the definition you have to orient yourself back to the place in the text where you clicked the link, to continue your reading. This is impractical. I have two questions:

1) is there a back jump function that let m find back to the clicked link?

2) is it possible to make emacs show the definition of the linked term, as a pop-up window, when hovering the mouse over the link?

1

I am pretty sure there is no definition associated with triple angle radio links in org-mode (https://orgmode.org/manual/Radio-targets.html). These can be in the middle of a line, for example, and there isn't a clear way to determine where the definitions starts or ends.

You should be able to jump back to the location you clicked on with the command org-mark-ring-goto, which is usually bound to something like C-c c (the minibuffer should tell you what key command to use to jump back).

org-ref provides a link for glossaries for this purpose: https://github.com/jkitchin/org-ref/blob/master/org-ref.org#glossaries, and the definition is shown in a tooltip.

Alternatively, you can modify the org-function that puts the tooltip on like this to at least show the line where the <<>> is defined:

(defun radio-tooltip (window object position)
  (save-excursion
    (goto-char position)
    (org-open-at-point)
    (buffer-substring (line-beginning-position) (line-end-position))))

(defun org-activate-target-links (limit)
  "Add text properties for target matches."
  (when org-target-link-regexp
    (let ((case-fold-search t))
      ;; `org-target-link-regexp' matches one character before the
      ;; actual target.
      (unless (bolp) (forward-char -1))
      (when (re-search-forward org-target-link-regexp limit t)
        (org-remove-flyspell-overlays-in (match-beginning 1) (match-end 1))
        (add-text-properties
         (match-beginning 1) (match-end 1)
         (list 'mouse-face 'highlight
               'keymap org-mouse-map
               'help-echo (if (string-prefix-p "<" (match-string 0))
                  "Radio target link"
                'radio-tooltip)
               'org-linked-text t))
    (org-rear-nonsticky-at (match-end 1))
    t))))
  • Thanks : ) but when pointing at the link with the mouse the links got cut in two pieces and one or more lines are inserted. Whats wrong ? – myotis Jul 16 at 15:01
  • what kind of mouse do you use? I can't think of a reason that would happen, unless you use a mac magic mouse where sometimes a finger move acts like a middle mouse button that sometimes pastes text. – John Kitchin Jul 16 at 16:24
  • its a Logitech mouse with cable – myotis Jul 16 at 16:29
  • I dont even need to click with the mouse, just pointing – myotis Jul 16 at 16:31
  • weird. I replaced org-return with org-open-at-point. See if that changes the behavior. – John Kitchin Jul 16 at 17:24

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.