emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/hyperbole 97a4d80 10/25: Raise org-mode ibtype priority


From: Stefan Monnier
Subject: [elpa] externals/hyperbole 97a4d80 10/25: Raise org-mode ibtype priority to near top; fix markdown # link activation
Date: Tue, 22 Sep 2020 10:29:27 -0400 (EDT)

branch: externals/hyperbole
commit 97a4d804e894af90df6ad95af5614cbb35995d27
Author: Bob Weiner <Bob.Weiner@DuffandPhelps.com>
Commit: Bob Weiner <Bob.Weiner@DuffandPhelps.com>

    Raise org-mode ibtype priority to near top; fix markdown # link activation
---
 Changes     |   8 +++++
 HY-NEWS     |   7 ++++
 hibtypes.el | 107 ++++++++++++++++++++++++++++++++----------------------------
 3 files changed, 72 insertions(+), 50 deletions(-)

diff --git a/Changes b/Changes
index 2aef647..fdef571 100644
--- a/Changes
+++ b/Changes
@@ -1,3 +1,11 @@
+2020-07-26  Bob Weiner  <rsw@gnu.org>
+
+* hibtypes.el (hsys-org): Move org links/refs to near top of priority list so 
things
+    like URLs embeded within Org links are handled by Org, not Hyperbole.
+              (markdown-follow-inline-link-p): Fixed to defer in-file links 
with
+    point on the link title to the `pathname' ibtype since
+    markdown-follow-link-at-point does not handle them properly.
+
 2020-07-25  Bob Weiner  <rsw@gnu.org>
 
 * hib-kbd.el (kbd-key:execute-special-series): Added and used in kbd-key:act
diff --git a/HY-NEWS b/HY-NEWS
index d980eb7..3869ab1 100644
--- a/HY-NEWS
+++ b/HY-NEWS
@@ -15,12 +15,19 @@
       associated with Agenda items such as TODOs in another window.  The
       Assist Key shows help.
 
+    - Org-mode: Raised to near top priority in implicit button types so that
+      pathnames, URLs, etc. within Org links are handled by Org rather than
+      Hyperbole.
+
   BUTTON TYPES
 
     - {Key Series} Button Support for Helm and Counsel: Key series buttons
       with M-x commands now work properly when counsel-mode or helm-mode are
       enabled and M-x is rebound.
 
+    - Markdown In-file Links: With point on the link title, in-file links are
+      now activated properly (previously point had to be on the link itself).
+
 
 ===========================================================================
 *                                   V7.1.2
diff --git a/hibtypes.el b/hibtypes.el
index db7f019..7c5bd0c 100644
--- a/hibtypes.el
+++ b/hibtypes.el
@@ -65,14 +65,6 @@
 (run-hooks 'hibtypes-begin-load-hook)
 
 ;;; ========================================================================
-;;; Follows Org mode links and radio targets and cycles Org heading views
-;;; ========================================================================
-
-;; Set the custom option `inhibit-hsys-org' non-nil to disable ALL Hyperbole
-;; support within Org major and minor modes.
-(require 'hsys-org)
-
-;;; ========================================================================
 ;;; Composes mail, in another window, to the e-mail address at point.
 ;;; ========================================================================
 
@@ -146,7 +138,7 @@ match.  See `hpath:find' function documentation for special 
file
 display options."
   ;;
   ;; Ignore paths in Buffer menu, dired and helm modes.
-  (unless (or (eq major-mode 'helm-major-mode)
+  (unless (or (derived-mode-p 'helm-major-mode)
                  (delq nil (mapcar (lambda (substring)
                                                  (string-match substring 
(format-mode-line mode-name)))
                                                '("Buffer Menu" "IBuffer" 
"Dired"))))
@@ -287,49 +279,56 @@ Return t if jump and nil otherwise."
     t)))
 
 (defun markdown-follow-inline-link-p (opoint)
-  "Test to see if on an inline link, jump to its referent if it is absolute 
(not relative within the file), otherwise return to OPOINT."
-  (skip-chars-forward "^\]\[()")
-  (if (looking-at "\][\[()]")
-      (progn (if (looking-at "\(")
-                        (skip-chars-backward "^\]\[()")
-                  (skip-chars-forward "\]\[\("))
-                ;; Leave point on the link even if not activated
-                ;; here, so that code elsewhere activates it.
-                (when (and (markdown-link-p)
-                               (save-match-data (not (or (hpath:www-at-p) 
(hpath:at-p)))))
-                      ;; In-file referents are handled by the 
'markdown-internal-link'
-                      ;; implicit button type, not here.
-                      (ibut:label-set (match-string-no-properties 0) 
(match-beginning 0) (match-end 0))
-                          (hpath:display-buffer (current-buffer))
-                          (hact 'markdown-follow-link-at-point)))
-    (goto-char opoint)
-    nil))
+  "Test to see if on an inline link, jump to its referent if it is absolute 
(not relative within the file) and return non-nil.
+Otherwise, if an internal link, move back to OPOINT and return nil."
+  (let (handle-link-flag
+       result)
+    (skip-chars-forward "^\]\[()")
+    (when (looking-at "\][\[()]")
+      (if (looking-at "\(")
+         (skip-chars-backward "^\]\[()")
+       (skip-chars-forward "\]\[\("))
+      ;; Leave point on the link even if not activated
+      ;; here, so that other ibtypes activate it.  If point is after
+      ;; the # character of an in-file link, then the following predicate
+      ;; fails and the `pathname' ibtype will handle it.  If point is before
+      ;; the # character, the link is handled here.
+      (setq handle-link-flag (not (or (hpath:www-at-p) (hpath:at-p))))
+      (when (setq result (and (markdown-link-p) handle-link-flag))
+       ;; In-file referents are handled by the `pathname' implicit
+       ;; button type, not here.
+       (ibut:label-set (match-string-no-properties 0) (match-beginning 0) 
(match-end 0))
+       (hpath:display-buffer (current-buffer))
+       (hact 'markdown-follow-link-at-point)))
+    (when handle-link-flag
+      (goto-char opoint))
+    result))
 
 (defib markdown-internal-link ()
   "Display any in-file Markdown link referent at point.
 Pathnames and urls are handled elsewhere."
-  (when (and (eq major-mode 'markdown-mode)
-                (not (hpath:www-at-p)))
+  (when (and (derived-mode-p 'markdown-mode)
+            (not (hpath:www-at-p)))
     (let ((opoint (point))
-             npoint)
+         npoint)
       (cond ((markdown-link-p)
-                (condition-case ()
-                        ;; Follows a reference link or footnote to its 
referent.
-                        (if (markdown-follow-link-p)
-                            (when (/= opoint (point))
-                              (ibut:label-set (match-string-no-properties 0) 
(match-beginning 0) (match-end 0))
-                              (setq npoint (point))
-                              (goto-char opoint)
-                              (hact 'link-to-file buffer-file-name npoint))
-                          ;; Follows an infile link.
-                      (markdown-follow-inline-link-p opoint))
-                  ;; May be on the name of an inline link, so move to the
-                  ;; link itself and follow that.
-                  (error (markdown-follow-inline-link-p opoint))))
-               ((markdown-wiki-link-p)
-                (ibut:label-set (match-string-no-properties 0) 
(match-beginning 0) (match-end 0))
-                (hpath:display-buffer (current-buffer))
-                (hact 'markdown-follow-wiki-link-at-point))))))
+            (condition-case ()
+                ;; Follows a reference link or footnote to its referent.
+                (if (markdown-follow-link-p)
+                    (when (/= opoint (point))
+                      (ibut:label-set (match-string-no-properties 0) 
(match-beginning 0) (match-end 0))
+                      (setq npoint (point))
+                      (goto-char opoint)
+                      (hact 'link-to-file buffer-file-name npoint))
+                  ;; Follows an absolute file link.
+                  (markdown-follow-inline-link-p opoint))
+              ;; May be on the name of an infile link, so move to the
+              ;; link itself and then let the `pathname' ibtype handle it.
+              (error (markdown-follow-inline-link-p opoint))))
+           ((markdown-wiki-link-p)
+            (ibut:label-set (match-string-no-properties 0) (match-beginning 0) 
(match-end 0))
+            (hpath:display-buffer (current-buffer))
+            (hact 'markdown-follow-wiki-link-at-point))))))
 
 ;;; ========================================================================
 ;;; Summarizes an Internet rfc for random access browsing by section.
@@ -359,7 +358,7 @@ Each line in the summary may be selected to jump to a 
section."
 (defib id-cflow ()
   "Expand or collapse C call trees and jump to code definitions.
 Require cross-reference tables built by the external `cxref' program of Cflow."
-  (when (and (eq major-mode 'id-cflow-mode)
+  (when (and (derived-mode-p 'id-cflow-mode)
                 (not (eolp)))
     (let ((pnt (point)))
          (save-excursion
@@ -707,7 +706,7 @@ buffer)."
   ;; -> 1391     apm(name_filter, value_filter, print_func, defined_only=True)
   ;; 1392
   ;; 1393 def apa(name_filter=None, value_filter=None, print_func=pd1, 
defined_only=False):
-  (unless (eq major-mode 'helm-major-mode)
+  (unless (derived-mode-p 'helm-major-mode)
     (save-excursion
       (beginning-of-line)
       (let ((line-num-regexp "\\( *\\|-+> \\)?\\([1-9][0-9]*\\) ")
@@ -754,7 +753,7 @@ buffer)."
   ;; 430-(defun hmouse-click-to-drag ()
   ;;
   ;; Use `rg -n --no-heading' for pathname on each line.
-  (unless (eq major-mode 'helm-major-mode)
+  (unless (derived-mode-p 'helm-major-mode)
     (save-excursion
       (beginning-of-line)
       (when (looking-at "\\([1-9][0-9]*\\)[-:]")
@@ -783,7 +782,7 @@ buffer) except for grep -A<num> context lines which are 
matched only
 in grep and shell buffers."
   ;; Locate and parse grep messages found in any buffer other than a
   ;; helm completion buffer.
-  (unless (eq major-mode 'helm-major-mode)
+  (unless (derived-mode-p 'helm-major-mode)
     (save-excursion
       (beginning-of-line)
       (when (or
@@ -1278,6 +1277,14 @@ arg1 ... argN '>'.  For example, <mail nil 
\"user@somewhere.org\">."
                (apply hrule:action actype (mapcar #'eval args))))))))
 
 ;;; ========================================================================
+;;; Follows Org mode links and radio targets and cycles Org heading views
+;;; ========================================================================
+
+;; Set the custom option `inhibit-hsys-org' non-nil to disable ALL Hyperbole
+;; support within Org major and minor modes.
+(require 'hsys-org)
+
+;;; ========================================================================
 ;;; Inserts completion into minibuffer or other window.
 ;;; ========================================================================
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]