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

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

[elpa] externals/hyperbole 912f02b 4/8: hpath:find - Add support for pro


From: ELPA Syncer
Subject: [elpa] externals/hyperbole 912f02b 4/8: hpath:find - Add support for prog, outline & text mode # anchors
Date: Tue, 18 May 2021 23:57:13 -0400 (EDT)

branch: externals/hyperbole
commit 912f02b62029849081164b2ddf4452f696583968
Author: Bob Weiner <rsw@gnu.org>
Commit: Bob Weiner <rsw@gnu.org>

    hpath:find - Add support for prog, outline & text mode # anchors
---
 ChangeLog |  3 +++
 hpath.el  | 32 ++++++++++++++++++++------------
 2 files changed, 23 insertions(+), 12 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 75e6e4d..c8eeba4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,6 @@
+* hpath.el (hpath:to-markup-anchor): Add support for path#anchor
+    links in programming, text and outlining major modes.
+
 * hactypes.el (link-to-ebut): Fix bug that always triggered an error
     if key-file was not given.  Also remove interactive conditional
     that prevented normalized-file from being set.
diff --git a/hpath.el b/hpath.el
index e5393c0..0cbf125 100644
--- a/hpath.el
+++ b/hpath.el
@@ -1210,24 +1210,32 @@ buffer but don't display it."
                           (buffer-name)
                           anchor))))
               (t
-               (let ((opoint (point))
-                     ;; Markdown or outline link ids are case
-                     ;; insensitive and - characters are converted to
-                     ;; spaces at the point of definition unless
-                     ;; anchor contains both - and space characters,
-                     ;; then no conversion occurs.
-                     (case-fold-search t)
-                     (anchor-name (if (string-match "-.* \\| .*-" anchor)
-                                      anchor
-                                    (subst-char-in-string ?- ?\  anchor))))
+               (let* ((opoint (point))
+                      (prog-mode (derived-mode-p 'prog-mode))
+                      ;; Markdown or outline link ids are case
+                      ;; insensitive and - characters are converted to
+                      ;; spaces at the point of definition unless
+                      ;; anchor contains both - and space characters,
+                      ;; then no conversion occurs.
+                      (case-fold-search (not prog-mode))
+                      (anchor-name (if (or prog-mode
+                                           (string-match "-.* \\| .*-" anchor))
+                                       anchor
+                                     (subst-char-in-string ?- ?\  anchor))))
                  (goto-char (point-min))
                  (if (re-search-forward (format
-                                         (cond ((or (and buffer-file-name
+                                         (cond ((derived-mode-p 'outline-mode) 
;; Includes Org mode
+                                                hpath:outline-section-pattern)
+                                               (prog-mode
+                                                "%s")
+                                               ((or (and buffer-file-name
                                                          (string-match 
hpath:markdown-suffix-regexp buffer-file-name))
                                                     (memq major-mode 
hpath:shell-modes))
                                                 hpath:markdown-section-pattern)
-                                               ((eq major-mode 'texinfo-mode)
+                                               ((derived-mode-p 'texinfo-mode)
                                                 hpath:texinfo-section-pattern)
+                                               ((derived-mode-p 'text-mode)
+                                                "%s")
                                                (t 
hpath:outline-section-pattern))
                                          (regexp-quote anchor-name)) nil t)
                      (progn (forward-line 0)



reply via email to

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