Stefan Kangas <stefankangas@HIDDEN>
to control <at> debbugs.gnu.org
.
Full text available.Received: (at 76103) by debbugs.gnu.org; 9 Feb 2025 15:24:18 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Sun Feb 09 10:24:18 2025 Received: from localhost ([127.0.0.1]:45804 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1th9AQ-0002cM-3K for submit <at> debbugs.gnu.org; Sun, 09 Feb 2025 10:24:18 -0500 Received: from mail-ed1-x52b.google.com ([2a00:1450:4864:20::52b]:61458) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from <stefankangas@HIDDEN>) id 1th9AN-0002c7-QV for 76103 <at> debbugs.gnu.org; Sun, 09 Feb 2025 10:24:16 -0500 Received: by mail-ed1-x52b.google.com with SMTP id 4fb4d7f45d1cf-5de7519e5a7so424828a12.2 for <76103 <at> debbugs.gnu.org>; Sun, 09 Feb 2025 07:24:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1739114649; x=1739719449; darn=debbugs.gnu.org; h=cc:to:subject:message-id:date:mime-version:references:in-reply-to :from:from:to:cc:subject:date:message-id:reply-to; bh=JPYoOpFlWPkr+F6Yg3M8AEwDUdM0OFoCVI1TnM4UxZ0=; b=NyCcw5uBs96iR83+uQnFVH5W6aLeYUykn+vvM1PqvKdNotJNcQJVq5Du1Ip1WM+Ck4 FipHtyFBywT2KAwO6+zy7py/To5artdYeqGJGpU1SQBhEket0axQDFB/0dLOtDh5onxG m7340WMkzETNMxWcxE8uPhTq1ZSiyI+mkUsg6UGM71UxzFiQbwxnb1UJe1qAkbdiRNCv OLckonF9UN68HFvMkhlgKTjsuRbLTe+t0nicF1xK11wHVm+hia/dApqSiXMmtAIaafor UmEsBpUc3ea30wFKEBB5kk8qxE+L6klDohvCoE5434FV7BUKw3DaEF/NzeG6VwR3sGIn ui9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739114649; x=1739719449; h=cc:to:subject:message-id:date:mime-version:references:in-reply-to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=JPYoOpFlWPkr+F6Yg3M8AEwDUdM0OFoCVI1TnM4UxZ0=; b=uUup5IFO+bKt8WGFLeFwi4dZCseB3wY5CtKBT/Y7ozhIclPHw74nNFz3+7bKFhbwUz K7bQOEc2Ah9pVD8q31QDe0EV1q9wpSaonv9EQgk7hvHYAvArz6IGAoQapp5LdQoLypAc Ai3L+xVK8DSv68T7ZR9DwO4N5x4WMGtzk2VYrMHJd9J2ql/7fnhvO8ZDUUgFSrU1IBs+ ch1yXkfn4xchKuDodfNsOxi8Kn16ODDlVPRVgAKzeHdVxAHUwJY3gUMwMO1IR+7m6+fV 41Tqb0uCFb/CYCeOPj9dsmVT5NKD1Tio5NBU+Am6frHvUqYzTguUauFlhhJ01VPu+j7G CFkw== X-Forwarded-Encrypted: i=1; AJvYcCXqm7tLg/JN8dnI4h4bg6Txo130yZHdkZZCWxQeQn9hwZMZfLupGPpYzRnApaPyxzFSMSecnA==@debbugs.gnu.org X-Gm-Message-State: AOJu0YyTVlgnvK3meirHHtzdzle8rEXPAYBU7hSD1ErlfqbZ3Usgfl77 EiS4JVxYwbTXTVaebID/iyQPq2vbNKGYZAKhBLyHZ3XZZjWL9E0+CkaYAUdv+nYcZ5kzYPIVog4 MQTIbRB/N9BFhHW2gGXfW3Y2w4Us= X-Gm-Gg: ASbGncvagpqsUrHHTN7vGkQjuote5n1m8ocGk+6Uqyg+H8+WnGHtDg8zw7JX7UjrJID 9uKkFP3+ncQKXSD/dAc5dji0RNw4sMhtdo1arWZu2AFjoxKlHbFNqxlAvOaLHPVLAADym4Sc= X-Google-Smtp-Source: AGHT+IGSCnMAAM6TMgSOSwxSZRmqxzWD3RgJgF8FRa+dOo1wu4+Adjw2OdfI1j27XaE0JwB1YrE1wSp1fncyvoI/Mbg= X-Received: by 2002:a05:6402:3907:b0:5da:d76:7b2e with SMTP id 4fb4d7f45d1cf-5de44e5e879mr12096758a12.0.1739114649430; Sun, 09 Feb 2025 07:24:09 -0800 (PST) Received: from 753933720722 named unknown by gmailapi.google.com with HTTPREST; Sun, 9 Feb 2025 07:24:09 -0800 From: Stefan Kangas <stefankangas@HIDDEN> In-Reply-To: <m2tt959wcq.fsf@HIDDEN> References: <m2y0yic2q6.fsf@HIDDEN> <86wme25iwu.fsf@HIDDEN> <m2seoqazbl.fsf@HIDDEN> <86cyfu56bk.fsf@HIDDEN> <m2bjvdc0qe.fsf@HIDDEN> <CADwFkmniMZ+oG4c8CVYW7Eey+axD9k5xGrfs+ZiKsbbhRneP2Q@HIDDEN> <m2tt959wcq.fsf@HIDDEN> MIME-Version: 1.0 Date: Sun, 9 Feb 2025 07:24:09 -0800 X-Gm-Features: AWEUYZl3gSYKkBTdaxP3Nw1bsQhyb9M65LozZRf4wsYXJEW-7kZPsSyFXBb9zrY Message-ID: <CADwFkmnQjCkxLOg1q-DGEt6FmsQeag6EkjNhUEn-bVnOm8zxnQ@HIDDEN> Subject: Re: bug#76103: [PATCH] New function 'process-output' To: Alvaro Ramirez <alvaro@HIDDEN> Content-Type: text/plain; charset="UTF-8" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 76103 Cc: Eli Zaretskii <eliz@HIDDEN>, acorallo@HIDDEN, 76103 <at> debbugs.gnu.org, juri@HIDDEN X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) Alvaro Ramirez <alvaro@HIDDEN> writes: >> AFAIU, the body of the proposed `process-output` could be >> reduced to >> >> (string-join (process-lines cmd) "\n") >> >> This makes me doubt if it's worth adding this new API. > > Is there a slight chance re-joining lines with a "\n" does not > preserve process output integrity? I don't know, sorry.
bug-gnu-emacs@HIDDEN
:bug#76103
; Package emacs
.
Full text available.Received: (at 76103) by debbugs.gnu.org; 7 Feb 2025 23:19:31 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Fri Feb 07 18:19:31 2025 Received: from localhost ([127.0.0.1]:37245 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1tgXdD-0003bZ-0y for submit <at> debbugs.gnu.org; Fri, 07 Feb 2025 18:19:31 -0500 Received: from out-186.mta1.migadu.com ([2001:41d0:203:375::ba]:41350) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from <alvaro@HIDDEN>) id 1tgXdA-0003bI-7V for 76103 <at> debbugs.gnu.org; Fri, 07 Feb 2025 18:19:29 -0500 X-Report-Abuse: Please report any abuse attempt to abuse@HIDDEN and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xenodium.com; s=default; t=1738970361; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=LkwGQxc/LLP5cspkpPZvnmT4LBY2fj0XtEgkdeKxdkA=; b=b74AjkwGwAkVM7ILU3qLpmmV9ITvvoY+vhYkTCa7z5ueSxTmCdrVQSyp5tnZglLYSO6wLe 203X9ELc72g8WQqhF/JoBvc7qgz8ofa7RZMjLHKFmhDmOLmOaNcHpLaraB+ngthbogcEJg mG0/DRDFs8LEqpZu33TzC0wmva9f0I0= From: Alvaro Ramirez <alvaro@HIDDEN> To: Stefan Kangas <stefankangas@HIDDEN> Subject: Re: bug#76103: [PATCH] New function 'process-output' In-Reply-To: <CADwFkmniMZ+oG4c8CVYW7Eey+axD9k5xGrfs+ZiKsbbhRneP2Q@HIDDEN> (Stefan Kangas's message of "Fri, 7 Feb 2025 13:21:57 -0600") References: <m2y0yic2q6.fsf@HIDDEN> <86wme25iwu.fsf@HIDDEN> <m2seoqazbl.fsf@HIDDEN> <86cyfu56bk.fsf@HIDDEN> <m2bjvdc0qe.fsf@HIDDEN> <CADwFkmniMZ+oG4c8CVYW7Eey+axD9k5xGrfs+ZiKsbbhRneP2Q@HIDDEN> Date: Fri, 07 Feb 2025 23:19:17 +0000 Message-ID: <m2tt959wcq.fsf@HIDDEN> MIME-Version: 1.0 Content-Type: text/plain; format=flowed X-Migadu-Flow: FLOW_OUT X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 76103 Cc: Eli Zaretskii <eliz@HIDDEN>, acorallo@HIDDEN, 76103 <at> debbugs.gnu.org, juri@HIDDEN X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) Thanks Stefan Stefan Kangas <stefankangas@HIDDEN> writes: > Alvaro Ramirez <alvaro@HIDDEN> writes: > >> Thanks Eli. >> >> Eli Zaretskii <eliz@HIDDEN> writes: >> >>> I'm not sure a 2.5 boost in performance >> >> (let ((before (benchmark-run 1000 >> (shell-command-to-string "seq 200"))) >> (after (benchmark-run 1000 >> (process-output "seq" "200")))) >> (/ (car before) >> (car after))) => 3.27 >> >> Roughly a 3.27 gain, or should I calculate differently? > > I would benchmark this against `process-lines` instead, because > it > doesn't spawn a shell. On this macOS machine, I get 1.15 for > that > benchmark. Eli can correct me here, but he may have suggested shell-command-to-string as it provided a closer-looking interface. When benchmarking against process-lines, the performance difference is indeed negligible. > >>> (on which platform, btw?) justifies yet another API. >> >> macOS. Need to grab a hold of a linux box to get equivalent >> figure. > > AFAIU, the body of the proposed `process-output` could be > reduced to > > (string-join (process-lines cmd) "\n") > > This makes me doubt if it's worth adding this new API. Is there a slight chance re-joining lines with a "\n" does not preserve process output integrity? If so, wouldn't users need to know process-lines internal details, thus inspect process-lines (elisp), process-lines-handling-status (elisp), line-beginning-position/line-end-position (.c), etc to ensure correct usage? > To find arguments that would justify the addition, I'd take a > look at > emacs.git to see which code we have that it would simplify. I'd > also > take a look at packages on GNU ELPA, NonGNU ELPA, and MELPA, to > find > even more supporting evidence. I had a quick look at emacs.git and GitHub (maybe where most of MELPA lives) and process-lines + string-join did not seem like a common pattern. Funnily, I found one in my code ;-) with-temp-buffer + call-process seems more prevalent. While with-temp-buffer or process-lines options do the job just fine, this route may not be as discoverable as process-output for an elisp newcomer.
bug-gnu-emacs@HIDDEN
:bug#76103
; Package emacs
.
Full text available.Received: (at 76103) by debbugs.gnu.org; 7 Feb 2025 19:22:08 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Fri Feb 07 14:22:08 2025 Received: from localhost ([127.0.0.1]:36569 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1tgTvT-00007b-QQ for submit <at> debbugs.gnu.org; Fri, 07 Feb 2025 14:22:08 -0500 Received: from mail-ed1-x52f.google.com ([2a00:1450:4864:20::52f]:46132) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from <stefankangas@HIDDEN>) id 1tgTvQ-00006u-HG for 76103 <at> debbugs.gnu.org; Fri, 07 Feb 2025 14:22:05 -0500 Received: by mail-ed1-x52f.google.com with SMTP id 4fb4d7f45d1cf-5de4c7720bcso1452966a12.0 for <76103 <at> debbugs.gnu.org>; Fri, 07 Feb 2025 11:22:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1738956118; x=1739560918; darn=debbugs.gnu.org; h=cc:to:subject:message-id:date:mime-version:references:in-reply-to :from:from:to:cc:subject:date:message-id:reply-to; bh=WRT7jVhTsxNv6gjxPIdhFVQG0FdhcnWyb413JEoHRaw=; b=LgUT9M0tONc9iReWpoItY9bKu4WNwUpU9O2d3s/uwOT89Rk9hcePjZ3tNuP49gej2N +MmSolabY3NZXwBAl9iZBAVAepJ75r9wsBUvJNRVDh8CGHjNgs6VFLm45/a8JhJT/G5P 9VECXh7WUm7+hiSh/j8CrJUSOq7oe1thgdlvGKIUnUKEhWvx01i5cF9uzHg+33HQvgDo xsA7B+vP6zpp7ECa2Vsd8zPEWGH+l7l4Mz1RJKcPBvSR9v32C6FsXJsZ3EE/u1RjD0nF dICHfI/iI36pAUT8pZBZwfAQIuG3uyY7H34RvEIrWmq6ozUxMQXyRweUftO9JoTpwQoi IPzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738956118; x=1739560918; h=cc:to:subject:message-id:date:mime-version:references:in-reply-to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=WRT7jVhTsxNv6gjxPIdhFVQG0FdhcnWyb413JEoHRaw=; b=lNlnxHewvNUagZaV/b60/G/q2XqSjo85khEzKoitYQlSUfU6l1/wYmbNwEF0y1Rwm8 YGm9XRfjDhRF2Cj4JsbTv6UJbhXgPdy05K2ZsplQkV0GLHPpzmfQcqxF2n8FzG44ndU2 7eubIIz9V/XP/66wFT5UADRDlyE1oFxsaT0IIfvMAEH/O2fpdIxMXORW8O9PhD2P5amc AzoMxSOhi6H7Hs38rOp+YHp5NeSfgNIsSrt9Qg9b1obzNTyttU9iCDgrG4Xz2rAxnLJr 4xuedkSN+iL2Aw0JtgZOfJ+Yg71yQeWshARs1JOb81k6zigZpgdJmsncge7Xt8Azx+Ou 0wSA== X-Forwarded-Encrypted: i=1; AJvYcCV2bFUlntqlkEcOXfkPRCzswnYngZQSv20n8BXbep7IUcwgrl6aDXWLiMvm/dta9OyZIEftdQ==@debbugs.gnu.org X-Gm-Message-State: AOJu0YysIXwdAyqQst389W1qDC9r6wUcdW16I+hOFt8XMekoL1fNptCH CyGg4suVZyJkKOLoNaQDC0H/NZ7gFA+OzIRljdmmvFZ21xhvVbPMWyyvie3ovs3CLw82eqb4zh/ +3i6SiMokt+byvlMZnBOIi25tfn8= X-Gm-Gg: ASbGncuYNzj/SnmtavdYtv6Gp7wAPnUVtFYEUxbfENsznmJK5acx1bP2tEACnPCQ7HB K1yhE46Ev9Xf0tefifmdT9Yk6CKQEYyX8IrJuv6Kklru85lftl9lRiswy2CjZ3v6BlBkWmjxU5+ 0= X-Google-Smtp-Source: AGHT+IEyfi1RFgKhyoSpjSM+dIFkFZxQvtaAtiECKIEpd2ZS6aRU19E11LtyvwXAHLEmKFBGRrmrZmlX/M3xlD3hwaI= X-Received: by 2002:a05:6402:2106:b0:5d0:e410:468b with SMTP id 4fb4d7f45d1cf-5de44feb890mr4617400a12.2.1738956118023; Fri, 07 Feb 2025 11:21:58 -0800 (PST) Received: from 753933720722 named unknown by gmailapi.google.com with HTTPREST; Fri, 7 Feb 2025 13:21:57 -0600 From: Stefan Kangas <stefankangas@HIDDEN> In-Reply-To: <m2bjvdc0qe.fsf@HIDDEN> References: <m2y0yic2q6.fsf@HIDDEN> <86wme25iwu.fsf@HIDDEN> <m2seoqazbl.fsf@HIDDEN> <86cyfu56bk.fsf@HIDDEN> <m2bjvdc0qe.fsf@HIDDEN> MIME-Version: 1.0 Date: Fri, 7 Feb 2025 13:21:57 -0600 X-Gm-Features: AWEUYZlefo1d7QyMhP_kBOsOV06oXf7TJJOcrtGsjDmuS49kPBjwbEiPdaCWCh8 Message-ID: <CADwFkmniMZ+oG4c8CVYW7Eey+axD9k5xGrfs+ZiKsbbhRneP2Q@HIDDEN> Subject: Re: bug#76103: [PATCH] New function 'process-output' To: Alvaro Ramirez <alvaro@HIDDEN>, Eli Zaretskii <eliz@HIDDEN> Content-Type: text/plain; charset="UTF-8" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 76103 Cc: acorallo@HIDDEN, 76103 <at> debbugs.gnu.org, juri@HIDDEN X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) Alvaro Ramirez <alvaro@HIDDEN> writes: > Thanks Eli. > > Eli Zaretskii <eliz@HIDDEN> writes: > >> I'm not sure a 2.5 boost in performance > > (let ((before (benchmark-run 1000 > (shell-command-to-string "seq 200"))) > (after (benchmark-run 1000 > (process-output "seq" "200")))) > (/ (car before) > (car after))) => 3.27 > > Roughly a 3.27 gain, or should I calculate differently? I would benchmark this against `process-lines` instead, because it doesn't spawn a shell. On this macOS machine, I get 1.15 for that benchmark. >> (on which platform, btw?) justifies yet another API. > > macOS. Need to grab a hold of a linux box to get equivalent > figure. AFAIU, the body of the proposed `process-output` could be reduced to (string-join (process-lines cmd) "\n") This makes me doubt if it's worth adding this new API. To find arguments that would justify the addition, I'd take a look at emacs.git to see which code we have that it would simplify. I'd also take a look at packages on GNU ELPA, NonGNU ELPA, and MELPA, to find even more supporting evidence.
bug-gnu-emacs@HIDDEN
:bug#76103
; Package emacs
.
Full text available.Received: (at 76103) by debbugs.gnu.org; 7 Feb 2025 17:13:46 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Fri Feb 07 12:13:46 2025 Received: from localhost ([127.0.0.1]:36251 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1tgRvG-0002Jq-4G for submit <at> debbugs.gnu.org; Fri, 07 Feb 2025 12:13:46 -0500 Received: from mout01.posteo.de ([185.67.36.65]:39013) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from <yantar92@HIDDEN>) id 1tgRvB-0002JW-El for 76103 <at> debbugs.gnu.org; Fri, 07 Feb 2025 12:13:43 -0500 Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id 3E5FD240027 for <76103 <at> debbugs.gnu.org>; Fri, 7 Feb 2025 18:13:35 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1738948415; bh=kWfpmVf/BoPlXIYvNdw/pp/uZsWdtwAYWgc31LtboLw=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type: From; b=pzEBXr64aWKcvgRkOa3Dlm2TTNDlBSAzCWjgQ+BG1uGaPtR5XyzoYiVG5LVFxS9hY wza8zXbj+sN68XGWUZeV/Pl4Fd8vARq99J4LxzZ7NuiG+Qcfo11WZ2TYIrHn8be3oU ywgYb/CXvoVRHUpRLP/HL0XLMhI+7H5gR9PbQbzYHNyX6/jZDjsXMTXUbUoya4B+d7 gKqpQZR733HK8+RKf/XNCwEB8dVL0hh2Vm85jmLJ/E4KNMDrAQyvd05KUBP/8QmwTg WVLpFk9+YkmtCmZ4/JvN4kPjkVAglkKFSE0TY/MSoxOi4RjBlIaf2FQI74t2dkaQPL pu7V0I9CaYQnQ== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4YqLCf0H9mz9rxT; Fri, 7 Feb 2025 18:13:33 +0100 (CET) From: Ihor Radchenko <yantar92@HIDDEN> To: Alvaro Ramirez <alvaro@HIDDEN> Subject: Re: bug#76103: [PATCH] New function 'process-output' In-Reply-To: <m2bjvdc0qe.fsf@HIDDEN> References: <m2y0yic2q6.fsf@HIDDEN> <86wme25iwu.fsf@HIDDEN> <m2seoqazbl.fsf@HIDDEN> <86cyfu56bk.fsf@HIDDEN> <m2bjvdc0qe.fsf@HIDDEN> Date: Fri, 07 Feb 2025 17:15:44 +0000 Message-ID: <87v7tlvfpb.fsf@localhost> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 76103 Cc: Eli Zaretskii <eliz@HIDDEN>, acorallo@HIDDEN, 76103 <at> debbugs.gnu.org, stefankangas@HIDDEN, juri@HIDDEN X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -3.3 (---) Alvaro Ramirez <alvaro@HIDDEN> writes: > (let ((before (benchmark-run 1000 > (shell-command-to-string "seq 200"))) > (after (benchmark-run 1000 > (process-output "seq" "200")))) > (/ (car before) > (car after))) => 3.27 > > Roughly a 3.27 gain, or should I calculate differently? Linux. Not the same every times, but always larger than 2x improvement. ; 5.333148970679263 ; 3.204657728630843 ; 2.0283408689679625 ; 4.1317904673085035 ; 5.0238578857970575 -- Ihor Radchenko // yantar92, Org mode maintainer, Learn more about Org mode at <https://orgmode.org/>. Support Org development at <https://liberapay.com/org-mode>, or support my work at <https://liberapay.com/yantar92>
bug-gnu-emacs@HIDDEN
:bug#76103
; Package emacs
.
Full text available.Received: (at 76103) by debbugs.gnu.org; 7 Feb 2025 14:02:00 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Fri Feb 07 09:02:00 2025 Received: from localhost ([127.0.0.1]:33517 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1tgOvg-0008Km-EG for submit <at> debbugs.gnu.org; Fri, 07 Feb 2025 09:02:00 -0500 Received: from out-176.mta1.migadu.com ([2001:41d0:203:375::b0]:18046) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from <alvaro@HIDDEN>) id 1tgOvb-0008KN-0P for 76103 <at> debbugs.gnu.org; Fri, 07 Feb 2025 09:01:58 -0500 X-Report-Abuse: Please report any abuse attempt to abuse@HIDDEN and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xenodium.com; s=default; t=1738936908; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=OVMomHUphyZA/Mqvax+Se4qvD4RBncm0LyK+q3MC500=; b=VQl+PqzvVSLwooyPxlmv4njW1IfsjNQVHrQTJDQBCPbUNOJsusCxnWxdrkfqPKn34YO2kj Nx7Q9pOQ/q8iaXyXGNdQat0JvlGP9BkjDq9Uas6rFyWD4+/hibDA1Z04bnNXQd5hKlHMak Ee2IsxSct/P4Xb18JZqRFB+bHEmLR4U= From: Alvaro Ramirez <alvaro@HIDDEN> To: Eli Zaretskii <eliz@HIDDEN> Subject: Re: bug#76103: [PATCH] New function 'process-output' In-Reply-To: <86cyfu56bk.fsf@HIDDEN> (Eli Zaretskii's message of "Fri, 07 Feb 2025 13:42:55 +0200") References: <m2y0yic2q6.fsf@HIDDEN> <86wme25iwu.fsf@HIDDEN> <m2seoqazbl.fsf@HIDDEN> <86cyfu56bk.fsf@HIDDEN> Date: Fri, 07 Feb 2025 14:01:45 +0000 Message-ID: <m2bjvdc0qe.fsf@HIDDEN> MIME-Version: 1.0 Content-Type: text/plain; format=flowed X-Migadu-Flow: FLOW_OUT X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 76103 Cc: acorallo@HIDDEN, 76103 <at> debbugs.gnu.org, stefankangas@HIDDEN, juri@HIDDEN X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) Thanks Eli. Eli Zaretskii <eliz@HIDDEN> writes: > I'm not sure a 2.5 boost in performance (let ((before (benchmark-run 1000 (shell-command-to-string "seq 200"))) (after (benchmark-run 1000 (process-output "seq" "200")))) (/ (car before) (car after))) => 3.27 Roughly a 3.27 gain, or should I calculate differently? > (on which platform, btw?) justifies yet another API. macOS. Need to grab a hold of a linux box to get equivalent figure. > We need to think about the downsides of > enlarging Emacs: the need to document each new API, the need to > maintain it, the need to somehow explain which one of the > alternatives > to use in each case, etc. Makes sense. > > But let's see what other maintainers think. Sounds good.
bug-gnu-emacs@HIDDEN
:bug#76103
; Package emacs
.
Full text available.Received: (at 76103) by debbugs.gnu.org; 7 Feb 2025 11:43:10 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Fri Feb 07 06:43:10 2025 Received: from localhost ([127.0.0.1]:33151 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1tgMlJ-00040i-Ik for submit <at> debbugs.gnu.org; Fri, 07 Feb 2025 06:43:10 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:33850) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from <eliz@HIDDEN>) id 1tgMlG-00040B-B8 for 76103 <at> debbugs.gnu.org; Fri, 07 Feb 2025 06:43:07 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <eliz@HIDDEN>) id 1tgMl9-0000m6-U1; Fri, 07 Feb 2025 06:42:59 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=2LwvpQjLVfWds70TvKAohQmsaocnsXW7m8XkKvMPN5A=; b=MUeR1CwkYh6zq3JAUC2d rBW1DR6zNbTIP2b0tx28OG/C1KGS6WJ/r3JzTeFLnG13weJcS/acwjGF3uMGhT0Ct6EXoO17AFdoE j3513uFFOin7kG/6GC0cIAtca4fmxae+YJihYs+KhltqOuDHlQI1aTnux5v4zy1SlC+zuEqxxzFEm eUIR8nNfqWGDm5MDoZRatYHNa53SEoLgu9MMuBdAaQGjl5w0eucV++nKQp11PYCAJQ1dqV2hplRaF Kf8ggagNqGoouI+ItzfXWlNQObxs14xSdJVjTRxkC7uwxn3UQPOhuM8pp9gI/oX+g2flDl/RrDSoR SwThUuypD3pYjQ==; Date: Fri, 07 Feb 2025 13:42:55 +0200 Message-Id: <86cyfu56bk.fsf@HIDDEN> From: Eli Zaretskii <eliz@HIDDEN> To: Alvaro Ramirez <alvaro@HIDDEN> In-Reply-To: <m2seoqazbl.fsf@HIDDEN> (message from Alvaro Ramirez on Fri, 07 Feb 2025 09:17:34 +0000) Subject: Re: bug#76103: [PATCH] New function 'process-output' References: <m2y0yic2q6.fsf@HIDDEN> <86wme25iwu.fsf@HIDDEN> <m2seoqazbl.fsf@HIDDEN> MIME-version: 1.0 Content-type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 76103 Cc: acorallo@HIDDEN, 76103 <at> debbugs.gnu.org, stefankangas@HIDDEN, juri@HIDDEN X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -3.3 (---) > From: Alvaro Ramirez <alvaro@HIDDEN> > Cc: Stefan Kangas <stefankangas@HIDDEN>, Andrea Corallo > <acorallo@HIDDEN>, 76103 <at> debbugs.gnu.org, juri@HIDDEN > Date: Fri, 07 Feb 2025 09:17:34 +0000 > > Hi Eli, > > Thanks for the questions and feedback. Thanks for answering them. > Eli Zaretskii <eliz@HIDDEN> writes: > > >> From: Álvaro Ramírez <alvaro@HIDDEN> > >> Date: Thu, 06 Feb 2025 19:06:25 +0000 > >> > >> I find process-lines super convenient for glueing command line > >> utilities. > >> > >> Often wished I had a similar function that neither split into > >> lines (process-lines) nor relied on shell > >> (shell-command-to-string). > >> > >> Proposing process-output as a close cousin to process-lines. > > > > Thanks, but can you explain why shell-command-to-string is not > > what > > you want? > > 1. Performance: Shell overhead isn't needed to get a process > output. > > (benchmark-run 1000 > (process-output "seq" "200")) => (1.239617 0 0.0) > > (benchmark-run 1000 > (shell-command-to-string "seq 200")) => (4.049149999999999 0 > 0.0) > > 2. Convenience API: The existing process-lines API is simple and > easy to reach out to when glueing command line utilities. > > Would be handy to have the same convenience available via > process-output. > > - Predictably and concisely named: easy to find, starts with > "process-". > - Structure + versatility: IMO while list of args is partially > structured, it remains fairly versatile (benefits from other > list-operating functions) vs unstructured string. > - Avoids all issues with unescaped params (compared to > shell-command-to-string). > > > And in any case, given that the implementation is basically 4 > > lines of > > Users would need to either re-implement this for each package they > build or duplicate the 4 lines every time they want a short-lived > process output. > > > Lisp, why do we need this in Emacs, > > Seems like a good core basic function to offer (same reasons as > above) which package authors can rely on without duplicating > across every packages. > > > and in subr.el on top of that > > subr.el was chosen since that's where the existing process-lines > lives. Happy to move to a more appropriate location. Suggestions? > > > (which means it will be preloaded)? Sounds like not justified > > for > > such a simple function. If some package needs it, and cannot > > use > > shell-command-to-string (for reasons I still don't understand), > > it can easily implement it as a utility function, no? > > I hope the above rationale helps. While in its entirety, it could > be open to opinion, perhaps we can justify purely on performance > alone? I'm not sure a 2.5 boost in performance (on which platform, btw?) justifies yet another API. We need to think about the downsides of enlarging Emacs: the need to document each new API, the need to maintain it, the need to somehow explain which one of the alternatives to use in each case, etc. But let's see what other maintainers think.
bug-gnu-emacs@HIDDEN
:bug#76103
; Package emacs
.
Full text available.Received: (at 76103) by debbugs.gnu.org; 7 Feb 2025 10:53:00 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Fri Feb 07 05:53:00 2025 Received: from localhost ([127.0.0.1]:33055 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1tgLym-00071N-CC for submit <at> debbugs.gnu.org; Fri, 07 Feb 2025 05:53:00 -0500 Received: from out-176.mta1.migadu.com ([2001:41d0:203:375::b0]:10129) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from <alvaro@HIDDEN>) id 1tgLyj-000715-Jv for 76103 <at> debbugs.gnu.org; Fri, 07 Feb 2025 05:52:58 -0500 X-Report-Abuse: Please report any abuse attempt to abuse@HIDDEN and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xenodium.com; s=default; t=1738925570; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=xNCKvUIZzRGsjUWx0Eme5lmbDBFIJUgfpLpDd1rpb7A=; b=tk/c94HnW3sGsul6lY/LCzwzhkk3JyiiJnTyszv7LqbL6EtK7hXr6SBVBN/6VpNT0r/zBs IFFin0cRoOkJLnasLhlapYEE9iOCZ4gJyWr8GAF/NIM5F1jvrNFO6TzUJs3cW+hRPvqW6J Q5fv3kjH4nMCnAOkI5r/i0Pdd6qzwLY= From: Alvaro Ramirez <alvaro@HIDDEN> To: Daniel Mendler <mail@HIDDEN> Subject: Re: bug#76103: [PATCH] New function 'process-output' In-Reply-To: <87cyfuw047.fsf@HIDDEN> (Daniel Mendler's message of "Fri, 07 Feb 2025 10:54:48 +0100") References: <m2y0yic2q6.fsf@HIDDEN> <87mseyrz5b.fsf@HIDDEN> <87cyfuw047.fsf@HIDDEN> Date: Fri, 07 Feb 2025 10:52:45 +0000 Message-ID: <m2h656auwy.fsf@HIDDEN> MIME-Version: 1.0 Content-Type: text/plain; format=flowed X-Migadu-Flow: FLOW_OUT X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 76103 Cc: 76103 <at> debbugs.gnu.org, Juri Linkov <juri@HIDDEN> X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) Daniel Mendler <mail@HIDDEN> writes: > Juri Linkov <juri@HIDDEN> writes: > >>> I find process-lines super convenient for glueing command line >>> utilities. >>> >>> Often wished I had a similar function that neither split into >>> lines >>> (process-lines) nor relied on shell (shell-command-to-string). >>> >>> Proposing process-output as a close cousin to process-lines. >>> >>> Happy to drop process-lines in favour of an existing function >>> I may have >>> missed. >> >> Unfortunately, there is no such function for process output. >> What is worse there is no similar function even for files. >> So everyone have to reimplement the same idiom dozens of times: >> >> (defun read-file (file) >> "Return FILE content as string." >> (with-temp-buffer >> (insert-file-contents file) >> (buffer-string))) >> >> (defun read-lines (file) >> "Return a list of lines of FILE." >> (with-temp-buffer >> (insert-file-contents file) >> (split-string (buffer-string) "\n" t))) These two also resonate dearly. Specially read-file available. I know now to go via with-temp-buffer, but as a newcomer, read-file would have been way more discoverable. >> >> For example, there is a complete implementation of read-file >> in org-babel-eval-read-file, uudecode-tests-read-file, >> eshell-test-file-string. >> >> Also there is a complete implementation of read-lines >> in vc--read-lines. >> >> Also this idiom is widely used in comint-exec, >> eieio-persistent-read, >> ert-write-junit-test-summary-report, >> faceup-test-font-lock-file, >> package--get-description, epa-file-insert-file-contents, >> erc-load-irc-script, gnus-splash-svg-color-symbols, eww-submit, >> tramp-get-lock-file, org-babel-R-evaluate-external-process, >> org-babel-R-evaluate-session, >> ob-session-async-R-value-callback, >> org-babel-julia-evaluate-external-process, >> org-babel-julia-evaluate-session, org-babel-execute:plantuml, >> org-babel-execute:sass, org-babel-screen-test, >> org-texinfo-supports-math-p, ps-prologue-file, shell, >> vc-cvs-file-to-string, vc-hg--active-bookmark-internal, >> erc-tests-common-snapshot-compare em-extpipe-tests--deftest, >> em-hist-test/check-history-file, eshell-test-file-string, >> files-tests-save-buffer-read-only-file, dbus--test-introspect, >> url-file, > > +1 I am in favor of adding such small utility functions to read > small > files or handle limited process output. I think many of us have > implemented such functions, and Juri's code search in the Emacs > code > base demonstrates that. I agree with Eli that for large files or > more > extensive processing working with a buffer is better. But in > other cases > these functions are still useful. > > If a set of such functions will be added to Emacs subr.el or > subr-x.el I > am happy to port them back via Compat, such that they are > available to > all ELPA packages, including the ones targeting older Emacs > versions. > > Daniel
bug-gnu-emacs@HIDDEN
:bug#76103
; Package emacs
.
Full text available.Received: (at 76103) by debbugs.gnu.org; 7 Feb 2025 09:55:10 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Fri Feb 07 04:55:10 2025 Received: from localhost ([127.0.0.1]:32884 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1tgL4n-000158-ST for submit <at> debbugs.gnu.org; Fri, 07 Feb 2025 04:55:10 -0500 Received: from server.qxqx.de ([2a01:4f8:c012:9177::1]:59993 helo=mail.qxqx.de) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from <mail@HIDDEN>) id 1tgL4k-00014N-MN for 76103 <at> debbugs.gnu.org; Fri, 07 Feb 2025 04:55:07 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=daniel-mendler.de; s=key; h=Content-Type:MIME-Version:Message-ID:Date: References:In-Reply-To:Subject:Cc:To:From:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=bgER8bxFy1BXKsMAQVGQCdt+0jN7aIFCfTzjqxiZTPc=; b=FAYSF18NtRDBFavcUoBIcj8rby EfIQoA91U8/EZO8WYkhDYLZNwVDY0DK3uYr73KuilQBlrAIwXlyGEg7Am4+xv67XwPhrTKZUWhnLx 0xIjJXGHKq8LKom16hhyU7TTd7Mw7MLd/m1eIOXleXRQ+g6eEbR+t+UsQ7fFQLVGA0tg=; From: Daniel Mendler <mail@HIDDEN> To: Juri Linkov <juri@HIDDEN> Subject: Re: bug#76103: [PATCH] New function 'process-output' In-Reply-To: <87mseyrz5b.fsf@HIDDEN> (Juri Linkov's message of "Fri, 07 Feb 2025 09:29:20 +0200") References: <m2y0yic2q6.fsf@HIDDEN> <87mseyrz5b.fsf@HIDDEN> Date: Fri, 07 Feb 2025 10:54:48 +0100 Message-ID: <87cyfuw047.fsf@HIDDEN> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 76103 Cc: =?utf-8?Q?=C3=81lvaro_Ram=C3=ADrez?= <alvaro@HIDDEN>, 76103 <at> debbugs.gnu.org X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.7 (-) Juri Linkov <juri@HIDDEN> writes: >> I find process-lines super convenient for glueing command line utilities. >> >> Often wished I had a similar function that neither split into lines >> (process-lines) nor relied on shell (shell-command-to-string). >> >> Proposing process-output as a close cousin to process-lines. >> >> Happy to drop process-lines in favour of an existing function I may have >> missed. > > Unfortunately, there is no such function for process output. > What is worse there is no similar function even for files. > So everyone have to reimplement the same idiom dozens of times: > > (defun read-file (file) > "Return FILE content as string." > (with-temp-buffer > (insert-file-contents file) > (buffer-string))) > > (defun read-lines (file) > "Return a list of lines of FILE." > (with-temp-buffer > (insert-file-contents file) > (split-string (buffer-string) "\n" t))) > > For example, there is a complete implementation of read-file > in org-babel-eval-read-file, uudecode-tests-read-file, > eshell-test-file-string. > > Also there is a complete implementation of read-lines > in vc--read-lines. > > Also this idiom is widely used in comint-exec, eieio-persistent-read, > ert-write-junit-test-summary-report, faceup-test-font-lock-file, > package--get-description, epa-file-insert-file-contents, > erc-load-irc-script, gnus-splash-svg-color-symbols, eww-submit, > tramp-get-lock-file, org-babel-R-evaluate-external-process, > org-babel-R-evaluate-session, ob-session-async-R-value-callback, > org-babel-julia-evaluate-external-process, > org-babel-julia-evaluate-session, org-babel-execute:plantuml, > org-babel-execute:sass, org-babel-screen-test, > org-texinfo-supports-math-p, ps-prologue-file, shell, > vc-cvs-file-to-string, vc-hg--active-bookmark-internal, > erc-tests-common-snapshot-compare em-extpipe-tests--deftest, > em-hist-test/check-history-file, eshell-test-file-string, > files-tests-save-buffer-read-only-file, dbus--test-introspect, url-file, +1 I am in favor of adding such small utility functions to read small files or handle limited process output. I think many of us have implemented such functions, and Juri's code search in the Emacs code base demonstrates that. I agree with Eli that for large files or more extensive processing working with a buffer is better. But in other cases these functions are still useful. If a set of such functions will be added to Emacs subr.el or subr-x.el I am happy to port them back via Compat, such that they are available to all ELPA packages, including the ones targeting older Emacs versions. Daniel
bug-gnu-emacs@HIDDEN
:bug#76103
; Package emacs
.
Full text available.Received: (at 76103) by debbugs.gnu.org; 7 Feb 2025 09:17:51 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Fri Feb 07 04:17:51 2025 Received: from localhost ([127.0.0.1]:32820 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1tgKUh-0007iE-10 for submit <at> debbugs.gnu.org; Fri, 07 Feb 2025 04:17:51 -0500 Received: from out-189.mta0.migadu.com ([91.218.175.189]:41036) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from <alvaro@HIDDEN>) id 1tgKUe-0007hu-37 for 76103 <at> debbugs.gnu.org; Fri, 07 Feb 2025 04:17:48 -0500 X-Report-Abuse: Please report any abuse attempt to abuse@HIDDEN and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xenodium.com; s=default; t=1738919856; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=9DG4TpFJ7mqSPe0GzAoQz6K9y8RMRhzFRi+iUq4p1R8=; b=HvYsta6tL05fhTnFA/bqHDK1tZBGLOsG3jnuAZxcj31LGxKtAsPS6K5wEcB3a+HEcSBZ6B 4F3H2NoAyJrUYZqotUWKL9rskfzNV6A1SUL8Mawylau1cFiEapDvenGzd8FwW1vgqdf4Ov 0mmX3pQrhOD3vJNlDj+Vh4A9/nVWilQ= From: Alvaro Ramirez <alvaro@HIDDEN> To: Eli Zaretskii <eliz@HIDDEN> Subject: Re: bug#76103: [PATCH] New function 'process-output' In-Reply-To: <86wme25iwu.fsf@HIDDEN> (Eli Zaretskii's message of "Fri, 07 Feb 2025 09:10:57 +0200") References: <m2y0yic2q6.fsf@HIDDEN> <86wme25iwu.fsf@HIDDEN> Date: Fri, 07 Feb 2025 09:17:34 +0000 Message-ID: <m2seoqazbl.fsf@HIDDEN> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 76103 Cc: Andrea Corallo <acorallo@HIDDEN>, 76103 <at> debbugs.gnu.org, Stefan Kangas <stefankangas@HIDDEN>, juri@HIDDEN X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.7 (-) Hi Eli, Thanks for the questions and feedback. Eli Zaretskii <eliz@HIDDEN> writes: >> From: =C3=81lvaro Ram=C3=ADrez <alvaro@HIDDEN> >> Date: Thu, 06 Feb 2025 19:06:25 +0000 >> >> I find process-lines super convenient for glueing command line >> utilities. >> >> Often wished I had a similar function that neither split into >> lines (process-lines) nor relied on shell >> (shell-command-to-string). >> >> Proposing process-output as a close cousin to process-lines. > > Thanks, but can you explain why shell-command-to-string is not=20 > what > you want? 1. Performance: Shell overhead isn't needed to get a process=20 output. (benchmark-run 1000 (process-output "seq" "200")) =3D> (1.239617 0 0.0) (benchmark-run 1000 (shell-command-to-string "seq 200")) =3D> (4.049149999999999 0=20 0.0) 2. Convenience API: The existing process-lines API is simple and=20 easy to reach out to when glueing command line utilities. Would be handy to have the same convenience available via=20 process-output. - Predictably and concisely named: easy to find, starts with=20 "process-". - Structure + versatility: IMO while list of args is partially=20 structured, it remains fairly versatile (benefits from other=20 list-operating functions) vs unstructured string. - Avoids all issues with unescaped params (compared to=20 shell-command-to-string). > And in any case, given that the implementation is basically 4=20 > lines of Users would need to either re-implement this for each package they=20 build or duplicate the 4 lines every time they want a short-lived=20 process output. > Lisp, why do we need this in Emacs, Seems like a good core basic function to offer (same reasons as=20 above) which package authors can rely on without duplicating=20 across every packages. > and in subr.el on top of that subr.el was chosen since that's where the existing process-lines=20 lives. Happy to move to a more appropriate location. Suggestions? > (which means it will be preloaded)? Sounds like not justified=20 > for > such a simple function. If some package needs it, and cannot=20 > use > shell-command-to-string (for reasons I still don't understand), > it can easily implement it as a utility function, no? I hope the above rationale helps. While in its entirety, it could=20 be open to opinion, perhaps we can justify purely on performance=20 alone? > > Stefan and Andrea, WDYT?
bug-gnu-emacs@HIDDEN
:bug#76103
; Package emacs
.
Full text available.Received: (at 76103) by debbugs.gnu.org; 7 Feb 2025 08:53:39 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Fri Feb 07 03:53:39 2025 Received: from localhost ([127.0.0.1]:60998 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1tgK7H-0006UF-G1 for submit <at> debbugs.gnu.org; Fri, 07 Feb 2025 03:53:39 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:46802) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from <eliz@HIDDEN>) id 1tgK7F-0006U2-Mp for 76103 <at> debbugs.gnu.org; Fri, 07 Feb 2025 03:53:38 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <eliz@HIDDEN>) id 1tgK78-0005oG-Qf; Fri, 07 Feb 2025 03:53:30 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=oRE+hXxcU1mpe9fI/6g9UQ/aViZEFRYfeV0HekcTF7c=; b=Kg2aBkdPWCRB A/KQ1IDX7ejXRYMxPwnUeaHjF3THZLtP4a5Y2UxkxsCV6jD/zxTXAbgTbvR7yD2I36r5rIIER4/FT AcKWysLHy/BuqYwTTrrCl4nZDrDK77uNvf5G4m1ZAxYpKFtcv9I5X3rzrRxjyUACeKm3AR2Ggu8JL 1A230h+/PxkLG5xu5hNlzf+rkkK6XDFgBdGt7oXegKzctuJjyw2Pbul+r24Pzot55TjPLR5jiGdaa XWQtNhekzjNdnMIwvXz4UtIKN3UJ57zf9vnikjkl7wRo0pZ+22EcsArNxaJ46LKP1cTCgU2c008tC egBV8rssJj6pjGhExqyydA==; Date: Fri, 07 Feb 2025 10:53:26 +0200 Message-Id: <86ed0a5e61.fsf@HIDDEN> From: Eli Zaretskii <eliz@HIDDEN> To: Juri Linkov <juri@HIDDEN> In-Reply-To: <87mseyrz5b.fsf@HIDDEN> (message from Juri Linkov on Fri, 07 Feb 2025 09:29:20 +0200) Subject: Re: bug#76103: [PATCH] New function 'process-output' References: <m2y0yic2q6.fsf@HIDDEN> <87mseyrz5b.fsf@HIDDEN> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 76103 Cc: alvaro@HIDDEN, 76103 <at> debbugs.gnu.org X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -3.3 (---) > Cc: 76103 <at> debbugs.gnu.org > From: Juri Linkov <juri@HIDDEN> > Date: Fri, 07 Feb 2025 09:29:20 +0200 > > > I find process-lines super convenient for glueing command line utilities. > > > > Often wished I had a similar function that neither split into lines > > (process-lines) nor relied on shell (shell-command-to-string). > > > > Proposing process-output as a close cousin to process-lines. > > > > Happy to drop process-lines in favour of an existing function I may have > > missed. > > Unfortunately, there is no such function for process output. > What is worse there is no similar function even for files. > So everyone have to reimplement the same idiom dozens of times: Why do so many Lisp programs use strings instead of processing the text in the buffer? I think it's a bad idea, both in terms of performance and in terms of GC pressure. My impression is that this is due to people having habits from other programming languages. Also please note the with-output-to-string macro, which could help in at least some of these situations.
bug-gnu-emacs@HIDDEN
:bug#76103
; Package emacs
.
Full text available.Received: (at 76103) by debbugs.gnu.org; 7 Feb 2025 07:40:14 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Fri Feb 07 02:40:14 2025 Received: from localhost ([127.0.0.1]:60710 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1tgIyE-0002pn-9r for submit <at> debbugs.gnu.org; Fri, 07 Feb 2025 02:40:14 -0500 Received: from relay5-d.mail.gandi.net ([217.70.183.197]:33703) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from <juri@HIDDEN>) id 1tgIyB-0002kE-6O for 76103 <at> debbugs.gnu.org; Fri, 07 Feb 2025 02:40:12 -0500 Received: by mail.gandi.net (Postfix) with ESMTPSA id 5F15744378; Fri, 7 Feb 2025 07:39:59 +0000 (UTC) From: Juri Linkov <juri@HIDDEN> To: =?iso-8859-1?Q?=C1lvaro_Ram=EDrez?= <alvaro@HIDDEN> Subject: Re: bug#76103: [PATCH] New function 'process-output' In-Reply-To: <m2y0yic2q6.fsf@HIDDEN> Organization: LINKOV.NET References: <m2y0yic2q6.fsf@HIDDEN> Date: Fri, 07 Feb 2025 09:29:20 +0200 Message-ID: <87mseyrz5b.fsf@HIDDEN> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/31.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain X-GND-State: clean X-GND-Score: 0 X-GND-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgddvkeeilecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfitefpfffkpdcuggftfghnshhusghstghrihgsvgenuceurghilhhouhhtmecufedtudenucenucfjughrpefhvfevufgjohhffffkfgggtgesthdtredttdertdenucfhrhhomheplfhurhhiucfnihhnkhhovhcuoehjuhhriheslhhinhhkohhvrdhnvghtqeenucggtffrrghtthgvrhhnpeffgeetfeevlefhleejfeeuheeiudeitdffhfdutdekfeffgffhveehteegueekheenucfkphepledurdduvdelrdeliedrledtnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepledurdduvdelrdeliedrledtpdhhvghlohepmhgrihhlrdhgrghnughirdhnvghtpdhmrghilhhfrhhomhepjhhurhhisehlihhnkhhovhdrnhgvthdpnhgspghrtghpthhtohepvddprhgtphhtthhopeejiedutdefseguvggssghughhsrdhgnhhurdhorhhgpdhrtghpthhtoheprghlvhgrrhhoseigvghnohguihhumhdrtghomh X-GND-Sasl: juri@HIDDEN X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 76103 Cc: 76103 <at> debbugs.gnu.org X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.7 (-) > I find process-lines super convenient for glueing command line utilities. > > Often wished I had a similar function that neither split into lines > (process-lines) nor relied on shell (shell-command-to-string). > > Proposing process-output as a close cousin to process-lines. > > Happy to drop process-lines in favour of an existing function I may have > missed. Unfortunately, there is no such function for process output. What is worse there is no similar function even for files. So everyone have to reimplement the same idiom dozens of times: (defun read-file (file) "Return FILE content as string." (with-temp-buffer (insert-file-contents file) (buffer-string))) (defun read-lines (file) "Return a list of lines of FILE." (with-temp-buffer (insert-file-contents file) (split-string (buffer-string) "\n" t))) For example, there is a complete implementation of read-file in org-babel-eval-read-file, uudecode-tests-read-file, eshell-test-file-string. Also there is a complete implementation of read-lines in vc--read-lines. Also this idiom is widely used in comint-exec, eieio-persistent-read, ert-write-junit-test-summary-report, faceup-test-font-lock-file, package--get-description, epa-file-insert-file-contents, erc-load-irc-script, gnus-splash-svg-color-symbols, eww-submit, tramp-get-lock-file, org-babel-R-evaluate-external-process, org-babel-R-evaluate-session, ob-session-async-R-value-callback, org-babel-julia-evaluate-external-process, org-babel-julia-evaluate-session, org-babel-execute:plantuml, org-babel-execute:sass, org-babel-screen-test, org-texinfo-supports-math-p, ps-prologue-file, shell, vc-cvs-file-to-string, vc-hg--active-bookmark-internal, erc-tests-common-snapshot-compare em-extpipe-tests--deftest, em-hist-test/check-history-file, eshell-test-file-string, files-tests-save-buffer-read-only-file, dbus--test-introspect, url-file, > +(defun process-output (program &rest args) > + "Execute PROGRAM with ARGS, returning its output as a string. > +Signal an error if the program returns with a non-zero exit status. > +Also see `process-lines'." > + (declare (important-return-value t)) > + (with-temp-buffer > + (let ((status (apply #'call-process program nil (current-buffer) nil args))) > + (unless (eq status 0) > + (error "%s exited with status %s" program status)) > + (buffer-string)))) Although process-lines than can be implemented with this as (split-string (process-output program args ...) "\n" t) probably better to not change the existing process-lines-handling-status since it's not clear whether it's enough to use 'split-string', or to use 'string-lines' like in css-mode-test-selectors and scss-mode-test-selectors.
bug-gnu-emacs@HIDDEN
:bug#76103
; Package emacs
.
Full text available.Received: (at 76103) by debbugs.gnu.org; 7 Feb 2025 07:11:08 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Fri Feb 07 02:11:08 2025 Received: from localhost ([127.0.0.1]:60634 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1tgIW3-0001Rg-LZ for submit <at> debbugs.gnu.org; Fri, 07 Feb 2025 02:11:07 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:56310) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from <eliz@HIDDEN>) id 1tgIW1-0001R7-72 for 76103 <at> debbugs.gnu.org; Fri, 07 Feb 2025 02:11:06 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <eliz@HIDDEN>) id 1tgIVv-00081d-Il; Fri, 07 Feb 2025 02:10:59 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=y75nzfeemBykkp17NhZyWlhDnaOB8OGCszW2LYYPu+A=; b=a92Yomx/dpna0ROCAd5d /VGeDexuwnQL7MBYR0Nru/uMGubAb2kLFe2Iol6uch+X8dCZWH767f8qOywrB6bDxbij4Ju1yEv8/ OJy9p0X0LT3K7JbwgZagX6OXJgmruib+Q4WtUvsY3YXR5TKLzZ1j5Hr9tq/rPjPXwqQeoEXcf8ymX +IbX/6pvhuJuCdn18bNRs2DW71kspbtMuW3xnrvfh8OBo7m3D5dHxY7ett1dfAOzJBcT8Fudwy+b6 vEjzTPMxf1JxHBT2vCl3wMg5/E07Jm3A8N0qXLN65d62BMcZ2AYjSaPMVru7OLxTIZG6Iu2utBrzX TvdKIqIQIZojJQ==; Date: Fri, 07 Feb 2025 09:10:57 +0200 Message-Id: <86wme25iwu.fsf@HIDDEN> From: Eli Zaretskii <eliz@HIDDEN> To: =?utf-8?Q?=C3=81lvaro_Ram=C3=ADrez?= <alvaro@HIDDEN>, Stefan Kangas <stefankangas@HIDDEN>, Andrea Corallo <acorallo@HIDDEN> In-Reply-To: <m2y0yic2q6.fsf@HIDDEN> (message from =?utf-8?Q?=C3=81l?= =?utf-8?Q?varo_Ram=C3=ADrez?= on Thu, 06 Feb 2025 19:06:25 +0000) Subject: Re: bug#76103: [PATCH] New function 'process-output' References: <m2y0yic2q6.fsf@HIDDEN> MIME-version: 1.0 Content-type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 76103 Cc: 76103 <at> debbugs.gnu.org X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -3.3 (---) > From: Álvaro Ramírez <alvaro@HIDDEN> > Date: Thu, 06 Feb 2025 19:06:25 +0000 > > I find process-lines super convenient for glueing command line > utilities. > > Often wished I had a similar function that neither split into > lines (process-lines) nor relied on shell > (shell-command-to-string). > > Proposing process-output as a close cousin to process-lines. Thanks, but can you explain why shell-command-to-string is not what you want? And in any case, given that the implementation is basically 4 lines of Lisp, why do we need this in Emacs, and in subr.el on top of that (which means it will be preloaded)? Sounds like not justified for such a simple function. If some package needs it, and cannot use shell-command-to-string (for reasons I still don't understand), it can easily implement it as a utility function, no? Stefan and Andrea, WDYT?
bug-gnu-emacs@HIDDEN
:bug#76103
; Package emacs
.
Full text available.Received: (at submit) by debbugs.gnu.org; 6 Feb 2025 19:06:44 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Thu Feb 06 14:06:44 2025 Received: from localhost ([127.0.0.1]:59483 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1tg7D2-00066v-58 for submit <at> debbugs.gnu.org; Thu, 06 Feb 2025 14:06:44 -0500 Received: from lists.gnu.org ([2001:470:142::17]:57212) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from <alvaro@HIDDEN>) id 1tg7Cz-00066e-Su for submit <at> debbugs.gnu.org; Thu, 06 Feb 2025 14:06:42 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <alvaro@HIDDEN>) id 1tg7Cu-0000WL-BY for bug-gnu-emacs@HIDDEN; Thu, 06 Feb 2025 14:06:36 -0500 Received: from out-174.mta1.migadu.com ([2001:41d0:203:375::ae]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <alvaro@HIDDEN>) id 1tg7Cs-0004PJ-F9 for bug-gnu-emacs@HIDDEN; Thu, 06 Feb 2025 14:06:36 -0500 X-Report-Abuse: Please report any abuse attempt to abuse@HIDDEN and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xenodium.com; s=default; t=1738868789; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type; bh=EuE4FAq58Uw/tQ7OVJGaXF6TNmb2kbgc0QS7kqjzAB8=; b=ZV9YYkUy+PvvIBx/6R34zjdYyZkUKAYa0J+jlpuGdIdUj74PAOS8rMTM75PXVMEihXqD4i BgmATtc0F0YlocVFYLEmXIHv3KnA5GpGkpFT8p23Z58h70ZpzYmyghP1+gkS0YCl3UDsWN sWBazpZdN4yNls6jUCofeRruFrtMxZU= From: =?utf-8?Q?=C3=81lvaro_Ram=C3=ADrez?= <alvaro@HIDDEN> To: bug-gnu-emacs@HIDDEN Subject: [PATCH] New function 'process-output' Date: Thu, 06 Feb 2025 19:06:25 +0000 Message-ID: <m2y0yic2q6.fsf@HIDDEN> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Migadu-Flow: FLOW_OUT Received-SPF: pass client-ip=2001:41d0:203:375::ae; envelope-from=alvaro@HIDDEN; helo=out-174.mta1.migadu.com X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1, DKIM_SIGNED=0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-Spam-Score: 1.0 (+) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -0.0 (/) --=-=-= Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable Hi folks, I find process-lines super convenient for glueing command line=20 utilities. Often wished I had a similar function that neither split into=20 lines (process-lines) nor relied on shell=20 (shell-command-to-string). Proposing process-output as a close cousin to process-lines. Happy to drop process-lines in favour of an existing function I=20 may have missed. =C3=81lvaro In GNU Emacs 31.0.50 (build 1, aarch64-apple-darwin24.0.0, NS appkit-2566.00 Version 15.0.1 (Build 24A348)) of 2025-02-06 built=20 on MacBookPro Repository revision: e333985b36e6efd06eb288256d82e0eaeb4d2bb4 Repository branch: master Windowing system distributor 'Apple', version 10.3.2566 System Description: macOS 15.0.1 Configured using: 'configure --with-ns --prefix=3D/Users/alvaro/stuff/active/code/third_party/emacs/nextstep/Emac= s.app/Contents/MacOS --enable-locallisppath=3D/Users/alvaro/stuff/active/code/third_party/emacs= /nextstep/Emacs.app/Contents/MacOS' --=-=-= Content-Type: text/patch; charset=utf-8 Content-Disposition: attachment; filename=0001-New-function-process-output.patch Content-Transfer-Encoding: quoted-printable From 23a1937079922f4e19b5a2b47343d429b93e7f5e Mon Sep 17 00:00:00 2001 From: =C3=81lvaro Ram=C3=ADrez <me@HIDDEN> Date: Thu, 6 Feb 2025 18:53:15 +0000 Subject: [PATCH] New function 'process-output' * lisp/subr.el (process-output): New convenience process function. Works like process-lines but returns process output as string. * test/lisp/subr-tests.el (subr-test-process-output): New test. * etc/NEWS: Announce the new feature. --- etc/NEWS | 4 ++++ lisp/subr.el | 11 +++++++++++ test/lisp/subr-tests.el | 4 ++++ 3 files changed, 19 insertions(+) diff --git a/etc/NEWS b/etc/NEWS index ade635aa924..eb1d23bd5a6 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -1354,6 +1354,10 @@ provide instructions for finding the definition. New convenience function 'find-function-update-type-alist' offers a concise way to update a symbol's 'find-function-type-alist' property. =20 +--- +** New function 'process-output' +Like existing 'process-lines' function, but returns output as a string. + * Changes in Emacs 31.1 on Non-Free Operating Systems =20 diff --git a/lisp/subr.el b/lisp/subr.el index 12f4ec38b78..4c859365af1 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -3241,6 +3241,17 @@ process-lines (declare (important-return-value t)) (apply #'process-lines-handling-status program nil args)) =20 +(defun process-output (program &rest args) + "Execute PROGRAM with ARGS, returning its output as a string. +Signal an error if the program returns with a non-zero exit status. +Also see `process-lines'." + (declare (important-return-value t)) + (with-temp-buffer + (let ((status (apply #'call-process program nil (current-buffer) nil a= rgs))) + (unless (eq status 0) + (error "%s exited with status %s" program status)) + (buffer-string)))) + (defun process-lines-ignore-status (program &rest args) "Execute PROGRAM with ARGS, returning its output as a list of lines. The exit status of the program is ignored. diff --git a/test/lisp/subr-tests.el b/test/lisp/subr-tests.el index 5b17c598efa..a4db8389a12 100644 --- a/test/lisp/subr-tests.el +++ b/test/lisp/subr-tests.el @@ -343,7 +343,10 @@ subr-test-global-key-binding (should (eq (global-key-binding "x") 'self-insert-command)) (should-not (global-key-binding [f12]))) =20 +(ert-deftest subr-test-process-output () + (should (equal (process-output "echo" "Hello world") "Hello world\n")) + (should-error (process-output "__echo" "Hello world") :type 'error)) + ;;;; Mode hooks. =20 -- 2.39.5 (Apple Git-154) --=-=-=--
Álvaro Ramírez <alvaro@HIDDEN>
:bug-gnu-emacs@HIDDEN
.
Full text available.bug-gnu-emacs@HIDDEN
:bug#76103
; Package emacs
.
Full text available.
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997 nCipher Corporation Ltd,
1994-97 Ian Jackson.