all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#25951: 26.0.50; Error when ediffing files that are visited using quoted file names
@ 2017-03-03 13:56 Philipp Stephani
  2017-04-21 22:14 ` Philipp Stephani
  0 siblings, 1 reply; 22+ messages in thread
From: Philipp Stephani @ 2017-03-03 13:56 UTC (permalink / raw)
  To: 25951


Assuming /tmp/[ab].py are existing files.

emacs -Q -f server-start /:/tmp/a.py

Then:

emacsclient --create-frame --eval '(ediff "/tmp/a.py" "/tmp/b.py")'

will result un an error:

*ERROR*: Wrong type argument: arrayp, nil

Backtrace is

Debugger entered--Lisp error: (wrong-type-argument arrayp nil)
  file-name-non-special(verify-visited-file-modtime #<buffer a.py>)
  verify-visited-file-modtime(#<buffer a.py>)
  apply(verify-visited-file-modtime #<buffer a.py>)
  tramp-run-real-handler(verify-visited-file-modtime (#<buffer a.py>))
  tramp-file-name-handler(verify-visited-file-modtime #<buffer a.py>)
  verify-visited-file-modtime(#<buffer a.py>)
  find-file-noselect("/tmp/a.py")
  ediff-find-file(file-A buf-A ediff-last-dir-A startup-hooks)
  ediff-files-internal("/tmp/a.py" "/tmp/b.py" nil nil ediff-files)
  ediff("/tmp/a.py" "/tmp/b.py")
  eval((ediff "/tmp/a.py" "/tmp/b.py"))
  server-eval-and-print("(ediff \"/tmp/a.py\" \"/tmp/b.py\")" #<process server <3>>)
  (more uninteresting frames)



In GNU Emacs 26.0.50 (build 10, x86_64-unknown-linux-gnu, GTK+ Version 3.10.8)
 of 2017-03-03 built on localhost
Repository revision: 244de7b0ed3bb23e700c9edef51e413602d8720a
Windowing system distributor 'The X.Org Foundation', version 11.0.11501000
System Description:	Ubuntu 14.04 LTS

Recent messages:
For information about GNU Emacs and the GNU system, type C-h C-a.

Configured using:
 'configure --enable-checking --enable-check-lisp-object-type
 --with-modules 'CFLAGS=-O0 -ggdb3''

Configured features:
XPM JPEG TIFF GIF PNG SOUND GSETTINGS NOTIFY GNUTLS FREETYPE XFT ZLIB
TOOLKIT_SCROLL_BARS GTK3 X11 MODULES

Important settings:
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix

Major mode: Lisp Interaction

Minor modes in effect:
  tooltip-mode: t
  global-eldoc-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug message puny seq byte-opt subr-x gv
bytecomp byte-compile cl-extra help-mode cconv cl-loaddefs pcase cl-lib
dired dired-loaddefs format-spec rfc822 mml easymenu mml-sec
password-cache epa derived epg epg-config gnus-util rmail rmail-loaddefs
mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils
mailheader sendmail rfc2047 rfc2045 ietf-drums mm-util mail-prsvr
mail-utils time-date mule-util tooltip eldoc electric uniquify
ediff-hook vc-hooks lisp-float-type mwheel term/x-win x-win
term/common-win x-dnd tool-bar dnd fontset image regexp-opt fringe
tabulated-list replace newcomment text-mode elisp-mode lisp-mode
prog-mode register page menu-bar rfn-eshadow isearch timer select
scroll-bar mouse jit-lock font-lock syntax facemenu font-core
term/tty-colors frame cl-generic cham georgian utf-8-lang misc-lang
vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms cp51932
hebrew greek romanian slovak czech european ethiopic indian cyrillic
chinese composite charscript case-table epa-hook jka-cmpr-hook help
simple abbrev obarray minibuffer cl-preloaded nadvice loaddefs button
faces cus-face macroexp files text-properties overlay sha1 md5 base64
format env code-pages mule custom widget hashtable-print-readable
backquote inotify dynamic-setting system-font-setting
font-render-setting move-toolbar gtk x-toolkit x multi-tty
make-network-process emacs)

Memory information:
((conses 16 96397 9305)
 (symbols 48 20188 1)
 (miscs 40 39 181)
 (strings 32 17669 3597)
 (string-bytes 1 574142)
 (vectors 16 14048)
 (vector-slots 8 483315 4785)
 (floats 8 48 68)
 (intervals 56 217 0)
 (buffers 976 12)
 (heap 1024 19322 1007))

-- 
Google Germany GmbH
Erika-Mann-Straße 33
80636 München

Registergericht und -nummer: Hamburg, HRB 86891
Sitz der Gesellschaft: Hamburg
Geschäftsführer: Matthew Scott Sucherman, Paul Terence Manicle

Diese E-Mail ist vertraulich.  Wenn Sie nicht der richtige Adressat sind,
leiten Sie diese bitte nicht weiter, informieren Sie den Absender und löschen
Sie die E-Mail und alle Anhänge.  Vielen Dank.

This e-mail is confidential.  If you are not the right addressee please do not
forward it, please inform the sender, and please erase this e-mail including
any attachments.  Thanks.





^ permalink raw reply	[flat|nested] 22+ messages in thread

* bug#25951: 26.0.50; Error when ediffing files that are visited using quoted file names
  2017-03-03 13:56 bug#25951: 26.0.50; Error when ediffing files that are visited using quoted file names Philipp Stephani
@ 2017-04-21 22:14 ` Philipp Stephani
  2017-04-21 22:50   ` npostavs
  0 siblings, 1 reply; 22+ messages in thread
From: Philipp Stephani @ 2017-04-21 22:14 UTC (permalink / raw)
  To: 25951


[-- Attachment #1.1: Type: text/plain, Size: 1207 bytes --]

Philipp Stephani <p.stephani2@gmail.com> schrieb am Fr., 3. März 2017 um
14:58 Uhr:

>
> Assuming /tmp/[ab].py are existing files.
>
> emacs -Q -f server-start /:/tmp/a.py
>
> Then:
>
> emacsclient --create-frame --eval '(ediff "/tmp/a.py" "/tmp/b.py")'
>
> will result un an error:
>
> *ERROR*: Wrong type argument: arrayp, nil
>
> Backtrace is
>
> Debugger entered--Lisp error: (wrong-type-argument arrayp nil)
>   file-name-non-special(verify-visited-file-modtime #<buffer a.py>)
>   verify-visited-file-modtime(#<buffer a.py>)
>   apply(verify-visited-file-modtime #<buffer a.py>)
>   tramp-run-real-handler(verify-visited-file-modtime (#<buffer a.py>))
>   tramp-file-name-handler(verify-visited-file-modtime #<buffer a.py>)
>   verify-visited-file-modtime(#<buffer a.py>)
>   find-file-noselect("/tmp/a.py")
>   ediff-find-file(file-A buf-A ediff-last-dir-A startup-hooks)
>   ediff-files-internal("/tmp/a.py" "/tmp/b.py" nil nil ediff-files)
>   ediff("/tmp/a.py" "/tmp/b.py")
>   eval((ediff "/tmp/a.py" "/tmp/b.py"))
>   server-eval-and-print("(ediff \"/tmp/a.py\" \"/tmp/b.py\")" #<process
> server <3>>)
>   (more uninteresting frames)
>
>
Patch is attached.

[-- Attachment #1.2: Type: text/html, Size: 1732 bytes --]

[-- Attachment #2: 0001-Fix-quoted-files-for-verify-visited-file-modtime.txt --]
[-- Type: text/plain, Size: 4467 bytes --]

From 9e5d1d09a4597885b1fc40feec6dbf64cf1e29cd Mon Sep 17 00:00:00 2001
From: Philipp Stephani <phst@google.com>
Date: Sat, 22 Apr 2017 00:12:23 +0200
Subject: [PATCH] Fix quoted files for 'verify-visited-file-modtime'

Fixes Bug#25951.

* lisp/files.el (file-name-non-special): Set the file name for the
correct buffer.

* test/lisp/files-tests.el (files-tests--file-name-non-special--buffers):
Add unit test.
---
 lisp/files.el            | 12 ++++++++++--
 test/lisp/files-tests.el | 42 +++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 51 insertions(+), 3 deletions(-)

diff --git a/lisp/files.el b/lisp/files.el
index 6848818cad..64843287e5 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -6987,8 +6987,16 @@ file-name-non-special
            (when (and visit buffer-file-name)
              (setq buffer-file-name (concat "/:" buffer-file-name))))))
       (`unquote-then-quote
