From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Jim Porter Newsgroups: gmane.emacs.bugs Subject: bug#71576: 30.0.50; [PATCH] Improve performance of Comint/Eshell password prompt handling Date: Sun, 16 Jun 2024 18:18:01 -0700 Message-ID: <81f2ba94-65a3-7c20-5f73-4d898713eb7f@gmail.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="30976"; mail-complaints-to="usenet@ciao.gmane.io" To: Stefan Kangas , 71576@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Jun 17 03:20:09 2024 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 1sJ12X-0007w0-Eb for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 17 Jun 2024 03:20:09 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sJ12T-0006pp-6V; Sun, 16 Jun 2024 21:20:05 -0400 Original-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 ) id 1sJ12R-0006pa-3O for bug-gnu-emacs@gnu.org; Sun, 16 Jun 2024 21:20:03 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sJ12O-0000uk-Si for bug-gnu-emacs@gnu.org; Sun, 16 Jun 2024 21:20:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sJ12Q-0008IU-Gz for bug-gnu-emacs@gnu.org; Sun, 16 Jun 2024 21:20:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Jim Porter Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 17 Jun 2024 01:20:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 71576 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 71576-submit@debbugs.gnu.org id=B71576.171858715131812 (code B ref 71576); Mon, 17 Jun 2024 01:20:02 +0000 Original-Received: (at 71576) by debbugs.gnu.org; 17 Jun 2024 01:19:11 +0000 Original-Received: from localhost ([127.0.0.1]:57685 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sJ11b-0008H1-4a for submit@debbugs.gnu.org; Sun, 16 Jun 2024 21:19:11 -0400 Original-Received: from mail-ot1-f50.google.com ([209.85.210.50]:45160) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sJ11Z-0008Gn-Kj for 71576@debbugs.gnu.org; Sun, 16 Jun 2024 21:19:10 -0400 Original-Received: by mail-ot1-f50.google.com with SMTP id 46e09a7af769-6f8d0a00a35so3277285a34.2 for <71576@debbugs.gnu.org>; Sun, 16 Jun 2024 18:19:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718587082; x=1719191882; darn=debbugs.gnu.org; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:mime-version:date:message-id:from:to:cc :subject:date:message-id:reply-to; bh=lK05lH3EtDDY9QZGsERyPbTqHK7uPQgM5c+fWfVqWG0=; b=Jky6CLLjI+bmzLEk/+4yIFmVcyXozgPIUmHznd8Rrr9utecAFUvbtfLGEh1mnDKm/u T4E01dQkLQWklc05eHye2xApYtjAA4msGGzNWl8/HSf+ov3kO1pRFUBbpInRX97B8R+8 bdvdajUI5bYGwl19efWM6In63WTcX6E3c+SkuISC23sPQv1fLkj0/Ou0oJLL+vAe0XLs 0+cQ0KIqjs8pS45TInOu/RnX6Gknga8Csp5hkI6eYTNfAddfFT1H5xa1rCn3rzAaT1f7 UQXVtlKmf/cbZqsR6teJiyFvG4dHPw0URJjx1RUh4qmIJArAYIDaZVDtS4lsP11ZsbbK FwJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718587082; x=1719191882; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=lK05lH3EtDDY9QZGsERyPbTqHK7uPQgM5c+fWfVqWG0=; b=rs8wIJr1p0LfKDlO3Du7naFi4tX7YU6saO0KGWuW3dzz7bV3P06B79hokAS7Zbf13J TPOm26AYtGCEWqUJFagxqwWQ23wM/bgxyUNcYktyqGnAiZYW0esSLghC5aze0JRiZ1Gd /2SALJG26Ppc3yNQt7iRe+vpYBLzYzPLvTTI/VvUmeLtAfY2zmKZAQlhGlc3K5C7bwIs mA4BqsMnu++kO8pyF4p3dKJjZkfN24kIQAQ2zoK1hyIpNtwoTQEJvB+6h2oAPs3SSejP RdcgvdGCCfO2gPItUI2etbOU8AS3ipz1nmgp4/XGtjBlfmAGnYK+oqO05k67zJvnb/mr Z5vg== X-Forwarded-Encrypted: i=1; AJvYcCWsjG1TQaELgDXnaq+YoeGa3SbqcPv0jswkoADD23QhtMEoxc9WyGMy/KOlvsSDNuGcuiTCpmBqJ6XqXtFaTUWN75aepRw= X-Gm-Message-State: AOJu0YwHQ9sy80B7GIHz0en8xhpW5ceVCSOEMtFWvCXoFyg1Izb8WF+u tvEaBQJGhG6EsDOQ1RADhA8A7gK+WaSGHsDKfDHVD3VGehwy7g/C X-Google-Smtp-Source: AGHT+IFS/3IEf3max40mPSgTyQzWK4x10fUvXvhzSmRu6PamS+/31I+b21fa4OFeg/7JxHBqq6GRPg== X-Received: by 2002:a05:6870:8197:b0:258:434b:7295 with SMTP id 586e51a60fabf-258434b7457mr9197741fac.12.1718587082162; Sun, 16 Jun 2024 18:18:02 -0700 (PDT) Original-Received: from [192.168.1.2] (syn-023-240-098-037.res.spectrum.com. [23.240.98.37]) by smtp.googlemail.com with ESMTPSA id d2e1a72fcca58-705ccb8d9a1sm6450383b3a.186.2024.06.16.18.18.01 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 16 Jun 2024 18:18:01 -0700 (PDT) Content-Language: en-US In-Reply-To: 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-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:287350 Archived-At: On 6/16/2024 3:53 AM, Stefan Kangas wrote: > Thanks. I'd be okay with putting this patch in Emacs 30, but let's see > what other people think. Sounds good to me. >> +(defcustom comint-password-prompt-max-length 256 >> + "The maximum amount of text to examine when matching password prompts. >> +When non-nil, only examine the last N characters of a block of output. >> +If nil, examine all the output. >> + >> +This is used by `comint-watch-for-password-prompt' to reduce the amount >> +of time spent searching for password prompts." >> + :version "30.1" >> + :type '(choice natnum >> + (const :tag "Examine all output" nil)) >> + :group 'comint) > > If this is hardcoded in Tramp, are we sure that we need this as an > option? I'd suggest making it into a defconst or defvar instead. I don't have a strong opinion here, so I'll wait to see if a majority forms around this... >> + (goto-char (if eshell-password-prompt-max-length >> + (max eshell-last-output-block-begin >> + (- eshell-last-output-end >> + eshell-password-prompt-max-length)) >> + eshell-last-output-block-begin)) >> + (when (let ((case-fold-search t)) >> + (re-search-forward eshell-password-prompt-regexp >> + eshell-last-output-end t)) > > Could this be simplified using re-search-backward with the BOUND > argument instead? I tried, but since I think most of this logic is necessary, it just amounted to swapping the 'if' block with 'eshell-last-output-end'. Performance doesn't look any different, and I find the current way a bit more readable. (This could probably be simplified if we want to require that 'eshell-password-prompt-max-length' be non-nil though.)