From 1cf9be18635229b9f9812906a09ba30620ea45fd Mon Sep 17 00:00:00 2001 From: cage Date: Sun, 23 Jan 2022 13:06:24 +0100 Subject: [PATCH] - added function 'fs:path-referencing-dir-p'. --- modules/expand-abbrev-command-window.lisp | 3 ++- src/filesystem-tree-window.lisp | 2 +- src/filesystem-utils.lisp | 3 +++ src/kami/client.lisp | 2 +- src/package.lisp | 1 + 5 files changed, 8 insertions(+), 3 deletions(-) diff --git a/modules/expand-abbrev-command-window.lisp b/modules/expand-abbrev-command-window.lisp index a506499..8924dd0 100644 --- a/modules/expand-abbrev-command-window.lisp +++ b/modules/expand-abbrev-command-window.lisp @@ -32,7 +32,8 @@ (in-package :modules) -(defparameter *expand-abbrev-rewriting-rules* '(("^!g" "gemini://")) +(defparameter *expand-abbrev-rewriting-rules* '(("^!g" "gemini://") + ("^!n" "np://")) "Before displaying messages that module will rewrites the first element of each item (a regular expression) of this list with the second diff --git a/src/filesystem-tree-window.lisp b/src/filesystem-tree-window.lisp index b132439..f2001db 100644 --- a/src/filesystem-tree-window.lisp +++ b/src/filesystem-tree-window.lisp @@ -23,7 +23,7 @@ (not dirp)) (list :path path :dirp dirp :markedp nil)) (dirp - (if (scan "/$" path) + (if (fs:path-referencing-dir-p path) (list :path path :dirp t :markedp nil) (list :path (strcat path "/") :dirp t :markedp nil))))) diff --git a/src/filesystem-utils.lisp b/src/filesystem-utils.lisp index 6c68036..ce4331f 100644 --- a/src/filesystem-utils.lisp +++ b/src/filesystem-utils.lisp @@ -152,6 +152,9 @@ (defun loopback-reference-dir-p (path) (string= (path-last-element path) ".")) +(defun path-referencing-dir-p (path) + (cl-ppcre:scan "/$" path)) + (defun collect-files/dirs (root) (let ((all-files '()) (all-dirs '())) diff --git a/src/kami/client.lisp b/src/kami/client.lisp index 70c70d1..ed02567 100644 --- a/src/kami/client.lisp +++ b/src/kami/client.lisp @@ -85,7 +85,7 @@ (assert path) (with-cloned-root-fid (*stream* root-fid) (if dirp - (9p:create-path *stream* root-fid (if (cl-ppcre:scan "/$" path) + (9p:create-path *stream* root-fid (if (fs:path-referencing-dir-p path) path (text-utils:strcat path "/"))) (9p:create-path *stream* root-fid path)))))) diff --git a/src/package.lisp b/src/package.lisp index 3a72e07..8073310 100644 --- a/src/package.lisp +++ b/src/package.lisp @@ -289,6 +289,7 @@ :collect-children :backreference-dir-p :loopback-reference-dir-p + :path-referencing-dir-p :collect-files/dirs :prepend-pwd :search-matching-file