[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/hyperbole d9e99faa85 1/7: Test if individual PATH exist
From: |
ELPA Syncer |
Subject: |
[elpa] externals/hyperbole d9e99faa85 1/7: Test if individual PATH exists without requiring 3 or more colons |
Date: |
Sun, 13 Mar 2022 11:57:36 -0400 (EDT) |
branch: externals/hyperbole
commit d9e99faa85ff1b2ab26e576c28050d43fcdbe8aa
Author: Bob Weiner <rsw@gnu.org>
Commit: Bob Weiner <rsw@gnu.org>
Test if individual PATH exists without requiring 3 or more colons
---
hpath.el | 45 ++++++++++++++++++++++++++++-----------------
test/hmouse-drv-tests.el | 6 +++---
test/hpath-tests.el | 2 +-
3 files changed, 32 insertions(+), 21 deletions(-)
diff --git a/hpath.el b/hpath.el
index ec63000aef..f7b461708d 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: 31-Jan-22 at 22:39:52 by Bob Weiner
+;; Last-Mod: 27-Feb-22 at 16:25:23 by Bob Weiner
;;
;; Copyright (C) 1991-2021 Free Software Foundation, Inc.
;; See the "HY-COPY" file for license information.
@@ -874,23 +874,34 @@ paths are allowed. Absolute pathnames must begin with a
`/' or `~'."
(setq non-exist t))
(cond ((and path (file-readable-p path))
path)
- ((and path (string-match-p hpath:path-variable-value-regexp 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)))
- (if subpath
- ;; Could be a shell command from a semicolon separated
- ;; list; ignore if so
- (unless (and (string-match "\\`\\s-*\\([^; ]+\\)" subpath)
- (executable-find (match-string 1 subpath)))
- (expand-file-name subpath))
- "."))
+ (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)))
diff --git a/test/hmouse-drv-tests.el b/test/hmouse-drv-tests.el
index 20e943106b..9d266a5a9a 100644
--- a/test/hmouse-drv-tests.el
+++ b/test/hmouse-drv-tests.el
@@ -200,12 +200,12 @@
(goto-char 16)
(hy-test-helpers:action-key-should-call-hpath:find "/tmp")))
-(ert-deftest hbut-pathname-path-variable-with-two-colons-is-one-file-test ()
- "Path variable value with two colons is insufficient to be recognized as a
path variable value."
+(ert-deftest hbut-pathname-path-variable-with-two-colons-a-path-test ()
+ "Path variable value with two colons is recognized as a path variable value."
(with-temp-buffer
(insert "\"/var/lib:/bar:/tmp\"")
(goto-char 16)
- (should (not (hpath:at-p)))))
+ (should (hpath:at-p))))
(ert-deftest hbut-pathname-path-variable-with-three-colons-is-a-path-test ()
"Path variable value with three colons is sufficient to be recognized as a
path variable value."
diff --git a/test/hpath-tests.el b/test/hpath-tests.el
index 9cddd8c01f..6ed59eb700 100644
--- a/test/hpath-tests.el
+++ b/test/hpath-tests.el
@@ -112,7 +112,7 @@
(with-temp-buffer
(insert "\":foo:bar:emacs\"")
(goto-char 8)
- (should (string= (hpath:at-p) (expand-file-name "bar")))))
+ (should (string= (hpath:at-p nil t) (expand-file-name "bar")))))
(ert-deftest
hpath:path-at-point-in-path-variable-shorter-than-three-colons-returns-nil-test
()
"Do not identify path variables with less than three colons."
- [elpa] externals/hyperbole updated (6fb181ab69 -> 5337b310e7), ELPA Syncer, 2022/03/13
- [elpa] externals/hyperbole d9e99faa85 1/7: Test if individual PATH exists without requiring 3 or more colons,
ELPA Syncer <=
- [elpa] externals/hyperbole 93a36a6e28 2/7: Update Markdown to HTML converter used in Makefile, ELPA Syncer, 2022/03/13
- [elpa] externals/hyperbole e7c9598c78 3/7: Fix formatting of table in org-mode implicit button description, ELPA Syncer, 2022/03/13
- [elpa] externals/hyperbole 715c41b9ba 5/7: Simplify and fix hyrolo multi-level entry sorting, ELPA Syncer, 2022/03/13
- [elpa] externals/hyperbole a11877cfbc 4/7: Merge branch 'master' of hyperbole, ELPA Syncer, 2022/03/13
- [elpa] externals/hyperbole 37d5ce93a3 6/7: Change web-site target to website, ELPA Syncer, 2022/03/13
- [elpa] externals/hyperbole 5337b310e7 7/7: Fix spelling errors in docs (#178), ELPA Syncer, 2022/03/13