From unknown Wed Jun 25 05:42:16 2025 X-Loop: help-debbugs@gnu.org Subject: bug#22377: 25.0.50; Issues involving desktop.el Resent-From: Stephen Berman Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 15 Jan 2016 14:31:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 22377 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 22377@debbugs.gnu.org X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.145286820730753 (code B ref -1); Fri, 15 Jan 2016 14:31:02 +0000 Received: (at submit) by debbugs.gnu.org; 15 Jan 2016 14:30:07 +0000 Received: from localhost ([127.0.0.1]:49748 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aK5OB-0007zw-1A for submit@debbugs.gnu.org; Fri, 15 Jan 2016 09:30:07 -0500 Received: from eggs.gnu.org ([208.118.235.92]:43099) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aK5O9-0007yC-NF for submit@debbugs.gnu.org; Fri, 15 Jan 2016 09:30:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aK5Ny-0001wA-OR for submit@debbugs.gnu.org; Fri, 15 Jan 2016 09:30:00 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,FREEMAIL_FROM autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:50532) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aK5Ny-0001w6-L1 for submit@debbugs.gnu.org; Fri, 15 Jan 2016 09:29:54 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34035) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aK5Nw-00066q-UA for bug-gnu-emacs@gnu.org; Fri, 15 Jan 2016 09:29:54 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aK5Ns-0001vb-Qz for bug-gnu-emacs@gnu.org; Fri, 15 Jan 2016 09:29:52 -0500 Received: from mout.gmx.net ([212.227.17.22]:53411) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aK5Ns-0001vT-G6 for bug-gnu-emacs@gnu.org; Fri, 15 Jan 2016 09:29:48 -0500 Received: from rosalinde ([89.245.87.150]) by mail.gmx.com (mrgmx103) with ESMTPSA (Nemesis) id 0Maa3B-1aZHut0QzR-00KAfB for ; Fri, 15 Jan 2016 15:29:46 +0100 From: Stephen Berman Date: Fri, 15 Jan 2016 15:29:44 +0100 Message-ID: <87pox2j4pz.fsf@gmx.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K0:RhiEJht/iL1zE/ByzTHp+xc2SGZA0K/w75Ncbce2r+aHWR9JBIo DQDsWXXx7rVv/gg4yw5GHMOLRTcU3DA0yXBYEpAV6VGNtUA9xtso0ks8mgcCTSvlR68HDPM C9DIp9HMS6X1EoM5+0zbNPnxuH6dyWcIBbH55g5NJLQpInFoeL3LenNLnzOaMKP2xJf9jee LQkHEGjNnor86Z90USXGg== X-UI-Out-Filterresults: notjunk:1;V01:K0:feSOz1Yx+6o=:TIj6tdFmZ3Z+OaVkr8FxHU 56MBuGUDoHGIpLJDHFx+nrTmJMcOcr/xWJx08zoLJnBSRAyRUXCkCpBBaBqdsm9r6xzVwBsEK RHCRH8VJm1ZleqcoUgnFa9q21cuGza7tez0dGMAy5xN7NGqAJMyn4t/V0SppIlJ2C3J2J6kDM Uopmcqk4Fc0Ve0TaKncYHfFRw9uM9fncfD8Em5R3FRVW5k33KXuq6savS7AbZXDfmV0WIF8OX pVJoSxF8tAmx8+T1vjN3aSOz9A3azP+xHbsDPhmf+ZyIIUtP3TKG/Kt7++gDunKrSxFSm3nk3 83Aut6IyV1p4Oo3KOknhGaJ2hzVLQZLc+Ppgt693vbeknUKad1oRcNc8y6FcaVlCRtCgB2GAs sFMDjjkiUR4/EWkxE5nb4qUyZwbLHFbUb+s8ZfyvVgUEHwHtmFKjtyF0HpFGw9Y2+3oQCmqUF WKfnBMTHuNNMOYHweqVrG1elhIk5r5IKZhPRsccYi8Vm+7bez49pVCxvw8TBju1xoBC0RaQxk SPz7HMglQD4KQHz2LpQ7NIlEAtjVyfmXNd3lNaFiYliw2apQ9diTBR/gKMjrpy0HeZuwbqMOn WVNxCL/kI2V1BFf1u/hq8+nu8HZ4gNzJ6GriJVaXVnoCbS3I2FPa1nM/TTFMFkFhdFB0PYGPe norj6WU7F3IkCJEtJ6DWpfoEzZbvgJg1EHLP/h6+9jGzARFRs6FNq0r8iV1a4Yt6nXiRoFiWf Ji0fxZDDd4TAWCuY0c9totGwysWQYcmc6jMRAnZxNz5onh4AtakqRAcsZ/xTIrRmhcZIYqXId fQqy6Pvxly2qJYDO+G/G+4tpsroblwfBhd/zOb7mTQTiP3hAnliVYunRRBNuaQOzdEetOcxgR CcF7BwwF9ihEalpnrZKes142lJk8Vs3HytDvz2FDqrAQZyUfm2wogmfruWeAjN X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.1 (----) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -4.1 (----) 0. Make sure there is no .emacs.desktop file that will be found by desktop-read. 1. emacs -Q 2. M-x todo-show to visit an existing Todo file or create a new one. 3. M-x desktop-save, use defaults. 4. C-x C-c 5. emacs -Q 6. M-x desktop-read =3D> The Todo file is displayed in Todo mode but is not narrowed to the current category as it should be, and the echo area displays this message: "Desktop: 1 frame, 0 buffers restored, 1 failed to restore." tl;dr: The patch below fix this; the following paragraphs explain the issues in more detail and justify the fix (also for doc-view). In addition to the echo area message, the *Messages* buffer contains this error message: "Desktop: Can=E2=80=99t load buffer Bla.todo: Wrong type argument: number-or-marker-p, nil". This comes from desktop-create-buffer and stepping through it (or setting debug-on-error between steps 5 and 6 above) shows that the error actually comes from todo-current-category and is raised because todo-category-number, which is set by the desktop buffer mode handler todo-restore-desktop-buffer, is nil instead of a number. The value of todo-category-number is supposed to be written to the .emacs.desktop file by calling todo-desktop-save-buffer, which is the buffer-local value of desktop-save-buffer in Todo mode -- but only when desktop-save-mode is non-nil. However, nothing prohibits invoking desktop-save when desktop-save-mode is nil, which in the above recipe results in the error observed. The simplest fix for this problem is to remove the conditioning in todo-mode.el on setting desktop-save-buffer. In fact, there are only a handful of libraries in Emacs that set desktop-save-buffer (rmail, eww, dired, info, vc-dir, mh-folder, doc-view, and todo-mode) and all but two set it unconditionally -- the exceptions are todo-mode and doc-view (and the former is because I took doc-view as a model when I added desktop support to todo-mode in response to bug#15225). And indeed, doc-view has the same type of desktop restoration issue as todo-mode: in the above recipe, replace step 2 by visiting e.g. some multipage PDF file, scroll to e.g. page 5, then continue the recipe with step 3; after step 6, the PDF file is restored to page 1 instead of page 5, and the same message as above is shown in the echo area. Removing the conditioning on setting desktop-save-buffer in doc-view.el solves the wrong page display. Both doc-view and, following it, todo-mode not only condition setting desktop-save-buffer on non-nil desktop-save-mode but also on this variable not being void. But isn't that only needed if these modes were invoked in an Emacs lacking desktop.el? At least the current version of todo-mode.el won't work in an Emacs old enough not to have desktop.el. And since the other libraries mentioned above do not have this condition, it seems unnecessary (dired does have `(eval-when-compile (require 'desktop))' but I wonder if that is still needed; and mh-folder.el also has similar checks but I think it's intended to work in older Emacsen). In any case, simply removing the entire condition on desktop-save-buffer from both doc-view and todo-mode does not make the byte compiler complain. There still remains the issue of the message "Desktop: 1 frame, 0 buffers restored, 1 failed to restore." It is wrong, because the buffer visiting the Todo file (or the PDF file in the doc-view case) is restored, though incorrectly displayed. In fact, removing the condition on desktop-save-buffer fixes the display but does not eliminate the erroneous message. This comes from desktop-read and is triggered by incrementing desktop-buffer-fail-count in desktop-create-buffer. This happens because the todo-mode and doc-view desktop buffer mode handlers do not return a buffer. The doc string of desktop-buffer-mode-handlers seems to allow this, but the result will invariably be a message about failing to restore buffers, which is clearly wrong for todo-mode and doc-view. The fix in both case is simply to have the handlers in these modes return the current buffer, which is what the desktop buffer mode handlers in the other libraries with desktop support do. I can't think of a successful use of a desktop buffer mode handler that fails to restore a buffer; if there isn't one, it would be better for the doc string of desktop-buffer-mode-handlers to explicitly say that the handler should return a buffer. The patch below fixes the display issues and the erroneous message in todo-mode and doc-view. Although I maintain only the former code, I'm pretty sure the fix is appropriate for the latter as well, so if there are no objections to the patch within a few days or so, I'll commit it to emacs-25. (I'll leave the desktop-buffer-mode-handlers doc string issue to someone more familiar with that library.) In GNU Emacs 25.0.50.4 (x86_64-suse-linux-gnu, GTK+ Version 3.14.15) of 2016-01-15 built on rosalinde Repository revision: 016b3d5894b8c424eab262aeefc646c6cd03a70a Windowing system distributor 'The X.Org Foundation', version 11.0.11601000 System Description: openSUSE 13.2 (Harlequin) (x86_64) diff --git a/lisp/calendar/todo-mode.el b/lisp/calendar/todo-mode.el index 353ca69..ebf0a82 100644 --- a/lisp/calendar/todo-mode.el +++ b/lisp/calendar/todo-mode.el @@ -5230,7 +5230,8 @@ todo-restore-desktop-buffer (with-current-buffer buffer (widen) (let ((todo-category-number (cdr (assq 'catnum misc)))) - (todo-category-select)))) + (todo-category-select) + (current-buffer)))) =20 (add-to-list 'desktop-buffer-mode-handlers '(todo-mode . todo-restore-desktop-buffer)) @@ -6579,8 +6580,7 @@ todo-modes-set-2 "Make some settings that apply to multiple Todo modes." (add-to-invisibility-spec 'todo) (setq buffer-read-only t) - (when (and (boundp 'desktop-save-mode) desktop-save-mode) - (setq-local desktop-save-buffer 'todo-desktop-save-buffer)) + (setq-local desktop-save-buffer 'todo-desktop-save-buffer) (when (boundp 'hl-line-range-function) (setq-local hl-line-range-function (lambda() (save-excursion diff --git a/lisp/doc-view.el b/lisp/doc-view.el index 2868113..06cf8dc 100644 --- a/lisp/doc-view.el +++ b/lisp/doc-view.el @@ -1714,7 +1714,8 @@ doc-view-restore-desktop-buffer ;; window-parameters in the window-state(s) and then restoring this ;; window-state should call us back (to interpret/use those paramete= rs). (doc-view-goto-page page) - (when slice (apply 'doc-view-set-slice slice))))) + (when slice (apply 'doc-view-set-slice slice)) + (current-buffer)))) =20 (add-to-list 'desktop-buffer-mode-handlers '(doc-view-mode . doc-view-restore-desktop-buffer)) @@ -1788,9 +1789,7 @@ doc-view-mode nil t) (add-hook 'clone-indirect-buffer-hook 'doc-view-clone-buffer-hook nil = t) (add-hook 'kill-buffer-hook 'doc-view-kill-proc nil t) - (when (and (boundp 'desktop-save-mode) - desktop-save-mode) - (setq-local desktop-save-buffer 'doc-view-desktop-save-buffer)) + (setq-local desktop-save-buffer 'doc-view-desktop-save-buffer) =20 (remove-overlays (point-min) (point-max) 'doc-view t) ;Just in case. ;; Keep track of display info ([vh]scroll, page number, overlay, From unknown Wed Jun 25 05:42:16 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: Stephen Berman Subject: bug#22377: closed (Re: bug#22377: 25.0.50; Issues involving desktop.el) Message-ID: References: <87y4bjmdm5.fsf@gmx.net> <87pox2j4pz.fsf@gmx.net> X-Gnu-PR-Message: they-closed 22377 X-Gnu-PR-Package: emacs Reply-To: 22377@debbugs.gnu.org Date: Thu, 21 Jan 2016 10:28:02 +0000 Content-Type: multipart/mixed; boundary="----------=_1453372082-27050-1" This is a multi-part message in MIME format... ------------=_1453372082-27050-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #22377: 25.0.50; Issues involving desktop.el which was filed against the emacs package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 22377@debbugs.gnu.org. --=20 22377: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D22377 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1453372082-27050-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 22377-done) by debbugs.gnu.org; 21 Jan 2016 10:27:49 +0000 Received: from localhost ([127.0.0.1]:55805 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aMCSz-00071t-KL for submit@debbugs.gnu.org; Thu, 21 Jan 2016 05:27:49 -0500 Received: from mout.gmx.net ([212.227.15.19]:63903) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aMCSy-00071g-D2 for 22377-done@debbugs.gnu.org; Thu, 21 Jan 2016 05:27:48 -0500 Received: from rosalinde ([89.245.88.13]) by mail.gmx.com (mrgmx001) with ESMTPSA (Nemesis) id 0LwrwO-1a2I0D3fIG-016Q2r for <22377-done@debbugs.gnu.org>; Thu, 21 Jan 2016 11:27:41 +0100 From: Stephen Berman To: 22377-done@debbugs.gnu.org Subject: Re: bug#22377: 25.0.50; Issues involving desktop.el References: <87pox2j4pz.fsf@gmx.net> Date: Thu, 21 Jan 2016 11:27:30 +0100 In-Reply-To: <87pox2j4pz.fsf@gmx.net> (Stephen Berman's message of "Fri, 15 Jan 2016 15:29:44 +0100") Message-ID: <87y4bjmdm5.fsf@gmx.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Provags-ID: V03:K0:VLsEw2EVkamc1Ny8kHd4vy/7CdDiL8pBn1lR5zvBt3sjPwCS0GI JtoItwzluAwtvtpXQlHqZkjKE3wbufEVIFr4ZtIFvX4q6sOPCtpkeyuu+AmCCcl4y4OAPsj dx0sE58CrMxztA933bB0+KrVnaQNbl0nfB3xRxyOFTc1qm/2Ek8dBAI5LBtP8UEetCv85zy hp2cU0so06C2/r4UgHQbQ== X-UI-Out-Filterresults: notjunk:1;V01:K0:lVPXxX+7BDU=:jg/oMojlejNCuhDpGMHRsb o9fACUVQrsG4A95D3+1Ne8OIWNjmf8yQuO4FyNBAXhCZ3YYzSCdWhdZ8Dpxlikp8ql/9rpjw3 0Q+AbHFoGf3zz7fHu0MF8AMG0NYLg0X4Mq/bblH0U4iWPuW9SjSHrXEGcAm4DrZthi3V8NpTY tBuDrYM+b9ngcjLkXJt0Q5T6F0n6CR4hib40qTsliYV75SWjCYXsfMAQ4qTC+uVtpUoLAJuC6 dUr4w/VUjyPRIEM+xjFiozMBBEQTl+sEfDUQzPObqOK/meRO6Q2f0Ao9CVYVLLpmhiDIbrfOv nsg2JIynekQLutLuejPs4sc0R1VrxHvuTyQi7B6VfcGhueASWnNm7fkg852X37p2pxjhUATgr cwisW9W3BahwYrj3huddyJq8qjQ9Y2EztDe0KWMznXT5BSeKk2UfgEO6mX7pXTFnWSfWMYYv9 mNiTkpvm7VMb2NvzH2b/5VuEZcVDH3pppJDpLr5cJGv1O3p2ap/2Unv8r4maAsNEfhzcrKn66 4wr+uHrBGN87yGSzfO5Yz/+NOfJG+EdgkM2e/OPtWQMT82TysRw7LPFl2JXXV0NJqrLJJvjJS kkvONmgYMpTjOxNVAmgiNmkSyNdWlF/p1+RBcYmIXwocsswoHzcGpA9JFeT6Fy/0tOjY60DGo MqKEtToD2sDbXvF4XsS0zoudjuZjwQwf31W81+qngefc0/xyOI+WZSRR5UDgIKqnk2met+L7O F7KhCK+gebCgiOg0rT2NIZ8CtjbhK2z53ajd91kNBkzqn/m831lXmjZDvikNGnSu/odt/YuBG 8BHhh3/ X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 22377-done X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) On Fri, 15 Jan 2016 15:29:44 +0100 Stephen Berman wrote: > 0. Make sure there is no .emacs.desktop file that will be found by > desktop-read. > 1. emacs -Q > 2. M-x todo-show to visit an existing Todo file or create a new one. > 3. M-x desktop-save, use defaults. > 4. C-x C-c > 5. emacs -Q > 6. M-x desktop-read > => The Todo file is displayed in Todo mode but is not narrowed to the > current category as it should be, and the echo area displays this > message: "Desktop: 1 frame, 0 buffers restored, 1 failed to restore." [...] > The patch below fixes the display issues and the erroneous message in > todo-mode and doc-view. Although I maintain only the former code, I'm > pretty sure the fix is appropriate for the latter as well, so if there > are no objections to the patch within a few days or so, I'll commit it > to emacs-25. (I'll leave the desktop-buffer-mode-handlers doc string > issue to someone more familiar with that library.) Done in commit 7bc7fd6058a28cdf7da672dc625c6d3f2e50aa1b and bug closed. ------------=_1453372082-27050-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 15 Jan 2016 14:30:07 +0000 Received: from localhost ([127.0.0.1]:49748 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aK5OB-0007zw-1A for submit@debbugs.gnu.org; Fri, 15 Jan 2016 09:30:07 -0500 Received: from eggs.gnu.org ([208.118.235.92]:43099) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aK5O9-0007yC-NF for submit@debbugs.gnu.org; Fri, 15 Jan 2016 09:30:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aK5Ny-0001wA-OR for submit@debbugs.gnu.org; Fri, 15 Jan 2016 09:30:00 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,FREEMAIL_FROM autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:50532) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aK5Ny-0001w6-L1 for submit@debbugs.gnu.org; Fri, 15 Jan 2016 09:29:54 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34035) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aK5Nw-00066q-UA for bug-gnu-emacs@gnu.org; Fri, 15 Jan 2016 09:29:54 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aK5Ns-0001vb-Qz for bug-gnu-emacs@gnu.org; Fri, 15 Jan 2016 09:29:52 -0500 Received: from mout.gmx.net ([212.227.17.22]:53411) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aK5Ns-0001vT-G6 for bug-gnu-emacs@gnu.org; Fri, 15 Jan 2016 09:29:48 -0500 Received: from rosalinde ([89.245.87.150]) by mail.gmx.com (mrgmx103) with ESMTPSA (Nemesis) id 0Maa3B-1aZHut0QzR-00KAfB for ; Fri, 15 Jan 2016 15:29:46 +0100 From: Stephen Berman To: bug-gnu-emacs@gnu.org Subject: 25.0.50; Issues involving desktop.el Date: Fri, 15 Jan 2016 15:29:44 +0100 Message-ID: <87pox2j4pz.fsf@gmx.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K0:RhiEJht/iL1zE/ByzTHp+xc2SGZA0K/w75Ncbce2r+aHWR9JBIo DQDsWXXx7rVv/gg4yw5GHMOLRTcU3DA0yXBYEpAV6VGNtUA9xtso0ks8mgcCTSvlR68HDPM C9DIp9HMS6X1EoM5+0zbNPnxuH6dyWcIBbH55g5NJLQpInFoeL3LenNLnzOaMKP2xJf9jee LQkHEGjNnor86Z90USXGg== X-UI-Out-Filterresults: notjunk:1;V01:K0:feSOz1Yx+6o=:TIj6tdFmZ3Z+OaVkr8FxHU 56MBuGUDoHGIpLJDHFx+nrTmJMcOcr/xWJx08zoLJnBSRAyRUXCkCpBBaBqdsm9r6xzVwBsEK RHCRH8VJm1ZleqcoUgnFa9q21cuGza7tez0dGMAy5xN7NGqAJMyn4t/V0SppIlJ2C3J2J6kDM Uopmcqk4Fc0Ve0TaKncYHfFRw9uM9fncfD8Em5R3FRVW5k33KXuq6savS7AbZXDfmV0WIF8OX pVJoSxF8tAmx8+T1vjN3aSOz9A3azP+xHbsDPhmf+ZyIIUtP3TKG/Kt7++gDunKrSxFSm3nk3 83Aut6IyV1p4Oo3KOknhGaJ2hzVLQZLc+Ppgt693vbeknUKad1oRcNc8y6FcaVlCRtCgB2GAs sFMDjjkiUR4/EWkxE5nb4qUyZwbLHFbUb+s8ZfyvVgUEHwHtmFKjtyF0HpFGw9Y2+3oQCmqUF WKfnBMTHuNNMOYHweqVrG1elhIk5r5IKZhPRsccYi8Vm+7bez49pVCxvw8TBju1xoBC0RaQxk SPz7HMglQD4KQHz2LpQ7NIlEAtjVyfmXNd3lNaFiYliw2apQ9diTBR/gKMjrpy0HeZuwbqMOn WVNxCL/kI2V1BFf1u/hq8+nu8HZ4gNzJ6GriJVaXVnoCbS3I2FPa1nM/TTFMFkFhdFB0PYGPe norj6WU7F3IkCJEtJ6DWpfoEzZbvgJg1EHLP/h6+9jGzARFRs6FNq0r8iV1a4Yt6nXiRoFiWf Ji0fxZDDd4TAWCuY0c9totGwysWQYcmc6jMRAnZxNz5onh4AtakqRAcsZ/xTIrRmhcZIYqXId fQqy6Pvxly2qJYDO+G/G+4tpsroblwfBhd/zOb7mTQTiP3hAnliVYunRRBNuaQOzdEetOcxgR CcF7BwwF9ihEalpnrZKes142lJk8Vs3HytDvz2FDqrAQZyUfm2wogmfruWeAjN X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.1 (----) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -4.1 (----) 0. Make sure there is no .emacs.desktop file that will be found by desktop-read. 1. emacs -Q 2. M-x todo-show to visit an existing Todo file or create a new one. 3. M-x desktop-save, use defaults. 4. C-x C-c 5. emacs -Q 6. M-x desktop-read =3D> The Todo file is displayed in Todo mode but is not narrowed to the current category as it should be, and the echo area displays this message: "Desktop: 1 frame, 0 buffers restored, 1 failed to restore." tl;dr: The patch below fix this; the following paragraphs explain the issues in more detail and justify the fix (also for doc-view). In addition to the echo area message, the *Messages* buffer contains this error message: "Desktop: Can=E2=80=99t load buffer Bla.todo: Wrong type argument: number-or-marker-p, nil". This comes from desktop-create-buffer and stepping through it (or setting debug-on-error between steps 5 and 6 above) shows that the error actually comes from todo-current-category and is raised because todo-category-number, which is set by the desktop buffer mode handler todo-restore-desktop-buffer, is nil instead of a number. The value of todo-category-number is supposed to be written to the .emacs.desktop file by calling todo-desktop-save-buffer, which is the buffer-local value of desktop-save-buffer in Todo mode -- but only when desktop-save-mode is non-nil. However, nothing prohibits invoking desktop-save when desktop-save-mode is nil, which in the above recipe results in the error observed. The simplest fix for this problem is to remove the conditioning in todo-mode.el on setting desktop-save-buffer. In fact, there are only a handful of libraries in Emacs that set desktop-save-buffer (rmail, eww, dired, info, vc-dir, mh-folder, doc-view, and todo-mode) and all but two set it unconditionally -- the exceptions are todo-mode and doc-view (and the former is because I took doc-view as a model when I added desktop support to todo-mode in response to bug#15225). And indeed, doc-view has the same type of desktop restoration issue as todo-mode: in the above recipe, replace step 2 by visiting e.g. some multipage PDF file, scroll to e.g. page 5, then continue the recipe with step 3; after step 6, the PDF file is restored to page 1 instead of page 5, and the same message as above is shown in the echo area. Removing the conditioning on setting desktop-save-buffer in doc-view.el solves the wrong page display. Both doc-view and, following it, todo-mode not only condition setting desktop-save-buffer on non-nil desktop-save-mode but also on this variable not being void. But isn't that only needed if these modes were invoked in an Emacs lacking desktop.el? At least the current version of todo-mode.el won't work in an Emacs old enough not to have desktop.el. And since the other libraries mentioned above do not have this condition, it seems unnecessary (dired does have `(eval-when-compile (require 'desktop))' but I wonder if that is still needed; and mh-folder.el also has similar checks but I think it's intended to work in older Emacsen). In any case, simply removing the entire condition on desktop-save-buffer from both doc-view and todo-mode does not make the byte compiler complain. There still remains the issue of the message "Desktop: 1 frame, 0 buffers restored, 1 failed to restore." It is wrong, because the buffer visiting the Todo file (or the PDF file in the doc-view case) is restored, though incorrectly displayed. In fact, removing the condition on desktop-save-buffer fixes the display but does not eliminate the erroneous message. This comes from desktop-read and is triggered by incrementing desktop-buffer-fail-count in desktop-create-buffer. This happens because the todo-mode and doc-view desktop buffer mode handlers do not return a buffer. The doc string of desktop-buffer-mode-handlers seems to allow this, but the result will invariably be a message about failing to restore buffers, which is clearly wrong for todo-mode and doc-view. The fix in both case is simply to have the handlers in these modes return the current buffer, which is what the desktop buffer mode handlers in the other libraries with desktop support do. I can't think of a successful use of a desktop buffer mode handler that fails to restore a buffer; if there isn't one, it would be better for the doc string of desktop-buffer-mode-handlers to explicitly say that the handler should return a buffer. The patch below fixes the display issues and the erroneous message in todo-mode and doc-view. Although I maintain only the former code, I'm pretty sure the fix is appropriate for the latter as well, so if there are no objections to the patch within a few days or so, I'll commit it to emacs-25. (I'll leave the desktop-buffer-mode-handlers doc string issue to someone more familiar with that library.) In GNU Emacs 25.0.50.4 (x86_64-suse-linux-gnu, GTK+ Version 3.14.15) of 2016-01-15 built on rosalinde Repository revision: 016b3d5894b8c424eab262aeefc646c6cd03a70a Windowing system distributor 'The X.Org Foundation', version 11.0.11601000 System Description: openSUSE 13.2 (Harlequin) (x86_64) diff --git a/lisp/calendar/todo-mode.el b/lisp/calendar/todo-mode.el index 353ca69..ebf0a82 100644 --- a/lisp/calendar/todo-mode.el +++ b/lisp/calendar/todo-mode.el @@ -5230,7 +5230,8 @@ todo-restore-desktop-buffer (with-current-buffer buffer (widen) (let ((todo-category-number (cdr (assq 'catnum misc)))) - (todo-category-select)))) + (todo-category-select) + (current-buffer)))) =20 (add-to-list 'desktop-buffer-mode-handlers '(todo-mode . todo-restore-desktop-buffer)) @@ -6579,8 +6580,7 @@ todo-modes-set-2 "Make some settings that apply to multiple Todo modes." (add-to-invisibility-spec 'todo) (setq buffer-read-only t) - (when (and (boundp 'desktop-save-mode) desktop-save-mode) - (setq-local desktop-save-buffer 'todo-desktop-save-buffer)) + (setq-local desktop-save-buffer 'todo-desktop-save-buffer) (when (boundp 'hl-line-range-function) (setq-local hl-line-range-function (lambda() (save-excursion diff --git a/lisp/doc-view.el b/lisp/doc-view.el index 2868113..06cf8dc 100644 --- a/lisp/doc-view.el +++ b/lisp/doc-view.el @@ -1714,7 +1714,8 @@ doc-view-restore-desktop-buffer ;; window-parameters in the window-state(s) and then restoring this ;; window-state should call us back (to interpret/use those paramete= rs). (doc-view-goto-page page) - (when slice (apply 'doc-view-set-slice slice))))) + (when slice (apply 'doc-view-set-slice slice)) + (current-buffer)))) =20 (add-to-list 'desktop-buffer-mode-handlers '(doc-view-mode . doc-view-restore-desktop-buffer)) @@ -1788,9 +1789,7 @@ doc-view-mode nil t) (add-hook 'clone-indirect-buffer-hook 'doc-view-clone-buffer-hook nil = t) (add-hook 'kill-buffer-hook 'doc-view-kill-proc nil t) - (when (and (boundp 'desktop-save-mode) - desktop-save-mode) - (setq-local desktop-save-buffer 'doc-view-desktop-save-buffer)) + (setq-local desktop-save-buffer 'doc-view-desktop-save-buffer) =20 (remove-overlays (point-min) (point-max) 'doc-view t) ;Just in case. ;; Keep track of display info ([vh]scroll, page number, overlay, ------------=_1453372082-27050-1--