From mboxrd@z Thu Jan 1 00:00:00 1970 From: Florian Beck Subject: Re: Using org-mode for Research and Notetaking Date: Tue, 26 Jul 2011 16:17:48 +0200 Message-ID: <874o29ceib.fsf@sophokles.streitblatt.de> References: <81d3hi75oj.fsf@gmail.com> <818vs674t7.fsf@gmail.com> <87liw582jg.fsf@gnu.org> <87zkkktwwk.fsf_-_@sophokles.streitblatt.de> <87bowy4l0j.fsf@gnu.org> <87hb6oso2y.fsf@sophokles.streitblatt.de> <87pql7w679.fsf@gnu.org> <87mxg1th7y.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([140.186.70.92]:46769) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QliTa-0002yZ-5Z for emacs-orgmode@gnu.org; Tue, 26 Jul 2011 10:19:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QliTW-00025P-KV for emacs-orgmode@gnu.org; Tue, 26 Jul 2011 10:19:14 -0400 Received: from mo-p05-ob.rzone.de ([81.169.146.181]:12895) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QliTW-000252-BH for emacs-orgmode@gnu.org; Tue, 26 Jul 2011 10:19:10 -0400 In-Reply-To: <87mxg1th7y.fsf@gnu.org> (Bastien's message of "Tue, 26 Jul 2011 13:27:13 +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: Bastien Cc: emacs-orgmode@gnu.org, Florian Beck Bastien 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