branch: externals/hyperbole commit 912f02b62029849081164b2ddf4452f696583968 Author: Bob Weiner <r...@gnu.org> Commit: Bob Weiner <r...@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)