emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Florian Beck <abstraktion@t-online.de>
To: Bastien <bzg@altern.org>
Cc: emacs-orgmode@gnu.org, Florian Beck <abstraktion@t-online.de>
Subject: Re: Using org-mode for Research and Notetaking
Date: Tue, 26 Jul 2011 16:17:48 +0200	[thread overview]
Message-ID: <874o29ceib.fsf@sophokles.streitblatt.de> (raw)
In-Reply-To: <87mxg1th7y.fsf@gnu.org> (Bastien's message of "Tue, 26 Jul 2011 13:27:13 +0200")

Bastien <bzg@altern.org> writes:

> Hi Tom,
>
> tsd@tsdye.com (Thomas S. Dye) writes:
>
>> Aloha all,
>>
>> Perhaps they are [[tag:boxed][already]] here with org-add-link-type?  It
>> seems to me that all that's missing is a way to specify a function to
>> determine on screen display.  But, I might be missing something.
>
> just as a quick follow-up: I understand the need.  I will hack
> org-link-protocols so that they can hold a custom face for each
> link type.  But this won't happen for 7.7, only around mid-sept
> if that's okay.

IIUC, entries would be of the form (TYPE FOLLOW EXPORT FACE).

What if instead of FACE you could (alternativly) specify a function that
supplied additional text properties? Possibly a face, of course, but
also interesting are `display' and `help-echo'.

I'm not a programmer, but I got this working with quite small changes
(rather untested, I admit):

diff -c /home/flo/elisp/org-mode/lisp/org.el /home/flo/tmp/org.el
*** /home/flo/elisp/org-mode/lisp/org.el	2011-07-26 15:52:16.160581036 +0200
--- /home/flo/tmp/org.el	2011-07-26 16:16:00.022669409 +0200
***************
*** 5315,5331 ****
  (defun org-activate-bracket-links (limit)
    "Run through the buffer and add overlays to bracketed links."
    (if (re-search-forward org-bracket-link-regexp limit t)
!       (let* ((help (concat "LINK: "
! 			   (org-match-string-no-properties 1)))
  	     ;; FIXME: above we should remove the escapes.
  	     ;; 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)))
! 	     (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
  	;; may have made some of this invisible.
  	(org-remove-flyspell-overlays-in (match-beginning 0) (match-end 0))
--- 5315,5348 ----
  (defun org-activate-bracket-links (limit)
    "Run through the buffer and add overlays to bracketed links."
    (if (re-search-forward org-bracket-link-regexp limit t)
!       (let* ((path (org-match-string-no-properties 1))
! 	     (help (concat "LINK: " path))
! 	     (type (save-match-data
! 		     (if (string-match
! 			  "^\\(.*?\\):"
! 			  path)
! 			 (org-match-string-no-properties 1 path))))
  	     ;; FIXME: above we should remove the escapes.
  	     ;; but that requires another match, protecting match data,
  	     ;; a lot of overhead for font-lock.
+ 	     (custom-attr-1 (nth 3 (assoc type org-link-protocols)))
+ 	     ;; Check if `org-link-protocols' is a face or a function
+ 	     ;; that returns text properties.
+ 	     (custom-attr
+ 	       (if (and custom-attr-1
+ 			(facep custom-attr-1))
+ 		   `(face ,custom-attr-1)
+ 		 (funcall (or custom-attr-1 'ignore) path)))
  	     (ip (org-maybe-intangible
  		  (list 'invisible 'org-link
  			'keymap org-mouse-map 'mouse-face 'highlight
  			'font-lock-multiline t 'help-echo help)))
! 	     (vp (append
! 		  (list 'keymap org-mouse-map 'mouse-face 'highlight
! 			'face 'org-link
! 			'font-lock-multiline t 'help-echo help)
! 		  ;; Let custom settings override the default.
! 		  custom-attr)))
  	;; We need to remove the invisible property here.  Table narrowing
  	;; may have made some of this invisible.
  	(org-remove-flyspell-overlays-in (match-beginning 0) (match-end 0))
***************
*** 5602,5608 ****
  	   (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))
! 	   (if (memq 'bracket lk) '(org-activate-bracket-links (0 'org-link t)))
  	   (if (memq 'radio lk) '(org-activate-target-links (0 'org-link t)))
  	   (if (memq 'date lk) '(org-activate-dates (0 'org-date t)))
  	   (if (memq 'footnote lk) '(org-activate-footnote-links))
--- 5619,5625 ----
  	   (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))
! 	   (if (memq 'bracket lk) 'org-activate-bracket-links)
  	   (if (memq 'radio lk) '(org-activate-target-links (0 'org-link t)))
  	   (if (memq 'date lk) '(org-activate-dates (0 'org-date t)))
  	   (if (memq 'footnote lk) '(org-activate-footnote-links))
***************
*** 8437,8444 ****
    (add-to-list 'org-link-types type t)
    (org-make-link-regexps)
    (if (assoc type org-link-protocols)
!       (setcdr (assoc type org-link-protocols) (list follow export))
!     (push (list type follow export) org-link-protocols)))
  
  (defvar org-agenda-buffer-name)
  
--- 8454,8461 ----
    (add-to-list 'org-link-types type t)
    (org-make-link-regexps)
    (if (assoc type org-link-protocols)
!       (setcdr (assoc type org-link-protocols) (list follow export face))
!     (push (list type follow export face) org-link-protocols)))
  
  (defvar org-agenda-buffer-name)
  

Diff finished.  Tue Jul 26 16:16:12 2011

-- 
Florian Beck

  reply	other threads:[~2011-07-26 14:19 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-10 11:09 RFC: Revisit org-export-content-div (in the context of org-s5) Jambunathan K
2011-07-10 11:28 ` Jambunathan K
2011-07-11 11:44   ` Bastien
2011-07-11 19:55     ` Using org-mode for Research and Notetaking Florian Beck
2011-07-12 14:23       ` John Hendy
2011-07-14 18:09         ` Florian Beck
2011-07-12 14:28       ` Giovanni Ridolfi
2011-07-13  8:55       ` Bastien
2011-07-13  9:59         ` Sebastien Vauban
2011-07-13 11:20           ` Bastien
2011-07-13 12:20             ` Sebastien Vauban
2011-07-13 13:43             ` Nicolas Goaziou
2011-07-16 11:40               ` Bastien
2011-07-18 12:42             ` Matt Lundin
2011-07-18 13:21               ` Sebastien Vauban
2011-07-18 14:53                 ` Matt Lundin
2011-07-18 14:03               ` Sebastien Vauban
2011-07-18 14:58                 ` Bastien
2011-07-14 18:40         ` Florian Beck
2011-07-14 18:59           ` Thomas S. Dye
2011-07-18 22:54           ` Bastien
2011-07-18 23:59             ` Thomas S. Dye
2011-07-19  1:34               ` Florian Beck
2011-07-26 11:27               ` Bastien
2011-07-26 14:17                 ` Florian Beck [this message]
2011-07-26 15:15                 ` Thomas S. Dye
2011-07-26 17:41                   ` Christian Moe
2011-07-11 11:44 ` RFC: Revisit org-export-content-div (in the context of org-s5) Bastien

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=874o29ceib.fsf@sophokles.streitblatt.de \
    --to=abstraktion@t-online.de \
    --cc=bzg@altern.org \
    --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).