From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: master 101f3cf5b9: Add support for user edits to VC command arguments Date: Fri, 23 Sep 2022 15:32:48 -0400 Message-ID: References: <166378878197.3568.7077863090259744101@vcs2.savannah.gnu.org> <20220921193303.1B687C11D81@vcs2.savannah.gnu.org> <87sfkjjdie.fsf@melete.silentflame.com> <87tu4y0yag.fsf@melete.silentflame.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="36918"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) Cc: emacs-devel@gnu.org To: Sean Whitton Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Sep 23 21:33:56 2022 Return-path: Envelope-to: ged-emacs-devel@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 1oboQu-0009Sc-FK for ged-emacs-devel@m.gmane-mx.org; Fri, 23 Sep 2022 21:33:56 +0200 Original-Received: from localhost ([::1]:48166 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oboQs-00045t-Um for ged-emacs-devel@m.gmane-mx.org; Fri, 23 Sep 2022 15:33:54 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:57748) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oboQ6-0003Ow-Ul for emacs-devel@gnu.org; Fri, 23 Sep 2022 15:33:07 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:61895) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oboPt-0002Z7-Kt for emacs-devel@gnu.org; Fri, 23 Sep 2022 15:33:05 -0400 Original-Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 2348C10013B; Fri, 23 Sep 2022 15:32:52 -0400 (EDT) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 08FAF1000EF; Fri, 23 Sep 2022 15:32:50 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1663961570; bh=CXMNWAU3oqk304moB+Fme3pW6iPeThFifLoUFTrMXso=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=Q1T38T5YqKdWuULXs8tHkEXpQhizOlosPVnm1UtaD2jwh/kADdJ1TFctv0Q7aSpAe yE6Omhd7rfVp1Uz8xhyuK4FUygadvb2ffrdl+1DxUv5u3RHgS0DEKWEMm18C7V1TZ4 GDA1kFCK2P57JDh0ML0g44upQwuTNUatEPzoTWMn2iK9J7EH1sI82OfAMdeO5WI+3r a9015g2GUb0QUbYkrRoyIxSD73eO+SusjOs6h/gSlrb2O66nKIcpbh8C/SVj5UMx9L 1jHy/1auFyrbI+cK9Loujsq0RaCB5bCnlma8OzAz7hhM8emCEKpwZ1LpD/U1+d5pZe eUldTKnnox7Iw== Original-Received: from alfajor (unknown [45.44.229.252]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id DB959120AAA; Fri, 23 Sep 2022 15:32:49 -0400 (EDT) In-Reply-To: <87tu4y0yag.fsf@melete.silentflame.com> (Sean Whitton's message of "Fri, 23 Sep 2022 10:56:55 -0700") Received-SPF: pass client-ip=132.204.25.50; envelope-from=monnier@iro.umontreal.ca; helo=mailscanner.iro.umontreal.ca X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, SPF_HELO_NONE=0.001, T_SPF_TEMPERROR=0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:296086 Archived-At: >>> Previously it was inserted without going via the hook. >> But why did you change the code so it goes via the hook? > So that it uses the user-updated value of the command, Ah, that makes sense. > From b0fcba8791a1702a41df0d4f12bb47d151eec5b9 Mon Sep 17 00:00:00 2001 > From: Sean Whitton > Date: Fri, 23 Sep 2022 10:43:31 -0700 > Subject: [PATCH 1/2] vc-git--pushpull: Restore handling of vc-git-program > > * lisp/vc/vc-git.el (vc-git--pushpull): Restore handling of > vc-git-program before recent change: respect a buffer-local value of > vc-git-program, and don't ignore user edits to the git program name > when PROMPT. LGTM. > From 594ff0b4bdad1f756614556f3487b98ad632c617 Mon Sep 17 00:00:00 2001 > From: Sean Whitton > Date: Fri, 23 Sep 2022 10:09:34 -0700 > Subject: [PATCH 2/2] Rework user edits to VC commands to use a more functional > style > > * lisp/vc/vc-dispatcher.el (vc-pre-command-functions): Delete. > (vc-filter-command-function): New variable. > (vc-user-edit-command): Factor out of vc-do-command. > (vc-do-command, vc-do-async-command): > * lisp/vc/vc-git.el (vc-git--pushpull): > * lisp/vc/vc.el (vc-print-branch-log): Use vc-filter-command-function > in place of vc-pre-command-functions and vc-pre-command-functions. IIUC you could also remove the `vc-want-edit-command-p` variable, right? > +(defvar vc-filter-command-function (lambda (&rest args) args) > + "Function called to transform VC commands before execution. > +The function is called inside the buffer in which the command > +will be run and is passed the COMMAND, FILE-OR-LIST and FLAGS > +arguments to `vc-do-command'. It should return a list with the > +same structure containing new values for these arguments.") That makes it sound like it receives 3 args (which sounds fine to me). > +(defun vc-user-edit-command (command file-or-list &rest flags) But these aren't 3 args, it's "2 or more". So the doc and the code don't match. BTW, `apply` and `&rest` are noticeably less efficient than `funcall` and normal args. Efficiency admittedly doesn't matter much here, but I'd recommend we don't needlessly use apply/&rest (i.e. I recommend we fix the code to match the doc than the other way around). Stefan