From mboxrd@z Thu Jan 1 00:00:00 1970 From: Paul Sexton Subject: Re: Patch: option to not hide brackets in org links Date: Thu, 10 May 2012 08:56:51 +0000 (UTC) Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Return-path: Received: from eggs.gnu.org ([208.118.235.92]:38913) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SSPBQ-00083B-L7 for emacs-orgmode@gnu.org; Thu, 10 May 2012 04:57:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SSPBK-0006ni-Eh for emacs-orgmode@gnu.org; Thu, 10 May 2012 04:57:12 -0400 Received: from plane.gmane.org ([80.91.229.3]:50368) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SSPBK-0006nI-7W for emacs-orgmode@gnu.org; Thu, 10 May 2012 04:57:06 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1SSPBH-0008HG-7u for emacs-orgmode@gnu.org; Thu, 10 May 2012 10:57:03 +0200 Received: from 121.98.239.28 ([121.98.239.28]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 10 May 2012 10:57:03 +0200 Received: from psexton.2a by 121.98.239.28 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 10 May 2012 10:57:03 +0200 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org Sean O'Halpin gmail.com> writes: > Is that publicly available anywhere? Here you go. To use, add orgl-enable to the relevant mode-hook, eg: (add-hook 'python-mode-hook 'orgl-enable) -------- (defface orgl-target-face '((t (:foreground "cyan" :background "royalblue4" :weight normal))) ;; '((t (:weight bold :box (:line-width 1 :color "red")))) "The face used to emphasise org-mode <>.") (make-face 'orgl-target-face) (setq orgl-target-face 'orgl-target-face) (defvar *orgl-link-abbrevs* '((lisp-mode ("defun" . "(defun %s (") ("class" . "(defclass %s (") ("wwdoc" . "file:../TODO::%s"))) "Define link abbreviations for each major mode. The variable contains a list, each element of which has the form (MAJOR-MODE (ABBREV . EXPANSION) .....) ABBREV is a short string. Links of the form '[[ABBREV:TEXT]]' will be expanded into EXPANSION. See the documentation for org-link-abbrev-alist for more details.") (defun orgl-do-font-lock (add-or-remove) "Add or remove font-lock rules for org hyperlinks." (funcall add-or-remove nil '((org-activate-bracket-links (0 'org-link t)))) (funcall add-or-remove nil `((,org-target-regexp (0 'orgl-target-face t))))) (defun orgl-enable () "Enable fontification of org-style hyperlinks in the current buffer." (interactive) ;; The following variable has to be bound to a string, or following links ;; will not work. ;; There is probably a more elegant solution. (unless org-todo-line-tags-regexp (set (make-local-variable 'org-todo-line-tags-regexp) "XYZ_THIS@SHOULD_NEVER~MATCH_ZYX")) (orgl-do-font-lock 'font-lock-add-keywords) ;; Stop org links from having invisible [[ brackets ]]. (remove-text-properties (point-min) (point-max) '(invisible nil)) (font-lock-fontify-buffer) ;; Add special link abbreviations. (unless org-link-abbrev-alist-local (make-local-variable 'org-link-abbrev-alist-local)) (dolist (pair (cdr (assoc major-mode *orgl-link-abbrevs*))) (pushnew pair org-link-abbrev-alist-local))) (defun orgl-disable () "Disable fontification of org-style hyperlinks in the current buffer." (interactive) (remove-text-properties (point-min) (point-max) '(mouse-face t keymap t org-linked-text t invisible t intangible t org-no-flyspell t)) (orgl-do-font-lock 'font-lock-remove-keywords) (font-lock-fontify-buffer) ;; Remove special link abbreviations (dolist (pair (cdr (assoc major-mode *orgl-link-abbrevs*))) (setq org-link-abbrev-alist-local (delete pair org-link-abbrev-alist-local))))