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

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

[elpa] externals/hyperbole e0c9803045 1/2: Fix a number of issues with p


From: ELPA Syncer
Subject: [elpa] externals/hyperbole e0c9803045 1/2: Fix a number of issues with pathname ibuts and klinks
Date: Tue, 25 Jan 2022 16:57:33 -0500 (EST)

branch: externals/hyperbole
commit e0c98030454d3000527a757bec9dfc472ba5b523
Author: Robert Weiner <rsw@gnu.org>
Commit: Robert Weiner <rsw@gnu.org>

    Fix a number of issues with pathname ibuts and klinks
---
 ChangeLog     | 17 ++++++++++++++++-
 hact.el       |  1 +
 hbut.el       | 13 +++++++++++++
 hibtypes.el   | 27 ++++++++++++++++++---------
 hpath.el      |  9 +++++++--
 kotl/klink.el |  8 +++++---
 6 files changed, 60 insertions(+), 15 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 1fe1d9c84e..e4c4885024 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,19 @@
-<<<<<<< HEAD
+2022-01-25  Bob Weiner  <rsw@gnu.org>
+
+* hpath.el (seq): Add (require 'seq) since seq-find is used herein.
+
+* hbut.el (defib): Add back edebug spec for defib that must have been 
accidentally
+    removed in some merge.
+
+* hibtypes.el (pathname): Add missing 'ibut:label-set' to enable flashing of 
simple
+    Fix that when path was expanded or normalized, pathname button would not 
flash
+    since it did not match the text.  Use 'orig-path' instead, except when 
point is
+    within a PATH-like variable value of colon or semicolon separated 
directories;
+    then use just the individual 'path' selected.
+
+* hactypes.el (link-to-kcell): Fix to process cell-ref only after any non-nil
+    file is displayed.
+
 2022-01-22  Bob Weiner  <rsw@gnu.org>
 
 * hycontrol.el (hycontrol-windows-grid-by-file-pattern): Add this command that 
creates
diff --git a/hact.el b/hact.el
index 1a417139bf..16be088490 100644
--- a/hact.el
+++ b/hact.el
@@ -506,6 +506,7 @@ Return symbol created when successful, else nil."
   (([&rest arg]
     [&optional ["&optional" arg &rest arg]]
     &optional ["&rest" arg])))
