From mboxrd@z Thu Jan 1 00:00:00 1970 From: John Kitchin Subject: Re: patch for custom colored links in org-mode Date: Tue, 28 Jun 2016 20:44:13 -0400 Message-ID: References: <87twgdxtfm.fsf@saiph.selenimh> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:54624) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bI3c6-00025R-EY for emacs-orgmode@gnu.org; Tue, 28 Jun 2016 20:44:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bI3c3-0004I5-8N for emacs-orgmode@gnu.org; Tue, 28 Jun 2016 20:44:22 -0400 Received: from mail-qk0-x22e.google.com ([2607:f8b0:400d:c09::22e]:35984) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bI3c3-0004I1-46 for emacs-orgmode@gnu.org; Tue, 28 Jun 2016 20:44:19 -0400 Received: by mail-qk0-x22e.google.com with SMTP id j2so6254551qkf.3 for ; Tue, 28 Jun 2016 17:44:18 -0700 (PDT) In-reply-to: <87twgdxtfm.fsf@saiph.selenimh> 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: Nicolas Goaziou Cc: org mode I took a stab at this implementation here: https://github.com/jkitchin/org-mode/compare/master...colored-link-2?expand=1 I wasn't too sure of the defcustom :type syntax. I also wasn't sure about this line https://github.com/jkitchin/org-mode/compare/master...colored-link-2?expand=1#diff-cfe1a32c56525d13db03755dbd7b4a01R6069 I set the invisible spec to whatever you set :display to, or 'org-link. However, if you set :display to t, it still gets folded. I thought any non-nil value that wasn't 'org-link would work, but apparently not. What do you think about this? With that patch, you can do this: Run this to set the display of doi links #+BEGIN_SRC emacs-lisp (setq org-link-display-parameters '(("doi" :face (:foreground "red" :underline t :weight bold) :display 'full))) #+END_SRC And then the doi links are bold, underlined red, and not folded in descriptive mode. doi:10.1021 bracketed: [[doi:test][what]] bracketed file link: [[file:test.org][test]] Nicolas Goaziou writes: > Hello, > > John Kitchin writes: > >> 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? > > This sounds like a good idea. Thank you for submitting it. > > However, I'm not convinced by the UI, i.e., creating a face specifically > named to trigger the feature. As a user, it doesn't seem very natural to > me. > > At first I thought it was better to extend `org-add-link-type' with > a FACE definition, but we wouldn't have caught default link types. > > So, maybe it is more reasonable to create a new variable, e.g., > `org-link-display-parameters', which would hold an alist between link > types and property lists (or something else), e.g., > > ("doi" :face my-special-face :display full) > ("special" :display path) > > Note that :display is a way to include your other idea about link > visibility. Default value for :face and :display would be, respectively, > `org-link' and `description'. > > Of course, we can also create two variables, one for the face, the other > for the visibility. > > WDYT? > > Regards, -- Professor John Kitchin Doherty Hall A207F Department of Chemical Engineering Carnegie Mellon University Pittsburgh, PA 15213 412-268-7803 @johnkitchin http://kitchingroup.cheme.cmu.edu