From mboxrd@z Thu Jan 1 00:00:00 1970 From: John Kitchin Subject: patch for custom help-echo on links Date: Fri, 01 Jul 2016 07:57:05 -0400 Message-ID: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:51556) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bIx4O-0007Am-4Q for emacs-orgmode@gnu.org; Fri, 01 Jul 2016 07:57:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bIx4K-0001Zq-Tg for emacs-orgmode@gnu.org; Fri, 01 Jul 2016 07:57:16 -0400 Received: from mail-qt0-x22a.google.com ([2607:f8b0:400d:c0d::22a]:35232) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bIx4K-0001Zh-NW for emacs-orgmode@gnu.org; Fri, 01 Jul 2016 07:57:12 -0400 Received: by mail-qt0-x22a.google.com with SMTP id f89so56192216qtd.2 for ; Fri, 01 Jul 2016 04:57:12 -0700 (PDT) Received: from Johns-MacBook-Air.local (c-67-171-67-30.hsd1.pa.comcast.net. [67.171.67.30]) by smtp.gmail.com with ESMTPSA id s6sm1092236qtc.11.2016.07.01.04.57.08 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 01 Jul 2016 04:57:09 -0700 (PDT) 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: emacs-orgmode --=-=-= Content-Type: text/plain 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 --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=custom-help-echo.patch 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 --=-=-=--