all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Lars Ingebrigtsen <larsi@mouse.gnus.org>
To: Akinori MUSHA <knu@iDaemons.org>
Cc: 37095@debbugs.gnu.org
Subject: bug#37095: [PATCH] Save match data in ucs-normalize-region
Date: Fri, 23 Aug 2019 05:51:29 +0200	[thread overview]
Message-ID: <87k1b4sfni.fsf@mouse.gnus.org> (raw)
In-Reply-To: <bf33401d-0f83-bd3e-fce2-94412e84266d@iDaemons.org> (Akinori MUSHA's message of "Tue, 20 Aug 2019 16:18:06 +0900")

Akinori MUSHA <knu@iDaemons.org> writes:

> A patch generated by git format-patch is attached below, which simply
> wraps `ucs-normalize-region` with `save-match-data`.
>
> I'm a user of the Emacs Mac port by mituharu was investigating a bug
> where dired fails to open a certain local directory on macOS.  The
> error was raised at `replace-match` in the `insert-directory`
> function:
>
> ```
> 		(when (re-search-forward "^ *\\(total\\)" nil t)
> 		  (let ((available (get-free-disk-space ".")))
> 		    (when available
> 		      ;; Replace "total" with "used", to avoid confusion.
> 		      (replace-match "total used in directory" nil nil nil 1)
> ```
>
> And it turned out the match data changed after returning from
> `get-free-disk-space` and that was why `replace-match` failed.

You don't say what Emacs version you're reporting this bug for, but the
following patch was applied in February 2018 to the Emacs trunk, so I
think this problem has been fixed by now:

diff --git a/lisp/files.el b/lisp/files.el
index 91aa95d631..75d3b7b1e7 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -6473,9 +6473,10 @@ get-free-disk-space
 space (normally, the number of free 1KB blocks).
 
 If DIR's free space cannot be obtained, this function returns nil."
-  (let ((avail (nth 2 (file-system-info dir))))
-    (if avail
-	(format "%.0f" (/ avail 1024)))))
+  (save-match-data
+    (let ((avail (nth 2 (file-system-info dir))))
+      (if avail
+	  (format "%.0f" (/ avail 1024))))))
 
 ;; The following expression replaces `dired-move-to-filename-regexp'.
 (defvar directory-listing-before-filename-regexp


-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





  reply	other threads:[~2019-08-23  3:51 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-20  7:18 bug#37095: [PATCH] Save match data in ucs-normalize-region Akinori MUSHA
2019-08-23  3:51 ` Lars Ingebrigtsen [this message]
2019-08-23  5:06   ` YAMAMOTO Mitsuharu
2019-08-23  7:21     ` Akinori MUSHA

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=87k1b4sfni.fsf@mouse.gnus.org \
    --to=larsi@mouse.gnus.org \
    --cc=37095@debbugs.gnu.org \
    --cc=knu@iDaemons.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.