From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#60464: 29.0.60; Regression - pcomplete-arg fails with argument 'last Date: Sun, 01 Jan 2023 13:38:28 -0500 Message-ID: References: <87358u5y6l.fsf@daniel-mendler.de> <226b32f79f2d431d75b6@heytings.org> <009141ba-c21a-a5cb-a81b-c72a12a26207@daniel-mendler.de> <226b32f79f728e6bfed4@heytings.org> <82cf05e4-3c3f-9804-4801-eb31988f6d7d@daniel-mendler.de> <226b32f79f325daf9c7a@heytings.org> <226b32f79fe1e154cfb4@heytings.org> <226b32f79f056489e881@heytings.org> Reply-To: Stefan Monnier Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="23951"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: Daniel Mendler , Eli Zaretskii , 60464@debbugs.gnu.org, Jim Porter To: Gregory Heytings Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Jan 01 19:39:16 2023 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 1pC3Eq-00062o-0y for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 01 Jan 2023 19:39:16 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pC3Ed-0001s4-U8; Sun, 01 Jan 2023 13:39:04 -0500 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 1pC3Ec-0001ri-DR for bug-gnu-emacs@gnu.org; Sun, 01 Jan 2023 13:39:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pC3Ec-0001kD-5k for bug-gnu-emacs@gnu.org; Sun, 01 Jan 2023 13:39:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pC3Eb-0005vF-Ry for bug-gnu-emacs@gnu.org; Sun, 01 Jan 2023 13:39:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 01 Jan 2023 18:39:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 60464 X-GNU-PR-Package: emacs Original-Received: via spool by 60464-submit@debbugs.gnu.org id=B60464.167259832022734 (code B ref 60464); Sun, 01 Jan 2023 18:39:01 +0000 Original-Received: (at 60464) by debbugs.gnu.org; 1 Jan 2023 18:38:40 +0000 Original-Received: from localhost ([127.0.0.1]:41750 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pC3EG-0005ub-1w for submit@debbugs.gnu.org; Sun, 01 Jan 2023 13:38:40 -0500 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:61414) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pC3ED-0005uN-QZ for 60464@debbugs.gnu.org; Sun, 01 Jan 2023 13:38:38 -0500 Original-Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 142B31002DE; Sun, 1 Jan 2023 13:38:31 -0500 (EST) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 2ED88100178; Sun, 1 Jan 2023 13:38:29 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1672598309; bh=8pBWNqiOKlnFJ03l54NPS67Kq0v8mzyDc+XHrTKeFoM=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=jcWwSrZ3e0MeFwhTTVo4TObpIRBq/sRt2X9fUGDR34ZIdEbwpQRh7PB42L3bXrq0I Sg/xdUs1IM53SyVNzu3sY525xBujaf/bgzQmJHVNtqk5FpzjkSzW1tckbiFwvDMr5C jkPEd+6wR+S97g2F358ekSDvfkZhTEd4MmZyS/SJnIkp7GovZliY2jWXOeJLrOGnyI FzlU85tb3HmIRsY9V/C4xAahJqM+AKAAUqf+UnU0y17Pnjf3SKRhuX9pAw1RT6LnT4 mKEsdTL2L0SkcPvdpkgS5Kft76sZchzeetGeFpcbQHgC5SnDlLSLERf1bihfKe13o+ CtlmtibpWOe9A== Original-Received: from pastel (unknown [45.72.200.228]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id EE92A120317; Sun, 1 Jan 2023 13:38:28 -0500 (EST) In-Reply-To: <226b32f79f056489e881@heytings.org> (Gregory Heytings's message of "Sun, 01 Jan 2023 18:19:20 +0000") 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:252274 Archived-At: > (let ((arg > (nth (+ (pcase index > ('first 0) > @@ -659,11 +660,11 @@ pcomplete-arg > (_ (- pcomplete-index (or index 0)))) > (or offset 0)) > pcomplete-args))) > - (if (stringp arg) > + (if (or (stringp arg) > + (eq index 'last)) > arg > (propertize > - (buffer-substring (pcomplete-begin index offset) > - (pcomplete-begin (1- (or index 0)) offset)) > + (car (split-string (pcomplete-actual-arg index offset))) > 'pcomplete-arg-value arg)))) I'm not sure what specific problem this is trying to solve (is it the choice of the "index" or is it the precise buffer positions of the bounds)? For the first, would the patch below help? [ For the second, I suspect we can't provide 100% reliably correct information anyway, so I think we'll need to find concrete usecases where it matters before we can judge how much effort is warranted. ] Stefan diff --git a/lisp/pcomplete.el b/lisp/pcomplete.el index 2d3730e294a..815ad252fbd 100644 --- a/lisp/pcomplete.el +++ b/lisp/pcomplete.el @@ -1,6 +1,6 @@ ;;; pcomplete.el --- programmable completion -*- lexical-binding: t -*- -;; Copyright (C) 1999-2022 Free Software Foundation, Inc. +;; Copyright (C) 1999-2023 Free Software Foundation, Inc. ;; Author: John Wiegley ;; Keywords: processes abbrev @@ -652,13 +652,12 @@ pcomplete-arg representation of the argument, namely what the user actually typed in, is returned, and the value of the argument is stored in the pcomplete-arg-value text property of that string." - (let ((arg - (nth (+ (pcase index + (let* ((index (+ (pcase index ('first 0) ('last pcomplete-last) (_ (- pcomplete-index (or index 0)))) - (or offset 0)) - pcomplete-args))) + (or offset 0))) + (arg (nth index pcomplete-args))) (if (stringp arg) arg (propertize