+
 (defalias 'actype:create #'defact)
 
 (defun    actype:delete (type)
diff --git a/hbut.el b/hbut.el
index 1494e8f113..232bee431a 100644
--- a/hbut.el
+++ b/hbut.el
@@ -1953,6 +1953,19 @@ type for ibtype is presently undefined."
              (htype:create ,type ibtypes ,doc nil ,at-func
                            '(to-p ,to-func style ,style))))))
 
+(put      'defib 'lisp-indent-function 'defun)
+
+;; Support edebug-defun for interactive debugging of ibtypes
+(def-edebug-spec defib
+ (&define name lambda-list
+          [&optional stringp]   ; Match the doc string, if present.
+          def-body))
+
+(def-edebug-spec lambda-list
+ (([&rest arg]
+   [&optional ["&optional" arg &rest arg]]
+   &optional ["&rest" arg])))
+
 (defalias 'ibtype:create #'defib)
 
 (defun ibtype:activate-link (referent)
diff --git a/hibtypes.el b/hibtypes.el
index 69d214b42c..9da2cd0f8d 100644
--- a/hibtypes.el
+++ b/hibtypes.el
@@ -34,6 +34,7 @@
 ;;; ************************************************************************
 
 (eval-when-compile (require 'hversion))
+(require 'cl-seq) ;; for cl-count
 (require 'subr-x) ;; For string-trim
 (require 'hactypes)
 
@@ -155,9 +156,11 @@ display options."
               (delq nil (mapcar (lambda (substring)
                                   (string-match substring (format-mode-line 
mode-name)))
                                 '("Buffer Menu" "IBuffer" "Dired"))))
-    (let ((path (hpath:at-p))
-         elisp-suffix
-          full-path)
+    (let* ((orig-path (hpath:delimited-possible-path))
+          ;; Normalized and expanded path
+          (path (hpath:at-p))
+          elisp-suffix
+           full-path)
       (if path
          (cond ((and (not (string-empty-p path))
                      (= (aref path 0) ?-)
@@ -168,7 +171,7 @@ display options."
                       full-path (locate-library path elisp-suffix))
                  (cond (full-path
                        (setq path (concat "-" path))
-                       (apply #'ibut:label-set path (hpath:start-end path))
+                       (apply #'ibut:label-set orig-path (hpath:start-end 
orig-path))
                        (hact 'hpath:find path))
                       (elisp-suffix
                        (hact 'error "(pathname): \"%s\" not found in 
`load-path'" path))
@@ -177,12 +180,17 @@ display options."
                       (t nil)))
                (t (when (string-match "\\`file://" path)
                      (setq path (substring path (match-end 0))))
-                   (apply #'ibut:label-set path (hpath:start-end path))
+                  (if (or (> (cl-count ?: orig-path) 2)
+                          (> (cl-count ?\; orig-path) 2))
+                      ;; PATH-like set of values; select just the one point is 
on
+                       (apply #'ibut:label-set path (hpath:start-end path))
+                    ;; Otherwise, use the unchanged orig-path
+                     (apply #'ibut:label-set orig-path (hpath:start-end 
orig-path)))
                    (hact 'link-to-file path)))
         ;;
         ;; Match PATH-related Environment and Lisp variable names and
        ;; Emacs Lisp and Info files without any directory component.
-        (when (setq path (hpath:delimited-possible-path))
+        (when (setq path orig-path)
           (cond ((and (string-match hpath:path-variable-regexp path)
                      (setq path (match-string 1 path))
                      (hpath:is-path-variable-p path))
@@ -194,6 +202,7 @@ display options."
                             ;; separated list; ignore if so.
                             (and (string-match "\\`\\s-*\\([^;         ]+\\)" 
path)
                                  (executable-find (match-string 1 path))))
+                   (apply #'ibut:label-set path (hpath:start-end path))
                   (hact 'link-to-file path)))
                ((setq elisp-suffix (string-match 
"\\`[^\\\\/~]+\\.el[cn]?\\(\\.gz\\)?\\'" path))
                  (cond ((string-match hpath:prefix-regexp path)
@@ -202,7 +211,7 @@ display options."
                        ((setq full-path
                              (let ((load-suffixes '(".el")))
                                (locate-library path elisp-suffix)))
-                       (apply #'ibut:label-set path (hpath:start-end path))
+                       (apply #'ibut:label-set orig-path (hpath:start-end 
orig-path))
                        (hact 'link-to-file full-path))
                       (elisp-suffix
                        (hact 'error "(pathname): \"%s\" not found in 
`load-path'" path))
@@ -216,10 +225,10 @@ display options."
                       (string-match "\\`(\\([^ \t\n\r\f]+\\))\\'" path)
                       (save-match-data (require 'info))
                       (Info-find-file (match-string 1 path) t))
-                 (apply #'ibut:label-set path (hpath:start-end path))
+                 (apply #'ibut:label-set orig-path (hpath:start-end orig-path))
                  (hact 'link-to-Info-node (format "%sTop" path)))
                 ((string-match hpath:info-suffix path)
-                 (apply #'ibut:label-set path (hpath:start-end path))
+                 (apply #'ibut:label-set orig-path (hpath:start-end orig-path))
                  (hact 'link-to-Info-node (format "(%s)Top" path)))
                 ;; Otherwise, fall through and allow other implicit
                 ;; button types to handle this context.
diff --git a/hpath.el b/hpath.el
index ebbd0c286f..cbc038edd6 100644
--- a/hpath.el
+++ b/hpath.el
@@ -18,6 +18,7 @@
 
 (require 'cl-lib)
 (require 'hact)
+(require 'seq) ;; For seq-find
 (require 'subr-x) ;; For string-trim
 (require 'hversion) ;; for (hyperb:window-system) definition
 (require 'hui-select) ;; for `hui-select-markup-modes'
@@ -857,7 +858,7 @@ Always returns nil if (hpath:remote-available-p) returns 
nil."
         (hpath:delete-trailer result))))
 
 (defun hpath:at-p (&optional type non-exist)
-  "Return delimited path or non-delimited remote path at point, if any.
+  "Return expanded and normalized delimited path or non-delimited remote path 
at point, if any.
 World-Wide Web urls are ignored and therefore dealt with by other code.
 Delimiters may be: double quotes, open and close single quote, whitespace, or
 Texinfo file references.  If optional TYPE is the symbol 'file or 'directory,
@@ -990,7 +991,8 @@ Make any existing path within a file buffer absolute before 
returning."
          (and sym (boundp sym) (stringp (symbol-value sym)) (symbol-value 
sym))))))
 
 (defun hpath:choose-from-path-variable (path-var &optional action-str)
-  "Interactively choose and return a path from the colon or 
semicolon-delimited set in PATH-VAR."
+  "Interactively choose and return a path from the colon or 
semicolon-delimited set in PATH-VAR.
+Optional ACTION-STR is used at the start of a prompt to choose the path."
   (let (path-value
        paths)
     (when (setq path-value (hpath:is-path-variable-p path-var)
@@ -1533,6 +1535,9 @@ form is what is returned for PATH."
                           (or (when (string-match-p hpath:variable-regexp path)
                                 ;; Path may be a link reference with embedded
                                 ;; variables that must be expanded.
+                                ;; A variable may be a PATH-type variable
+                                ;; where the first matching expansion
+                                ;; that matches the full path must be utilized.
                                 (setq path (hpath:substitute-value path)
                                       non-exist t)) ;; Ensure non-existent 
path links handled as pathnames.
                               t)
diff --git a/kotl/klink.el b/kotl/klink.el
index 7fbb97a29a..c483e4af43 100644
--- a/kotl/klink.el
+++ b/kotl/klink.el
@@ -182,15 +182,16 @@ link-end-position, (including delimiters)."
 ;;; Hyperbole type definitions
 ;;; ************************************************************************
 
+
 (defib klink ()
   "Follow a link delimited by <> to a koutline cell.
 See documentation for the `link-to-kotl' function for valid klink formats."
   (let* ((link-and-pos (klink:at-p))
         (link (car link-and-pos))
         (start-pos (car (cdr link-and-pos))))
-    (if link
-       (progn (ibut:label-set link-and-pos)
-              (hact 'klink:act link start-pos)))))
+    (when link
+      (ibut:label-set link-and-pos)
+      (hact 'klink:act link start-pos))))
 
 (defact link-to-kotl (link)
   "Display at the top of another window the referent pointed to by LINK.
@@ -231,6 +232,7 @@ See documentation for `kcell:ref-to-id' for valid cell-ref 
formats."
 ;;; Private functions
 ;;; ************************************************************************
 
+
 (defun klink:act (link start-pos)
   (let ((obuf (current-buffer)))
     ;; Perform klink's action which is to jump to link referent.



reply via email to

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