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 via email to