branch: externals/hyperbole commit f7f3265d50a79af93c387e921122adb359c358fc Author: Robert Weiner <r...@gnu.org> Commit: GitHub <nore...@github.com>
Fixes for direct link creation, path handling and org-id buttons (#382) --- ChangeLog | 27 +++ TAGS | 648 +++++++++++++++++++++++++++++----------------------------- hargs.el | 7 +- hbut.el | 57 +++--- hibtypes.el | 19 +- hmouse-tag.el | 4 +- hpath.el | 76 +++---- hui.el | 242 ++++++++++++---------- 8 files changed, 575 insertions(+), 505 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9a1b4bf18e..faf42dda3b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,32 @@ +2023-08-29 Bob Weiner <r...@gnu.org> + +* hbut.el (ibut:operate): Fix to ensure point is within button after + name deletion or new button insertion. + +* hui.el (hui:ibut-link-directly, hui:ebut-link-directly, + hui:gbut-link-directly): Start by clearing 'hbut:current + attributes. + 2023-08-28 Bob Weiner <r...@gnu.org> +* hargs.el (hargs:delimited): Fix to add full length (rather than -1) + chars of opening delimiter to search forward limit so match to + opening delimiters when point is immediately before. + +* hbut.el (ibut:create): Fix to move point within ibut text only if + found a matching ibut at point. If point is in front of the text + delimiter and no name, don't move point. + +* hpath.el (hpath:at-p): Fix to not send a string with "::" in it to + 'file-readable-p' which will trigger a no read method found error + otherwise. Also, return nil if path is an empty string. + +* hibtypes.el (org-id): Tighten match to just Org ID characters and restore + buffer mode to prior mode when necessary after 'org-id-find' switches + it to Org mode. + +* hui.el (hui:ibut-link-create): Fix to handle name attributes properly. + * hargs.el (hargs:iform-read): Reset global 'hargs:defaults' to nil when not to prevent errant values in any future calls. diff --git a/TAGS b/TAGS index 0a0a77dc21..208602f43e 100644 --- a/TAGS +++ b/TAGS @@ -100,26 +100,26 @@ hargs.el,997 (defun hargs:action-get 72,2719 (defun hargs:buffer-substring 84,3257 (defun hargs:delimited 94,3810 -(defun hargs:get 216,8784 -(defmacro hargs:make-iform-vector 253,10357 -(defun hargs:match-p 281,11516 -(defun hargs:prompt 292,12051 -(defun hargs:select-event-window 301,12366 -(defun hargs:set-string-to-complete 311,12807 -(defun hargs:unset-string-to-complete 318,13144 -(defun hargs:sexpression-p 322,13279 -(defun hargs:actype-get 350,14462 -(defun hargs:at-p 357,14767 -(defun hargs:completion 542,22029 -(defun hargs:iform-read 616,24574 -(defun hargs:read 691,27413 -(defun hargs:read-buffer-name 733,29044 -(defun hargs:read-match 738,29231 -(defun hargs:select-p 772,30629 -(defvar hargs:reading-symbol 865,34041 -(defconst hargs:iform-vector868,34116 -(defconst hargs:iform-extensions-vector974,37633 -(defvar hargs:string-to-complete 1020,39400 +(defun hargs:get 217,8828 +(defmacro hargs:make-iform-vector 254,10401 +(defun hargs:match-p 282,11560 +(defun hargs:prompt 293,12095 +(defun hargs:select-event-window 302,12410 +(defun hargs:set-string-to-complete 312,12851 +(defun hargs:unset-string-to-complete 319,13188 +(defun hargs:sexpression-p 323,13323 +(defun hargs:actype-get 351,14506 +(defun hargs:at-p 358,14811 +(defun hargs:completion 543,22073 +(defun hargs:iform-read 617,24618 +(defun hargs:read 692,27457 +(defun hargs:read-buffer-name 734,29088 +(defun hargs:read-match 739,29275 +(defun hargs:select-p 773,30673 +(defvar hargs:reading-symbol 866,34085 +(defconst hargs:iform-vector869,34160 +(defconst hargs:iform-extensions-vector975,37677 +(defvar hargs:string-to-complete 1021,39444 hbdata.el,879 (defun hbdata:action 77,3183 @@ -159,155 +159,155 @@ hbmap.el,259 (defvar hbmap:dir-filename120,4405 hbut.el,5801 -(defconst hbut:max-len 33,1059 -(defsubst hbut:max-len 40,1300 -(defvar ebut:hattr-save 55,1885 -(defun ebut:act 59,2002 -(defun ebut:alist 70,2404 -(defun ebut:at-p 76,2625 -(defun ebut:create 83,2932 -(defun ebut:delete 105,3933 -(defun ebut:edit 118,4401 -(defun ebut:get 131,4932 -(defun ebut:is-p 200,7455 -(defun ebut:key 205,7643 -(defun ebut:key-of-label-p 212,7881 -(defalias 'ebut:to-key-src ebut:to-key-src217,8087 -(defalias 'ebut:key-src-set-buffer ebut:key-src-set-buffer218,8141 -(defalias 'ebut:key-src-fmt ebut:key-src-fmt219,8203 -(defalias 'ebut:key-to-label ebut:key-to-label220,8258 -(defun ebut:label-p 224,8340 -(defalias 'ebut:label-regexp ebut:label-regexp287,10913 -(defalias 'ebut:label-instances-regexp ebut:label-instances-regexp288,10973 -(defalias 'ebut:label-to-key ebut:label-to-key290,11044 -(defun ebut:list 292,11095 -(defalias 'map-ebut map-ebut314,11937 -(defun ebut:map 316,11970 -(defun ebut:next-occurrence 326,12461 -(defun ebut:operate 341,13140 -(defun ebut:program 450,17338 -(defun ebut:search 481,18771 -(defun ebut:to 560,21423 -(defun ebut:delimit 596,22796 -(defun ebut:match-regexp 623,23864 -(defconst ebut:label-start 634,24304 -(defconst ebut:label-end 636,24405 -(defconst hbut:instance-sep 638,24504 -(defun gbut:act 645,24844 -(defun gbut:delete 660,25459 -(defun gbut:ebut-program 665,25682 -(defun gbut:file 685,26573 -(defun gbut:get 689,26731 -(defun gbut:help 701,27145 -(defun gbut:label-list 712,27568 -(defun gbut:label-p 716,27687 -(defun gbut:to 731,28502 -(defun gbut:key-list 749,29159 -(defun gbut:ebut-key-list 753,29285 -(defun gbut:ibut-key-list 767,29746 -(defun hattr:attributes 780,30255 -(defun hattr:clear 790,30560 -(defun hattr:copy 801,30936 -(defun hattr:emacs-button-attributes 812,31326 -(defun hattr:emacs-button-is-p 825,31819 -(defun hattr:get 832,32108 -(defun hattr:list 836,32242 -(defun hattr:memq 844,32519 -(defun hattr:report 856,32950 -(defun hattr:save 884,33976 -(defun hattr:set 902,34828 -(defalias 'hattr:summarize hattr:summarize906,35007 -(defvar hattr:filename908,35051 -(defun hbut:act 918,35484 -(defun hbut:action 980,38181 -(defun hbut:at-p 991,38517 -(defun hbut:comment 1004,38917 -(defvar hbut:fill-prefix-regexps1037,40144 -(defun hbut:fill-prefix-remove 1061,40992 -(defun hbut:delete 1071,41384 -(defun hbut:funcall 1086,42017 -(defun hbut:get 1116,43239 -(defun hbut:get-key-src 1127,43767 -(defun hbut:is-p 1185,46054 -(defun hbut:key 1190,46213 -(defun hbut:to-key-src 1197,46433 -(defun hbut:key-src-fmt 1204,46752 -(defun hbut:key-src-set-buffer 1220,47402 -(defun hbut:key-to-label 1242,48101 -(defun hbut:label 1263,48785 -(defun hbut:label-list 1270,49031 -(defun hbut:label-p 1274,49185 -(defun hbut:label-regexp 1287,49960 -(defun hbut:label-instances-regexp 1317,50989 -(defun hbut:label-to-key 1352,52228 -(defun hbut:map 1365,52818 -(defvar hbut:syntax-table 1423,55019 -(defun hbut:modify-syntax 1429,55289 -(defun hbut:outside-comment-p 1444,55916 -(defun hbut:rename 1452,56276 -(defun hbut:report 1463,56682 -(defun hbut:source 1522,58616 -(defalias 'hbut:summarize hbut:summarize1537,59189 -(defun hbut:to 1539,59231 -(defvar hbut:current 1546,59559 -(defconst hbut:source-prefix 1549,59664 -(defun hbut:key-list 1556,59995 -(defun hbut:ebut-key-list 1560,60160 -(defun hbut:ibut-key-list 1575,60685 -(defun ibut:act 1589,61228 -(defun ibut:alist 1600,61634 -(defun ibut:at-p 1606,61863 -(defun ibut:at-type-p 1625,62680 -(defun ibut:set-name-and-label-key-p 1639,63290 -(cl-defun ibut:create 1733,66804 -(def-edebug-spec cl-defun1919,73243 -(def-edebug-spec lambda-key-list1924,73390 -(defun ibut:delete 1933,73613 -(defun ibut:delete-occurrence 1965,74785 -(defun ibut:delimit 1974,75112 -(defun ibut:get 2004,76304 -(defun ibut:is-p 2026,77121 -(defun ibut:label-map 2034,77414 -(defun ibut:label-key-match 2046,78003 -(defun ibut:label-p 2056,78396 -(defun ibut:label-regexp 2101,80401 -(defun ibut:label-instances-regexp 2107,80692 -(defun ibut:label-set 2113,81020 -(defun ibut:label-sort-keys 2137,82111 -(defun ibut:list 2156,82741 -(defun ibut:key 2178,83592 -(defalias 'ibut:to-key-src ibut:to-key-src2185,83835 -(defalias 'ibut:key-to-label ibut:key-to-label2186,83883 -(defalias 'ibut:label-to-key ibut:label-to-key2187,83933 -(defalias 'map-ibut map-ibut2188,83983 -(defun ibut:map 2190,84025 -(defun ibut:next-occurrence 2202,84516 -(defun ibut:operate 2217,85261 -(defun ibut:org-at-read-only-p 2420,94654 -(defun ibut:insert-text 2439,95198 -(defun ibut:previous-occurrence 2520,98521 -(defun ibut:program 2535,99252 -(defun ibut:rename 2579,101355 -(defalias 'ibut:summarize ibut:summarize2601,102374 -(defun ibut:to 2603,102416 -(defun ibut:at-to-name-p 2651,104217 -(defun ibut:to-name 2675,105015 -(defun ibut:to-text 2708,106327 -(defconst ibut:label-start 2759,108380 -(defconst ibut:label-end 2761,108481 -(defvar ibut:label-separator 2764,108581 -(defvar ibut:label-separator-regexp 2772,108898 -(defmacro defib 2779,109238 -(def-edebug-spec defib2814,110875 -(def-edebug-spec lambda-list2819,111015 -(defalias 'ibtype:create ibtype:create2824,111133 -(defun ibtype:activate-link 2826,111168 -(defmacro defil 2838,111620 -(defmacro defal 2935,115958 -(defalias 'ibtype:create-action-link-type ibtype:create-action-link-type2991,118127 -(defalias 'ibtype:create-regexp-link-type ibtype:create-regexp-link-type2992,118178 -(defun ibtype:def-symbol 2994,118230 -(defun ibtype:delete 3004,118587 +(defconst hbut:max-len 33,1060 +(defsubst hbut:max-len 40,1301 +(defvar ebut:hattr-save 55,1886 +(defun ebut:act 59,2003 +(defun ebut:alist 70,2405 +(defun ebut:at-p 76,2626 +(defun ebut:create 83,2933 +(defun ebut:delete 105,3934 +(defun ebut:edit 118,4402 +(defun ebut:get 131,4933 +(defun ebut:is-p 200,7456 +(defun ebut:key 205,7644 +(defun ebut:key-of-label-p 212,7882 +(defalias 'ebut:to-key-src ebut:to-key-src217,8088 +(defalias 'ebut:key-src-set-buffer ebut:key-src-set-buffer218,8142 +(defalias 'ebut:key-src-fmt ebut:key-src-fmt219,8204 +(defalias 'ebut:key-to-label ebut:key-to-label220,8259 +(defun ebut:label-p 224,8341 +(defalias 'ebut:label-regexp ebut:label-regexp287,10914 +(defalias 'ebut:label-instances-regexp ebut:label-instances-regexp288,10974 +(defalias 'ebut:label-to-key ebut:label-to-key290,11045 +(defun ebut:list 292,11096 +(defalias 'map-ebut map-ebut314,11938 +(defun ebut:map 316,11971 +(defun ebut:next-occurrence 326,12462 +(defun ebut:operate 341,13141 +(defun ebut:program 450,17339 +(defun ebut:search 481,18772 +(defun ebut:to 560,21424 +(defun ebut:delimit 596,22797 +(defun ebut:match-regexp 623,23865 +(defconst ebut:label-start 634,24305 +(defconst ebut:label-end 636,24406 +(defconst hbut:instance-sep 638,24505 +(defun gbut:act 645,24845 +(defun gbut:delete 660,25460 +(defun gbut:ebut-program 665,25683 +(defun gbut:file 685,26574 +(defun gbut:get 689,26732 +(defun gbut:help 701,27146 +(defun gbut:label-list 712,27569 +(defun gbut:label-p 716,27688 +(defun gbut:to 731,28503 +(defun gbut:key-list 749,29160 +(defun gbut:ebut-key-list 753,29286 +(defun gbut:ibut-key-list 767,29747 +(defun hattr:attributes 780,30256 +(defun hattr:clear 790,30561 +(defun hattr:copy 801,30937 +(defun hattr:emacs-button-attributes 812,31327 +(defun hattr:emacs-button-is-p 825,31820 +(defun hattr:get 832,32109 +(defun hattr:list 836,32243 +(defun hattr:memq 844,32520 +(defun hattr:report 856,32951 +(defun hattr:save 884,33977 +(defun hattr:set 902,34829 +(defalias 'hattr:summarize hattr:summarize906,35008 +(defvar hattr:filename908,35052 +(defun hbut:act 918,35485 +(defun hbut:action 980,38182 +(defun hbut:at-p 991,38518 +(defun hbut:comment 1004,38918 +(defvar hbut:fill-prefix-regexps1037,40145 +(defun hbut:fill-prefix-remove 1061,40993 +(defun hbut:delete 1071,41385 +(defun hbut:funcall 1086,42018 +(defun hbut:get 1116,43240 +(defun hbut:get-key-src 1127,43768 +(defun hbut:is-p 1185,46055 +(defun hbut:key 1190,46214 +(defun hbut:to-key-src 1197,46434 +(defun hbut:key-src-fmt 1204,46753 +(defun hbut:key-src-set-buffer 1220,47403 +(defun hbut:key-to-label 1242,48102 +(defun hbut:label 1263,48786 +(defun hbut:label-list 1270,49032 +(defun hbut:label-p 1274,49186 +(defun hbut:label-regexp 1287,49961 +(defun hbut:label-instances-regexp 1317,50990 +(defun hbut:label-to-key 1352,52229 +(defun hbut:map 1365,52819 +(defvar hbut:syntax-table 1423,55020 +(defun hbut:modify-syntax 1429,55290 +(defun hbut:outside-comment-p 1444,55917 +(defun hbut:rename 1452,56277 +(defun hbut:report 1463,56683 +(defun hbut:source 1522,58617 +(defalias 'hbut:summarize hbut:summarize1537,59190 +(defun hbut:to 1539,59232 +(defvar hbut:current 1546,59560 +(defconst hbut:source-prefix 1549,59665 +(defun hbut:key-list 1556,59996 +(defun hbut:ebut-key-list 1560,60161 +(defun hbut:ibut-key-list 1575,60686 +(defun ibut:act 1589,61229 +(defun ibut:alist 1600,61635 +(defun ibut:at-p 1606,61864 +(defun ibut:at-type-p 1625,62681 +(defun ibut:set-name-and-label-key-p 1639,63291 +(cl-defun ibut:create 1733,66805 +(def-edebug-spec cl-defun1918,73147 +(def-edebug-spec lambda-key-list1923,73294 +(defun ibut:delete 1932,73517 +(defun ibut:delete-occurrence 1964,74689 +(defun ibut:delimit 1973,75016 +(defun ibut:get 2003,76208 +(defun ibut:is-p 2025,77025 +(defun ibut:label-map 2033,77318 +(defun ibut:label-key-match 2045,77907 +(defun ibut:label-p 2056,78336 +(defun ibut:label-regexp 2101,80341 +(defun ibut:label-instances-regexp 2107,80632 +(defun ibut:label-set 2113,80960 +(defun ibut:label-sort-keys 2137,82051 +(defun ibut:list 2156,82681 +(defun ibut:key 2178,83532 +(defalias 'ibut:to-key-src ibut:to-key-src2185,83775 +(defalias 'ibut:key-to-label ibut:key-to-label2186,83823 +(defalias 'ibut:label-to-key ibut:label-to-key2187,83873 +(defalias 'map-ibut map-ibut2188,83923 +(defun ibut:map 2190,83965 +(defun ibut:next-occurrence 2202,84456 +(defun ibut:operate 2217,85201 +(defun ibut:org-at-read-only-p 2424,94729 +(defun ibut:insert-text 2443,95273 +(defun ibut:previous-occurrence 2527,98694 +(defun ibut:program 2542,99425 +(defun ibut:rename 2586,101528 +(defalias 'ibut:summarize ibut:summarize2608,102547 +(defun ibut:to 2610,102589 +(defun ibut:at-to-name-p 2658,104390 +(defun ibut:to-name 2682,105188 +(defun ibut:to-text 2715,106500 +(defconst ibut:label-start 2766,108553 +(defconst ibut:label-end 2768,108654 +(defvar ibut:label-separator 2771,108754 +(defvar ibut:label-separator-regexp 2779,109071 +(defmacro defib 2786,109411 +(def-edebug-spec defib2821,111048 +(def-edebug-spec lambda-list2826,111188 +(defalias 'ibtype:create ibtype:create2831,111306 +(defun ibtype:activate-link 2833,111341 +(defmacro defil 2845,111793 +(defmacro defal 2942,116131 +(defalias 'ibtype:create-action-link-type ibtype:create-action-link-type2998,118300 +(defalias 'ibtype:create-regexp-link-type ibtype:create-regexp-link-type2999,118351 +(defun ibtype:def-symbol 3001,118403 +(defun ibtype:delete 3011,118760 hgnus.el,110 (defun Gnus-init 54,1683 @@ -412,53 +412,53 @@ hib-social.el,1373 hibtypes.el,1548 (defib python-tb-previous-line 76,2614 (defib org-id 104,3810 -(defun org-id:help 128,4880 -(defib pathname 153,5906 -(defun mail-address-at-p 273,11891 -(defib mail-address 284,12381 -(defib org-link-outside-org-mode 324,14288 -(defib annot-bib 345,15311 -(defun markdown-follow-link-p 372,16466 -(defun markdown-follow-inline-link-p 393,17131 -(defib markdown-internal-link 420,18415 -(defib rfc-toc 450,19959 -(defib id-cflow 475,21029 -(defib ctags 522,23083 -(defib etags 548,24485 -(defib cscope 585,26390 -(defib text-toc 612,27542 -(defib dir-summary 644,29124 -(defib rfc 680,30694 -(defib man-apropos 714,32148 -(defun hlink 742,33404 -(defun hlink:parse-label-and-file 762,34397 -(defconst elink:start 784,35314 -(defconst elink:end 786,35419 -(defib elink 789,35517 -(defconst glink:start 799,35918 -(defconst glink:end 801,36021 -(defib glink 804,36117 -(defconst ilink:start 813,36407 -(defconst ilink:end 815,36512 -(defib ilink 818,36610 -(defib pathname-line-and-column 833,37266 -(defib ipython-stack-frame 861,38859 -(defib ripgrep-msg 903,41021 -(defib grep-msg 949,43162 -(defun hib-python-traceback 1017,47011 -(defib debugger-source 1028,47623 -(defib elisp-compiler-msg 1114,51664 -(defib patch-msg 1216,56735 -(defib texinfo-ref 1243,57939 -(defib gnus-push-button 1328,62537 -(defib Info-node 1340,63079 -(defib hyp-address 1373,64768 -(defib hyp-source 1392,65782 -(defconst action:start 1419,66901 -(defconst action:end 1422,67010 -(defib action 1431,67360 -(defun action:help 1526,71596 -(defib completion 1553,72688 +(defun org-id:help 137,5252 +(defib pathname 162,6278 +(defun mail-address-at-p 282,12263 +(defib mail-address 293,12753 +(defib org-link-outside-org-mode 333,14660 +(defib annot-bib 354,15683 +(defun markdown-follow-link-p 381,16838 +(defun markdown-follow-inline-link-p 402,17503 +(defib markdown-internal-link 429,18787 +(defib rfc-toc 459,20331 +(defib id-cflow 484,21401 +(defib ctags 531,23455 +(defib etags 557,24857 +(defib cscope 594,26762 +(defib text-toc 621,27914 +(defib dir-summary 653,29496 +(defib rfc 689,31066 +(defib man-apropos 723,32520 +(defun hlink 751,33776 +(defun hlink:parse-label-and-file 771,34769 +(defconst elink:start 793,35686 +(defconst elink:end 795,35791 +(defib elink 798,35889 +(defconst glink:start 808,36290 +(defconst glink:end 810,36393 +(defib glink 813,36489 +(defconst ilink:start 822,36779 +(defconst ilink:end 824,36884 +(defib ilink 827,36982 +(defib pathname-line-and-column 842,37638 +(defib ipython-stack-frame 870,39231 +(defib ripgrep-msg 912,41393 +(defib grep-msg 958,43534 +(defun hib-python-traceback 1026,47383 +(defib debugger-source 1037,47995 +(defib elisp-compiler-msg 1123,52036 +(defib patch-msg 1225,57107 +(defib texinfo-ref 1252,58311 +(defib gnus-push-button 1337,62909 +(defib Info-node 1349,63451 +(defib hyp-address 1382,65140 +(defib hyp-source 1401,66154 +(defconst action:start 1428,67273 +(defconst action:end 1431,67382 +(defib action 1440,67732 +(defun action:help 1535,71968 +(defib completion 1562,73060 hinit.el,145 (defvar hyperb:user-email 22,623 @@ -768,10 +768,10 @@ hmouse-tag.el,3201 (defun smart-java-packages 1291,54458 (defun smart-library-symbol 1362,57169 (defun smart-tags-display 1377,57728 -(defun smart-tags-file-path 1411,59211 -(defun smart-tags-org-src-block-p 1434,60062 -(defun smart-tags-file-list 1439,60250 -(defun smart-tags-noselect-function 1476,61974 +(defun smart-tags-file-path 1411,59210 +(defun smart-tags-org-src-block-p 1434,60061 +(defun smart-tags-file-list 1439,60249 +(defun smart-tags-noselect-function 1476,61973 hpath.el,5601 (defcustom hpath:auto-completing-read-modes 42,1401 @@ -842,67 +842,67 @@ hpath.el,5601 (defun hpath:remote-at-p 780,35235 (defun hpath:remote-p 848,38029 (defun hpath:at-p 919,40591 -(defun hpath:call 970,43041 -(defun hpath:is-path-variable-p 1065,47520 -(defun hpath:choose-from-path-variable 1072,47820 -(defun hpath:delimited-possible-path 1089,48708 -(defun hpath:display-buffer 1142,51084 -(defun hpath:display-buffer-other-frame 1158,51820 -(defun hpath:display-buffer-function 1179,52615 -(defun hpath:display-path-function 1184,52871 -(defun hpath:resolve 1189,53122 -(defun hpath:expand 1211,54136 -(defun hpath:prepend-shell-directory 1240,55608 -(defvar hpath:compressed-suffix-regexp 1274,57406 -(defun hpath:expand-with-variable 1277,57562 -(defun hpath:file-line-and-column 1315,59281 -(defun hpath:find-noselect 1333,60158 -(defun hpath:find 1342,60507 -(defun hpath:to-markup-anchor 1507,67492 -(defun hpath:find-executable 1572,70307 -(defun hpath:find-line 1587,70811 -(defun hpath:find-other-frame 1607,71581 -(defun hpath:find-other-window 1622,72059 -(defun hpath:get-external-display-alist 1632,72554 -(defun hpath:is-p 1651,73543 -(defun hpath:push-tag-mark 1753,78383 -(defun hpath:relative-arguments 1767,78895 -(defun hpath:relative-to 1777,79325 -(defun hpath:rfc 1809,80613 -(defun hpath:start-end 1814,80786 -(defun hpath:return-one-value 1843,81990 -(defun hpath:substitute-value 1881,83671 -(defun hpath:substitute-var 1925,85326 -(defun hpath:symlink-referent 1963,86792 -(defun hpath:symlink-expand 1978,87387 -(defun hpath:to-line 2013,89026 -(defun hpath:trim 2022,89313 -(defun hpath:normalize 2031,89651 -(defun hpath:validate 2039,90037 -(defun hpath:find-file-urls-p 2062,90944 -(defun hpath:handle-urls 2068,91203 -(defalias 'hyperb:substitute-in-file-namehyperb:substitute-in-file-name2085,91945 -(defun substitute-in-file-name 2088,92036 -(defun hpath:enable-find-file-urls 2101,92678 -(defun hpath:disable-find-file-urls 2132,93808 -(defun hpath:find-file-urls-mode 2161,94843 -(defun hpath:url-at-p 2173,95330 -(defun hpath:url-p 2184,95821 -(defun hpath:www-at-p 2195,96216 -(defun hpath:www-p 2211,96913 -(defun hpath:command-string 2219,97236 -(defun hpath:display-where-function 2228,97643 -(defun hpath:remote-available-p 2238,98113 -(defun hpath:remote-default-user 2257,98960 -(defun hpath:delete-trailer 2271,99416 -(defun hpath:exists-p 2279,99700 -(defun hpath:find-file-mailcap 2310,100697 -(defun hpath:find-program 2326,101213 -(defun hpath:match 2347,102084 -(defun hpath:get-single-string-variable-value 2361,102684 -(defun hpath:substitute-dir 2391,103778 -(defun hpath:substitute-match-value 2457,106861 -(defun hpath:substitute-var-name 2519,109077 +(defun hpath:call 974,43196 +(defun hpath:is-path-variable-p 1069,47675 +(defun hpath:choose-from-path-variable 1076,47975 +(defun hpath:delimited-possible-path 1093,48863 +(defun hpath:display-buffer 1146,51239 +(defun hpath:display-buffer-other-frame 1162,51975 +(defun hpath:display-buffer-function 1183,52770 +(defun hpath:display-path-function 1188,53026 +(defun hpath:resolve 1193,53277 +(defun hpath:expand 1215,54291 +(defun hpath:prepend-shell-directory 1244,55763 +(defvar hpath:compressed-suffix-regexp 1278,57561 +(defun hpath:expand-with-variable 1281,57717 +(defun hpath:file-line-and-column 1319,59436 +(defun hpath:find-noselect 1337,60313 +(defun hpath:find 1346,60662 +(defun hpath:to-markup-anchor 1511,67647 +(defun hpath:find-executable 1576,70462 +(defun hpath:find-line 1591,70966 +(defun hpath:find-other-frame 1611,71736 +(defun hpath:find-other-window 1626,72214 +(defun hpath:get-external-display-alist 1636,72709 +(defun hpath:is-p 1655,73698 +(defun hpath:push-tag-mark 1757,78538 +(defun hpath:relative-arguments 1771,79050 +(defun hpath:relative-to 1781,79480 +(defun hpath:rfc 1813,80768 +(defun hpath:start-end 1818,80941 +(defun hpath:return-one-value 1847,82145 +(defun hpath:substitute-value 1885,83826 +(defun hpath:substitute-var 1929,85481 +(defun hpath:symlink-referent 1967,86947 +(defun hpath:symlink-expand 1982,87542 +(defun hpath:to-line 2017,89181 +(defun hpath:trim 2026,89468 +(defun hpath:normalize 2035,89806 +(defun hpath:validate 2043,90192 +(defun hpath:find-file-urls-p 2066,91099 +(defun hpath:handle-urls 2072,91358 +(defalias 'hyperb:substitute-in-file-namehyperb:substitute-in-file-name2089,92100 +(defun substitute-in-file-name 2092,92191 +(defun hpath:enable-find-file-urls 2105,92833 +(defun hpath:disable-find-file-urls 2136,93963 +(defun hpath:find-file-urls-mode 2165,94998 +(defun hpath:url-at-p 2177,95485 +(defun hpath:url-p 2188,95976 +(defun hpath:www-at-p 2199,96371 +(defun hpath:www-p 2215,97068 +(defun hpath:command-string 2223,97391 +(defun hpath:display-where-function 2232,97798 +(defun hpath:remote-available-p 2242,98268 +(defun hpath:remote-default-user 2261,99115 +(defun hpath:delete-trailer 2275,99571 +(defun hpath:exists-p 2283,99855 +(defun hpath:find-file-mailcap 2314,100852 +(defun hpath:find-program 2330,101368 +(defun hpath:match 2351,102239 +(defun hpath:get-single-string-variable-value 2365,102839 +(defun hpath:substitute-dir 2395,103933 +(defun hpath:substitute-match-value 2461,107016 +(defun hpath:substitute-var-name 2523,109232 hrmail.el,723 (defun Rmail-init 47,1512 @@ -1520,49 +1520,49 @@ hui.el,2341 (defun hui:gbut-delete 556,22313 (defun hui:gbut-edit 571,22975 (defun hui:gbut-link-directly 661,26470 -(defun hui:gbut-rename 692,27717 -(defun hui:gibut-create 704,28183 -(defun hui:hbut-act 732,29237 -(defun hui:hbut-buf 740,29608 -(defun hui:hbut-current-act 765,30370 -(defun hui:hbut-delete 775,30745 -(defun hui:hbut-help 817,32590 -(defun hui:hbut-label 858,34076 -(defun hui:hbut-label-default 870,34603 -(defun hui:hbut-rename 885,35338 -(defun hui:hbut-report 895,35694 -(defalias 'hui:hbut-summarize hui:hbut-summarize906,36046 -(defun hui:ibut-act 908,36096 -(defun hui:ibut-create 923,36659 -(defun hui:ibut-edit 970,38784 -(defun hui:ibut-label-create 1040,41461 -(defun hui:ibut-rename 1078,43336 -(defun hui:ebut-link-directly 1112,44491 -(defun hui:ibut-link-directly 1205,48047 -(defun hui:action 1311,52290 -(defun hui:actype 1362,54002 -(defun hui:buf-writable-err 1381,54995 -(defvar hui:ignore-buffers-regexp 1401,55858 -(defun hui:ebut-delete-op 1404,56028 -(defun hui:ebut-message 1435,57281 -(defun hui:ebut-unmark 1446,57685 -(defun hui:file-find 1506,60148 -(defun hui:hbut-operate 1513,60418 -(defun hui:hbut-term-highlight 1556,62443 -(defun hui:hbut-term-unhighlight 1570,62845 -(defun hui:help-ebut-highlight 1579,63131 -(defun hui:htype-delete 1585,63379 -(defun hui:htype-help 1596,63786 -(defun hui:htype-help-current-window 1647,65554 -(defun hui:ibut-delete-op 1654,65919 -(defun hui:ibut-message 1680,67070 -(defun hui:key-dir 1691,67474 -(defun hui:key-src 1700,67822 -(defun hui:ebut-link-create 1709,68193 -(defun hui:ibut-link-create 1732,69392 -(defun hui:link-possible-types 1759,70756 -(defun hui:list-remove-text-properties 1891,76018 -(defvar hui:ebut-label-prev 1901,76408 +(defun hui:gbut-rename 694,27748 +(defun hui:gibut-create 706,28214 +(defun hui:hbut-act 734,29268 +(defun hui:hbut-buf 742,29639 +(defun hui:hbut-current-act 767,30401 +(defun hui:hbut-delete 777,30776 +(defun hui:hbut-help 819,32621 +(defun hui:hbut-label 860,34107 +(defun hui:hbut-label-default 872,34634 +(defun hui:hbut-rename 887,35369 +(defun hui:hbut-report 897,35725 +(defalias 'hui:hbut-summarize hui:hbut-summarize908,36077 +(defun hui:ibut-act 910,36127 +(defun hui:ibut-create 925,36690 +(defun hui:ibut-edit 972,38815 +(defun hui:ibut-label-create 1042,41492 +(defun hui:ibut-rename 1080,43367 +(defun hui:ebut-link-directly 1114,44522 +(defun hui:ibut-link-directly 1210,48171 +(defun hui:action 1319,52507 +(defun hui:actype 1370,54219 +(defun hui:buf-writable-err 1389,55212 +(defvar hui:ignore-buffers-regexp 1409,56075 +(defun hui:ebut-delete-op 1412,56245 +(defun hui:ebut-message 1443,57498 +(defun hui:ebut-unmark 1454,57902 +(defun hui:file-find 1514,60365 +(defun hui:hbut-operate 1521,60635 +(defun hui:hbut-term-highlight 1564,62660 +(defun hui:hbut-term-unhighlight 1578,63062 +(defun hui:help-ebut-highlight 1587,63348 +(defun hui:htype-delete 1593,63596 +(defun hui:htype-help 1604,64003 +(defun hui:htype-help-current-window 1655,65771 +(defun hui:ibut-delete-op 1662,66136 +(defun hui:ibut-message 1688,67287 +(defun hui:key-dir 1699,67691 +(defun hui:key-src 1708,68039 +(defun hui:ebut-link-create 1717,68410 +(defun hui:ibut-link-create 1740,69609 +(defun hui:link-possible-types 1777,71236 +(defun hui:list-remove-text-properties 1913,76752 +(defvar hui:ebut-label-prev 1923,77142 hvar.el,272 (defvar var::append-list 34,1095 diff --git a/hargs.el b/hargs.el index eac839e1aa..2a5cfc4c08 100644 --- a/hargs.el +++ b/hargs.el @@ -3,7 +3,7 @@ ;; Author: Bob Weiner ;; ;; Orig-Date: 31-Oct-91 at 23:17:35 -;; Last-Mod: 9-Aug-23 at 00:16:24 by Bob Weiner +;; Last-Mod: 28-Aug-23 at 17:59:39 by Bob Weiner ;; ;; SPDX-License-Identifier: GPL-3.0-or-later ;; @@ -105,10 +105,11 @@ of (string-matched start-pos end-pos). Optional EXCLUDE-REGEXP is compared against the match string with its delimiters included; any string that matches this regexp is ignored." (let* ((opoint (point)) - ;; This initial limit if the forward search limit for start delimiters + ;; This initial limit is the forward search limit for start delimiters (limit (if start-regexp-flag opoint - (min (+ opoint (1- (length start-delim))) + ;; (min (+ opoint (1- (length start-delim))) + (min (+ opoint (length start-delim)) (point-max)))) (start-search-func (if start-regexp-flag 're-search-forward 'search-forward)) (end-search-func (if end-regexp-flag 're-search-forward 'search-forward)) diff --git a/hbut.el b/hbut.el index 0aa9609d85..7267fe2714 100644 --- a/hbut.el +++ b/hbut.el @@ -3,7 +3,7 @@ ;; Author: Bob Weiner ;; ;; Orig-Date: 18-Sep-91 at 02:57:09 -;; Last-Mod: 28-Aug-23 at 12:47:30 by Bob Weiner +;; Last-Mod: 29-Aug-23 at 01:38:44 by Bob Weiner ;; ;; SPDX-License-Identifier: GPL-3.0-or-later ;; @@ -22,7 +22,7 @@ (eval-and-compile (mapc #'require '(cl-lib elisp-mode help-mode hversion hmoccur hbmap htz hbdata hact hui-select view))) -(require 'hmouse-drv) ;For `hui--ignore-action-key-depress-prev-point'. +(require 'hmouse-drv) ; For `hui--ignore-action-key-depress-prev-point'. ;;; ************************************************************************ ;;; Public declarations @@ -1769,7 +1769,6 @@ If a new button is created, store its attributes in the symbol, (unwind-protect (progn (unless but-sym - ;; (hattr:clear 'hbut:current) ;; Commented out since was causing ibut:at-p to fail. ;; Set attributes of button at point, if any (setq name-and-lbl-key-flag (ibut:set-name-and-label-key-p)) @@ -1784,14 +1783,14 @@ If a new button is created, store its attributes in the symbol, (progn (when (or but-sym-flag name-and-lbl-key-flag) (setq text-start (or (hattr:get 'hbut:current 'lbl-start) (point)) - text-end (hattr:get 'hbut:current 'lbl-end))) - (unless (and text-start - (<= text-start (point)) - text-end - (>= text-end (point))) - ;; Move to text of ibut before trying to activate it - ;; (may be on name) - (goto-char (+ (or text-start (point)) 2))) + text-end (hattr:get 'hbut:current 'lbl-end)) + (unless (and text-start + (<= text-start (point)) + text-end + (>= text-end (point))) + ;; Move to text of ibut before trying to activate it + ;; (may be on name) + (goto-char (+ (or text-start (point)) 2)))) (setq ibtype-point (point)) (while (and (not is-type) types) (setq itype (car types)) @@ -2048,10 +2047,11 @@ non-nil)." There may be multiple results if there are numbered instances with the same label. Names are returned in the order they are first encountered." - (apply #'set:create - (ibut:map - (lambda (lbl _start _end) (ibut:label-to-key lbl)) - (ibut:label-instances-regexp name-key)))) + (when (stringp name-key) + (apply #'set:create + (ibut:map + (lambda (lbl _start _end) (ibut:label-to-key lbl)) + (ibut:label-instances-regexp name-key))))) (defun ibut:label-p (&optional as-label start-delim end-delim pos-flag two-lines-flag) "Return key for the implicit button name that point is within, else nil. @@ -2338,7 +2338,10 @@ Summary of operations based on inputs (name arg comes from \\='hbut:current attr (delete-region (goto-char (hattr:get 'hbut:current 'name-start)) (hattr:get 'hbut:current 'name-end)) (when (looking-at ibut:label-separator-regexp) - (delete-region (match-beginning 0) (match-end 0)))))))) + (delete-region (match-beginning 0) (match-end 0)))) + ;; Skip past any likely opening delim preceding button text. + (skip-chars-forward "\"<{[|") + (setq start (point)))))) (t ;; Above flag is 't when we are creating the first instance ;; of the button name @@ -2381,10 +2384,11 @@ Summary of operations based on inputs (name arg comes from \\='hbut:current attr (ibut:insert-text 'hbut:current))) (goto-char (or start (max (- (point) 2) (point-min)))) - ;; Skip past any inserted comment char - (skip-syntax-forward "-<") - ;; Skip past any name or label opening delim chars - (skip-chars-forward "\"<{[| \t\n\r")) + (when start + ;; Skip past any inserted comment char + (skip-syntax-forward "-<") + ;; Skip past any name or label opening delim chars + (skip-chars-forward "\"<{[| \t\n\r"))) ;; Set all in-memory hbut attributes for any button at point (ibut:at-p) @@ -2438,10 +2442,11 @@ Summary of operations based on inputs (name arg comes from \\='hbut:current attr (defun ibut:insert-text (ibut) "Space, delimit and insert the text part of IBUT." - (cond ((looking-at ibut:label-separator-regexp) - (goto-char (match-end 0))) - ((not (or (string-empty-p (or (hattr:get ibut 'name) "")))) - (insert ibut:label-separator))) + (when (hattr:get ibut 'name) + (cond ((looking-at ibut:label-separator-regexp) + (goto-char (match-end 0))) + ((not (or (string-empty-p (or (hattr:get ibut 'name) "")))) + (insert ibut:label-separator)))) (let* ((orig-actype (or (hattr:get ibut 'actype) (hattr:get ibut 'categ))) (actype (or (actype:elisp-symbol orig-actype) @@ -2515,7 +2520,9 @@ Summary of operations based on inputs (name arg comes from \\='hbut:current attr ('nil (error "(ibut:insert-text): actype must be a Hyperbole actype or Lisp function symbol, not '%s'" orig-actype)) ;; Generic action button type (_ (insert (format "<%s%s%s>" (actype:def-symbol actype) (if args " " "") - (if args (hypb:format-args args) ""))))))) + (if args (hypb:format-args args) ""))))) + (unless (looking-at "\\s-\\|\\'") + (insert " ")))) (defun ibut:previous-occurrence (lbl-key &optional buffer) "Move point to previous occurrence of an implicit button with LBL-KEY. diff --git a/hibtypes.el b/hibtypes.el index 61eae1e2fa..fabf1aeb49 100644 --- a/hibtypes.el +++ b/hibtypes.el @@ -3,7 +3,7 @@ ;; Author: Bob Weiner ;; ;; Orig-Date: 19-Sep-91 at 20:45:31 -;; Last-Mod: 28-Aug-23 at 02:17:49 by Bob Weiner +;; Last-Mod: 28-Aug-23 at 16:02:32 by Bob Weiner ;; ;; SPDX-License-Identifier: GPL-3.0-or-later ;; @@ -112,7 +112,7 @@ If the referenced location is found, return non-nil." (end (when bounds (cdr bounds))) m) ;; Ignore ID definitions or when not on a possible ID - (when id + (when (and id (string-match "\\`[:alnum:][-[:alnum:]:.@]+\\'" id)) (when (and start end) (ibut:label-set id start end)) (if (and (not assist-flag) @@ -120,9 +120,18 @@ If the referenced location is found, return non-nil." (re-search-forward ":\\(CUSTOM_\\)?ID:[ \t]+" (line-end-position) t))) (hact 'message "On ID definition; use {C-u M-RET} to copy a link to an ID.") - (when (let ((inhibit-message t)) ;; Inhibit org-id-find status msgs - (setq m (or (and (featurep 'org-roam) (org-roam-id-find id 'marker)) - (org-id-find id 'marker)))) + (when (let ((inhibit-message t) ;; Inhibit org-id-find status msgs + (obuf (current-buffer)) + (omode major-mode)) + (prog1 (setq m (or (and (featurep 'org-roam) + (org-roam-id-find id 'marker)) + (org-id-find id 'marker))) + ;; org-find-id sets current buffer mode to Org + ;; mode even if ID is not found; switch it back + ;; when necessary. + (when (and (eq obuf (current-buffer)) + (not (eq omode major-mode))) + (funcall omode)))) (hact 'link-to-org-id-marker m))))))) (defun org-id:help (_hbut) diff --git a/hmouse-tag.el b/hmouse-tag.el index 746bf09cbe..e2c6f91b1a 100644 --- a/hmouse-tag.el +++ b/hmouse-tag.el @@ -3,7 +3,7 @@ ;; Author: Bob Weiner ;; ;; Orig-Date: 24-Aug-91 -;; Last-Mod: 28-Aug-23 at 00:23:22 by Bob Weiner +;; Last-Mod: 28-Aug-23 at 16:19:42 by Bob Weiner ;; ;; SPDX-License-Identifier: GPL-3.0-or-later ;; @@ -1375,7 +1375,7 @@ See the \"${hyperb:dir}/smart-clib-sym\" script for more information." found))) (defun smart-tags-display (tag next &optional list-of-tags-tables) - (when next (setq tag nil)) + (when next (setq tag nil)) (let* ((tags-table-list (or list-of-tags-tables (and (boundp 'tags-table-list) (not (smart-tags-org-src-block-p)) diff --git a/hpath.el b/hpath.el index ae953051be..a0e2255f52 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: 27-Aug-23 at 18:36:02 by Bob Weiner +;; Last-Mod: 28-Aug-23 at 16:48:31 by Bob Weiner ;; ;; SPDX-License-Identifier: GPL-3.0-or-later ;; @@ -928,44 +928,48 @@ optional NON-EXIST, nonexistent local paths are allowed. Absolute pathnames must begin with a `/' or `~'." (let ((path (hpath:delimited-possible-path non-exist)) subpath) + (when path + (setq path (string-trim path))) (when (and path (not non-exist) (string-match hpath:prefix-regexp path) (not (string-equal (match-string 0 path) path))) (setq non-exist t)) - (cond ((and path (file-readable-p path)) - path) - ((and path - ;; Don't allow more than one set of grouping chars - (not (string-match-p "\)\\s-*\(\\|\\]\\s-*\\[\\|\}\\s-*\{" path)) - ;; With point inside a path variable, return the path that point is on or to the right of. - (setq subpath (or (and (setq subpath (hargs:delimited "[:\"\']\\|^\\s-*" "[:\"\']\\|\\s-*$" t t nil "[\t\n\r\f]\\|[;:] \\| [;:]")) - (not (string-match-p "[:;\t\n\r\f]" subpath)) - subpath) - (and (setq subpath (hargs:delimited "[;\"\']\\|^\\s-*" "[;\"\']\\|\\s-*$" t t nil "[\t\n\r\f]\\|[;:] \\| [;:]")) - (not (string-match-p "[;\t\n\r\f]\\|:[^:]*:" subpath)) - subpath))) - ;; Handle anchored or action prefix char paths in the - ;; following clause; otherwise, might just be looking - ;; at part of the path - (and subpath (not (or (string-match-p "#" subpath) - (string-match-p hpath:prefix-regexp subpath)))) - (setq subpath - (if subpath - (cond ((and (string-match "\\`\\s-*\\([^; \t]+\\)" subpath) - (executable-find (match-string 1 subpath))) - ;; Could be a shell command from a semicolon separated - ;; list; ignore if so - nil) - (t (expand-file-name subpath))) - ;; Only default to current path if know are within a PATH value - (when (string-match-p hpath:path-variable-value-regexp path) - "."))) - (hpath:is-p subpath type non-exist)) - subpath) - ((hpath:is-p path type non-exist)) - ;; Local file URLs - ;; ((hpath:is-p (hargs:delimited "file://" "[ \t\n\r\"\'\}]" nil t))) - ((hpath:remote-at-p)) - ((hpath:www-at-p) nil)))) + (unless (and path (or (string-empty-p path) + (string-match "::" path))) + (cond ((and path (file-readable-p path)) + path) + ((and path + ;; Don't allow more than one set of grouping chars + (not (string-match-p "\)\\s-*\(\\|\\]\\s-*\\[\\|\}\\s-*\{" path)) + ;; With point inside a path variable, return the path that point is on or to the right of. + (setq subpath (or (and (setq subpath (hargs:delimited "[:\"\']\\|^\\s-*" "[:\"\']\\|\\s-*$" t t nil "[\t\n\r\f]\\|[;:] \\| [;:]")) + (not (string-match-p "[:;\t\n\r\f]" subpath)) + subpath) + (and (setq subpath (hargs:delimited "[;\"\']\\|^\\s-*" "[;\"\']\\|\\s-*$" t t nil "[\t\n\r\f]\\|[;:] \\| [;:]")) + (not (string-match-p "[;\t\n\r\f]\\|:[^:]*:" subpath)) + subpath))) + ;; Handle anchored or action prefix char paths in the + ;; following clause; otherwise, might just be looking + ;; at part of the path + (and subpath (not (or (string-match-p "#" subpath) + (string-match-p hpath:prefix-regexp subpath)))) + (setq subpath + (if subpath + (cond ((and (string-match "\\`\\s-*\\([^; \t]+\\)" subpath) + (executable-find (match-string 1 subpath))) + ;; Could be a shell command from a semicolon separated + ;; list; ignore if so + nil) + (t (expand-file-name subpath))) + ;; Only default to current path if know are within a PATH value + (when (string-match-p hpath:path-variable-value-regexp path) + "."))) + (hpath:is-p subpath type non-exist)) + subpath) + ((hpath:is-p path type non-exist)) + ;; Local file URLs + ;; ((hpath:is-p (hargs:delimited "file://" "[ \t\n\r\"\'\}]" nil t))) + ((hpath:remote-at-p)) + ((hpath:www-at-p) nil))))) (defun hpath:call (func path &optional non-exist) "Call FUNC with a PATH and optional NON-EXIST flag. diff --git a/hui.el b/hui.el index 9ae1cc34be..6092f9434e 100644 --- a/hui.el +++ b/hui.el @@ -3,7 +3,7 @@ ;; Author: Bob Weiner ;; ;; Orig-Date: 19-Sep-91 at 21:42:03 -;; Last-Mod: 28-Aug-23 at 12:49:04 by Bob Weiner +;; Last-Mod: 29-Aug-23 at 01:11:29 by Bob Weiner ;; ;; SPDX-License-Identifier: GPL-3.0-or-later ;; @@ -666,6 +666,8 @@ button. With optional prefix ARG non-nil, insert a named implicit button. See also documentation for `hui:link-possible-types'." (interactive "P") + + (hattr:clear 'hbut:current) (save-window-excursion (when (or (= (count-windows) 1) (= (hypb:count-visible-windows) 1)) @@ -1125,6 +1127,7 @@ from those instead. See also documentation for (assist-key-clear-variables) (hmouse-choose-link-and-referent-windows))) + (hattr:clear 'hbut:current) (unless (called-interactively-p 'any) ;; Clear smart key variables so this does not improperly reference ;; values left over from a prior drag or click. @@ -1136,6 +1139,11 @@ from those instead. See also documentation for (list depress-window release-window) (hmouse-choose-link-and-referent-windows)) + (select-window referent-window) + ;; This sets hbut:current to link-to button attributes. + (setq link-types (hui:link-possible-types) + num-types (length link-types)) + (select-window link-but-window) ;; It is rarely possible that a *Warnings* buffer popup might have ;; displaced the button src buffer in the depress window, so switch @@ -1162,9 +1170,6 @@ from those instead. See also documentation for "ebut-link-directly" "Create button named: ") lbl-key (hbut:label-to-key but-lbl)))) - (select-window referent-window) - (setq link-types (hui:link-possible-types) - num-types (length link-types)) ;; num-types is the number of possible link types to choose among (cond ((= num-types 0) @@ -1226,6 +1231,7 @@ drag from a window to another window's modeline." (append (hmouse-choose-link-and-referent-windows) current-prefix-arg))) + (hattr:clear 'hbut:current) (unless (called-interactively-p 'any) ;; Clear smart key variables so this does not improperly reference ;; values left over from a prior drag or click. @@ -1238,6 +1244,11 @@ drag from a window to another window's modeline." (list depress-window release-window) (hmouse-choose-link-and-referent-windows)) + (select-window referent-window) + ;; This sets hbut:current to link-to button attributes. + (setq link-types (hui:link-possible-types) + num-types (length link-types)) + (select-window link-but-window) ;; It is rarely possible that a *Warnings* buffer popup might have ;; displaced the button src buffer in the depress window, so switch @@ -1264,9 +1275,6 @@ drag from a window to another window's modeline." "ibut-link-directly" "Name for implicit button: ") name-key (hbut:label-to-key but-name))) - (select-window referent-window) - (setq link-types (hui:link-possible-types) - num-types (length link-types)) ;; num-types is the number of possible link types to choose among (cond ((= num-types 0) @@ -1740,9 +1748,7 @@ which to create button. BUT-DIR is the directory of BUT-LOC. TYPE-AND-ARGS is the action type for the button followed by any arguments it requires. Any text properties are removed from string arguments." - ;; Don't set 'name attribute here since this may be a rename where - ;; we need to use the existing name attribute before renaming to - ;; label version of `name-key'. + (hattr:set 'hbut:current 'categ 'implicit) (hattr:set 'hbut:current 'loc but-loc) (hattr:set 'hbut:current 'dir but-dir) @@ -1754,7 +1760,19 @@ string arguments." (unless (and but-loc (or (equal (buffer-name) but-loc) (eq (current-buffer) but-loc))) (hbut:key-src-set-buffer but-loc)) - (ibut:operate (ibut:key-to-label name-key) edit-flag)) + (if edit-flag + (if name-key + (ibut:operate (ibut:key-to-label name-key) t) + (ibut:operate nil t)) + (if name-key + (if (hattr:get 'hbut:current 'name) + ;; Don't set 'name attribute here since is a rename where + ;; we need to use the existing name attribute before renaming to + ;; label version of `name-key'. + (ibut:operate (ibut:key-to-label name-key)) + (hattr:set 'hbut:current 'name (ibut:key-to-label name-key)) + (ibut:operate)) + (ibut:operate)))) (defun hui:link-possible-types () "Return list of possible link action types during editing of a Hyperbole button. @@ -1788,105 +1806,109 @@ Buffer without File link-to-buffer-tmp" (let (val hbut-sym lbl-key) - (delq nil - (list (cond ((and (featurep 'org-id) - (cond ((save-excursion - (beginning-of-line) - (when (looking-at "[ \t]*:ID:[ \t]+\\([^ \t\r\n\f]+\\)") - ;; Org ID definition - (list 'link-to-org-id (match-string 1))))) - (t (let* ((id (thing-at-point 'symbol t)) ;; Could be a uuid or some other form of id - (bounds (when id (bounds-of-thing-at-point 'symbol))) - (start (when bounds (car bounds))) - (case-fold-search t)) - ;; Org ID link - must have id: prefix or is ignored. - (when start - (save-excursion - (goto-char (max (- start 3) (point-min))) - (when (looking-at "\\bid:") - (list 'link-to-org-id id))))))))) - - (t (cond ((and (prog1 (setq hbut-sym (hbut:at-p)) - ;; Next line forces use of any ibut name in the link. - (save-excursion (ibut:at-to-name-p hbut-sym))) - (setq lbl-key (hattr:get hbut-sym 'lbl-key)) - (eq (current-buffer) (get-file-buffer (gbut:file)))) - (list 'link-to-gbut lbl-key)) - ((and hbut-sym (eq (hattr:get hbut-sym 'categ) 'explicit)) - (list 'link-to-ebut lbl-key)) - (hbut-sym - (list 'link-to-ibut lbl-key (or buffer-file-name (buffer-name)))) - ((and (require 'bookmark) - (derived-mode-p 'bookmark-bmenu-mode) - (list 'link-to-bookmark (bookmark-bmenu-bookmark)))) - ((let (node) - (cond ((derived-mode-p 'Info-mode) - (if (and Info-current-node - (member Info-current-node - (Info-index-nodes Info-current-file)) - (Info-menu-item-at-p)) - (let ((hargs:reading-type 'Info-index-item)) - (list 'link-to-Info-index-item (hargs:at-p))) - (let ((hargs:reading-type 'Info-node)) - (list 'link-to-Info-node (hargs:at-p))))) - ((and (derived-mode-p #'texinfo-mode) - (save-excursion - (beginning-of-line) - (or (looking-at "@node ") - (re-search-backward "^@node " nil t)))) - (require 'texnfo-upd) - (setq node (texinfo-copy-node-name)) - (list 'link-to-texinfo-node buffer-file-name node)) - ((hmail:reader-p) - (list 'link-to-mail - (list (rmail:msg-id-get) buffer-file-name)))))) - (t (cond - ((let ((hargs:reading-type 'directory)) - (setq val (hargs:at-p t))) - (list 'link-to-directory val)) - ((let ((hargs:reading-type 'file)) - (setq val (hargs:at-p t))) - (list 'link-to-file val (point))) - ((derived-mode-p #'kotl-mode) - (list 'link-to-kcell buffer-file-name (kcell-view:idstamp))) - ;; If link is within an outline-regexp prefix, use - ;; a link-to-string-match. - ((and (boundp 'outline-regexp) - (stringp outline-regexp) - (save-excursion - (<= (point) - (progn - (beginning-of-line) - (if (looking-at outline-regexp) - (match-end 0) - 0))))) - (save-excursion - (let ((heading (string-trim - (buffer-substring-no-properties - (point) - (line-end-position)))) - (occur 0)) - (end-of-line) - (while (and (not (string-empty-p heading)) - (search-backward heading nil t)) - (setq occur (1+ occur))) - (list 'link-to-string-match - heading occur buffer-file-name)))) - (buffer-file-name - (list 'link-to-file buffer-file-name (point))) - (t (list 'link-to-buffer-tmp (buffer-name))))) - ;; - ;; Deleted link to elisp possibility as it can embed - ;; long elisp functions in the button data file and - ;; possibly not parse them correctly. - ;; - ;; (and (fboundp 'smart-emacs-lisp-mode-p) - ;; (smart-emacs-lisp-mode-p) - ;; (or (eq (char-syntax (following-char)) ?\() - ;; (eq (char-syntax (preceding-char)) ?\))) - ;; (setq val (hargs:sexpression-p)) - ;; (list 'eval-elisp val)) - ))))))) + (prog1 (delq nil + (list (cond ((and (featurep 'org-id) + (cond ((save-excursion + (beginning-of-line) + (when (looking-at "[ \t]*:ID:[ \t]+\\([^ \t\r\n\f]+\\)") + ;; Org ID definition + (list 'link-to-org-id (match-string 1))))) + (t (let* ((id (thing-at-point 'symbol t)) ;; Could be a uuid or some other form of id + (bounds (when id (bounds-of-thing-at-point 'symbol))) + (start (when bounds (car bounds))) + (case-fold-search t)) + ;; Org ID link - must have id: prefix or is ignored. + (when start + (save-excursion + (goto-char (max (- start 3) (point-min))) + (when (looking-at "\\bid:") + (list 'link-to-org-id id))))))))) + + ;; Next clause forces use of any ibut name in the link + ;; and sets hbut:current button attributes. + (t (cond ((and (prog1 (setq hbut-sym (hbut:at-p)) + (save-excursion (ibut:at-to-name-p hbut-sym))) + (setq lbl-key (hattr:get hbut-sym 'lbl-key)) + (eq (current-buffer) (get-file-buffer (gbut:file)))) + (list 'link-to-gbut lbl-key)) + ((and hbut-sym (eq (hattr:get hbut-sym 'categ) 'explicit)) + (list 'link-to-ebut lbl-key)) + (hbut-sym + (list 'link-to-ibut lbl-key (or buffer-file-name (buffer-name)))) + ((and (require 'bookmark) + (derived-mode-p 'bookmark-bmenu-mode) + (list 'link-to-bookmark (bookmark-bmenu-bookmark)))) + ((let (node) + (cond ((derived-mode-p 'Info-mode) + (if (and Info-current-node + (member Info-current-node + (Info-index-nodes Info-current-file)) + (Info-menu-item-at-p)) + (let ((hargs:reading-type 'Info-index-item)) + (list 'link-to-Info-index-item (hargs:at-p))) + (let ((hargs:reading-type 'Info-node)) + (list 'link-to-Info-node (hargs:at-p))))) + ((and (derived-mode-p #'texinfo-mode) + (save-excursion + (beginning-of-line) + (or (looking-at "@node ") + (re-search-backward "^@node " nil t)))) + (require 'texnfo-upd) + (setq node (texinfo-copy-node-name)) + (list 'link-to-texinfo-node buffer-file-name node)) + ((hmail:reader-p) + (list 'link-to-mail + (list (rmail:msg-id-get) buffer-file-name)))))) + (t (cond + ((let ((hargs:reading-type 'directory)) + (setq val (hargs:at-p t))) + (list 'link-to-directory val)) + ((let ((hargs:reading-type 'file)) + (setq val (hargs:at-p t))) + (list 'link-to-file val (point))) + ((derived-mode-p #'kotl-mode) + (list 'link-to-kcell buffer-file-name (kcell-view:idstamp))) + ;; If link is within an outline-regexp prefix, use + ;; a link-to-string-match. + ((and (boundp 'outline-regexp) + (stringp outline-regexp) + (save-excursion + (<= (point) + (progn + (beginning-of-line) + (if (looking-at outline-regexp) + (match-end 0) + 0))))) + (save-excursion + (let ((heading (string-trim + (buffer-substring-no-properties + (point) + (line-end-position)))) + (occur 0)) + (end-of-line) + (while (and (not (string-empty-p heading)) + (search-backward heading nil t)) + (setq occur (1+ occur))) + (list 'link-to-string-match + heading occur buffer-file-name)))) + (buffer-file-name + (list 'link-to-file buffer-file-name (point))) + (t (list 'link-to-buffer-tmp (buffer-name))))) + ;; + ;; Deleted link to elisp possibility as it can embed + ;; long elisp functions in the button data file and + ;; possibly not parse them correctly. + ;; + ;; (and (fboundp 'smart-emacs-lisp-mode-p) + ;; (smart-emacs-lisp-mode-p) + ;; (or (eq (char-syntax (following-char)) ?\() + ;; (eq (char-syntax (preceding-char)) ?\))) + ;; (setq val (hargs:sexpression-p)) + ;; (list 'eval-elisp val)) + ))))) + ;; This is a referent button to link to, not the source button, + ;; so clear it. + (hattr:clear 'hbut:current)))) (defun hui:list-remove-text-properties (lst) "Return LST, a list, with text properties removed from any string elements."