* colored-links take 2
@ 2016-06-30 17:56 John Kitchin
2016-07-01 12:58 ` Nicolas Goaziou
0 siblings, 1 reply; 2+ messages in thread
From: John Kitchin @ 2016-06-30 17:56 UTC (permalink / raw)
To: emacs-orgmode@gnu.org
[-- Attachment #1: Type: text/plain, Size: 149 bytes --]
I forgot a little piece in the last patch. This one is probably right.
It is based off of https://github.com/jkitchin/org-mode/blob/colored-link-3.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: colored-link.patch --]
[-- Type: text/x-patch, Size: 3088 bytes --]
diff --git a/lisp/org.el b/lisp/org.el
index 89b72bc..451a668 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -1867,6 +1867,18 @@ return the description to use."
:tag "Org Store Link"
:group 'org-link)
+(defcustom org-link-display-parameters nil
+ "An alist of properties to display a link with.
+The first element in each list is a string of the link
+type. Subsequent optional elements make up a p-list. :face can be
+used to change the face on the link (the default is
+`org-link'. If :display is 'full the full link will show in
+descriptive link mode."
+ :type '(alist :tag "Link display paramters"
+ :key-type 'string
+ :value-type '(plist))
+ :group 'org-link)
+
(defcustom org-url-hexify-p t
"When non-nil, hexify URL when creating a link."
:type 'boolean
@@ -5864,14 +5876,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 (match-string-no-properties 0)))
+ (link (match-string-no-properties 0))
+ (type (match-string-no-properties 1)))
(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 (or (plist-get
+ (cdr (assoc type org-link-display-parameters))
+ :face)
+ 'org-link)
'htmlize-link `(:uri ,link)
'keymap org-mouse-map))
(org-rear-nonsticky-at (match-end 0))
@@ -6064,8 +6081,14 @@ by a #."
(when (and (re-search-forward org-bracket-link-regexp limit t)
(not (org-in-src-block-p)))
(let* ((hl (match-string-no-properties 1))
+ (type (save-match-data
+ (string-match "\\(.*?\\):" hl)
+ (match-string 1 hl)))
(help (concat "LINK: " (save-match-data (org-link-unescape hl))))
- (ip (list 'invisible 'org-link
+ (ip (list 'invisible (or (plist-get
+ (cdr (assoc type org-link-display-parameters))
+ :display)
+ 'org-link)
'keymap org-mouse-map 'mouse-face 'highlight
'font-lock-multiline t 'help-echo help
'htmlize-link `(:uri ,hl)))
@@ -6362,8 +6385,8 @@ needs to be inserted at a specific position in the font-lock sequence.")
;; Links
(when (memq 'tag lk) '(org-activate-tags (1 'org-tag prepend)))
(when (memq 'angle lk) '(org-activate-angle-links (0 'org-link t)))
- (when (memq 'plain lk) '(org-activate-plain-links (0 'org-link t)))
- (when (memq 'bracket lk) '(org-activate-bracket-links (0 'org-link t)))
+ (when (memq 'plain lk) '(org-activate-plain-links (0 'org-link)))
+ (when (memq 'bracket lk) '(org-activate-bracket-links (0 'org-link)))
(when (memq 'radio lk) '(org-activate-target-links (1 'org-link t)))
(when (memq 'date lk) '(org-activate-dates (0 'org-date t)))
(when (memq 'footnote lk) '(org-activate-footnote-links))
[-- Attachment #3: Type: text/plain, Size: 190 bytes --]
--
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: colored-links take 2
2016-06-30 17:56 colored-links take 2 John Kitchin
@ 2016-07-01 12:58 ` Nicolas Goaziou
0 siblings, 0 replies; 2+ messages in thread
From: Nicolas Goaziou @ 2016-07-01 12:58 UTC (permalink / raw)
To: John Kitchin; +Cc: emacs-orgmode@gnu.org
John Kitchin <jkitchin@andrew.cmu.edu> writes:
> I forgot a little piece in the last patch. This one is probably right.
Thank you. Some comments follow.
> +(defcustom org-link-display-parameters nil
> + "An alist of properties to display a link with.
An alist between link types and properties to ...
> +The first element in each list is a string of the link
first element -> key
> +type. Subsequent optional elements make up a p-list. :face can be
Double spaces are required between sentences.
> +used to change the face on the link (the default is
> +`org-link'. If :display is 'full the full link will show in
Ditto. Also 'full -> `full'.
There should probably be other allowed values for :display, e.g., `path'
and `description'.
> +descriptive link mode."
> + :type '(alist :tag "Link display paramters"
> + :key-type 'string
> + :value-type '(plist))
> + :group 'org-link)
:type is wrong, it should be string' not 'string and plist instead of
'(plist). Also, allowed keywords should probably be specified somewhere.
> (list 'mouse-face 'highlight
> - 'face 'org-link
> + 'face (or (plist-get
> + (cdr (assoc type org-link-display-parameters))
> + :face)
> + 'org-link)
(plist-get ....) is begging for a getter, e.g.
`org-link--parameter-value' (which is called with two arguments, the
type as a string and the property as a keyword).
> + (ip (list 'invisible (or (plist-get
> + (cdr (assoc type org-link-display-parameters))
> + :display)
> + 'org-link)
See above.
Regards,
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-07-01 12:58 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-06-30 17:56 colored-links take 2 John Kitchin
2016-07-01 12:58 ` Nicolas Goaziou
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.