25

Although it is convenient how org-mode shows hyperlinks, there are times when I want to see the underlying plain text, e.g. [[./file.org][Title]]. How can I do this?

I know about org-insert-link, but it is not what I want:

C-c C-l runs the command org-insert-link, which is an interactive compiled Lisp function in `org.el'.

...

If there is already a link at point, this command will allow you to edit link and description parts.

27

I just found a nice function in the org source code: M-x org-toggle-link-display.

Here is the source code, just for fun:

(defun org-toggle-link-display ()
  "Toggle the literal or descriptive display of links."
  (interactive)
  (if org-descriptive-links
      (progn (org-remove-from-invisibility-spec '(org-link))
         (org-restart-font-lock)
         (setq org-descriptive-links nil))
    (progn (add-to-invisibility-spec '(org-link))
       (org-restart-font-lock)
       (setq org-descriptive-links t))))
  • 3
    This. Also, if you want to keep this behavior permanently, simply add (setq org-descriptive-links nil) to your init file. – undostres Dec 15 '14 at 2:01
  • 2
    Note this variable is accessible from the "Org > Hyperlinks" menu – Andrew Swann Dec 15 '14 at 8:22
12

A useful way to do this is

M-x font-lock-mode

which toggles font locking. When font locking is off, the hyperlink is visible in its undecorated form [[./file.org][Title]]. This can be a useful approach for seeing other pieces of mark-up in the buffer.

3

I've been using this function. It will toggle between fundamental-mode and the original mode (org-mode in this case). It's a bit weird, but I like it:

(defun illiterate ()
  (interactive)
  (let ((coding-system-for-read 'utf-8))
    (if (eq major-mode 'fundamental-mode)
        (revert-buffer nil t)
      (let ((pt (1+ (length
                     (encode-coding-string
                      (buffer-substring-no-properties (point-min) (point))
                      'utf-8))))
            (file-name (buffer-file-name)))
        (kill-buffer (current-buffer))
        (find-file-literally file-name)
        (goto-char pt)))))
  • 2
    Why can't you just call fundamental-mode? – Malabarba Dec 15 '14 at 0:42
  • 3
    Plain fundamental-mode won't work, since org-mode messes too much with text properties and they don't get reset. It needs to be the way it is. – abo-abo Dec 15 '14 at 8:47
2

A low-tech way is to move point to the beginning of the link text and type C-d (i.e., invoke org-delete-char). That removes the first "[" character, so that you no longer have a properly formatted hyperlink, and you can see the remainder of it as raw text. Then when you're done, just invoke undo to restore it to what you had previously.

  • 1
    This did not work for me in Emacs 24.4 (9.0) on Mac OS X with the default org installation. – David J. Dec 15 '14 at 15:56
0

Org mode achieves the link effect using the following code:

(if org-descriptive-links (add-to-invisibility-spec '(org-link)))

This adds org-link to the variable buffer-invisibility-spec which means that text which has its invisible property set to org-link will be hidden.

Using M-x visible-mode RET you can reset buffer-invisibility-spec temporary to nil, which means the hidden text will be shown from there on.

Using M-x visible-mode RET again you can reset buffer-invisibility-spec to its previous value, which will hide the relevant text parts again.

  • @Drew Better now? I don't know what else do add – clemera Dec 2 '18 at 10:09
  • @Drew Updated the answer – clemera Dec 2 '18 at 16:20

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.