33; ; Author: Bob Weiner
44; ;
55; ; Orig-Date: 19-Sep-91 at 20:45:31
6- ; ; Last-Mod: 14 -Mar-26 at 03:16:36 by Bob Weiner
6+ ; ; Last-Mod: 17 -Mar-26 at 19:48:06 by Bob Weiner
77; ;
88; ; SPDX-License-Identifier: GPL-3.0-or-later
99; ;
3737; ;; Other required Elisp libraries
3838; ;; ************************************************************************
3939
40- (require 'cl-lib ) ; ; for cl-count
40+ (require 'cl-lib ) ; ; for cl-count and cl-find
4141(require 'find-func ) ; ; used by grep-msg ibtype
4242(eval-when-compile (require 'hversion ))
4343(require 'hactypes )
44+ (require 'hsys-org )
4445(require 'hypb )
4546(require 'org-macs ) ; ; for org-uuid-regexp
4647(require 'subr-x ) ; ; for string-trim
@@ -175,17 +176,19 @@ only to prevent false matches."
175176 (start (when bounds (car bounds)))
176177 (end (when bounds (cdr bounds)))
177178 m)
179+ ; ; Remove any "ID:" or "id:" prefix
180+ (when (and id (string-prefix-p " id:" id t ))
181+ (setq id (substring id 3 )
182+ start (+ start 3 )))
178183 ; ; Ignore ID definitions or when not on a possible ID
179- (when (and id (if (fboundp 'org-uuidgen-p )
180- (org-uuidgen-p id)
181- (string-match org-uuid-regexp (downcase id))))
184+ (when (hsys-org-uuid-is-p id)
182185 (when (and start end)
183186 (ibut:label-set id start end))
184187 (if (and (not assist-flag)
185188 (save-excursion (beginning-of-line )
186189 (re-search-forward " :\\ (CUSTOM_\\ )?ID:[ \t ]+"
187190 (line-end-position ) t )))
188- (hact 'message " On ID definition; use {C-u M-RET} to copy a link to an ID." )
191+ (hact 'message " On Org ID definition; use {C-u M-RET} to copy a link to an ID." )
189192 (when (let ((inhibit-message t ) ; ; Inhibit org-id-find status msgs
190193 (obuf (current-buffer ))
191194 (omode major-mode))
@@ -208,6 +211,9 @@ If the referenced location is found, return non-nil."
208211 (let ((id (thing-at-point 'symbol t )) ; ; Could be a uuid or some other form of id
209212 m
210213 mpos)
214+ ; ; Remove any "ID:" or "id:" prefix
215+ (when (and id (string-prefix-p " id:" id t ))
216+ (setq id (substring id 3 )))
211217 ; ; Ignore ID definitions or when not on a possible ID
212218 (when (and id
213219 (let ((inhibit-message t )) ; ; Inhibit org-id-find status msgs
@@ -350,7 +356,10 @@ display options."
350356 ; ; Match PATH-related Environment and Lisp variable names and
351357 ; ; Emacs Lisp and Info files without any directory component.
352358 (when (setq path orig-path)
353- (cond ((and (string-match hpath:path-variable-regexp path)
359+ (cond ((string-match " \\ `#[^#]+" path)
360+ (apply #'ibut:label-set path (hpath:start-end path))
361+ (hact 'link-to-file path))
362+ ((and (string-match hpath:path-variable-regexp path)
354363 (setq path (match-string-no-properties 1 path))
355364 (hpath:is-path-variable-p path))
356365 (setq path (if (or assist-flag (hyperb:stack-frame '(hkey-help)))
@@ -490,7 +499,6 @@ handle any links they recognize first."
490499 ; ; Prevent infinite recursion, e.g. if called via
491500 ; ; `org-metareturn-hook' from `org-meta-return' invocation.
492501 (not (hyperb:stack-frame '(ibtypes::debugger-source org-meta-return))))
493- (require 'hsys-org )
494502 (declare-function hsys-org-link-at-p " hsys-org" ())
495503 (declare-function hsys-org-set-ibut-label " hsys-org" (start-end))
496504 (let ((start-end (hsys-org-link-at-p)))
@@ -985,9 +993,10 @@ See `hpath:find' function documentation for special file display options."
985993 (col-num (when (match-end 4 )
986994 (string-to-number (match-string-no-properties 5 path-line-and-col))))
987995 (label (match-string-no-properties 1 path-line-and-col))
988- ; ; Next variable must come last as it can overwrite the match-data
989- (file (hpath:expand label)))
990- (when (setq file (hpath:is-p file))
996+ ; ; Next variable should come last as it can overwrite the match-data
997+ file)
998+ (when (setq file (or (hpath:is-p (hpath:expand label))
999+ (hywiki-get-existing-page-file label)))
9911000 (ibut:label-set label start (+ start (length label)))
9921001 (if col-num
9931002 (hact 'link-to-file-line-and-column file line-num col-num)
@@ -1017,8 +1026,9 @@ LINE-NUM may be an integer or string."
10171026 (and (or (null (setq ext (file-name-extension file)))
10181027 (member (concat " ." ext) (get-load-suffixes )))
10191028 (ignore-errors (find-library-name file)))
1020- (expand-file-name file))))
1021- (when (file-exists-p file)
1029+ (hpath:is-p (expand-file-name file))
1030+ (hywiki-get-existing-page-file file))))
1031+ (when (file-exists-p (hpath:normalize file))
10221032 (actypes::link-to-file-line file line-num))))
10231033
10241034(defib ipython-stack-frame ()
@@ -1624,7 +1634,7 @@ action type, function symbol to call or test to execute, i.e.
16241634 (let ((hbut:max-len 0 )
16251635 (name (hattr:get 'hbut:current 'name ))
16261636 (testing-flag (when (bound-and-true-p ert--running-tests) t ))
1627- actype actype-sym action args lbl var-flag)
1637+ actname actype actype-sym action args is-var lbl sep var-flag)
16281638
16291639 ; ; Continue only if there if there is one of:
16301640 ; ; 1. `ert--running-tests' is non-nil
@@ -1640,23 +1650,26 @@ action type, function symbol to call or test to execute, i.e.
16401650 (when (string-match " \\ `\\ $" lbl)
16411651 (setq var-flag t
16421652 lbl (substring lbl 1 )))
1643- (setq actype (if (string-match-p " " lbl) ( car ( split-string lbl) ) lbl)
1644- actype-sym (or (actype:elisp-symbol actype ) (intern-soft actype ))
1653+ (setq actname (if (setq sep ( cl-position ?\ lbl)) ( substring lbl 0 sep ) lbl)
1654+ actype-sym (or (actype:elisp-symbol actname ) (intern-soft actname ))
16451655 ; ; Must ignore that (boundp nil) would be t here.
16461656 actype (and actype-sym
1647- (or (fboundp actype-sym) (boundp actype-sym)
1657+ (or (fboundp actype-sym)
1658+ (setq is-var (boundp actype-sym))
16481659 (special-form-p actype-sym)
16491660 (ert-test-boundp actype-sym))
16501661 actype-sym))
1651- (when actype
1662+ (when (and actype (or (null is-var)
1663+ ; ; is a variable so can't have arguments
1664+ (equal actname lbl)))
16521665 ; ; For <hynote> buttons, need to double quote each argument so
16531666 ; ; 'read' does not change the idstamp 02 to 2.
16541667 (when (and (memq actype '(hy hynote))
16551668 (string-match-p " " lbl))
16561669 (setq lbl (replace-regexp-in-string " \" \\ (.*\\ )\\ '" " \\ 1\" "
16571670 (combine-and-quote-strings
16581671 (split-string lbl) " \" \" " ))))
1659- (setq action (read (concat " (" lbl " )" ))
1672+ (setq action (ignore-errors ( read (concat " (" lbl " )" ) ))
16601673 args (cdr action))
16611674 ; ; Ensure action uses an fboundp symbol if executing a
16621675 ; ; Hyperbole actype.
@@ -1762,8 +1775,7 @@ not yet existing HyWikiWords."
17621775 (cl-destructuring-bind (wikiword start end)
17631776 (hywiki-referent-exists-p :range )
17641777 (when wikiword
1765- (unless (or (ibtypes::pathname-line-and-column)
1766- (ibtypes::pathname))
1778+ (unless (file-exists-p (hywiki-word-from-reference wikiword))
17671779 (if (and start end)
17681780 (ibut:label-set wikiword start end)
17691781 (ibut:label-set wikiword))
0 commit comments