-       (let ((buffer-file-name (substring buffer-file-name 2)))
-         (apply operation arguments)))
+       (let ((buffer (current-buffer)))
+         ;; `unquote-then-quote' is only used for the
+         ;; `verify-visited-file-modtime' action, which takes a buffer
+         ;; as only optional argument.
+         (with-current-buffer (or (car arguments) buffer)
+           (let ((buffer-file-name (substring buffer-file-name 2)))
+             ;; Make sure to hide the temporary buffer change from the
+             ;; underlying operation.
+             (with-current-buffer buffer
+               (apply operation arguments))))))
       (_
        (apply operation arguments)))))
 
diff --git a/test/lisp/files-tests.el b/test/lisp/files-tests.el
index 80bbeb1bc5..ed66533d48 100644
--- a/test/lisp/files-tests.el
+++ b/test/lisp/files-tests.el
@@ -1,4 +1,4 @@
-;;; files-tests.el --- tests for files.el.
+;;; files-tests.el --- tests for files.el.  -*- lexical-binding: t; -*-
 
 ;; Copyright (C) 2012-2017 Free Software Foundation, Inc.
 
@@ -20,6 +20,7 @@
 ;;; Code:
 
 (require 'ert)
+(require 'nadvice)
 
 ;; Set to t if the local variable was set, `query' if the query was
 ;; triggered.
@@ -251,5 +252,44 @@ files-test-bug-18141-file
                       (start-file-process "foo" nil "true"))))
   (should (eq (let ((default-directory "/:/")) (shell-command "true")) 0)))
 
+(ert-deftest files-tests--file-name-non-special--buffers ()
+  "Check that Bug#25951 is fixed.
+We call `verify-visited-file-modtime' on a buffer visiting a file
+with a quoted name.  We use two different variants: first with
+the buffer current and a nil argument, second passing the buffer
+object explicitly.  In both cases no error should be raised and
+the `file-name-non-special' handler for quoted file names should
+be invoked with the right arguments."
+  (with-temp-buffer
+    (let* ((buffer-file-name "/:/tmp/bug25951.txt")
+           (buffer-visiting-file (current-buffer))
+           (actual-args ())
+           (log (lambda (&rest args) (push args actual-args))))
+      (set-visited-file-modtime '(1 2 3 4))
+      (should (equal (find-file-name-handler buffer-file-name
+                                             #'verify-visited-file-modtime)
+                     #'file-name-non-special))
+      (advice-add #'file-name-non-special :before log)
+      (unwind-protect
+          (progn
+            (should (stringp buffer-file-name))
+            ;; This should call the file name handler with the right
+            ;; buffer and not signal an error.  The file doesn't
+            ;; actually exist, so this should return nil.
+            (should-not (verify-visited-file-modtime))
+            (with-temp-buffer
+              (should (stringp (buffer-file-name buffer-visiting-file)))
+              ;; This should call the file name handler with the right
+              ;; buffer and not signal an error.  The file doesn't
+              ;; actually exist, so this should return nil.
+              (should-not (verify-visited-file-modtime buffer-visiting-file)))))
+      (advice-remove #'file-name-non-special 'bug25951)
+      ;; Verify that the handler was actually called.  We called
+      ;; `verify-visited-file-modtime' twice, so both calls should be
+      ;; recorded in reverse order.
+      (should (equal actual-args
+                     `((verify-visited-file-modtime ,buffer-visiting-file)
+                       (verify-visited-file-modtime nil)))))))
+
 (provide 'files-tests)
 ;;; files-tests.el ends here
-- 
2.12.2


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* bug#25951: 26.0.50; Error when ediffing files that are visited using quoted file names
  2017-04-21 22:14 ` Philipp Stephani
@ 2017-04-21 22:50   ` npostavs
  2017-04-22 19:43     ` Philipp Stephani
  0 siblings, 1 reply; 22+ messages in thread
From: npostavs @ 2017-04-21 22:50 UTC (permalink / raw)
  To: Philipp Stephani; +Cc: 25951

Philipp Stephani <p.stephani2@gmail.com> writes:

> +       (let ((buffer (current-buffer)))
> +         ;; `unquote-then-quote' is only used for the
> +         ;; `verify-visited-file-modtime' action, which takes a buffer
> +         ;; as only optional argument.
> +         (with-current-buffer (or (car arguments) buffer)
> +           (let ((buffer-file-name (substring buffer-file-name 2)))
> +             ;; Make sure to hide the temporary buffer change from the
> +             ;; underlying operation.
> +             (with-current-buffer buffer
> +               (apply operation arguments))))))

I think this could be simplified by using the buffer-file-name function:

    ;; `unquote-then-quote' is only used for the
    ;; `verify-visited-file-modtime' action, which takes a buffer
    ;; as only optional argument.
    (let ((buffer-file-name
           (substring (buffer-file-name (car arguments)) 2)))
      (apply operation arguments))





^ permalink raw reply	[flat|nested] 22+ messages in thread

* bug#25951: 26.0.50; Error when ediffing files that are visited using quoted file names
  2017-04-21 22:50   ` npostavs
@ 2017-04-22 19:43     ` Philipp Stephani
  2017-04-22 20:32       ` npostavs
  0 siblings, 1 reply; 22+ messages in thread
From: Philipp Stephani @ 2017-04-22 19:43 UTC (permalink / raw)
  To: npostavs; +Cc: 25951

[-- Attachment #1: Type: text/plain, Size: 1145 bytes --]

<npostavs@users.sourceforge.net> schrieb am Sa., 22. Apr. 2017 um 00:48 Uhr:

> Philipp Stephani <p.stephani2@gmail.com> writes:
>
> > +       (let ((buffer (current-buffer)))
> > +         ;; `unquote-then-quote' is only used for the
> > +         ;; `verify-visited-file-modtime' action, which takes a buffer
> > +         ;; as only optional argument.
> > +         (with-current-buffer (or (car arguments) buffer)
> > +           (let ((buffer-file-name (substring buffer-file-name 2)))
> > +             ;; Make sure to hide the temporary buffer change from the
> > +             ;; underlying operation.
> > +             (with-current-buffer buffer
> > +               (apply operation arguments))))))
>
> I think this could be simplified by using the buffer-file-name function:
>
>     ;; `unquote-then-quote' is only used for the
>     ;; `verify-visited-file-modtime' action, which takes a buffer
>     ;; as only optional argument.
>     (let ((buffer-file-name
>            (substring (buffer-file-name (car arguments)) 2)))
>       (apply operation arguments))
>

That's not the same, it will set the file name of the wrong buffer.

[-- Attachment #2: Type: text/html, Size: 1683 bytes --]

^ permalink raw reply	[flat|nested] 22+ messages in thread

* bug#25951: 26.0.50; Error when ediffing files that are visited using quoted file names
  2017-04-22 19:43     ` Philipp Stephani
@ 2017-04-22 20:32       ` npostavs
  2017-04-23 16:54         ` Philipp Stephani
  0 siblings, 1 reply; 22+ messages in thread
From: npostavs @ 2017-04-22 20:32 UTC (permalink / raw)
  To: Philipp Stephani; +Cc: 25951

Philipp Stephani <p.stephani2@gmail.com> writes:

> <npostavs@users.sourceforge.net> schrieb am Sa., 22. Apr. 2017 um 00:48 Uhr:
>
>> Philipp Stephani <p.stephani2@gmail.com> writes:
>>
>> > +       (let ((buffer (current-buffer)))
>> > +         ;; `unquote-then-quote' is only used for the
>> > +         ;; `verify-visited-file-modtime' action, which takes a buffer
>> > +         ;; as only optional argument.
>> > +         (with-current-buffer (or (car arguments) buffer)
>> > +           (let ((buffer-file-name (substring buffer-file-name 2)))
>> > +             ;; Make sure to hide the temporary buffer change from the
>> > +             ;; underlying operation.
>> > +             (with-current-buffer buffer
>> > +               (apply operation arguments))))))
>>
>> I think this could be simplified by using the buffer-file-name function:
>>
>>     (let ((buffer-file-name
>>            (substring (buffer-file-name (car arguments)) 2)))
>>       (apply operation arguments))
>>
>
> That's not the same, it will set the file name of the wrong buffer.

Oh, I think I get it now.  It could be written like this, right?

    (cl-letf* ((buf (or (car arguments) (current-buffer)))
               ((buffer-local-value buffer-file-name buf)
                (substring (buffer-file-name buf) 2)))
      (apply operation arguments))





^ permalink raw reply	[flat|nested] 22+ messages in thread

* bug#25951: 26.0.50; Error when ediffing files that are visited using quoted file names
  2017-04-22 20:32       ` npostavs
@ 2017-04-23 16:54         ` Philipp Stephani
  2017-04-23 17:06           ` [PATCH] Fix quoted files for 'verify-visited-file-modtime' Philipp Stephani
  2017-04-29 11:49           ` Philipp Stephani
  0 siblings, 2 replies; 22+ messages in thread
From: Philipp Stephani @ 2017-04-23 16:54 UTC (permalink / raw)
  To: npostavs; +Cc: 25951

[-- Attachment #1: Type: text/plain, Size: 1553 bytes --]

<npostavs@users.sourceforge.net> schrieb am Sa., 22. Apr. 2017 um 22:31 Uhr:

> Philipp Stephani <p.stephani2@gmail.com> writes:
>
> > <npostavs@users.sourceforge.net> schrieb am Sa., 22. Apr. 2017 um 00:48
> Uhr:
> >
> >> Philipp Stephani <p.stephani2@gmail.com> writes:
> >>
> >> > +       (let ((buffer (current-buffer)))
> >> > +         ;; `unquote-then-quote' is only used for the
> >> > +         ;; `verify-visited-file-modtime' action, which takes a
> buffer
> >> > +         ;; as only optional argument.
> >> > +         (with-current-buffer (or (car arguments) buffer)
> >> > +           (let ((buffer-file-name (substring buffer-file-name 2)))
> >> > +             ;; Make sure to hide the temporary buffer change from
> the
> >> > +             ;; underlying operation.
> >> > +             (with-current-buffer buffer
> >> > +               (apply operation arguments))))))
> >>
> >> I think this could be simplified by using the buffer-file-name function:
> >>
> >>     (let ((buffer-file-name
> >>            (substring (buffer-file-name (car arguments)) 2)))
> >>       (apply operation arguments))
> >>
> >
> > That's not the same, it will set the file name of the wrong buffer.
>
> Oh, I think I get it now.  It could be written like this, right?
>
>     (cl-letf* ((buf (or (car arguments) (current-buffer)))
>                ((buffer-local-value buffer-file-name buf)
>                 (substring (buffer-file-name buf) 2)))
>       (apply operation arguments))
>

Yes, that should work, thanks. Will send a new patch in a second.

[-- Attachment #2: Type: text/html, Size: 2393 bytes --]

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [PATCH] Fix quoted files for 'verify-visited-file-modtime'
  2017-04-23 16:54         ` Philipp Stephani
@ 2017-04-23 17:06           ` Philipp Stephani
  2017-04-26  5:38             ` Eli Zaretskii
  2017-04-29 11:49           ` Philipp Stephani
  1 sibling, 1 reply; 22+ messages in thread
From: Philipp Stephani @ 2017-04-23 17:06 UTC (permalink / raw)
  To: emacs-devel; +Cc: Philipp Stephani

Fixes Bug#25951.

* lisp/files.el (file-name-non-special): Set the file name for the
correct buffer.

* test/lisp/files-tests.el (files-tests--file-name-non-special--buffers):
Add unit test.
---
 lisp/files.el            |  9 ++++++++-
 test/lisp/files-tests.el | 42 +++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 49 insertions(+), 2 deletions(-)

diff --git a/lisp/files.el b/lisp/files.el
index 6848818cad..2e9ab1aad1 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -28,6 +28,8 @@
 
 ;;; Code:
 
+(eval-when-compile (require 'cl-lib))
+
 (defvar font-lock-keywords)
 
 (defgroup backup nil
@@ -6987,7 +6989,12 @@ file-name-non-special
            (when (and visit buffer-file-name)
              (setq buffer-file-name (concat "/:" buffer-file-name))))))
       (`unquote-then-quote
-       (let ((buffer-file-name (substring buffer-file-name 2)))
+       (cl-letf* ((buffer (or (car arguments) (current-buffer)))
+                  ((buffer-local-value 'buffer-file-name buffer)
+                   (substring (buffer-file-name buffer) 2)))
+         ;; `unquote-then-quote' is only used for the
+         ;; `verify-visited-file-modtime' action, which takes a buffer
+         ;; as only optional argument.
          (apply operation arguments)))
       (_
        (apply operation arguments)))))
diff --git a/test/lisp/files-tests.el b/test/lisp/files-tests.el
index 80bbeb1bc5..9c633198f1 100644
--- a/test/lisp/files-tests.el
+++ b/test/lisp/files-tests.el
@@ -1,4 +1,4 @@
-;;; files-tests.el --- tests for files.el.
+;;; files-tests.el --- tests for files.el.  -*- lexical-binding: t; -*-
 
 ;; Copyright (C) 2012-2017 Free Software Foundation, Inc.
 
@@ -20,6 +20,7 @@
 ;;; Code:
 
 (require 'ert)
+(require 'nadvice)
 
 ;; Set to t if the local variable was set, `query' if the query was
 ;; triggered.
@@ -251,5 +252,44 @@ files-test-bug-18141-file
                       (start-file-process "foo" nil "true"))))
   (should (eq (let ((default-directory "/:/")) (shell-command "true")) 0)))
 
