[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Viewing link information

From: Garjola Dindi
Subject: Re: Viewing link information
Date: Fri, 30 Oct 2020 17:38:00 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

On Fri 30-Oct-2020 at 17:14:37 +01, Russell Adams
<RLAdams@AdamsInfoServ.Com> wrote: 
> Are there other ways to view information about an org link that I
> don't list below?
>  - M-x org-insert-link, the prompts for link and description show the
>    current values. Requires interacting with the prompts.
>  - Switch to fundamental mode
>  - M-x org-toggle-link-display
> Are there ways to see this information live while navigating? Maybe on
> the modeline, or messages?

I have this in my init file. I don't remember where I got it from.

It displays the link target in the minibuffer when point is on a link. 

#+BEGIN_SRC emacs-lisp
(defvar my/org-link-target-message-timer nil
  "Variable to store the link message timer in.")

(defun my/org-link-target-show-link-messages ()
  "Turn on link messages.
You will see a message in the minibuffer when on an org link."
  (or my/org-link-target-message-timer
      (setq my/org-link-target-message-timer
            (run-with-idle-timer 0.5 t
            my/org-link-target-show-link-on-enter t)))

(defun my/org-link-target-cancel-link-messages ()
  "Stop showing messages in minibuffer when on a link."
  (cancel-timer my/org-link-target-message-timer)
  (setq my/org-link-target-message-timer nil
        my/org-link-target-show-link-on-enter nil))

(setq my/org-link-target-show-link-on-enter t)

(when my/org-link-target-show-link-on-enter

(defun my/org-link-target-link-message ()
  "Print a minibuffer message about the link that point is on."
  ;; the way links are recognized in org-element-context counts blank
  ;; spaces after a link and the closing brackets in literal links. We
  ;; don't try to get a message if the cursor is on those, or if it is
  ;; on a blank line.
  (when (not (or (looking-at " ")       ;looking at a space
                 (lookinpg-at "^$")     ;looking at a blank line
                 (looking-at "]")       ;looking at a bracket at the end
                                        ;looking at the end of the line.
                 (looking-at "$")))

      (when (eq major-mode 'org-mode)
        (let* ((object (org-element-context))
               (type (org-element-property :type object))
               (link-content (org-element-property :path
            (when (-contains? '("http" "https" "file") type)
              (message "%s:%s" type link-content))))))))

reply via email to

[Prev in Thread] Current Thread [Next in Thread]