emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: The issue with with-temp-buffer (or with-current-buffer)


From: OGAWA Hirofumi
Subject: Re: The issue with with-temp-buffer (or with-current-buffer)
Date: Sat, 16 Dec 2017 07:40:37 +0900
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

OGAWA Hirofumi <address@hidden> writes:

> Eli Zaretskii <address@hidden> writes:
>
>>> After some debugging, I noticed `with-current-buffer' that is
>>> used in `with-temp-buffer' doesn't restore `point'.
>>
>> Please try the latest shr.el from the emacs-26 branch, I think you
>> will find that this problem is solved there.
>>
>>> Well so, this behavior (doesn't restore point) of
>>> `with-temp-buffer' (or `with-current-buffer') is intented or bug?
>>
>> It's intended.
>>
>>> And to fix this issue, we should change which one of
>>> with-temp-buffer, with-current-buffer, shr-insert-document, or
>>> user of shr-insert-document?
>>
>> I think shr.el was already fixed.
>
> I've tested the following master and emacs-26 branches...
>
>       master 5e6fb1e246b1e7f44ebba48e7e24f597a8eb92dd
>       emacs-26 3003ac046900f9e7fdaa3161b99dbb1cc8f37b32
>
> However result is still same (there is the described issue).

I confirmed the following patch fixes the issue, although I'm not
sure if the code is proper or better fix is there.

Thanks

---

 lisp/net/shr.el |    7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff -puN lisp/net/shr.el~shr-fix-point-modification lisp/net/shr.el
--- emacs/lisp/net/shr.el~shr-fix-point-modification    2017-12-16 
07:32:47.777230050 +0900
+++ emacs-hirofumi/lisp/net/shr.el      2017-12-16 07:35:48.083847035 +0900
@@ -591,9 +591,10 @@ size, and full-buffer size."
 (defun shr-string-pixel-width (string)
   (if (not shr-use-fonts)
       (length string)
-    (with-temp-buffer
-      (insert string)
-      (shr-pixel-column))))
+    (save-excursion
+      (with-temp-buffer
+        (insert string)
+        (shr-pixel-column)))))
 
 (defsubst shr--translate-insertion-chars ()
   ;; Remove soft hyphens.
_
-- 
OGAWA Hirofumi <address@hidden>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]