From mboxrd@z Thu Jan 1 00:00:00 1970 From: Christian Wittern Subject: Re: patch for custom colored links in org-mode Date: Mon, 27 Jun 2016 21:52:32 +0900 Message-ID: <57712190.6060007@gmail.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:56926) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bHW1p-0001XK-TC for emacs-orgmode@gnu.org; Mon, 27 Jun 2016 08:52:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bHW1m-00062e-8Y for emacs-orgmode@gnu.org; Mon, 27 Jun 2016 08:52:40 -0400 Received: from mail-pa0-x234.google.com ([2607:f8b0:400e:c03::234]:32805) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bHW1l-00062X-Tq for emacs-orgmode@gnu.org; Mon, 27 Jun 2016 08:52:38 -0400 Received: by mail-pa0-x234.google.com with SMTP id b13so59086556pat.0 for ; Mon, 27 Jun 2016 05:52:37 -0700 (PDT) Received: from [192.168.0.17] (119-231-15-229f1.kyt1.eonet.ne.jp. [119.231.15.229]) by smtp.gmail.com with ESMTPSA id k22sm7198935pfj.16.2016.06.27.05.52.33 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 27 Jun 2016 05:52:35 -0700 (PDT) In-Reply-To: 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" To: emacs-orgmode@gnu.org Dear John, I was wishing for this feature for a couple of years and would very much like for this to become possible! While I do not exactly understand how you are doing it, if it works that should be good enough. Thanks a lot! Christian On 06/26/2016 10:35 PM, John Kitchin wrote: > Hi all, > > I tried this aproach to enable custom colored links in org-mode if an > org-link-type face is defined. If no face is applied, then it just gets > the default org-link face > > For example this will make all doi links red. > > (defface org-link-doi > `((t (:inherit org-link > :foreground "red"))) > "Color for doi links.") > > It seems to work pretty well for me. What do you think about making this > a feature in org-mode? > > diff --git a/lisp/org.el b/lisp/org.el > index af68539..f1c500d 100644 > --- a/lisp/org.el > +++ b/lisp/org.el > @@ -5851,14 +5851,19 @@ prompted for." > "Add link properties for plain links." > (when (and (re-search-forward org-plain-link-re limit t) > (not (org-in-src-block-p))) > - (let ((face (get-text-property (max (1- (match-beginning 0)) (point-min)) > - 'face)) > - (link (org-match-string-no-properties 0))) > + (let* ((face (get-text-property (max (1- (match-beginning 0)) (point-min)) > + 'face)) > + (link (org-match-string-no-properties 0)) > + (type (org-match-string-no-properties 1)) > + (link-face-symbol (intern (format "org-link-%s" type))) > + (link-face (if (facep link-face-symbol) > + link-face-symbol > + 'org-link))) > (unless (if (consp face) (memq 'org-tag face) (eq 'org-tag face)) > (org-remove-flyspell-overlays-in (match-beginning 0) (match-end 0)) > (add-text-properties (match-beginning 0) (match-end 0) > (list 'mouse-face 'highlight > - 'face 'org-link > + 'face link-face > 'htmlize-link `(:uri ,link) > 'keymap org-mouse-map)) > (org-rear-nonsticky-at (match-end 0)) > @@ -6340,8 +6345,8 @@ needs to be inserted at a specific position in the font-lock sequence.") > ;; Links > (if (memq 'tag lk) '(org-activate-tags (1 'org-tag prepend))) > (if (memq 'angle lk) '(org-activate-angle-links (0 'org-link t))) > - (if (memq 'plain lk) '(org-activate-plain-links (0 'org-link t))) > - (if (memq 'bracket lk) '(org-activate-bracket-links (0 'org-link t))) > + (if (memq 'plain lk) '(org-activate-plain-links (0 'org-link))) > + (if (memq 'bracket lk) '(org-activate-bracket-links (0 'org-link))) > (if (memq 'radio lk) '(org-activate-target-links (1 'org-link t))) > (if (memq 'date lk) '(org-activate-dates (0 'org-date t))) > (if (memq 'footnote lk) '(org-activate-footnote-links)) > > -- Christian Wittern, Kyoto