From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Wolfgang Scherer Newsgroups: gmane.emacs.bugs Subject: bug#37185: 24.5.1: vc--add-line, vc--remove-regexp are sub-optimal Date: Sun, 25 Aug 2019 22:32:35 +0200 Message-ID: <8d3275a0-149c-6f6a-ff22-c6ef27395188@gmx.de> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="148336"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.2 To: 37185@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Aug 25 23:02:42 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1i1zer-000cTP-Aw for geb-bug-gnu-emacs@m.gmane.org; Sun, 25 Aug 2019 23:02:41 +0200 Original-Received: from localhost ([::1]:47992 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i1zep-0007t4-P6 for geb-bug-gnu-emacs@m.gmane.org; Sun, 25 Aug 2019 17:02:39 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:53725) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i1zdK-0007EP-Ni for bug-gnu-emacs@gnu.org; Sun, 25 Aug 2019 17:01:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i1zdI-0005jT-N9 for bug-gnu-emacs@gnu.org; Sun, 25 Aug 2019 17:01:06 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:36367) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i1zdG-0005hH-II for bug-gnu-emacs@gnu.org; Sun, 25 Aug 2019 17:01:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1i1zdG-0003FV-Er for bug-gnu-emacs@gnu.org; Sun, 25 Aug 2019 17:01:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Wolfgang Scherer Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 25 Aug 2019 21:01:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 37185 X-GNU-PR-Package: emacs X-Debbugs-Original-To: Emacs Bugs Original-Received: via spool by submit@debbugs.gnu.org id=B.156676680512343 (code B ref -1); Sun, 25 Aug 2019 21:01:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 25 Aug 2019 21:00:05 +0000 Original-Received: from localhost ([127.0.0.1]:45188 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1i1zcK-0003D0-Dz for submit@debbugs.gnu.org; Sun, 25 Aug 2019 17:00:04 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:44312) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1i1zBu-0002Qd-H2 for submit@debbugs.gnu.org; Sun, 25 Aug 2019 16:32:46 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:49114) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i1zBt-0006vV-0p for bug-gnu-emacs@gnu.org; Sun, 25 Aug 2019 16:32:46 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i1zBr-0000xo-Rd for bug-gnu-emacs@gnu.org; Sun, 25 Aug 2019 16:32:44 -0400 Original-Received: from mout.gmx.net ([212.227.15.18]:59509) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i1zBr-0000xe-Ft for bug-gnu-emacs@gnu.org; Sun, 25 Aug 2019 16:32:43 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1566765157; bh=pI2C2jmujtGrbxQmF/opNbKAkMcbUylG+sWJsNy61Hc=; h=X-UI-Sender-Class:To:From:Subject:Date; b=Jz43+4RUhS44UF6Fy8l4dTdmIpcxKyJ/B6a/hg9ty8V7VXlafUSlzoOLZKFBA8FWz 5pVw0vsS9swNQqIwFttZINy4FNuLm0Hrj3SH7d98nmyfShx7bbdx6wKY8q2B2ixzuB lSP7toW8oQHhIK0EteH/dzLll2AlkncefwXsDU0Q= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Original-Received: from sheckley.simul.de ([87.144.35.29]) by mail.gmx.com (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MhD2O-1iesiN2dbG-00eOji for ; Sun, 25 Aug 2019 22:32:37 +0200 Original-Received: from [127.0.0.1] (sheckley.simul.de [127.0.0.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by sheckley.simul.de (Postfix) with ESMTPSA id B88A31940560 for ; Sun, 25 Aug 2019 22:32:35 +0200 (CEST) Openpgp: preference=signencrypt Autocrypt: addr=Wolfgang.Scherer@gmx.de; prefer-encrypt=mutual; keydata= xsDiBEb46IgRBACMHOAb1KNo1Ylk+ebri+4R+bG4tyKlqBlrpv8D9/ZwRdXSGt+0DyCHoaAd 7KW7noHapLe87DunABOjKG4nqTGv+dRiWuUBlp3I4aYRFDVa3Da+XnIYkMHKqhK59VEHQCdp Km42nuLS7TS+n99at9YwzTG6VBdOlBKTlRFngOjVLwCg1RGXJ6X3EjS1FKCQeXziURVpWlkD /2zY6Ayhx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mUnEhuEnBSy/4hZ67n7Fewu33UKD Lm9rLKW7mD1MuNyRlwDI23ImbFLM6IDYYklR0N6sKF8NHfRJvoEMn5c/u3RVYhZ/nl+NBqOeU qCzJRhtxx/4v17WAr1HWFwq0qXATnNM4mtIZhwNhYff5K7JAuln1F77sa/8/ujJjMNeQOzrJ6 43wJncrZ/BE9pHNxohBHvY4/7cd+x/0vc2pkekgoNJx5KAgz+k9yQ3KW9q8VwJHktLHN6CiRZ YWpip9jQMRDcEGFWhfrxIDDfzawAkdClv0WCs26RMdxxWjG5tK+0dcRW/dAJt13E8HmibU576 VsBZ031TpuyOS5LywNUeeYO6YK7oURdgCd+OpDjLsAvh17taCQbQtSCUEnGJx4W0VaAdawTZk p9jdK6dqUjm4r6zJKdVy3UrfhBZHj//hJKleCG+TO75P6KlC/Bz5gJ5OS19cdGNMdtmb1QFSW 63mZdvKyYoGzS1syMeg3pltlKSUS/lww8Y5IOpFcnrL1oiYglw0M7If216xtAawig1JDahJc9 E6hXfSnFGfMO32B7wEsh6HrA5xts6qYezs6DuJ/aN13qThOUkd4HjWA9JJoVPbovvaqyWKSU X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Mailman-Approved-At: Sun, 25 Aug 2019 17:00:03 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 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.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:165860 Archived-At: In a *vc-dir* buffer for mercurial, ignoring a file with `vc-dir-ignore': - If the file `.hgignore' is not found, an error is raised: =C2=A0=C2=A0=C2=A0 vc--add-line: Opening input file: datei oder Verzeichni= s nicht gefunden, /srv/install/linux/emacs/check/.hgignore =C2=A0 This error is unnecesary and serves no real purpose. - If the file `.hgignore' exists, `vc--add-line' reads the file =C2=A0 from the filesysstem into a temporary buffer and saves the =C2=A0 modified buffer back into the filesystem. =C2=A0 If the file `.hgignore' was already open in a different buffer, =C2=A0 a prompt is displayed, when trying to modify the contents of =C2=A0 that buffer: =C2=A0=C2=A0=C2=A0 File .hgignore changed on disk.=C2=A0 Reread from disk?= (y or n) y =C2=A0 This is at least annoying, if not seriously wrong. - When adding a new entry to a `.hgignore' file that is already =C2=A0 terminated with a newline, `vc--add-line' produces an empty =C2=A0 line and the file ends without a newline, which seriously =C2=A0 interferes with diffs. =C2=A0 I fail to see any purpose for such a behavior. Since `vc-cvs-append-to-ignore' uses `find-file-no-select', there should be no problem applying the same semantics for mercurial. The following patch agains the Savannah repository implements the algorithm from `vc-cvs-append-to-ignore' in `vc--add-line' and `vc--remove-regexp' as applicable. diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el index 4cac153..bd0b601 100644 =2D-- a/lisp/vc/vc.el +++ b/lisp/vc/vc.el @@ -1449,20 +1449,21 @@ Argument BACKEND is the backend you are using." =C2=A0;; Subroutine for `vc-git-ignore' and `vc-hg-ignore'. =C2=A0(defun vc--add-line (string file) =C2=A0=C2=A0 "Add STRING as a line to FILE." -=C2=A0 (with-temp-buffer -=C2=A0=C2=A0=C2=A0 (insert-file-contents file) +=C2=A0 (with-current-buffer (find-file-noselect file) +=C2=A0=C2=A0=C2=A0 (goto-char (point-min)) =C2=A0=C2=A0=C2=A0=C2=A0 (unless (re-search-forward (concat "^" (regexp-qu= ote string) "$") nil t) =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (goto-char (point-max)) -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (insert (concat "\n" string)) -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (write-region (point-min) (point-max) file= )))) +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (unless (bolp) (insert "\n")) +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (insert string "\n") +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (save-buffer)))) =C2=A0 =C2=A0(defun vc--remove-regexp (regexp file) =C2=A0=C2=A0 "Remove all matching for REGEXP in FILE." -=C2=A0 (with-temp-buffer -=C2=A0=C2=A0=C2=A0 (insert-file-contents file) +=C2=A0 (with-current-buffer (find-file-noselect file) +=C2=A0=C2=A0=C2=A0 (goto-char (point-min)) =C2=A0=C2=A0=C2=A0=C2=A0 (while (re-search-forward regexp nil t) =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (replace-match "")) -=C2=A0=C2=A0=C2=A0 (write-region (point-min) (point-max) file))) +=C2=A0=C2=A0=C2=A0 (save-buffer))) =C2=A0 =C2=A0(defun vc-checkout (file &optional rev) =C2=A0=C2=A0 "Retrieve a copy of the revision REV of FILE.