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

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

[elpa] externals/hyperbole 9a8912d 1/2: Add pathname ib support for recu


From: ELPA Syncer
Subject: [elpa] externals/hyperbole 9a8912d 1/2: Add pathname ib support for recursive 'ls' listings in shell buffers
Date: Sat, 27 Nov 2021 19:57:17 -0500 (EST)

branch: externals/hyperbole
commit 9a8912de97e86007816e72403821130b3f495817
Author: Bob Weiner <rsw@gnu.org>
Commit: Bob Weiner <rsw@gnu.org>

    Add pathname ib support for recursive 'ls' listings in shell buffers
---
 ChangeLog   |  6 ++++++
 HY-NEWS     |  9 ++++++---
 hibtypes.el | 13 +++++++------
 hpath.el    | 16 +++++++++++++++-
 4 files changed, 34 insertions(+), 10 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index b31f37c..b483172 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2021-11-27  Bob Weiner  <rsw@gnu.org>
+
+* hpath.el (hpath:prepend-ls-directory): When in a shell buffer and on a
+    filename result of an 'ls *' or recursive 'ls', prepend the subdir to the
+    filename and return it, else nil.
+
 2021-11-07  Bob Weiner  <rsw@gnu.org>
 
 * hypb.el (hypb:mark): Remove and use builtin mark function.
diff --git a/HY-NEWS b/HY-NEWS
index 2e3c842..dc7e63c 100644
--- a/HY-NEWS
+++ b/HY-NEWS
@@ -163,9 +163,12 @@
       source reference line so if not on a Hyperbole button, move back a line
       before checking.
 
-    - Pathname Implicit Buttons: Variable substitutions are now made with
-      fixed case, so that the case of a value with both upper and lower
-      case characters is never changed, for example a value of ${HOME}.
+    - Pathname Implicit Buttons: Recursive 'ls' listings are now recognized
+      properly, prepending the preceding directory to each entry for viewing.
+
+      Variable substitutions are now made with fixed case, so that the
+      case of a value with both upper and lower case characters is
+      never changed, for example a value of ${HOME}.
 
     - Todotxt Mode Support: Smart key support for the todotxt mode
       https://github.com/rpdillon/todotxt.el.
diff --git a/hibtypes.el b/hibtypes.el
index c8de177..167b9ed 100644
--- a/hibtypes.el
+++ b/hibtypes.el
@@ -133,12 +133,13 @@ PATH-style variable, the path at point is used; empty 
paths, e.g. ::
 represent the current directory, '.'.
 
 Also works for delimited and non-delimited remote pathnames,
-Texinfo @file{} entries, and hash-style link references to HTML,
-XML, SGML, Markdown or Emacs outline headings, shell script
-comments, and MSWindows paths (see \"${hyperb:dir}/DEMO#POSIX and
-MSWindows Paths\" for details).  Emacs Lisp library
-files (filenames without any directory component that end in .el,
-.elc or .eln) are looked up using the `load-path' directory list.
+recursive 'ls' listings, Texinfo @file{} entries, and hash-style
+link references to HTML, XML, SGML, Markdown or Emacs outline
+headings, shell script comments, and MSWindows paths (see
+\"${hyperb:dir}/DEMO#POSIX and MSWindows Paths\" for details).
+Emacs Lisp library files (filenames without any directory
+component that end in .el, .elc or .eln) are looked up using the
+`load-path' directory list.
 
 The pathname may contain references to Emacs Lisp variables or
 shell environment variables using the syntax, \"${variable-name}\".
diff --git a/hpath.el b/hpath.el
index b39f954..6d9ebc9 100644
--- a/hpath.el
+++ b/hpath.el
@@ -939,7 +939,7 @@ double quotes, open and close single quote, whitespace, or 
Texinfo file referenc
 With optional NON-EXIST, nonexistent local paths are allowed.  Absolute 
pathnames
 must begin with a `/' or `~'.
 
-With optional INCLUDE-POSITIONS, returns a triplet list of (path start-pos
+With optional INCLUDE-POSITIONS, return a triplet list of (path start-pos
 end-pos) or nil."
   ;; Prevents MSWindows to Posix path substitution
   (let ((hyperb:microsoft-os-p t))
@@ -964,6 +964,9 @@ end-pos) or nil."
            ;; whitespace delimited root dirs, e.g. " / ".
            (when (and (stringp p) (not (string-match "\"\\|\\`[/\\]+\\'" p))
                       (delq nil (mapcar (lambda (c) (/= punc (char-syntax c))) 
p)))
+             ;; Prepend proper directory to ls * or recursive ls file listing
+             (setq p (or (hpath:prepend-ls-directory) p))
+             (setcar triplet p)
              (if include-positions
                  triplet
                p)))))))
@@ -1027,6 +1030,17 @@ window in which the buffer is displayed."
   ;; For compressed Elisp libraries, add any found compressed suffix to the 
path.
   (or (locate-library path t) path))
 
+(defun hpath:prepend-ls-directory ()
+  "When in a shell buffer and on a filename result of an 'ls *' or recursive 
'ls', prepend the subdir to the filename and return it, else nil."
+  (when (derived-mode-p #'shell-mode)
+    (let ((filename (thing-at-point 'filename t))
+         dir)
+      (save-excursion
+       (when (and filename (re-search-backward "^$\\|\\`\\|^\\(.+\\):$" nil t)
+                  (setq dir (match-string-no-properties 1))
+                  (file-exists-p dir))
+         (concat (file-name-as-directory dir) filename))))))
+
 (defvar hpath:compressed-suffix-regexp (concat (regexp-opt '(".gz" ".Z" ".zip" 
".bz2" ".xz" ".zst")) "\\'")
    "Regexp of compressed file name suffixes.")
 



reply via email to

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