From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Manuel Giraud Newsgroups: gmane.emacs.bugs Subject: bug#58307: 29.0.50; Fix battery mode over TRAMP on *BSD Date: Thu, 06 Oct 2022 10:17:17 +0200 Message-ID: <87ilkxl62a.fsf@elite.giraud> References: <87ilkyfhlo.fsf@elite.giraud> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="39067"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 58307@debbugs.gnu.org To: Stefan Kangas Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Oct 06 10:48:26 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ogMYK-0009zi-UL for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 06 Oct 2022 10:48:25 +0200 Original-Received: from localhost ([::1]:41124 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ogMYJ-0004LA-Cg for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 06 Oct 2022 04:48:23 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:37660) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogM51-0003Wt-0b for bug-gnu-emacs@gnu.org; Thu, 06 Oct 2022 04:18:07 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:59768) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ogM4w-0003ZL-4b for bug-gnu-emacs@gnu.org; Thu, 06 Oct 2022 04:18:06 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ogM4v-00005i-Ts for bug-gnu-emacs@gnu.org; Thu, 06 Oct 2022 04:18:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Manuel Giraud Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 06 Oct 2022 08:18:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 58307 X-GNU-PR-Package: emacs Original-Received: via spool by 58307-submit@debbugs.gnu.org id=B58307.166504424432754 (code B ref 58307); Thu, 06 Oct 2022 08:18:01 +0000 Original-Received: (at 58307) by debbugs.gnu.org; 6 Oct 2022 08:17:24 +0000 Original-Received: from localhost ([127.0.0.1]:58842 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ogM4J-0008WE-LF for submit@debbugs.gnu.org; Thu, 06 Oct 2022 04:17:23 -0400 Original-Received: from ledu-giraud.fr ([51.159.28.247]:15855) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ogM4G-0008W3-B8 for 58307@debbugs.gnu.org; Thu, 06 Oct 2022 04:17:22 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; s=rsa; bh=k/+0rub9zVd1Ulz+ 4tGH9ZAfH5upZIJWQ4qVWUQKCZM=; h=date:references:in-reply-to:subject: cc:to:from; d=ledu-giraud.fr; b=AeujLAlOO/DnTLytOFUNf3y57X6VzHxJAAdDPf YsOcvPwzEXvlEzPwSVuQtFH5MYLxx7TDUZ63ppVSMdnXCCdhPPoH/pxuHV+7ltRPh0J93P /ZN3Y8p+q4yH+Q+CeggY0R9QkISepyN6WRPlik6yS47G6nnpaIXa/9nZowysqCytcQO/dJ /8TOWKr7bKRzmjEIM4TsEfQpVdHqdhZ5Ra86bMOYt/g0sy201CkQJKxYRvGSV2AeTx/tYL 5sDGigeih0g4laUuRyqfQ6hUHYqafSjIoIzrCIqSnyDR/6HoJAt0GrrPi1QhMbfr+V2yBV ubXugdFXwp6xmuv25Qq00slA== Original-Received: from elite.giraud ( [10.1.1.1]) by ledu-giraud.fr (OpenSMTPD) with ESMTPSA id 551e68fb (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Thu, 6 Oct 2022 10:17:18 +0200 (CEST) In-Reply-To: (Stefan Kangas's message of "Wed, 5 Oct 2022 15:51:35 -0700") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:244615 Archived-At: --=-=-= Content-Type: text/plain Thank you Stefan and Michael! Here is an updated version. My wording in the comment might not be correct. Best regards. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Fix-BSD-battery-mode-over-TRAMP-bug-58307.patch >From f9b1ee4df0280daab91a103fde4ee3a707d4224c Mon Sep 17 00:00:00 2001 From: Manuel Giraud Date: Wed, 5 Oct 2022 15:59:14 +0200 Subject: [PATCH] Fix BSD battery mode over TRAMP (bug#58307) * lisp/battery.el (battery--call-process-to-string): Simple wrapper to `call-process' that outputs to a string. (battery-bsd-apm): Use it instead of `shell-command-to-string'. --- lisp/battery.el | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/lisp/battery.el b/lisp/battery.el index 72b3dfdae7..4c83f8a7d3 100644 --- a/lisp/battery.el +++ b/lisp/battery.el @@ -914,6 +914,15 @@ battery-upower ;;; `apm' interface for BSD. +;; This function is a wrapper on `call-process' that return the +;; standard output in a string. We are using it instead +;; `shell-command-to-string' because this last one is trying to run +;; PROGRAM on the remote host if the buffer is remote. +(defun battery--call-process-to-string (program &rest args) + (with-output-to-string + (with-current-buffer standard-output + (apply #'call-process program nil t nil args)))) + (defun battery-bsd-apm () "Get APM status information from BSD apm binary. The following %-sequences are provided: @@ -929,13 +938,14 @@ battery-bsd-apm %t Remaining time (to charge or discharge) in the form `h:min'" (let* ((os-name (car (split-string ;; FIXME: Can't we use something like `system-type'? - (shell-command-to-string "/usr/bin/uname")))) + (battery--call-process-to-string (executable-find "uname"))))) (apm-flag (pcase os-name ("OpenBSD" "mP") ("FreeBSD" "st") (_ "ms"))) - (apm-cmd (concat "/usr/sbin/apm -abl" apm-flag)) - (apm-output (split-string (shell-command-to-string apm-cmd))) + (apm-args (concat "-abl" apm-flag)) + (apm-output (split-string + (battery--call-process-to-string (executable-find "apm") apm-args))) (indices (pcase os-name ;; FreeBSD's manpage documents that multiple ;; outputs are ordered by "the order in which -- 2.37.3 --=-=-= Content-Type: text/plain -- Manuel Giraud --=-=-=--