Subject: bug#24036: 25.0.95; Prevent warnings when opening files during desktop restore

From: Kaushal Modi <[email-masked]>
Date: Wed, 20 Jul 2016 13:58:15 +0000

Hi,

This bug report is more like a minor enhancement in the process of file
restoration during desktop-restore.

@Juanma, Stefan: I am copying you guys to review this as this section of
desktop.el has commits made by you the most. (PS: vc-region-history is
awesome!)

I use the *Messages* buffer at startup as a check that everything's good in
my config.

But as I use desktop save/restore in my workflow, I also get stuff like

Note: file is write protected [2 times]
<something else>
Note: file is write protected [19 times]
<something else>
Note: file is write protected
<something else>
Note: file is write protected [3 times]

Finally after much digging I had figured out that it is
`desktop-restore-file-buffer` that is causing this.

I understand that "file is write protected" and other warning are useful to
the user when they are doing find-file interactively. But in this scenario,
they just add clutter in the *Messages* buffer and provide no useful debug
info.

The patch that I am proposing in this report has been living in my emacs
config since Nov 2014! and I have not seen a single bad side-effect of
that. I hope this get merged into the master.

===== patch start
>From e5fdf14a387248c282abd94effe7f97be51340b5 Mon Sep 17 00:00:00 2001
From: Kaushal Modi <[email-masked]>
Date: Wed, 20 Jul 2016 09:50:38 -0400
Subject: [PATCH] No find-file warnings during desktop-restore

* lisp/desktop.el (desktop-restore-file-buffer): Do not print warnings
  when files are being opened during desktop restore.
---
 lisp/desktop.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/desktop.el b/lisp/desktop.el
index 1f460b7..df4ff55 100644
--- a/lisp/desktop.el
+++ b/lisp/desktop.el
@@ -1402,7 +1402,7 @@ desktop-restore-file-buffer
  (or coding-system-for-read
     (cdr (assq 'buffer-file-coding-system
        desktop-buffer-locals))))
-       (buf (find-file-noselect buffer-filename)))
+       (buf (find-file-noselect buffer-filename :nowarn)))
   (condition-case nil
       (switch-to-buffer buf)
     (error (pop-to-buffer buf)))
-- 
2.6.0.rc0.24.gec371ff
===== patch end

In GNU Emacs 25.0.95.11 (x86_64-unknown-linux-gnu, GTK+ Version 2.24.23)
 of 2016-06-29
Repository revision: 6192b6c3a4374b2cb6e02ca865e1899a04a7f7dc
Windowing system distributor 'The X.Org Foundation', version 11.0.60900000
System Description: Red Hat Enterprise Linux Workstation release 6.6
(Santiago)

Thanks!
-- 

Kaushal Modi