From: John Kitchin <jkitchin@andrew.cmu.edu>
To: emacs-orgmode <emacs-orgmode@gnu.org>
Subject: patch for custom help-echo on links
Date: Fri, 01 Jul 2016 07:57:05 -0400 [thread overview]
Message-ID: <m2shvty3ji.fsf@Johns-MacBook-Air.local> (raw)
[-- Attachment #1: Type: text/plain, Size: 417 bytes --]
I have attached a patch to allow org-link-display-parameters (introduced
in a previous patch for custom faces) to also provide a custom tooltip.
It can be a string or a function, and if neither the old behavior is
used.
WDYT?
--
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
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: custom-help-echo.patch --]
[-- Type: text/x-patch, Size: 3105 bytes --]
diff --git a/lisp/org.el b/lisp/org.el
index 451a668..612a85e 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -1873,7 +1873,9 @@ 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."
+descriptive link mode. :help-echo can be either a string or a function
+that returns a string. That function should have args of (begin
+end type path) and it should return a string."
:type '(alist :tag "Link display paramters"
:key-type 'string
:value-type '(plist))
@@ -5877,10 +5879,14 @@ prompted for."
(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))
- (type (match-string-no-properties 1)))
+ (let* ((face (get-text-property (max (1- (match-beginning 0)) (point-min))
+ 'face))
+ (link (match-string-no-properties 0))
+ (type (match-string-no-properties 1))
+ (path (match-string-no-properties 2))
+ (help-echo (plist-get
+ (cdr (assoc type org-link-display-parameters))
+ :help-echo)))
(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)
@@ -5889,6 +5895,15 @@ prompted for."
(cdr (assoc type org-link-display-parameters))
:face)
'org-link)
+ 'help-echo (cond
+ ((stringp help-echo)
+ help-echo)
+ ((functionp help-echo)
+ (funcall help-echo
+ (match-beginning 0)
+ (match-end 0)
+ type path))
+ (t nil))
'htmlize-link `(:uri ,link)
'keymap org-mouse-map))
(org-rear-nonsticky-at (match-end 0))
@@ -6084,13 +6099,31 @@ by a #."
(type (save-match-data
(string-match "\\(.*?\\):" hl)
(match-string 1 hl)))
- (help (concat "LINK: " (save-match-data (org-link-unescape hl))))
+ (path (save-match-data
+ (string-match ".*:\\(.*\\)" hl)
+ (match-string 1 hl)))
+ (help-echo (plist-get
+ (cdr (assoc type org-link-display-parameters))
+ :help-echo))
+ (help (cond
+ ((stringp help-echo)
+ help-echo)
+ ((functionp help-echo)
+ (funcall help-echo
+ (match-beginning 0)
+ (match-end 0)
+ type path))
+ (t
+ (concat "LINK: "
+ (save-match-data
+ (org-link-unescape hl))))))
(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
+ 'font-lock-multiline t
+ 'help-echo help
'htmlize-link `(:uri ,hl)))
(vp (list 'keymap org-mouse-map 'mouse-face 'highlight
'font-lock-multiline t 'help-echo help
reply other threads:[~2016-07-01 11:57 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=m2shvty3ji.fsf@Johns-MacBook-Air.local \
--to=jkitchin@andrew.cmu.edu \
--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).