diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml new file mode 100644 index 0000000..a2c6142 --- /dev/null +++ b/.github/workflows/workflow.yml @@ -0,0 +1,46 @@ +name: CI +on: + push: + pull_request: + workflow_dispatch: + +jobs: + check-compatibility: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + emacs_version: + - 25.1 + - 25.2 + - 25.3 + - 26.1 + - 26.2 + - 26.3 + - 27.1 + - 27.2 + - 28.1 + - snapshot + steps: + - uses: actions/checkout@v3 + - uses: purcell/setup-emacs@master + with: + version: ${{ matrix.emacs_version }} + - uses: actions/cache@v2 + id: cache-cask-packages + with: + path: .cask + key: cache-cask-packages-000 + - uses: actions/cache@v2 + id: cache-cask-executable + with: + path: ~/.cask + key: cache-cask-executable-000 + - name: "Cask setup" + uses: cask/setup-cask@master + if: steps.cask-cache-executable.outputs.cache-hit != 'true' + - name: "Install Cask dependencies" + run: cask install + if: steps.cask-cache-executable.outputs.cache-hit != 'true' + - name: "Check version compatibility" + run: make all diff --git a/Cask b/Cask new file mode 100644 index 0000000..ddb6808 --- /dev/null +++ b/Cask @@ -0,0 +1,7 @@ +(source melpa) +(source gnu) + +(package-file "eshell-info-banner.el") + +(development + (depends-on "s")) diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..5fc928e --- /dev/null +++ b/Makefile @@ -0,0 +1,11 @@ +# -*- indent-tabs-mode: t -*- + +export EMACS ?= $(shell which emacs) +CASK ?= $(shell which cask) + +all: compile + +compile: + ${CASK} exec ${EMACS} -Q --script bin/compile-package.el 2>&1 | grep -A 2 -E "([Ee]rror|[Ww]arning):" && exit 1 || exit 0 + +.PHONY: all compile diff --git a/README.org b/README.org index abe3c48..5c7224d 100644 --- a/README.org +++ b/README.org @@ -3,6 +3,7 @@ #+email: lucien@phundrak.com [[https://melpa.org/#/eshell-info-banner][file:https://melpa.org/packages/eshell-info-banner-badge.svg]] [[https://stable.melpa.org/#/eshell-info-banner][file:https://stable.melpa.org/packages/eshell-info-banner-badge.svg]] +[[https://github.com/Phundrak/eshell-info-banner.el/actions/workflows/workflow.yml][file:https://github.com/Phundrak/eshell-info-banner.el/actions/workflows/workflow.yml/badge.svg]] * Introduction ~eshell-info-banner.el~ is a utility for creating an informative banner, diff --git a/bin/compile-package.el b/bin/compile-package.el new file mode 100644 index 0000000..0d36b6a --- /dev/null +++ b/bin/compile-package.el @@ -0,0 +1 @@ +(byte-recompile-directory "." 0 'force) diff --git a/eshell-info-banner.el b/eshell-info-banner.el index 8ba50d3..2021e51 100644 --- a/eshell-info-banner.el +++ b/eshell-info-banner.el @@ -139,18 +139,19 @@ :group 'eshell-info-banner :type 'list) -(defun eshell-info-banner--executable-find (program) + +(defmacro eshell-info-banner--executable-find (program) "Find PROGRAM executable, possibly on a remote machine. This is a wrapper around `executable-find' in order to avoid issues with older versions of the functions only accepting one argument. `executable-find'’s remote argument has the value of `eshell-info-banner-tramp-aware'." (if (version< emacs-version "27.1") - (let ((default-directory (if eshell-info-banner-tramp-aware - default-directory - "~"))) - (executable-find program)) - (executable-find program eshell-info-banner-tramp-aware))) + `(let ((default-directory (if eshell-info-banner-tramp-aware + default-directory + "~"))) + (executable-find ,program)) + `(executable-find ,program eshell-info-banner-tramp-aware))) (defcustom eshell-info-banner-duf-executable "duf" "Path to the `duf' executable." @@ -265,13 +266,13 @@ If the executable `uptime' is not found, return nil." (if (not (seq-some (lambda (keyword) (string-match-p keyword uptime-str)) '("invalid" "illegal" "unknown"))) - (s-chop-prefix "up " (string-trim uptime-str)) + (s-chop-prefix "up " (s-trim uptime-str)) (let ((uptime-str (eshell-info-banner--shell-command-to-string "uptime"))) (save-match-data (string-match "[^,]+up *\\([^,]+\\)," uptime-str) - (string-trim (substring-no-properties uptime-str - (match-beginning 1) - (match-end 1))))))))) + (s-trim (substring-no-properties uptime-str + (match-beginning 1) + (match-end 1))))))))) ; Partitions ;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -387,7 +388,7 @@ MOUNT-POSITION." :size size :used used :percent (string-to-number - (string-trim-left percent (regexp-quote "%"))))))) + (s-chop-suffix "%" percent)))))) partitions)))) (defun eshell-info-banner--get-mounted-partitions-gnu () @@ -477,7 +478,7 @@ For TEXT-PADDING and BAR-LENGTH, see the documentation of "Get the output of COMMAND corresponding to memory information. This function is to be only used on platforms which support sysctl." (string-to-number - (string-trim + (s-trim (car (last (split-string (eshell-info-banner--shell-command-to-string command) " " @@ -489,7 +490,7 @@ See `eshell-info-banner--get-memory'." (let* ((total (eshell-info-banner--get-memory-unix-command-to-mem "sysctl hw.physmem64")) (used (- total (* 1024 (string-to-number - (string-trim + (s-trim (with-temp-buffer (insert-file-contents-literally "/proc/meminfo") (save-match-data @@ -733,9 +734,9 @@ If RELEASE-FILE is nil, use '/etc/os-release'." (let ((os (eshell-info-banner--get-os-information-from-registry))) (save-match-data (string-match "\\([^()]+\\) *(\\([^()]+\\))" os) - `(,(string-trim (substring-no-properties os - (match-beginning 1) - (match-end 1))) + `(,(s-trim (substring-no-properties os + (match-beginning 1) + (match-end 1))) . ,(substring-no-properties os (match-beginning 2) @@ -747,9 +748,9 @@ If RELEASE-FILE is nil, use '/etc/os-release'." `(,(cond ;; Bedrock Linux ((file-exists-p (concat prefix "/bedrock/etc/bedrock-release")) - (string-trim (with-temp-buffer - (insert-file-contents (concat prefix "/bedrock/etc/bedrock-release")) - (buffer-string)))) + (s-trim (with-temp-buffer + (insert-file-contents (concat prefix "/bedrock/etc/bedrock-release")) + (buffer-string)))) ;; Proxmox ((eshell-info-banner--executable-find "pveversion") (let ((distro (eshell-info-banner--shell-command-to-string "pveversion"))) @@ -775,16 +776,16 @@ If RELEASE-FILE is nil, use '/etc/os-release'." (match-end 1)))))) ((equal system-type 'gnu/kfreebsd) (let* ((default-directory (if eshell-info-banner-tramp-aware default-directory "~"))) - (string-trim (with-temp-buffer - (process-file "uname" nil t nil "-s") - (buffer-string))))) + (s-trim (with-temp-buffer + (process-file "uname" nil t nil "-s") + (buffer-string))))) ((and (file-exists-p (concat prefix "/system/app")) (file-exists-p (concat prefix "/system/priv-app"))) (concat "Android " - (string-trim (eshell-info-banner--shell-command-to-string "getprop ro.build.version.release")))) + (s-trim (eshell-info-banner--shell-command-to-string "getprop ro.build.version.release")))) (t "Unknown")) . - ,(string-trim (eshell-info-banner--shell-command-to-string "uname -rs"))))) + ,(s-trim (eshell-info-banner--shell-command-to-string "uname -rs"))))) (defmacro eshell-info-banner--get-macos-name (version) "Get the name of the current macOS or OSX system based on its VERSION." @@ -799,10 +800,10 @@ If RELEASE-FILE is nil, use '/etc/os-release'." (defun eshell-info-banner--get-os-information-darwin () "See `eshell-info-banner--get-os-information'." `(,(eshell-info-banner--get-macos-name - (string-trim + (s-trim (eshell-info-banner--shell-command-to-string "sw_vers -productVersion"))) . - ,(string-trim (eshell-info-banner--shell-command-to-string "uname -rs")))) + ,(s-trim (eshell-info-banner--shell-command-to-string "uname -rs")))) (defun eshell-info-banner--get-os-information () "Get operating system identifying information.