From 081742a07e7bf438655b390f46e0ce103a0b0e55 Mon Sep 17 00:00:00 2001 From: William Carroll Date: Sat, 30 Jul 2022 11:12:58 -0700 Subject: feat(wpcarro/emacs): Package fs.el According to SourceGraph, this is unused, but I'm checking it in for historical purposes. Change-Id: I24bcb1c71a9f6de527bb54057cf13d01493c45bf Reviewed-on: https://cl.tvl.fyi/c/depot/+/6016 Tested-by: BuildkiteCI Reviewed-by: wpcarro Autosubmit: wpcarro --- users/wpcarro/emacs/.emacs.d/wpc/fs.el | 69 ---------------------------------- 1 file changed, 69 deletions(-) delete mode 100644 users/wpcarro/emacs/.emacs.d/wpc/fs.el (limited to 'users/wpcarro/emacs/.emacs.d/wpc') diff --git a/users/wpcarro/emacs/.emacs.d/wpc/fs.el b/users/wpcarro/emacs/.emacs.d/wpc/fs.el deleted file mode 100644 index c303b2353956..000000000000 --- a/users/wpcarro/emacs/.emacs.d/wpc/fs.el +++ /dev/null @@ -1,69 +0,0 @@ -;;; fs.el --- Make working with the filesystem easier -*- lexical-binding: t -*- - -;; Author: William Carroll -;; Version: 0.0.1 -;; Package-Requires: ((emacs "24.1")) - -;;; Commentary: -;; Ergonomic alternatives for working with the filesystem. - -;;; Code: - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; Dependencies -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -(require 'dash) -(require 'f) -(require 's) - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; Library -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -(defun fs-ensure-file (path) - "Ensure that a file and its directories in `PATH' exist. -Will error for inputs with a trailing slash." - (when (s-ends-with? "/" path) - (error (format "Input path has trailing slash: %s" path))) - (->> path - f-dirname - fs-ensure-dir) - (f-touch path)) - -(f-dirname "/tmp/a/b/file.txt") - -(defun fs-ensure-dir (path) - "Ensure that a directory and its ancestor directories in `PATH' exist." - (->> path - f-split - (apply #'f-mkdir))) - -(defun fs-ls (dir &optional full-path?) - "List the files in `DIR' one-level deep. -Should behave similarly in spirit to the Unix command, ls. -If `FULL-PATH?' is set, return the full-path of the files." - (-drop 2 (directory-files dir full-path?))) - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; Tests -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -(ert-deftest fs-test-ensure-file () - (let ((file "/tmp/file/a/b/c/file.txt")) - ;; Ensure this file doesn't exist first to prevent false-positives. - (f-delete file t) - (fs-ensure-file file) - (should (and (f-exists? file) - (f-file? file))))) - -(ert-deftest fs-test-ensure-dir () - (let ((dir "/tmp/dir/a/b/c")) - ;; Ensure the directory doesn't exist. - (f-delete dir t) - (fs-ensure-dir dir) - (should (and (f-exists? dir) - (f-dir? dir))))) - -(provide 'fs) -;;; fs.el ends here -- cgit 1.4.1