From: Wolfgang Scherer <Wolfgang.Scherer@gmx.de>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 37185@debbugs.gnu.org
Subject: bug#37185: *** GMX Spamverdacht *** Re: bug#37185: 24.5.1: vc--add-line, vc--remove-regexp are sub-optimal
Date: Tue, 27 Aug 2019 00:52:47 +0200 [thread overview]
Message-ID: <12aa168d-54d2-93d9-ab7b-f35a5acaea13@gmx.de> (raw)
In-Reply-To: <8336hoh1dx.fsf@gnu.org>
[-- Attachment #1: Type: text/plain, Size: 281 bytes --]
> It is best to generate your patches using "git format-patch" and then
> send them as an attachment, I think this will solve these problems,
OK. I gave it a shot. Patch is attached.
Since it is slightly different than the first submission, please use this new version for review.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-vc-add-line-vc-remove-regexp-enhanced.patch --]
[-- Type: text/x-patch; name="0001-vc-add-line-vc-remove-regexp-enhanced.patch", Size: 2019 bytes --]
From cf4a651a2ae799efd3c11ac2ccb83fbb1f2683b5 Mon Sep 17 00:00:00 2001
From: Wolfgang Scherer <wolfgang.scherer@gmx.de>
Date: Tue, 27 Aug 2019 00:45:48 +0200
Subject: [PATCH] vc--add-line, vc--remove-regexp enhanced
* lisp/vc/vc.el (vc--add-line): Create file, if it does not exist.
Use existing buffer to avoid discrepancies with filesytem. Make sure,
the file ends with a newline.
(vc--remove-line): Do not Create file, if it does not exist. Use
existing buffer to avoid discrepancies with filesytem. (bug#37185)
Copyright-paperwork-exempt: yes
---
lisp/vc/vc.el | 20 +++++++++++---------
1 file changed, 11 insertions(+), 9 deletions(-)
diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el
index 4cac153..d97e7a2 100644
--- a/lisp/vc/vc.el
+++ b/lisp/vc/vc.el
@@ -1449,20 +1449,22 @@ Argument BACKEND is the backend you are using."
;; Subroutine for `vc-git-ignore' and `vc-hg-ignore'.
(defun vc--add-line (string file)
"Add STRING as a line to FILE."
- (with-temp-buffer
- (insert-file-contents file)
+ (with-current-buffer (find-file-noselect file)
+ (goto-char (point-min))
(unless (re-search-forward (concat "^" (regexp-quote string) "$") nil t)
(goto-char (point-max))
- (insert (concat "\n" string))
- (write-region (point-min) (point-max) file))))
+ (unless (bolp) (insert "\n"))
+ (insert string "\n")
+ (save-buffer))))
(defun vc--remove-regexp (regexp file)
"Remove all matching for REGEXP in FILE."
- (with-temp-buffer
- (insert-file-contents file)
- (while (re-search-forward regexp nil t)
- (replace-match ""))
- (write-region (point-min) (point-max) file)))
+ (if (file-exists-p file)
+ (with-current-buffer (find-file-noselect file)
+ (goto-char (point-min))
+ (while (re-search-forward regexp nil t)
+ (replace-match ""))
+ (save-buffer))))
(defun vc-checkout (file &optional rev)
"Retrieve a copy of the revision REV of FILE.
--
2.7.4
next prev parent reply other threads:[~2019-08-26 22:52 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-25 20:32 bug#37185: 24.5.1: vc--add-line, vc--remove-regexp are sub-optimal Wolfgang Scherer
2019-08-26 6:44 ` Eli Zaretskii
2019-08-26 22:52 ` Wolfgang Scherer [this message]
2019-08-27 7:37 ` bug#37185: *** GMX Spamverdacht *** " Eli Zaretskii
2019-08-27 23:38 ` bug#37185: *** GMX Spamverdacht *** " Wolfgang Scherer
2019-09-14 0:45 ` bug#37185: " Dmitry Gutov
2019-09-16 17:14 ` Wolfgang Scherer
2019-09-16 17:15 ` Wolfgang Scherer
2019-12-24 22:39 ` Dmitry Gutov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=12aa168d-54d2-93d9-ab7b-f35a5acaea13@gmx.de \
--to=wolfgang.scherer@gmx.de \
--cc=37185@debbugs.gnu.org \
--cc=eliz@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.