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

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

[elpa] externals/hyperbole ceb8b52c8a 1/2: hibtypes.el(ipython-stack-fra


From: ELPA Syncer
Subject: [elpa] externals/hyperbole ceb8b52c8a 1/2: hibtypes.el(ipython-stack-frame, ripgrep-msg, grep-msg): Standardize
Date: Mon, 1 Jul 2024 09:58:13 -0400 (EDT)

branch: externals/hyperbole
commit ceb8b52c8a7a9e6c5f158d113594f49f1e3fa640
Author: bw <rsw@gnu.org>
Commit: bw <rsw@gnu.org>

    hibtypes.el(ipython-stack-frame, ripgrep-msg, grep-msg): Standardize
    
    hibtypes.el (hib-link-to-file-line): Add this new function to
    standardize multiple file and line display ibtypes.
---
 ChangeLog   | 12 ++++++++--
 hactypes.el |  5 +++--
 hasht.el    |  6 ++---
 hibtypes.el | 75 +++++++++++++++++++++++++------------------------------------
 hpath.el    | 15 ++++++++-----
 5 files changed, 57 insertions(+), 56 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index c3c9deb99a..ef6f1a2f86 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,9 +1,17 @@
+2024-06-30  Bob Weiner  <rsw@gnu.org>
+
+* hpath.el (hpath:find-line): Allow line-num and col-num to be strings.
+  hibtypes.el (hib-link-to-file-line): Add to share among multiple grep
+    file ibtypes.
+  hibtypes.el (ipython-stack-frame, ripgrep-msg, grep-msg): Standardize
+    by using above new function.
+
 2024-06-30  Mats Lidell  <matsl@gnu.org>
 
 * Makefile (internal-docker-all-tests-ert-output): Target for running all
     tests using ert from within docker used by docker-all-tests.
-    (VERSIONS_VERSIONS): List of Emacs versions to run batch-tests and 
all-tests to
-    check same versions as the CI/CD run locally.
+    (VERSIONS_VERSIONS): List of Emacs versions to run batch-tests and
+    all-tests to check same versions as the CI/CD run locally.
     (docker-all-tests, docker-batch-tests): Targets for running
     batch-tests and all-tests for all DOCKER_VERSIONS.
     Update developer target documentation.
diff --git a/hactypes.el b/hactypes.el
index c855245d3a..6627f7b4ec 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:     10-Mar-24 at 18:35:02 by Bob Weiner
+;; Last-Mod:     30-Jun-24 at 17:12:44 by Bob Weiner
 ;;
 ;; SPDX-License-Identifier: GPL-3.0-or-later
 ;;
@@ -429,7 +429,8 @@ the window or as close as possible."
     (hypb:error "(link-to-file): Invalid file name: \"%s\"" path)))
 
 (defact link-to-file-line (path line-num)
-  "Display a file given by PATH scrolled to LINE-NUM."
+  "Display a file given by PATH scrolled to LINE-NUM.
+LINE-NUM may be an integer or string."
   (interactive "fPath to link to: \nnDisplay at line number: ")
   ;; Remove any double quotes and whitespace at the start and end of
   ;; the path that interactive use may have introduced.
diff --git a/hasht.el b/hasht.el
index 17d0c5e51f..0e3706edc5 100644
--- a/hasht.el
+++ b/hasht.el
@@ -8,7 +8,7 @@
 ;; AUTHOR:       Bob Weiner
 ;;
 ;; ORIG-DATE:    16-Mar-90 at 03:38:48
-;; LAST-MOD:     30-Jul-16 at 08:50:38 by Bob Weiner
+;; LAST-MOD:     30-Jun-24 at 17:39:31 by Bob Weiner
 ;;
 ;; Copyright (C) 1990-1995, 1997, 2016  Free Software Foundation, Inc.
 ;; See the file BR-COPY for license information.
@@ -50,7 +50,7 @@
 ;;; ************************************************************************
 
 (defvar hash-merge-values-function 'hash-merge-values
-  "*Function to call in hash-merge to merge the values from 2 hash tables that 
contain the same key.
+  "*Hash-merge function to merge values from 2 hash tables with the same key.
 It is sent the two values as arguments.")
 
 ;;; ************************************************************************
@@ -194,7 +194,7 @@ in reverse order of occurrence (they are prepended to the 
list)."
     (cons 'hasht obarray)))
 
 (defun hash-map (func hash-table)
-  "Return a list of the results of applying FUNC to each (<value> . <key>) 
element of HASH-TABLE."
+  "Return result of applying FUNC over each (<value> . <key>) in HASH-TABLE."
   (if (not (hashp hash-table))
       (error "(hash-map): Invalid hash-table: `%s'" hash-table))
   (let ((result))
diff --git a/hibtypes.el b/hibtypes.el
index 9217f6cf97..48d9d7dba3 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:     30-Jun-24 at 16:00:23 by Bob Weiner
+;; Last-Mod:     30-Jun-24 at 17:22:40 by Bob Weiner
 ;;
 ;; SPDX-License-Identifier: GPL-3.0-or-later
 ;;
@@ -899,6 +899,29 @@ See `hpath:find' function documentation for special file 
display options."
 ;;; compilation errors or HyRolo stuck position error messages.
 ;;; ========================================================================
 
+(defun hib-link-to-file-line (file line-num)
+  "Expand FILE and jump to its LINE-NUM in Hyperbole specified window.
+The variable `hpath:display-where' determines where to display the file.
+LINE-NUM may be an integer or string."
+  ;; RSW 12-05-2021 - Added hpath:expand in next line to
+  ;; resolve any variables in the path before checking if absolute.
+  (let ((source-loc (unless (file-name-absolute-p (hpath:expand file))
+                      (hbut:to-key-src t)))
+       ext)
+    (if (stringp source-loc)
+        (setq file (expand-file-name file (file-name-directory source-loc)))
+      (setq file (or (hpath:prepend-shell-directory file)
+                    ;; find-library-name will strip file
+                    ;; suffixes, so use it only when the file
+                    ;; either doesn't have a suffix or has a
+                    ;; library suffix.
+                    (and (or (null (setq ext (file-name-extension file)))
+                             (member (concat "." ext) (get-load-suffixes)))
+                         (ignore-errors (find-library-name file)))
+                    (expand-file-name file))))
+    (when (file-exists-p file)
+      (actypes::link-to-file-line file line-num))))
+
 (defib ipython-stack-frame ()
   "Jump to the line associated with an ipython stack frame line numbered msg.
 ipython outputs each pathname once followed by all matching lines
@@ -931,15 +954,8 @@ than a helm completion buffer)."
                       (not (re-search-forward " in " nil (line-end-position)))
                       (and (setq file (buffer-substring-no-properties 
(line-beginning-position) (match-beginning 0)))
                            (string-empty-p (string-trim file))))
-            (let* ((but-label (concat file ":" line-num))
-                   (source-loc (unless (file-name-absolute-p file)
-                                 (hbut:to-key-src t))))
-              (when (stringp source-loc)
-                (setq file (expand-file-name file (file-name-directory 
source-loc))))
-              (when (file-readable-p file)
-                (setq line-num (string-to-number line-num))
-                (ibut:label-set but-label)
-                (hact 'link-to-file-line file line-num)))))))))
+           (ibut:label-set (concat file ":" line-num))
+           (hact 'hib-link-to-file-line file line-num)))))))
 
 (defib ripgrep-msg ()
   "Jump to the line associated with a ripgrep (rg) line numbered msg.
@@ -974,18 +990,8 @@ than a helm completion buffer)."
           (unless (or (looking-at "[1-9][0-9]*[-:]\\|--$")
                       (and (setq file (buffer-substring-no-properties 
(line-beginning-position) (line-end-position)))
                            (string-empty-p (string-trim file))))
-            (let* ((but-label (concat file ":" line-num))
-                  ;; RSW 12-05-2021 - Added hpath:expand in next line to
-                  ;; resolve any variables in the path before checking if 
absolute.
-                  (source-loc (unless (file-name-absolute-p (hpath:expand 
file))
-                                 (hbut:to-key-src t))))
-              (if (stringp source-loc)
-                  (setq file (expand-file-name file (file-name-directory 
source-loc)))
-               (setq file (or (hpath:prepend-shell-directory file) file)))
-              (when (file-readable-p file)
-                (setq line-num (string-to-number line-num))
-                (ibut:label-set but-label)
-                (hact 'link-to-file-line file line-num)))))))))
+           (ibut:label-set (concat file ":" line-num))
+           (hact 'hib-link-to-file-line file line-num)))))))
 
 (defib hyrolo-stuck-msg ()
   "Jump to the position where a HyRolo search has become stuck from the error.
@@ -1055,28 +1061,9 @@ in grep and shell buffers."
              (and (string-match "grep\\|shell" (buffer-name))
                   (looking-at "\\([^ \t\n\r:\"'`]+\\)-\\([1-9][0-9]*\\)-")))
         (let* ((file (match-string-no-properties 1))
-               (line-num  (or (match-string-no-properties 2) "1"))
-               (but-label (concat file ":" line-num))
-              ;; RSW 12-05-2021 - Added hpath:expand in next line to
-              ;; resolve any variables in the path before checking if absolute.
-               (source-loc (unless (file-name-absolute-p (hpath:expand file))
-                             (hbut:to-key-src t)))
-              ext)
-          (if (stringp source-loc)
-              (setq file (expand-file-name file (file-name-directory 
source-loc)))
-           (setq file (or (hpath:prepend-shell-directory file)
-                          ;; find-library-name will strip file
-                          ;; suffixes, so use it only when the file
-                          ;; either doesn't have a suffix or has a
-                          ;; library suffix.
-                          (and (or (null (setq ext (file-name-extension file)))
-                                   (member (concat "." ext) 
(get-load-suffixes)))
-                               (ignore-errors (find-library-name file)))
-                          (expand-file-name file))))
-         (when (file-exists-p file)
-            (setq line-num (string-to-number line-num))
-            (ibut:label-set but-label)
-            (hact 'link-to-file-line file line-num)))))))
+               (line-num  (or (match-string-no-properties 2) "1")))
+         (ibut:label-set (concat file ":" line-num))
+         (hact 'hib-link-to-file-line file line-num))))))
 
 ;;; ========================================================================
 ;;; Jumps to source line associated with debugger stack frame or breakpoint
diff --git a/hpath.el b/hpath.el
index e687b39590..7e2a63e7bb 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:     23-Jun-24 at 00:09:03 by Mats Lidell
+;; Last-Mod:     30-Jun-24 at 17:09:25 by Bob Weiner
 ;;
 ;; SPDX-License-Identifier: GPL-3.0-or-later
 ;;
@@ -1686,6 +1686,7 @@ Return nil if none are found."
 
 (defun hpath:find-line (filename line-num &optional col-num display-where)
   "Edit file FILENAME with point placed at LINE-NUM and optional COL-NUM.
+When given, LINE-NUM and COL-NUM may be strings or integers.
 
 `hpath:display-where-alist' is consulted using the optional
 argument, DISPLAY-WHERE (a symbol) or if that is nil, the value
@@ -1700,10 +1701,14 @@ frame.  Always return t."
   (hpath:find
    (concat
     filename
-    (when (integerp line-num)
-      (concat ":" (int-to-string line-num)))
-    (when (integerp col-num)
-      (concat ":" (int-to-string col-num))))
+    (cond ((integerp line-num)
+          (concat ":" (int-to-string line-num)))
+         ((stringp line-num)
+          (concat ":" line-num)))
+    (cond ((integerp col-num)
+          (concat ":" (int-to-string col-num)))
+         ((stringp col-num)
+          (concat ":" col-num))))
    display-where)
   t)
 



reply via email to

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