branch: externals/hyperbole commit 10a8f7a0d931b0bb00cd2f8d769c2465eb0d8e26 Merge: b65a514949 a2171562ca Author: Robert Weiner <r...@gnu.org> Commit: GitHub <nore...@github.com>
Merge pull request #331 from rswgnu/rsw Fix a number of hsys-org issues to match latest Org releases --- ChangeLog | 17 +++++++++++++++++ hactypes.el | 30 ++++++++++++++---------------- hload-path.el | 4 ++-- hpath.el | 7 +++++-- hsys-org.el | 41 +++++++++++++++++++++++++---------------- 5 files changed, 63 insertions(+), 36 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1078f692ac..d3e108f36e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,22 @@ +2023-05-21 Bob Weiner <r...@gnu.org> + +* hsys-org.el (hsys-org-search-internal-link-p) + hsys-org-search-radio-target-link-p): Replace 'org-show-context' + with newer 'org-fold-show-context' and alias this when necessary. + (hsys-org-radio-target-link-at-p): Remove test of + (hsys-org-link-at-p) since does not have link delimiters and already verified + uses link-face. + +* hactypes.el (link-to-ibut): Remove save-excursion and save-restriction calls + so if ilink refers to an ibut in a different file, point is left there + before the action is invoked. Fixes ilinks like: <ilink:bs: /tmp/a.org> + +* hsys-org.el (hsys-org-link-at-p): Suppress display of *Warnings* backtrace. + 2023-05-20 Bob Weiner <r...@gnu.org> +* hpath.el (hpath:normalize): Improve doc. + * hui.el (hui:ibut-create, hui:ebut-create, hui:ibut-link-create, hui:ebut-link-create): hbut.el (ebut:program, ibut:program): diff --git a/hactypes.el b/hactypes.el index 903de92b5d..a622feb99e 100644 --- a/hactypes.el +++ b/hactypes.el @@ -3,7 +3,7 @@ ;; Author: Bob Weiner ;; ;; Orig-Date: 23-Sep-91 at 20:34:36 -;; Last-Mod: 29-Mar-23 at 18:14:35 by Bob Weiner +;; Last-Mod: 21-May-23 at 03:15:30 by Bob Weiner ;; ;; SPDX-License-Identifier: GPL-3.0-or-later ;; @@ -522,21 +522,19 @@ on the implicit button to which to link." (hypb:error "(link-to-ibut): Point must be on an implicit button to create a link-to-ibut")) (let (but normalized-file) - (cond (but-src - (unless (and (get-buffer but-src) - (not (buffer-file-name (get-buffer but-src)))) - (setq normalized-file (hpath:normalize but-src)))) - (t (setq normalized-file buffer-file-name))) - (save-excursion - (save-restriction - (when but-src - (set-buffer (or (get-buffer but-src) (get-file-buffer normalized-file)))) - (widen) - (when (or (not normalized-file) (hmail:editor-p) (hmail:reader-p)) - (hmail:msg-narrow)) - (when (integerp point) - (goto-char (min point (point-max)))) - (setq but (ibut:to key)))) + (if but-src + (unless (and (get-buffer but-src) + (not (buffer-file-name (get-buffer but-src)))) + (setq normalized-file (hpath:normalize but-src))) + (setq normalized-file (hpath:normalize buffer-file-name))) + (when but-src + (set-buffer (or (get-buffer but-src) (get-file-buffer normalized-file)))) + (widen) + (when (or (not normalized-file) (hmail:editor-p) (hmail:reader-p)) + (hmail:msg-narrow)) + (when (integerp point) + (goto-char (min point (point-max)))) + (setq but (ibut:to key)) (cond (but (hbut:act but)) (key diff --git a/hload-path.el b/hload-path.el index 2b038ca6f4..3e9f4f0935 100644 --- a/hload-path.el +++ b/hload-path.el @@ -3,7 +3,7 @@ ;; Author: Bob Weiner ;; ;; Orig-Date: 29-Jun-16 at 14:39:33 -;; Last-Mod: 23-Oct-22 at 00:38:27 by Mats Lidell +;; Last-Mod: 21-May-23 at 03:55:58 by Bob Weiner ;; ;; SPDX-License-Identifier: GPL-3.0-or-later ;; @@ -116,8 +116,8 @@ the symbol list. For `suspicious', only `set-buffer' can be used." (if (fboundp 'with-suppressed-warnings) `(with-suppressed-warnings ,warnings ,@body) `(with-no-warnings ,@body))) -;; New autoload generation function defined only in Emacs 28 +;; New autoload generation function defined only in Emacs 28 (defalias 'hload-path--make-directory-autoloads (cond ((fboundp 'loaddefs-generate) #'loaddefs-generate) diff --git a/hpath.el b/hpath.el index e05d8ba3c7..90ee4fcfa0 100644 --- a/hpath.el +++ b/hpath.el @@ -3,7 +3,7 @@ ;; Author: Bob Weiner ;; ;; Orig-Date: 1-Nov-91 at 00:44:23 -;; Last-Mod: 20-May-23 at 14:05:35 by Bob Weiner +;; Last-Mod: 20-May-23 at 23:20:22 by Bob Weiner ;; ;; SPDX-License-Identifier: GPL-3.0-or-later ;; @@ -2025,7 +2025,10 @@ Return LINKNAME unchanged if it is not a symbolic link but is a pathname." path) (defun hpath:normalize (filename) - "Normalize and return PATH if PATH is a valid, readable path, else signal error." + "Normalize and return PATH if PATH is a valid, readable path, else signal error. +Replace Emacs Lisp variables and environment variables (format of +${var}) with their values in PATH. The first matching value for + variables like `${PATH}' is used." (hpath:validate (hpath:substitute-value (buffer-file-name (hpath:find-noselect filename))))) diff --git a/hsys-org.el b/hsys-org.el index baefeefcd3..5134d3ba9f 100644 --- a/hsys-org.el +++ b/hsys-org.el @@ -3,7 +3,7 @@ ;; Author: Bob Weiner ;; ;; Orig-Date: 2-Jul-16 at 14:54:14 -;; Last-Mod: 20-May-23 at 16:28:08 by Bob Weiner +;; Last-Mod: 21-May-23 at 04:32:45 by Bob Weiner ;; ;; SPDX-License-Identifier: GPL-3.0-or-later ;; @@ -34,6 +34,7 @@ (require 'hbut) (require 'org) (require 'org-element) +(require 'org-fold nil t) ;; Avoid any potential library name conflict by giving the load directory. (require 'set (expand-file-name "set" hyperb:dir)) @@ -82,7 +83,11 @@ with different settings of this option. For example, a nil value makes ;;; Public declarations ;;; ************************************************************************ -(declare-function org-show-context nil) ;; Obsolete as of Org 9.6 +;; `org-show-context' is obsolete as of Org 9.6, use `org-fold-show-context' +;; instead. +(unless (fboundp #'org-fold-show-context) + (with-suppressed-warnings ((obsolete org-show-context)) + (defalias 'org-fold-show-context #'org-show-context))) ;;; ************************************************************************ ;;; Public variables @@ -221,16 +226,26 @@ Return the (start . end) buffer positions of the region." (let ((case-fold-search t)) (looking-at org-babel-src-block-regexp)))) +;; (defun hsys-org-link-at-p () +;; "Return non-nil iff point is on an Org mode link. +;; Assume caller has already checked that the current buffer is in `org-mode' +;; or are looking for an Org link in another buffer type." +;; (unless (or (smart-eolp) (smart-eobp)) +;; (with-suppressed-warnings nil +;; ;; org-element-context may call looking-at with a nil value, +;; ;; triggering an error, so catch it. Also, suppress *Warnings* +;; ;; display of backtrace. +;; (condition-case () +;; (eq (org-element-type (org-element-context)) 'link) +;; (error nil))))) + (defun hsys-org-link-at-p () "Return non-nil iff point is on an Org mode link. Assume caller has already checked that the current buffer is in `org-mode' or are looking for an Org link in another buffer type." (unless (or (smart-eolp) (smart-eobp)) - (condition-case () - ;; org-element-context may call looking-at with a nil value, - ;; triggering an error, so catch it. - (eq (org-element-type (org-element-context)) 'link) - (error nil)))) + (with-suppressed-warnings nil + (org-in-regexp org-link-any-re nil t)))) ;; Assume caller has already checked that the current buffer is in org-mode. (defun hsys-org-heading-at-p (&optional _) @@ -258,7 +273,6 @@ Assume caller has already checked that the current buffer is in `org-mode'." Link region is (start . end) and includes delimiters, else nil." (and (hsys-org-face-at-p 'org-link) (equal (get-text-property (point) 'help-echo) "Radio target link") - (hsys-org-link-at-p) (hsys-org-region-with-text-property-value (point) 'face))) (defun hsys-org-radio-target-def-at-p () @@ -309,7 +323,7 @@ The region is (start . end) and includes any delimiters, else nil." (defun hsys-org-face-at-p (org-face-type) "Return ORG-FACE-TYPE iff point is on a character with that face, else nil. - ORG-FACE-TYPE must be a symbol, not a symbol name." +ORG-FACE-TYPE must be a symbol, not a symbol name." (let ((face-prop (get-text-property (point) 'face))) (when (or (eq face-prop org-face-type) @@ -332,9 +346,7 @@ White spaces are insignificant. Return t if a link is found, else nil." (backward-char) (let ((object (org-element-context))) (when (eq (org-element-type object) 'link) - (if (fboundp 'org-fold-show-context) ;; From Org 9.6 - (org-fold-show-context 'link-search) - (org-show-context 'link-search)) + (org-fold-show-context 'link-search) (goto-char (or (previous-single-property-change (point) 'face) (point-min))) (throw :link-match t)))) (goto-char origin) @@ -355,9 +367,7 @@ White spaces are insignificant. Return t if a target link is found, else nil." (backward-char) (let ((object (org-element-context))) (when (eq (org-element-type object) 'link) - (if (fboundp 'org-fold-show-context) ;; From Org 9.6 - (org-fold-show-context 'link-search) - (org-show-context 'link-search)) + (org-fold-show-context 'link-search) (throw :radio-match t)))) (goto-char origin) nil))) @@ -370,7 +380,6 @@ White spaces are insignificant. Return t if a target link is found, else nil." (buffer-substring-no-properties (car start-end) (cdr start-end)))) (car start-end) (cdr start-end)))) - (defun hsys-org-to-next-radio-target-link (target) "Move to the start of the next radio TARGET link if found. TARGET must be a string."