emacs-orgmode@gnu.org archives
 help / color / mirror / code / 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	[thread overview]
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 Viewing link information 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://www.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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).