From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Lars Ingebrigtsen Newsgroups: gmane.emacs.bugs Subject: bug#49124: Wdired doesn't like re-search-forward/replace-match Date: Mon, 21 Jun 2021 15:11:50 +0200 Message-ID: <87k0mns6p5.fsf@gnus.org> References: <87o8c1b9yf.fsf@web.de> <87sg1d9td6.fsf@web.de> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="2635"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: 49124@debbugs.gnu.org, Eduardo Ochs To: Michael Heerdegen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Jun 21 15:13:21 2021 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 1lvJjt-0000XA-EH for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 21 Jun 2021 15:13:21 +0200 Original-Received: from localhost ([::1]:54864 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lvJjs-0001YL-7O for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 21 Jun 2021 09:13:20 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:46740) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lvJjb-0001Vt-2B for bug-gnu-emacs@gnu.org; Mon, 21 Jun 2021 09:13:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:52495) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lvJja-0000m9-Mq for bug-gnu-emacs@gnu.org; Mon, 21 Jun 2021 09:13:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lvJja-0001SD-BE for bug-gnu-emacs@gnu.org; Mon, 21 Jun 2021 09:13:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Lars Ingebrigtsen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 21 Jun 2021 13:13:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 49124 X-GNU-PR-Package: emacs Original-Received: via spool by 49124-submit@debbugs.gnu.org id=B49124.16242811235499 (code B ref 49124); Mon, 21 Jun 2021 13:13:02 +0000 Original-Received: (at 49124) by debbugs.gnu.org; 21 Jun 2021 13:12:03 +0000 Original-Received: from localhost ([127.0.0.1]:35805 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lvJic-0001Qd-H1 for submit@debbugs.gnu.org; Mon, 21 Jun 2021 09:12:03 -0400 Original-Received: from quimby.gnus.org ([95.216.78.240]:52288) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lvJiZ-0001Q4-NZ for 49124@debbugs.gnu.org; Mon, 21 Jun 2021 09:12:01 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date: References:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=CcsYHjfLAavASYO0qW+gszSrQGfM/bS/jG4c6tnPgpk=; b=UPNY8qLuVakLVUN1PZrbFVYB8b yRsD071gOMbREQ6LpTqAh34hLDGhyJVGZGp1gHCbVIhS3uNoRJEqOTtkAh/Fb9m4tZ/ZfYIf4PCob h1HhWKi0CB7MVnS21gJd8ZDJhzl/6csxKOd26z0C5nvr1A0ScMAUB9oVUOF/z4DuXB4g=; Original-Received: from cm-84.212.220.105.getinternet.no ([84.212.220.105] helo=elva) by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lvJiQ-0004MM-LF; Mon, 21 Jun 2021 15:11:53 +0200 X-Now-Playing: The Police's _Outlandos d'Amour_: "Can't Stand Losing You" In-Reply-To: <87sg1d9td6.fsf@web.de> (Michael Heerdegen's message of "Sun, 20 Jun 2021 04:12:37 +0200") 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" Xref: news.gmane.io gmane.emacs.bugs:208819 Archived-At: Michael Heerdegen writes: > AFAIU we just need a (save-restriction (widen) ...) wrapper for the code > of `wdired--before-change-fn' and `wdired--restore-properties'. You can > try that in your instance, e.g. using an advice. I guess you're suggesting the change below? (It looks big, but it's mostly whitespace changes because of the `save-restriction'.) Eduardo, can you try the patch and see whether it fixes the problem you're seeing? diff --git a/lisp/wdired.el b/lisp/wdired.el index 22c1cebe13..fd549bac32 100644 --- a/lisp/wdired.el +++ b/lisp/wdired.el @@ -297,26 +297,28 @@ wdired--self-insert (defun wdired--before-change-fn (beg end) (save-match-data (save-excursion - ;; Make sure to process entire lines. - (goto-char end) - (setq end (line-end-position)) - (goto-char beg) - (forward-line 0) - - (while (< (point) end) - (unless (wdired--line-preprocessed-p) + (save-restriction + (widen) + ;; Make sure to process entire lines. + (goto-char end) + (setq end (line-end-position)) + (goto-char beg) + (forward-line 0) + + (while (< (point) end) + (unless (wdired--line-preprocessed-p) + (with-silent-modifications + (put-text-property (point) (1+ (point)) 'front-sticky t) + (wdired--preprocess-files) + (when wdired-allow-to-change-permissions + (wdired--preprocess-perms)) + (when (fboundp 'make-symbolic-link) + (wdired--preprocess-symlinks)))) + (forward-line)) + (when (eobp) (with-silent-modifications - (put-text-property (point) (1+ (point)) 'front-sticky t) - (wdired--preprocess-files) - (when wdired-allow-to-change-permissions - (wdired--preprocess-perms)) - (when (fboundp 'make-symbolic-link) - (wdired--preprocess-symlinks)))) - (forward-line)) - (when (eobp) - (with-silent-modifications - ;; Is this good enough? Assumes no extra white lines from dired. - (put-text-property (1- (point-max)) (point-max) 'read-only t)))))) + ;; Is this good enough? Assumes no extra white lines from dired. + (put-text-property (1- (point-max)) (point-max) 'read-only t))))))) (defun wdired-isearch-filter-read-only (beg end) "Skip matches that have a read-only property." @@ -700,47 +702,49 @@ wdired-check-kill-buffer (defun wdired--restore-properties (beg end _len) (save-match-data (save-excursion - (let ((lep (line-end-position)) - (used-F (dired-check-switches - dired-actual-switches - "F" "classify"))) - ;; Deleting the space between the link name and the arrow (a - ;; noop) also deletes the end-name property, so restore it. - (when (and (save-excursion - (re-search-backward dired-permission-flags-regexp nil t) - (looking-at "l")) - (get-text-property (1- (point)) 'dired-filename) - (not (get-text-property (point) 'dired-filename)) - (not (get-text-property (point) 'end-name))) + (save-restriction + (widen) + (let ((lep (line-end-position)) + (used-F (dired-check-switches + dired-actual-switches + "F" "classify"))) + ;; Deleting the space between the link name and the arrow (a + ;; noop) also deletes the end-name property, so restore it. + (when (and (save-excursion + (re-search-backward dired-permission-flags-regexp nil t) + (looking-at "l")) + (get-text-property (1- (point)) 'dired-filename) + (not (get-text-property (point) 'dired-filename)) + (not (get-text-property (point) 'end-name))) (put-text-property (point) (1+ (point)) 'end-name t)) - (beginning-of-line) - (when (re-search-forward - directory-listing-before-filename-regexp lep t) - (setq beg (point) - end (if (or - ;; If the file is a symlink, put the - ;; dired-filename property only on the link - ;; name. (Using (file-symlink-p - ;; (dired-get-filename)) fails in - ;; wdired-mode, bug#32673.) - (and (re-search-backward - dired-permission-flags-regexp nil t) - (looking-at "l") - ;; macOS and Ultrix adds "@" to the end - ;; of symlinks when using -F. - (if (and used-F - dired-ls-F-marks-symlinks) - (re-search-forward "@? -> " lep t) - (search-forward " -> " lep t))) - ;; When dired-listing-switches includes "F" - ;; or "classify", don't treat appended - ;; indicator characters as part of the file - ;; name (bug#34915). - (and used-F - (re-search-forward "[*/@|=>]$" lep t))) - (goto-char (match-beginning 0)) - lep)) - (put-text-property beg end 'dired-filename t)))))) + (beginning-of-line) + (when (re-search-forward + directory-listing-before-filename-regexp lep t) + (setq beg (point) + end (if (or + ;; If the file is a symlink, put the + ;; dired-filename property only on the link + ;; name. (Using (file-symlink-p + ;; (dired-get-filename)) fails in + ;; wdired-mode, bug#32673.) + (and (re-search-backward + dired-permission-flags-regexp nil t) + (looking-at "l") + ;; macOS and Ultrix adds "@" to the end + ;; of symlinks when using -F. + (if (and used-F + dired-ls-F-marks-symlinks) + (re-search-forward "@? -> " lep t) + (search-forward " -> " lep t))) + ;; When dired-listing-switches includes "F" + ;; or "classify", don't treat appended + ;; indicator characters as part of the file + ;; name (bug#34915). + (and used-F + (re-search-forward "[*/@|=>]$" lep t))) + (goto-char (match-beginning 0)) + lep)) + (put-text-property beg end 'dired-filename t))))))) (defun wdired-next-line (arg) "Move down lines then position at filename or the current column. -- (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no