Replace s-trim with string-trim

Progressively phasing out s.el as a dependency
This commit is contained in:
Lucien Cartier-Tilet 2022-04-02 18:09:24 +02:00
parent f9490f07a1
commit dedcb8cee5
Signed by: phundrak
GPG Key ID: BD7789E705CB8DCA
1 changed files with 21 additions and 19 deletions

View File

@ -256,13 +256,13 @@ If the executable `uptime' is not found, return nil."
(if (not (seq-some (lambda (keyword) (if (not (seq-some (lambda (keyword)
(string-match-p keyword uptime-str)) (string-match-p keyword uptime-str))
'("invalid" "illegal" "unknown"))) '("invalid" "illegal" "unknown")))
(s-chop-prefix "up " (s-trim uptime-str)) (s-chop-prefix "up " (string-trim uptime-str))
(let ((uptime-str (eshell-info-banner--shell-command-to-string "uptime"))) (let ((uptime-str (eshell-info-banner--shell-command-to-string "uptime")))
(save-match-data (save-match-data
(string-match "[^,]+up *\\([^,]+\\)," uptime-str) (string-match "[^,]+up *\\([^,]+\\)," uptime-str)
(s-trim (substring-no-properties uptime-str (string-trim (substring-no-properties uptime-str
(match-beginning 1) (match-beginning 1)
(match-end 1))))))))) (match-end 1)))))))))
; Partitions ;;;;;;;;;;;;;;;;;;;;;;;;;; ; Partitions ;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -468,7 +468,7 @@ For TEXT-PADDING and BAR-LENGTH, see the documentation of
"Get the output of COMMAND corresponding to memory information. "Get the output of COMMAND corresponding to memory information.
This function is to be only used on platforms which support sysctl." This function is to be only used on platforms which support sysctl."
(string-to-number (string-to-number
(s-trim (string-trim
(car (last (car (last
(split-string (eshell-info-banner--shell-command-to-string command) (split-string (eshell-info-banner--shell-command-to-string command)
" " " "
@ -480,7 +480,7 @@ See `eshell-info-banner--get-memory'."
(let* ((total (eshell-info-banner--get-memory-unix-command-to-mem "sysctl hw.physmem64")) (let* ((total (eshell-info-banner--get-memory-unix-command-to-mem "sysctl hw.physmem64"))
(used (- total (used (- total
(* 1024 (string-to-number (* 1024 (string-to-number
(s-trim (string-trim
(with-temp-buffer (with-temp-buffer
(insert-file-contents-literally "/proc/meminfo") (insert-file-contents-literally "/proc/meminfo")
(save-match-data (save-match-data
@ -720,9 +720,9 @@ If RELEASE-FILE is nil, use '/etc/os-release'."
(let ((os (eshell-info-banner--get-os-information-from-registry))) (let ((os (eshell-info-banner--get-os-information-from-registry)))
(save-match-data (save-match-data
(string-match "\\([^()]+\\) *(\\([^()]+\\))" os) (string-match "\\([^()]+\\) *(\\([^()]+\\))" os)
`(,(s-trim (substring-no-properties os `(,(string-trim (substring-no-properties os
(match-beginning 1) (match-beginning 1)
(match-end 1))) (match-end 1)))
. .
,(substring-no-properties os ,(substring-no-properties os
(match-beginning 2) (match-beginning 2)
@ -734,9 +734,9 @@ If RELEASE-FILE is nil, use '/etc/os-release'."
`(,(cond `(,(cond
;; Bedrock Linux ;; Bedrock Linux
((file-exists-p (concat prefix "/bedrock/etc/bedrock-release")) ((file-exists-p (concat prefix "/bedrock/etc/bedrock-release"))
(s-trim (with-temp-buffer (string-trim (with-temp-buffer
(insert-file-contents (concat prefix "/bedrock/etc/bedrock-release")) (insert-file-contents (concat prefix "/bedrock/etc/bedrock-release"))
(buffer-string)))) (buffer-string))))
;; Proxmox ;; Proxmox
((eshell-info-banner--executable-find "pveversion") ((eshell-info-banner--executable-find "pveversion")
(let ((distro (eshell-info-banner--shell-command-to-string "pveversion"))) (let ((distro (eshell-info-banner--shell-command-to-string "pveversion")))
@ -762,16 +762,16 @@ If RELEASE-FILE is nil, use '/etc/os-release'."
(match-end 1)))))) (match-end 1))))))
((equal system-type 'gnu/kfreebsd) ((equal system-type 'gnu/kfreebsd)
(let* ((default-directory (if eshell-info-banner-tramp-aware default-directory "~"))) (let* ((default-directory (if eshell-info-banner-tramp-aware default-directory "~")))
(s-trim (with-temp-buffer (string-trim (with-temp-buffer
(process-file "uname" nil t nil "-s") (process-file "uname" nil t nil "-s")
(buffer-string))))) (buffer-string)))))
((and (file-exists-p (concat prefix "/system/app")) ((and (file-exists-p (concat prefix "/system/app"))
(file-exists-p (concat prefix "/system/priv-app"))) (file-exists-p (concat prefix "/system/priv-app")))
(concat "Android " (concat "Android "
(s-trim (eshell-info-banner--shell-command-to-string "getprop ro.build.version.release")))) (string-trim (eshell-info-banner--shell-command-to-string "getprop ro.build.version.release"))))
(t "Unknown")) (t "Unknown"))
. .
,(s-trim (eshell-info-banner--shell-command-to-string "uname -rs"))))) ,(string-trim (eshell-info-banner--shell-command-to-string "uname -rs")))))
(defmacro eshell-info-banner--get-macos-name (version) (defmacro eshell-info-banner--get-macos-name (version)
"Get the name of the current macOS or OSX system based on its VERSION." "Get the name of the current macOS or OSX system based on its VERSION."
@ -785,9 +785,11 @@ If RELEASE-FILE is nil, use '/etc/os-release'."
(defun eshell-info-banner--get-os-information-darwin () (defun eshell-info-banner--get-os-information-darwin ()
"See `eshell-info-banner--get-os-information'." "See `eshell-info-banner--get-os-information'."
`(,(eshell-info-banner--get-macos-name (s-trim (eshell-info-banner--shell-command-to-string "sw_vers -productVersion"))) `(,(eshell-info-banner--get-macos-name
(string-trim
(eshell-info-banner--shell-command-to-string "sw_vers -productVersion")))
. .
,(s-trim (eshell-info-banner--shell-command-to-string "uname -rs")))) ,(string-trim (eshell-info-banner--shell-command-to-string "uname -rs"))))
(defun eshell-info-banner--get-os-information () (defun eshell-info-banner--get-os-information ()
"Get operating system identifying information. "Get operating system identifying information.