emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Paul Sexton <psexton.2a@gmail.com>
To: emacs-orgmode@gnu.org
Subject: Patch: option to not hide brackets in org links
Date: Wed, 9 May 2012 21:07:07 +0000 (UTC)	[thread overview]
Message-ID: <loom.20120509T225253-569@post.gmane.org> (raw)

I would like to be able to control whether the '[[' ...']]' brackets around
links are made invisible during fontification. The motivation is that I have a
minor mode that makes org-style links fully active and fontifed in other major
modes. But I can imagine some others might want to use it, as behaviour of
these invisible brackets is sometimes unpredictable at the end of lines --
sometimes the cursor appears outside the link, but pressing return actually 
introduces a newline in the link. 

The following is a patch to org.el that accomplishes this. It introduces a new
boolean global variable, defaulting to current behaviour.

--- dotemacs/site-lisp/org/lisp/org.el	2012-05-06 10:45:07.000000000 +1200
+++ org-new.el	2012-05-10 09:00:14.000000000 +1200
@@ -1383,6 +1383,17 @@
   :group 'org-link
   :type 'function)
 
+
+(defcustom org-hide-link-brackets-p
+  t
+  "Should the double square brackets [[...]] around links be invisible?
+Default is t."
+  :group 'org-link
+  :type 'boolean)
+
+(put 'org-hide-link-brackets-p 'safe-local-variable 'booleanp)
+
+
 (defgroup org-link-store nil
   "Options concerning storing links in Org-mode."
   :tag "Org Store Link"
@@ -5576,9 +5587,10 @@
 	     ;; but that requires another match, protecting match data,
 	     ;; a lot of overhead for font-lock.
 	     (ip (org-maybe-intangible
-		  (list 'invisible 'org-link
-			'keymap org-mouse-map 'mouse-face 'highlight
-			'font-lock-multiline t 'help-echo help)))
+		  (append (list 'keymap org-mouse-map 'mouse-face 'highlight
+                                'font-lock-multiline t 'help-echo help)
+                          (if org-hide-link-brackets-p
+                              (list 'invisible 'org-link) nil))))
 	     (vp (list 'keymap org-mouse-map 'mouse-face 'highlight
 		       'font-lock-multiline t 'help-echo help)))
 	;; We need to remove the invisible property here.  Table narrowing

             reply	other threads:[~2012-05-09 21:07 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-09 21:07 Paul Sexton [this message]
2012-05-10  7:31 ` Patch: option to not hide brackets in org links Sean O'Halpin
2012-05-10  8:56   ` Paul Sexton
2012-05-13  1:41     ` Sean O'Halpin
2012-05-13 23:43       ` Paul Sexton
2012-05-13 23:50         ` Samuel Wales

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=loom.20120509T225253-569@post.gmane.org \
    --to=psexton.2a@gmail.com \
    --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).