Org-mode mailing list
 help / color / mirror / Atom feed
From: Garjola Dindi <garjola@garjola.net>
To: emacs-orgmode@gnu.org
Subject: Re: Viewing link information
Date: Fri, 30 Oct 2020 17:38:00 +0100
Message-ID: <874kmb7jpz.fsf@pc-117-162.ovh.com> (raw)
In-Reply-To: <20201030161437.GE28730@maokai>

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."
  (interactive)
  (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-link-message)
	    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."
  (interactive)
  (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
  (my/org-link-target-show-link-messages))

(defun my/org-link-target-link-message ()
  "Print a minibuffer message about the link that point is on."
  (interactive)
  ;; 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 "$")))

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



  reply	other threads:[~2020-10-30 16:38 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-30 16:14 Russell Adams
2020-10-30 16:38 ` Garjola Dindi [this message]
2020-10-30 16:48 ` Greg Minshall
2020-10-31  2:47 ` Maxim Nikulin
2020-11-09 17:05 ` ian martins
2020-11-10 16:42   ` Maxim Nikulin
2020-11-09 22:15 ` Diego Zamboni

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://orgmode.org

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=874kmb7jpz.fsf@pc-117-162.ovh.com \
    --to=garjola@garjola.net \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Org-mode mailing list

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://orgmode.org/list/0 list/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 list list/ https://orgmode.org/list \
		emacs-orgmode@gnu.org
	public-inbox-index list

Example config snippet for mirrors.
Newsgroups are available over NNTP:
	nntp://news.yhetil.org/yhetil.emacs.orgmode
	nntp://news.gmane.io/gmane.emacs.orgmode


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git