emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[elpa] externals/auctex e9af1e68fb 15/77: Fix preview-latex to work with


From: Tassilo Horn
Subject: [elpa] externals/auctex e9af1e68fb 15/77: Fix preview-latex to work with desktop.el again
Date: Fri, 26 Aug 2022 16:06:32 -0400 (EDT)

branch: externals/auctex
commit e9af1e68fb464a45369e19ff85162c49467c87e6
Author: Ikumi Keita <ikumi@ikumi.que.jp>
Commit: Ikumi Keita <ikumi@ikumi.que.jp>

    Fix preview-latex to work with desktop.el again
    
    * preview.el.in (): Don't use obsolete variable
    `desktop-buffer-misc-functions'.
    (): Just use `desktop-buffer-mode-handlers' which all supported
    Emacsens now have.
    Use autoload cookie instead of `eval-after-load'.
    (desktop-buffer-preview): Add autoload cookie so that it's available
    before preview.el is loaded.
    (LaTeX-preview-setup): Don't use `desktop-buffer-misc' because it
    isn't available (It's now lexically scoped variable in
    `desktop-create-buffer'.  In addition, `LaTeX-preview-setup' isn't
    called anyway during `desktop-buffer-misc' is bound.).
---
 preview.el.in | 36 ++++++++++++++++--------------------
 1 file changed, 16 insertions(+), 20 deletions(-)

diff --git a/preview.el.in b/preview.el.in
index a995485d77..96c5706683 100644
--- a/preview.el.in
+++ b/preview.el.in
@@ -2328,11 +2328,6 @@ kept."
         (and save-info
              (cons 'preview (cons timestamp (nreverse save-info))))))))
 
-(eval-after-load "desktop"
-  '(add-hook
-    'desktop-buffer-misc-functions
-    #'desktop-buffer-preview-misc-data))
-
 (defvar preview-temp-dirs nil
 "List of top level temporary directories in use from preview.
 Any directory not in this list will be cleared out by preview
@@ -2388,6 +2383,18 @@ BUFFER-MISC is the appropriate data to be used."
                   (preview-buffer-restore-internal
                    buffer-misc))))))
 
+;; Add autoload cookies explicitly for desktop.el.
+;; <Background> preview-latex doesn't conform to the following
+;; assumptions of desktop.el:
+;; (1) The file associated with the major mode by autoload has defun
+;;     of handler, which restores the state of the buffer.
+;; (2) The file has suitable `add-to-list' form also for
+;;     `desktop-buffer-mode-handlers' to register the entry of the
+;;     handler.
+;; This isn't the case here because the file associated with
+;; `latex-mode' is tex-mode.el, neither preview.el nor latex.el.  Thus
+;; we include both of them as explicit autoloads in preview-latex.el.
+;;;###autoload
 (defun desktop-buffer-preview (file-name _buffer-name misc)
   "Hook function for restoring persistent previews into a buffer."
   (when (and file-name (file-readable-p file-name))
@@ -2398,18 +2405,9 @@ BUFFER-MISC is the appropriate data to be used."
             buf)
         buf))))
 
-(eval-after-load "desktop"
-  '(if (boundp 'desktop-buffer-mode-handlers)
-       (add-to-list 'desktop-buffer-mode-handlers
-                    '(latex-mode . desktop-buffer-preview))
-     (defvar desktop-buffer-file-name)
-     (defvar desktop-buffer-name)
-     (defvar desktop-buffer-misc)
-     (add-hook 'desktop-buffer-handlers (lambda ()
-                                          (desktop-buffer-preview
-                                           desktop-buffer-file-name
-                                           desktop-buffer-name
-                                           desktop-buffer-misc)))))
+;;;###autoload
+(add-to-list 'desktop-buffer-mode-handlers
+             '(latex-mode . desktop-buffer-preview))
 
 (defcustom preview-auto-cache-preamble 'ask
   "Whether to generate a preamble cache format automatically.
@@ -3115,9 +3113,7 @@ to add the preview functionality."
         `(menu-item "Preview at point" preview-at-point
                     :image ,preview-tb-icon
                     :help "Preview on/off at point"
-                    :vert-only t)))
-    (if (boundp 'desktop-buffer-misc)
-        (preview-buffer-restore desktop-buffer-misc))))
+                    :vert-only t)))))
 
 (defun preview-clean-subdir (dir)
   "Cleans out a temporary DIR with preview image files."



reply via email to

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