+(ert-deftest files-tests--file-name-non-special--buffers ()
+  "Check that Bug#25951 is fixed.
+We call `verify-visited-file-modtime' on a buffer visiting a file
+with a quoted name.  We use two different variants: first with
+the buffer current and a nil argument, second passing the buffer
+object explicitly.  In both cases no error should be raised and
+the `file-name-non-special' handler for quoted file names should
+be invoked with the right arguments."
+  (with-temp-buffer
+    (let* ((buffer-file-name "/:/tmp/bug25951.txt")
+           (buffer-visiting-file (current-buffer))
+           (actual-args ())
+           (log (lambda (&rest args) (push args actual-args))))
+      (set-visited-file-modtime '(1 2 3 4))
+      (should (equal (find-file-name-handler buffer-file-name
+                                             #'verify-visited-file-modtime)
+                     #'file-name-non-special))
+      (advice-add #'file-name-non-special :before log)
+      (unwind-protect
+          (progn
+            (should (stringp buffer-file-name))
+            ;; This should call the file name handler with the right
+            ;; buffer and not signal an error.  The file doesn't
+            ;; actually exist, so this should return nil.
+            (should-not (verify-visited-file-modtime))
+            (with-temp-buffer
+              (should (stringp (buffer-file-name buffer-visiting-file)))
+              ;; This should call the file name handler with the right
+              ;; buffer and not signal an error.  The file doesn't
+              ;; actually exist, so this should return nil.
+              (should-not (verify-visited-file-modtime buffer-visiting-file))))
+        (advice-remove #'file-name-non-special 'bug25951))
+      ;; Verify that the handler was actually called.  We called
+      ;; `verify-visited-file-modtime' twice, so both calls should be
+      ;; recorded in reverse order.
+      (should (equal actual-args
+                     `((verify-visited-file-modtime ,buffer-visiting-file)
+                       (verify-visited-file-modtime nil)))))))
+
 (provide 'files-tests)
 ;;; files-tests.el ends here
-- 
2.12.2




^ permalink raw reply related	[flat|nested] 22+ messages in thread

* Re: [PATCH] Fix quoted files for 'verify-visited-file-modtime'
  2017-04-23 17:06           ` [PATCH] Fix quoted files for 'verify-visited-file-modtime' Philipp Stephani
@ 2017-04-26  5:38             ` Eli Zaretskii
  2017-04-29 12:20               ` Philipp Stephani
  2017-04-29 12:20               ` Philipp Stephani
  0 siblings, 2 replies; 22+ messages in thread
From: Eli Zaretskii @ 2017-04-26  5:38 UTC (permalink / raw)
  To: Philipp Stephani; +Cc: phst, emacs-devel

> From: Philipp Stephani <p.stephani2@gmail.com>
> Date: Sun, 23 Apr 2017 19:06:07 +0200
> Cc: Philipp Stephani <phst@google.com>
> 
> +  (with-temp-buffer
> +    (let* ((buffer-file-name "/:/tmp/bug25951.txt")

Please don't use file names that make assumptions about the underlying
filesystem structure.  I think our convention for files created by the
test suite to use make-temp-file.  Is there any reason this test
couldn't do the same?

Thanks.



^ permalink raw reply	[flat|nested] 22+ messages in thread

* bug#25951: [PATCH] Fix quoted files for 'verify-visited-file-modtime'
  2017-04-23 16:54         ` Philipp Stephani
  2017-04-23 17:06           ` [PATCH] Fix quoted files for 'verify-visited-file-modtime' Philipp Stephani
@ 2017-04-29 11:49           ` Philipp Stephani
  1 sibling, 0 replies; 22+ messages in thread
From: Philipp Stephani @ 2017-04-29 11:49 UTC (permalink / raw)
  To: 25951, npostavs; +Cc: Philipp Stephani

Fixes Bug#25951.

* lisp/files.el (file-name-non-special): Set the file name for the
correct buffer.

* test/lisp/files-tests.el (files-tests--file-name-non-special--buffers):
Add unit test.
---
 lisp/files.el            |  9 ++++++++-
 test/lisp/files-tests.el | 42 +++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 49 insertions(+), 2 deletions(-)

diff --git a/lisp/files.el b/lisp/files.el
index 6848818cad..2e9ab1aad1 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -28,6 +28,8 @@
 
 ;;; Code:
 
+(eval-when-compile (require 'cl-lib))
+
 (defvar font-lock-keywords)
 
 (defgroup backup nil
@@ -6987,7 +6989,12 @@ file-name-non-special
            (when (and visit buffer-file-name)
              (setq buffer-file-name (concat "/:" buffer-file-name))))))
       (`unquote-then-quote
-       (let ((buffer-file-name (substring buffer-file-name 2)))
+       (cl-letf* ((buffer (or (car arguments) (current-buffer)))
+                  ((buffer-local-value 'buffer-file-name buffer)
+                   (substring (buffer-file-name buffer) 2)))
+         ;; `unquote-then-quote' is only used for the
+         ;; `verify-visited-file-modtime' action, which takes a buffer
+         ;; as only optional argument.
          (apply operation arguments)))
       (_
        (apply operation arguments)))))
diff --git a/test/lisp/files-tests.el b/test/lisp/files-tests.el
index 80bbeb1bc5..9c633198f1 100644
--- a/test/lisp/files-tests.el
+++ b/test/lisp/files-tests.el
@@ -1,4 +1,4 @@
-;;; files-tests.el --- tests for files.el.
+;;; files-tests.el --- tests for files.el.  -*- lexical-binding: t; -*-
 
 ;; Copyright (C) 2012-2017 Free Software Foundation, Inc.
 
@@ -20,6 +20,7 @@
 ;;; Code:
 
 (require 'ert)
+(require 'nadvice)
 
 ;; Set to t if the local variable was set, `query' if the query was
 ;; triggered.
@@ -251,5 +252,44 @@ files-test-bug-18141-file
                       (start-file-process "foo" nil "true"))))
   (should (eq (let ((default-directory "/:/")) (shell-command "true")) 0)))
 
+(ert-deftest files-tests--file-name-non-special--buffers ()
+  "Check that Bug#25951 is fixed.
+We call `verify-visited-file-modtime' on a buffer visiting a file
+with a quoted name.  We use two different variants: first with
+the buffer current and a nil argument, second passing the buffer
+object explicitly.  In both cases no error should be raised and
+the `file-name-non-special' handler for quoted file names should
+be invoked with the right arguments."
+  (with-temp-buffer
+    (let* ((buffer-file-name "/:/tmp/bug25951.txt")
+           (buffer-visiting-file (current-buffer))
+           (actual-args ())
+           (log (lambda (&rest args) (push args actual-args))))
+      (set-visited-file-modtime '(1 2 3 4))
+      (should (equal (find-file-name-handler buffer-file-name
+                                             #'verify-visited-file-modtime)
+                     #'file-name-non-special))
+      (advice-add #'file-name-non-special :before log)
+      (unwind-protect
+          (progn
+            (should (stringp buffer-file-name))
+            ;; This should call the file name handler with the right
+            ;; buffer and not signal an error.  The file doesn't
+            ;; actually exist, so this should return nil.
+            (should-not (verify-visited-file-modtime))
+            (with-temp-buffer
+              (should (stringp (buffer-file-name buffer-visiting-file)))
+              ;; This should call the file name handler with the right
+              ;; buffer and not signal an error.  The file doesn't
+              ;; actually exist, so this should return nil.
+              (should-not (verify-visited-file-modtime buffer-visiting-file))))
+        (advice-remove #'file-name-non-special 'bug25951))
+      ;; Verify that the handler was actually called.  We called
+      ;; `verify-visited-file-modtime' twice, so both calls should be
+      ;; recorded in reverse order.
+      (should (equal actual-args
+                     `((verify-visited-file-modtime ,buffer-visiting-file)
+                       (verify-visited-file-modtime nil)))))))
+
 (provide 'files-tests)
 ;;; files-tests.el ends here
-- 
2.12.2






^ permalink raw reply related	[flat|nested] 22+ messages in thread

* bug#25951: [PATCH] Fix quoted files for 'verify-visited-file-modtime'
  2017-04-26  5:38             ` Eli Zaretskii
  2017-04-29 12:20               ` Philipp Stephani
@ 2017-04-29 12:20               ` Philipp Stephani
  1 sibling, 0 replies; 22+ messages in thread
From: Philipp Stephani @ 2017-04-29 12:20 UTC (permalink / raw)
  To: 25951, npostavs, emacs-devel, eliz; +Cc: Philipp Stephani

Fixes Bug#25951.

* lisp/files.el (file-name-non-special): Set the file name for the
correct buffer.

* test/lisp/files-tests.el (files-tests--file-name-non-special--buffers):
Add unit test.
(files-tests--with-advice, files-tests--with-temp-file): New helper
macros.
---
 lisp/files.el            |  9 ++++++-
 test/lisp/files-tests.el | 64 +++++++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 71 insertions(+), 2 deletions(-)

diff --git a/lisp/files.el b/lisp/files.el
index 6848818cad..2e9ab1aad1 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -28,6 +28,8 @@
 
 ;;; Code:
 
+(eval-when-compile (require 'cl-lib))
+
 (defvar font-lock-keywords)
 
 (defgroup backup nil
@@ -6987,7 +6989,12 @@ file-name-non-special
            (when (and visit buffer-file-name)
              (setq buffer-file-name (concat "/:" buffer-file-name))))))
       (`unquote-then-quote
-       (let ((buffer-file-name (substring buffer-file-name 2)))
+       (cl-letf* ((buffer (or (car arguments) (current-buffer)))
+                  ((buffer-local-value 'buffer-file-name buffer)
+                   (substring (buffer-file-name buffer) 2)))
+         ;; `unquote-then-quote' is only used for the
+         ;; `verify-visited-file-modtime' action, which takes a buffer
+         ;; as only optional argument.
          (apply operation arguments)))
       (_
        (apply operation arguments)))))
diff --git a/test/lisp/files-tests.el b/test/lisp/files-tests.el
index 80bbeb1bc5..4583b1af3c 100644
--- a/test/lisp/files-tests.el
+++ b/test/lisp/files-tests.el
@@ -1,4 +1,4 @@
-;;; files-tests.el --- tests for files.el.
+;;; files-tests.el --- tests for files.el.  -*- lexical-binding: t; -*-
 
 ;; Copyright (C) 2012-2017 Free Software Foundation, Inc.
 
@@ -20,6 +20,7 @@
 ;;; Code:
 
 (require 'ert)
+(require 'nadvice)
 
 ;; Set to t if the local variable was set, `query' if the query was
 ;; triggered.
@@ -251,5 +252,66 @@ files-test-bug-18141-file
                       (start-file-process "foo" nil "true"))))
   (should (eq (let ((default-directory "/:/")) (shell-command "true")) 0)))
 
+(defmacro files-tests--with-advice (symbol where function &rest body)
+  (declare (indent 3))
+  (cl-check-type symbol symbol)
+  (cl-check-type where keyword)
+  (cl-check-type function function)
+  (macroexp-let2 nil function function
+    `(progn
+       (advice-add #',symbol ,where ,function)
+       (unwind-protect
+           (progn ,@body)
+         (advice-remove #',symbol ,function)))))
+
+(defmacro files-tests--with-temp-file (name &rest body)
+  (declare (indent 1))
+  (cl-check-type name symbol)
+  `(let ((,name (make-temp-file "emacs")))
+     (unwind-protect
+         (progn ,@body)
+       (delete-file ,name))))
+
+(ert-deftest files-tests--file-name-non-special--buffers ()
+  "Check that Bug#25951 is fixed.
+We call `verify-visited-file-modtime' on a buffer visiting a file
+with a quoted name.  We use two different variants: first with
+the buffer current and a nil argument, second passing the buffer
+object explicitly.  In both cases no error should be raised and
+the `file-name-non-special' handler for quoted file names should
+be invoked with the right arguments."
+  (files-tests--with-temp-file temp-file-name
+    (with-temp-buffer
+     (let* ((buffer-visiting-file (current-buffer))
+            (actual-args ())
+            (log (lambda (&rest args) (push args actual-args))))
+       (insert-file-contents (concat "/:" temp-file-name) :visit)
+       (should (stringp buffer-file-name))
+       (should (string-prefix-p "/:" buffer-file-name))
+       (should (consp (visited-file-modtime)))
+       (should (equal (find-file-name-handler buffer-file-name
+                                              #'verify-visited-file-modtime)
+                      #'file-name-non-special))
+       (files-tests--with-advice file-name-non-special :before log
+         ;; This should call the file name handler with the right
+         ;; buffer and not signal an error.  The file hasn't been
+         ;; modified, so `verify-visited-file-modtime' should return
+         ;; t.
+         (should (equal (verify-visited-file-modtime) t))
+         (with-temp-buffer
+           (should (stringp (buffer-file-name buffer-visiting-file)))
+           ;; This should call the file name handler with the right
+           ;; buffer and not signal an error.  The file hasn't been
+           ;; modified, so `verify-visited-file-modtime' should return
+           ;; t.
+           (should (equal (verify-visited-file-modtime buffer-visiting-file)
+                          t))))
+       ;; Verify that the handler was actually called.  We called
+       ;; `verify-visited-file-modtime' twice, so both calls should be
+       ;; recorded in reverse order.
+       (should (equal actual-args
+                      `((verify-visited-file-modtime ,buffer-visiting-file)
+                        (verify-visited-file-modtime nil))))))))
+
 (provide 'files-tests)
 ;;; files-tests.el ends here
-- 
2.12.2






^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH] Fix quoted files for 'verify-visited-file-modtime'
  2017-04-26  5:38             ` Eli Zaretskii
@ 2017-04-29 12:20               ` Philipp Stephani
  2017-05-06 19:27                 ` bug#25951: " Philipp
  2017-05-06 19:27                 ` Philipp
  2017-04-29 12:20               ` Philipp Stephani
  1 sibling, 2 replies; 22+ messages in thread
From: Philipp Stephani @ 2017-04-29 12:20 UTC (permalink / raw)
  To: 25951, npostavs, emacs-devel, eliz; +Cc: Philipp Stephani

Fixes Bug#25951.

* lisp/files.el (file-name-non-special): Set the file name for the
correct buffer.

* test/lisp/files-tests.el (files-tests--file-name-non-special--buffers):
Add unit test.
(files-tests--with-advice, files-tests--with-temp-file): New helper
macros.
---
 lisp/files.el            |  9 ++++++-
 test/lisp/files-tests.el | 64 +++++++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 71 insertions(+), 2 deletions(-)

diff --git a/lisp/files.el b/lisp/files.el
index 6848818cad..2e9ab1aad1 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -28,6 +28,8 @@
 
 ;;; Code:
 
+(eval-when-compile (require 'cl-lib))
+
 (defvar font-lock-keywords)
 
 (defgroup backup nil
@@ -6987,7 +6989,12 @@ file-name-non-special
            (when (and visit buffer-file-name)
              (setq buffer-file-name (concat "/:" buffer-file-name))))))
       (`unquote-then-quote
-       (let ((buffer-file-name (substring buffer-file-name 2)))
+       (cl-letf* ((buffer (or (car arguments) (current-buffer)))
+                  ((buffer-local-value 'buffer-file-name buffer)
+                   (substring (buffer-file-name buffer) 2)))
+         ;; `unquote-then-quote' is only used for the
+         ;; `verify-visited-file-modtime' action, which takes a buffer
+         ;; as only optional argument.
          (apply operation arguments)))
       (_
        (apply operation arguments)))))
diff --git a/test/lisp/files-tests.el b/test/lisp/files-tests.el
index 80bbeb1bc5..4583b1af3c 100644
--- a/test/lisp/files-tests.el
+++ b/test/lisp/files-tests.el
@@ -1,4 +1,4 @@
-;;; files-tests.el --- tests for files.el.
+;;; files-tests.el --- tests for files.el.  -*- lexical-binding: t; -*-
 
 ;; Copyright (C) 2012-2017 Free Software Foundation, Inc.
 
@@ -20,6 +20,7 @@
 ;;; Code:
 
 (require 'ert)
+(require 'nadvice)
 
 ;; Set to t if the local variable was set, `query' if the query was
 ;; triggered.
@@ -251,5 +252,66 @@ files-test-bug-18141-file
                       (start-file-process "foo" nil "true"))))
   (should (eq (let ((default-directory "/:/")) (shell-command "true")) 0)))
 
+(defmacro files-tests--with-advice (symbol where function &rest body)
+  (declare (indent 3))
+  (cl-check-type symbol symbol)
+  (cl-check-type where keyword)
+  (cl-check-type function function)
+  (macroexp-let2 nil function function
+    `(progn
+       (advice-add #',symbol ,where ,function)
+       (unwind-protect
+           (progn ,@body)
+         (advice-remove #',symbol ,function)))))
+
+(defmacro files-tests--with-temp-file (name &rest body)
+  (declare (indent 1))
+  (cl-check-type name symbol)
+  `(let ((,name (make-temp-file "emacs")))
+     (unwind-protect
+         (progn ,@body)
+       (delete-file ,name))))
+
+(ert-deftest files-tests--file-name-non-special--buffers ()
+  "Check that Bug#25951 is fixed.
+We call `verify-visited-file-modtime' on a buffer visiting a file
+with a quoted name.  We use two different variants: first with
+the buffer current and a nil argument, second passing the buffer
+object explicitly.  In both cases no error should be raised and
+the `file-name-non-special' handler for quoted file names should
+be invoked with the right arguments."
+  (files-tests--with-temp-file temp-file-name
+    (with-temp-buffer
+     (let* ((buffer-visiting-file (current-buffer))
+            (actual-args ())
+            (log (lambda (&rest args) (push args actual-args))))
+       (insert-file-contents (concat "/:" temp-file-name) :visit)
+       (should (stringp buffer-file-name))
+       (should (string-prefix-p "/:" buffer-file-name))
+       (should (consp (visited-file-modtime)))
+       (should (equal (find-file-name-handler buffer-file-name
+                                              #'verify-visited-file-modtime)
+                      #'file-name-non-special))
+       (files-tests--with-advice file-name-non-special :before log
+         ;; This should call the file name handler with the right
+         ;; buffer and not signal an error.  The file hasn't been
+         ;; modified, so `verify-visited-file-modtime' should return
+         ;; t.
+         (should (equal (verify-visited-file-modtime) t))
+         (with-temp-buffer
+           (should (stringp (buffer-file-name buffer-visiting-file)))
+           ;; This should call the file name handler with the right
+           ;; buffer and not signal an error.  The file hasn't been
+           ;; modified, so `verify-visited-file-modtime' should return
+           ;; t.
+           (should (equal (verify-visited-file-modtime buffer-visiting-file)
+                          t))))
+       ;; Verify that the handler was actually called.  We called
+       ;; `verify-visited-file-modtime' twice, so both calls should be
+       ;; recorded in reverse order.
+       (should (equal actual-args
+                      `((verify-visited-file-modtime ,buffer-visiting-file)
+                        (verify-visited-file-modtime nil))))))))
+
 (provide 'files-tests)
 ;;; files-tests.el ends here
-- 
2.12.2




^ permalink raw reply related	[flat|nested] 22+ messages in thread

* bug#25951: [PATCH] Fix quoted files for 'verify-visited-file-modtime'
  2017-04-29 12:20               ` Philipp Stephani
@ 2017-05-06 19:27                 ` Philipp
  2017-05-06 19:27                 ` Philipp
  1 sibling, 0 replies; 22+ messages in thread
From: Philipp @ 2017-05-06 19:27 UTC (permalink / raw)
  To: npostavs, emacs-devel, eliz, 25951-done; +Cc: Philipp Stephani

[-- Attachment #1: Type: text/plain, Size: 5380 bytes --]

Philipp Stephani <p.stephani2@gmail.com> schrieb am Sa., 29. Apr. 2017 um
14:20 Uhr:

> Fixes Bug#25951.
>
> * lisp/files.el (file-name-non-special): Set the file name for the
> correct buffer.
>
> * test/lisp/files-tests.el (files-tests--file-name-non-special--buffers):
> Add unit test.
> (files-tests--with-advice, files-tests--with-temp-file): New helper
> macros.
> ---
>  lisp/files.el            |  9 ++++++-
>  test/lisp/files-tests.el | 64
> +++++++++++++++++++++++++++++++++++++++++++++++-
>  2 files changed, 71 insertions(+), 2 deletions(-)
>
> diff --git a/lisp/files.el b/lisp/files.el
> index 6848818cad..2e9ab1aad1 100644
> --- a/lisp/files.el
> +++ b/lisp/files.el
> @@ -28,6 +28,8 @@
>
>  ;;; Code:
>
> +(eval-when-compile (require 'cl-lib))
> +
>  (defvar font-lock-keywords)
>
>  (defgroup backup nil
> @@ -6987,7 +6989,12 @@ file-name-non-special
>             (when (and visit buffer-file-name)
>               (setq buffer-file-name (concat "/:" buffer-file-name))))))
>        (`unquote-then-quote
> -       (let ((buffer-file-name (substring buffer-file-name 2)))
> +       (cl-letf* ((buffer (or (car arguments) (current-buffer)))
> +                  ((buffer-local-value 'buffer-file-name buffer)
> +                   (substring (buffer-file-name buffer) 2)))
> +         ;; `unquote-then-quote' is only used for the
> +         ;; `verify-visited-file-modtime' action, which takes a buffer
> +         ;; as only optional argument.
>           (apply operation arguments)))
>        (_
>         (apply operation arguments)))))
> diff --git a/test/lisp/files-tests.el b/test/lisp/files-tests.el
> index 80bbeb1bc5..4583b1af3c 100644
> --- a/test/lisp/files-tests.el
> +++ b/test/lisp/files-tests.el
> @@ -1,4 +1,4 @@
> -;;; files-tests.el --- tests for files.el.
> +;;; files-tests.el --- tests for files.el.  -*- lexical-binding: t; -*-
>
>  ;; Copyright (C) 2012-2017 Free Software Foundation, Inc.
>
> @@ -20,6 +20,7 @@
>  ;;; Code:
>
>  (require 'ert)
> +(require 'nadvice)
>
>  ;; Set to t if the local variable was set, `query' if the query was
>  ;; triggered.
> @@ -251,5 +252,66 @@ files-test-bug-18141-file
>                        (start-file-process "foo" nil "true"))))
>    (should (eq (let ((default-directory "/:/")) (shell-command "true"))
> 0)))
>
> +(defmacro files-tests--with-advice (symbol where function &rest body)
> +  (declare (indent 3))
> +  (cl-check-type symbol symbol)
> +  (cl-check-type where keyword)
> +  (cl-check-type function function)
> +  (macroexp-let2 nil function function
> +    `(progn
> +       (advice-add #',symbol ,where ,function)
> +       (unwind-protect
> +           (progn ,@body)
> +         (advice-remove #',symbol ,function)))))
> +
> +(defmacro files-tests--with-temp-file (name &rest body)
> +  (declare (indent 1))
> +  (cl-check-type name symbol)
> +  `(let ((,name (make-temp-file "emacs")))
> +     (unwind-protect
> +         (progn ,@body)
> +       (delete-file ,name))))
> +
> +(ert-deftest files-tests--file-name-non-special--buffers ()
> +  "Check that Bug#25951 is fixed.
> +We call `verify-visited-file-modtime' on a buffer visiting a file
> +with a quoted name.  We use two different variants: first with
> +the buffer current and a nil argument, second passing the buffer
> +object explicitly.  In both cases no error should be raised and
> +the `file-name-non-special' handler for quoted file names should
> +be invoked with the right arguments."
> +  (files-tests--with-temp-file temp-file-name
> +    (with-temp-buffer
> +     (let* ((buffer-visiting-file (current-buffer))
> +            (actual-args ())
> +            (log (lambda (&rest args) (push args actual-args))))
> +       (insert-file-contents (concat "/:" temp-file-name) :visit)
> +       (should (stringp buffer-file-name))
> +       (should (string-prefix-p "/:" buffer-file-name))
> +       (should (consp (visited-file-modtime)))
> +       (should (equal (find-file-name-handler buffer-file-name
> +
> #'verify-visited-file-modtime)
> +                      #'file-name-non-special))
> +       (files-tests--with-advice file-name-non-special :before log
> +         ;; This should call the file name handler with the right
> +         ;; buffer and not signal an error.  The file hasn't been
> +         ;; modified, so `verify-visited-file-modtime' should return
> +         ;; t.
> +         (should (equal (verify-visited-file-modtime) t))
> +         (with-temp-buffer
> +           (should (stringp (buffer-file-name buffer-visiting-file)))
> +           ;; This should call the file name handler with the right
> +           ;; buffer and not signal an error.  The file hasn't been
> +           ;; modified, so `verify-visited-file-modtime' should return
> +           ;; t.
> +           (should (equal (verify-visited-file-modtime
> buffer-visiting-file)
> +                          t))))
> +       ;; Verify that the handler was actually called.  We called
> +       ;; `verify-visited-file-modtime' twice, so both calls should be
> +       ;; recorded in reverse order.
> +       (should (equal actual-args
> +                      `((verify-visited-file-modtime
> ,buffer-visiting-file)
> +                        (verify-visited-file-modtime nil))))))))
> +
>  (provide 'files-tests)
>  ;;; files-tests.el ends here
> --
> 2.12.2
>
>
No further comments, so I've pushed this as 5e47c2e52b.

[-- Attachment #2: Type: text/html, Size: 6629 bytes --]

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH] Fix quoted files for 'verify-visited-file-modtime'
  2017-04-29 12:20               ` Philipp Stephani
  2017-05-06 19:27                 ` bug#25951: " Philipp
@ 2017-05-06 19:27                 ` Philipp
  2017-05-06 20:28                   ` bug#25951: " Glenn Morris
  1 sibling, 1 reply; 22+ messages in thread
From: Philipp @ 2017-05-06 19:27 UTC (permalink / raw)
  To: npostavs, emacs-devel, eliz, 25951-done; +Cc: Philipp Stephani

[-- Attachment #1: Type: text/plain, Size: 5380 bytes --]

Philipp Stephani <p.stephani2@gmail.com> schrieb am Sa., 29. Apr. 2017 um
14:20 Uhr:

> Fixes Bug#25951.
>
> * lisp/files.el (file-name-non-special): Set the file name for the
> correct buffer.
>
> * test/lisp/files-tests.el (files-tests--file-name-non-special--buffers):
> Add unit test.
> (files-tests--with-advice, files-tests--with-temp-file): New helper
> macros.
> ---
>  lisp/files.el            |  9 ++++++-
>  test/lisp/files-tests.el | 64
> +++++++++++++++++++++++++++++++++++++++++++++++-
>  2 files changed, 71 insertions(+), 2 deletions(-)
>
> diff --git a/lisp/files.el b/lisp/files.el
> index 6848818cad..2e9ab1aad1 100644
> --- a/lisp/files.el
> +++ b/lisp/files.el
> @@ -28,6 +28,8 @@
>
>  ;;; Code:
>
> +(eval-when-compile (require 'cl-lib))
> +
>  (defvar font-lock-keywords)
>
>  (defgroup backup nil
> @@ -6987,7 +6989,12 @@ file-name-non-special
>             (when (and visit buffer-file-name)
>               (setq buffer-file-name (concat "/:" buffer-file-name))))))
>        (`unquote-then-quote
> -       (let ((buffer-file-name (substring buffer-file-name 2)))
> +       (cl-letf* ((buffer (or (car arguments) (current-buffer)))
> +                  ((buffer-local-value 'buffer-file-name buffer)
> +                   (substring (buffer-file-name buffer) 2)))
> +         ;; `unquote-then-quote' is only used for the
> +         ;; `verify-visited-file-modtime' action, which takes a buffer
> +         ;; as only optional argument.
>           (apply operation arguments)))
>        (_
>         (apply operation arguments)))))
> diff --git a/test/lisp/files-tests.el b/test/lisp/files-tests.el
> index 80bbeb1bc5..4583b1af3c 100644
> --- a/test/lisp/files-tests.el
> +++ b/test/lisp/files-tests.el
> @@ -1,4 +1,4 @@
> -;;; files-tests.el --- tests for files.el.
> +;;; files-tests.el --- tests for files.el.  -*- lexical-binding: t; -*-
>
>  ;; Copyright (C) 2012-2017 Free Software Foundation, Inc.
>
> @@ -20,6 +20,7 @@
>  ;;; Code:
>
>  (require 'ert)
> +(require 'nadvice)
>
>  ;; Set to t if the local variable was set, `query' if the query was
>  ;; triggered.
> @@ -251,5 +252,66 @@ files-test-bug-18141-file
>                        (start-file-process "foo" nil "true"))))
>    (should (eq (let ((default-directory "/:/")) (shell-command "true"))
> 0)))
>
> +(defmacro files-tests--with-advice (symbol where function &rest body)
> +  (declare (indent 3))
> +  (cl-check-type symbol symbol)
> +  (cl-check-type where keyword)
> +  (cl-check-type function function)
> +  (macroexp-let2 nil function function
> +    `(progn
> +       (advice-add #',symbol ,where ,function)
> +       (unwind-protect
> +           (progn ,@body)
> +         (advice-remove #',symbol ,function)))))
> +
> +(defmacro files-tests--with-temp-file (name &rest body)
> +  (declare (indent 1))
> +  (cl-check-type name symbol)
> +  `(let ((,name (make-temp-file "emacs")))
> +     (unwind-protect
> +         (progn ,@body)
> +       (delete-file ,name))))
> +
> +(ert-deftest files-tests--file-name-non-special--buffers ()
> +  "Check that Bug#25951 is fixed.
> +We call `verify-visited-file-modtime' on a buffer visiting a file
> +with a quoted name.  We use two different variants: first with
> +the buffer current and a nil argument, second passing the buffer
> +object explicitly.  In both cases no error should be raised and
> +the `file-name-non-special' handler for quoted file names should
> +be invoked with the right arguments."
> +  (files-tests--with-temp-file temp-file-name
> +    (with-temp-buffer
> +     (let* ((buffer-visiting-file (current-buffer))
> +            (actual-args ())
> +            (log (lambda (&rest args) (push args actual-args))))
> +       (insert-file-contents (concat "/:" temp-file-name) :visit)
> +       (should (stringp buffer-file-name))
> +       (should (string-prefix-p "/:" buffer-file-name))
> +       (should (consp (visited-file-modtime)))
> +       (should (equal (find-file-name-handler buffer-file-name
> +
> #'verify-visited-file-modtime)
> +                      #'file-name-non-special))
> +       (files-tests--with-advice file-name-non-special :before log
> +         ;; This should call the file name handler with the right
> +         ;; buffer and not signal an error.  The file hasn't been
> +         ;; modified, so `verify-visited-file-modtime' should return
> +         ;; t.
> +         (should (equal (verify-visited-file-modtime) t))
> +         (with-temp-buffer
> +           (should (stringp (buffer-file-name buffer-visiting-file)))
> +           ;; This should call the file name handler with the right
> +           ;; buffer and not signal an error.  The file hasn't been
> +           ;; modified, so `verify-visited-file-modtime' should return
> +           ;; t.
> +           (should (equal (verify-visited-file-modtime
> buffer-visiting-file)
> +                          t))))
> +       ;; Verify that the handler was actually called.  We called
> +       ;; `verify-visited-file-modtime' twice, so both calls should be
> +       ;; recorded in reverse order.
> +       (should (equal actual-args
> +                      `((verify-visited-file-modtime
> ,buffer-visiting-file)
> +                        (verify-visited-file-modtime nil))))))))
> +
>  (provide 'files-tests)
>  ;;; files-tests.el ends here
> --
> 2.12.2
>
>
No further comments, so I've pushed this as 5e47c2e52b.

[-- Attachment #2: Type: text/html, Size: 6629 bytes --]

^ permalink raw reply	[flat|nested] 22+ messages in thread

* bug#25951: [PATCH] Fix quoted files for 'verify-visited-file-modtime'
  2017-05-06 19:27                 ` Philipp
@ 2017-05-06 20:28                   ` Glenn Morris
  2017-05-06 20:41                     ` npostavs
  0 siblings, 1 reply; 22+ messages in thread
From: Glenn Morris @ 2017-05-06 20:28 UTC (permalink / raw)
  To: 25951; +Cc: p.stephani2


This fails to build: http://hydra.nixos.org/build/52549555





^ permalink raw reply	[flat|nested] 22+ messages in thread

* bug#25951: [PATCH] Fix quoted files for 'verify-visited-file-modtime'
  2017-05-06 20:28                   ` bug#25951: " Glenn Morris
@ 2017-05-06 20:41                     ` npostavs
  2017-05-06 21:21                       ` [PATCH] Fix bootstrap build of files.el Philipp
                                         ` (2 more replies)
  0 siblings, 3 replies; 22+ messages in thread
From: npostavs @ 2017-05-06 20:41 UTC (permalink / raw)
  To: Glenn Morris; +Cc: 25951, p.stephani2

Glenn Morris <rgm@gnu.org> writes:

> This fails to build: http://hydra.nixos.org/build/52549555

    Loading /tmp/nix-build-emacs-tarball-unknown.drv-0/x1vxdahi72zl4bj2yd676ichh4iwi9iw-git-export/lisp/files.el (source)...
    Warning: Unknown defun property `gv-setter' in cl-fifth
    Warning: Unknown defun property `gv-setter' in cl-sixth
    Warning: Unknown defun property `gv-setter' in cl-seventh
    Warning: Unknown defun property `gv-setter' in cl-eighth
    Warning: Unknown defun property `gv-setter' in cl-ninth
    Warning: Unknown defun property `gv-setter' in cl-tenth
    Symbol's function definition is void: gv-define-simple-setter
    make[1]: *** [bootstrap-emacs] Error 255

Looks like my suggestion of using cl-letf doesn't work because it's too
early in the bootstrap process.  Should work with the original code (but
perhaps add a comment about why we can't use cl-letf).





^ permalink raw reply	[flat|nested] 22+ messages in thread

* bug#25951: [PATCH] Fix bootstrap build of files.el
  2017-05-06 20:41                     ` npostavs
  2017-05-06 21:21                       ` [PATCH] Fix bootstrap build of files.el Philipp
@ 2017-05-06 21:21                       ` Philipp
  2017-05-06 21:27                       ` bug#25951: [PATCH] Fix quoted files for 'verify-visited-file-modtime' Philipp
  2 siblings, 0 replies; 22+ messages in thread
From: Philipp @ 2017-05-06 21:21 UTC (permalink / raw)
  To: rgm, npostavs, emacs-devel, 25951; +Cc: Philipp

* lisp/files.el (file-name-non-special): Don't use cl-letf.
---
 lisp/files.el | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/lisp/files.el b/lisp/files.el
index 7e627d36d4..8ac1993754 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -29,7 +29,6 @@
 ;;; Code:
 
 (eval-when-compile
-  (require 'cl-lib)
   (require 'pcase)
   (require 'easy-mmode)) ; For `define-minor-mode'.
 
@@ -7032,13 +7031,18 @@ file-name-non-special
            (when (and visit buffer-file-name)
              (setq buffer-file-name (concat "/:" buffer-file-name))))))
       (`unquote-then-quote
-       (cl-letf* ((buffer (or (car arguments) (current-buffer)))
-                  ((buffer-local-value 'buffer-file-name buffer)
-                   (substring (buffer-file-name buffer) 2)))
+       ;; We can't use `cl-letf' with `(buffer-local-value)' here
+       ;; because it wouldn't work during bootstrapping.
+       (let ((buffer (current-buffer)))
          ;; `unquote-then-quote' is only used for the
          ;; `verify-visited-file-modtime' action, which takes a buffer
          ;; as only optional argument.
-         (apply operation arguments)))
+         (with-current-buffer (or (car arguments) buffer)
+           (let ((buffer-file-name (substring buffer-file-name 2)))
+             ;; Make sure to hide the temporary buffer change from the
+             ;; underlying operation.
+             (with-current-buffer buffer
+               (apply operation arguments))))))
       (_
        (apply operation arguments)))))
 
-- 
2.12.2






^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH] Fix bootstrap build of files.el
  2017-05-06 20:41                     ` npostavs
@ 2017-05-06 21:21                       ` Philipp
  2017-05-07  1:24                         ` Glenn Morris
  2017-05-07  1:24                         ` bug#25951: " Glenn Morris
  2017-05-06 21:21                       ` Philipp
  2017-05-06 21:27                       ` bug#25951: [PATCH] Fix quoted files for 'verify-visited-file-modtime' Philipp
  2 siblings, 2 replies; 22+ messages in thread
From: Philipp @ 2017-05-06 21:21 UTC (permalink / raw)
  To: rgm, npostavs, emacs-devel, 25951; +Cc: Philipp

* lisp/files.el (file-name-non-special): Don't use cl-letf.
---
 lisp/files.el | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/lisp/files.el b/lisp/files.el
index 7e627d36d4..8ac1993754 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -29,7 +29,6 @@
 ;;; Code:
 
 (eval-when-compile
-  (require 'cl-lib)
   (require 'pcase)
   (require 'easy-mmode)) ; For `define-minor-mode'.
 
@@ -7032,13 +7031,18 @@ file-name-non-special
            (when (and visit buffer-file-name)
              (setq buffer-file-name (concat "/:" buffer-file-name))))))
       (`unquote-then-quote
-       (cl-letf* ((buffer (or (car arguments) (current-buffer)))
-                  ((buffer-local-value 'buffer-file-name buffer)
-                   (substring (buffer-file-name buffer) 2)))
+       ;; We can't use `cl-letf' with `(buffer-local-value)' here
+       ;; because it wouldn't work during bootstrapping.
+       (let ((buffer (current-buffer)))
          ;; `unquote-then-quote' is only used for the
          ;; `verify-visited-file-modtime' action, which takes a buffer
          ;; as only optional argument.
-         (apply operation arguments)))
+         (with-current-buffer (or (car arguments) buffer)
+           (let ((buffer-file-name (substring buffer-file-name 2)))
+             ;; Make sure to hide the temporary buffer change from the
+             ;; underlying operation.
+             (with-current-buffer buffer
+               (apply operation arguments))))))
       (_
        (apply operation arguments)))))
 
-- 
2.12.2




^ permalink raw reply related	[flat|nested] 22+ messages in thread

* bug#25951: [PATCH] Fix quoted files for 'verify-visited-file-modtime'
  2017-05-06 20:41                     ` npostavs
  2017-05-06 21:21                       ` [PATCH] Fix bootstrap build of files.el Philipp
  2017-05-06 21:21                       ` Philipp
@ 2017-05-06 21:27                       ` Philipp
  2 siblings, 0 replies; 22+ messages in thread
From: Philipp @ 2017-05-06 21:27 UTC (permalink / raw)
  To: npostavs, Glenn Morris; +Cc: 25951

[-- Attachment #1: Type: text/plain, Size: 1041 bytes --]

<npostavs@users.sourceforge.net> schrieb am Sa., 6. Mai 2017 um 22:39 Uhr:

> Glenn Morris <rgm@gnu.org> writes:
>
> > This fails to build: http://hydra.nixos.org/build/52549555
>
>     Loading
> /tmp/nix-build-emacs-tarball-unknown.drv-0/x1vxdahi72zl4bj2yd676ichh4iwi9iw-git-export/lisp/files.el
> (source)...
>     Warning: Unknown defun property `gv-setter' in cl-fifth
>     Warning: Unknown defun property `gv-setter' in cl-sixth
>     Warning: Unknown defun property `gv-setter' in cl-seventh
>     Warning: Unknown defun property `gv-setter' in cl-eighth
>     Warning: Unknown defun property `gv-setter' in cl-ninth
>     Warning: Unknown defun property `gv-setter' in cl-tenth
>     Symbol's function definition is void: gv-define-simple-setter
>     make[1]: *** [bootstrap-emacs] Error 255
>
> Looks like my suggestion of using cl-letf doesn't work because it's too
> early in the bootstrap process.  Should work with the original code (but
> perhaps add a comment about why we can't use cl-letf).
>

Installed commit cea3b22bc7.

[-- Attachment #2: Type: text/html, Size: 1586 bytes --]

^ permalink raw reply	[flat|nested] 22+ messages in thread

* bug#25951: [PATCH] Fix bootstrap build of files.el
  2017-05-06 21:21                       ` [PATCH] Fix bootstrap build of files.el Philipp
  2017-05-07  1:24                         ` Glenn Morris
@ 2017-05-07  1:24                         ` Glenn Morris
  1 sibling, 0 replies; 22+ messages in thread
From: Glenn Morris @ 2017-05-07  1:24 UTC (permalink / raw)
  To: Philipp; +Cc: Philipp, 25951, npostavs, emacs-devel


We have a diffs mailing list, so you don't need to send your patches to
two other mailing lists as well.





^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH] Fix bootstrap build of files.el
  2017-05-06 21:21                       ` [PATCH] Fix bootstrap build of files.el Philipp
@ 2017-05-07  1:24                         ` Glenn Morris
  2017-05-07 11:35                           ` bug#25951: " Philipp
  2017-05-07 11:35                           ` Philipp
  2017-05-07  1:24                         ` bug#25951: " Glenn Morris
  1 sibling, 2 replies; 22+ messages in thread
From: Glenn Morris @ 2017-05-07  1:24 UTC (permalink / raw)
  To: Philipp; +Cc: Philipp, 25951, emacs-devel, npostavs


We have a diffs mailing list, so you don't need to send your patches to
two other mailing lists as well.



^ permalink raw reply	[flat|nested] 22+ messages in thread

* bug#25951: [PATCH] Fix bootstrap build of files.el
  2017-05-07  1:24                         ` Glenn Morris
@ 2017-05-07 11:35                           ` Philipp
  2017-05-07 11:35                           ` Philipp
  1 sibling, 0 replies; 22+ messages in thread
From: Philipp @ 2017-05-07 11:35 UTC (permalink / raw)
  To: Glenn Morris; +Cc: Philipp, 25951, emacs-devel, npostavs

[-- Attachment #1: Type: text/plain, Size: 323 bytes --]

Glenn Morris <rgm@gnu.org> schrieb am So., 7. Mai 2017 um 03:25 Uhr:

>
> We have a diffs mailing list, so you don't need to send your patches to
> two other mailing lists as well.
>
>

Yes, I just wanted to have my patch reviewed before committing, but since
it broke bootstrapping I decided to install it without review.

[-- Attachment #2: Type: text/html, Size: 618 bytes --]

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH] Fix bootstrap build of files.el
  2017-05-07  1:24                         ` Glenn Morris
  2017-05-07 11:35                           ` bug#25951: " Philipp
@ 2017-05-07 11:35                           ` Philipp
  1 sibling, 0 replies; 22+ messages in thread
From: Philipp @ 2017-05-07 11:35 UTC (permalink / raw)
  To: Glenn Morris; +Cc: Philipp, 25951, npostavs, emacs-devel

[-- Attachment #1: Type: text/plain, Size: 323 bytes --]

Glenn Morris <rgm@gnu.org> schrieb am So., 7. Mai 2017 um 03:25 Uhr:

>
> We have a diffs mailing list, so you don't need to send your patches to
> two other mailing lists as well.
>
>

Yes, I just wanted to have my patch reviewed before committing, but since
it broke bootstrapping I decided to install it without review.

[-- Attachment #2: Type: text/html, Size: 618 bytes --]

^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2017-05-07 11:35 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-03-03 13:56 bug#25951: 26.0.50; Error when ediffing files that are visited using quoted file names Philipp Stephani
2017-04-21 22:14 ` Philipp Stephani
2017-04-21 22:50   ` npostavs
2017-04-22 19:43     ` Philipp Stephani
2017-04-22 20:32       ` npostavs
2017-04-23 16:54         ` Philipp Stephani
2017-04-23 17:06           ` [PATCH] Fix quoted files for 'verify-visited-file-modtime' Philipp Stephani
2017-04-26  5:38             ` Eli Zaretskii
2017-04-29 12:20               ` Philipp Stephani
2017-05-06 19:27                 ` bug#25951: " Philipp
2017-05-06 19:27                 ` Philipp
2017-05-06 20:28                   ` bug#25951: " Glenn Morris
2017-05-06 20:41                     ` npostavs
2017-05-06 21:21                       ` [PATCH] Fix bootstrap build of files.el Philipp
2017-05-07  1:24                         ` Glenn Morris
2017-05-07 11:35                           ` bug#25951: " Philipp
2017-05-07 11:35                           ` Philipp
2017-05-07  1:24                         ` bug#25951: " Glenn Morris
2017-05-06 21:21                       ` Philipp
2017-05-06 21:27                       ` bug#25951: [PATCH] Fix quoted files for 'verify-visited-file-modtime' Philipp
2017-04-29 12:20               ` Philipp Stephani
2017-04-29 11:49           ` Philipp Stephani

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.