5

I've been having an odd interaction between desktop save and the theme system. I noticed while trying to set up a custom theme that certain elements weren't matching the theme values. Things like the background color or the cursor color were holding onto their previous values.

Finally, I traced it back to my .emacs.desktop file, an excerpt:

;; Global section:
(setq (foreground-color . "#93a1a1") (background-color . "#002b36") 
(mouse-color . "black") (border-color . "black") (screen-gamma) (line-spacing) 
(left-fringe . 10) (right-fringe . 11) (alpha) (menu-bar-lines . 1) 
(tool-bar-lines . 0) (title) (fullscreen) (icon-type) (auto-raise) (auto-lower) 
(cursor-type . box) (scroll-bar-width . 17) (horizontal-scroll-bars . t) 
(display-type . color) (background-mode . dark) (cursor-color . "#fdf6e3")

Is there some way to make it not do that? I like the desktop feature for preserving my open files and window position, but I don't want it to keep all that style information. I've hunted around and tried setting desktop-globals-to-save and other variables but nothing seems to do it.

2
  • If I were to make a guess, I would probably start with looking at desktop-save-frameset, which calls frameset-save. There is no function that I am aware of which adds the parameter desktop-dont-save, but it looks like the doc-string of desktop-save-frameset makes a reference to a test of whether it has a value -- these are cons cells. It is possible to strip certain elements of the list returned by frameset-save -- e.g., if the car of the cons cell is mouse-color.
    – lawlist
    Jan 4 '15 at 17:43
  • I agree with @lawlist, these look like frame parameters. You might like to M-x report--emacs-bug to see what the experts on frameset and desktop.el can do about it.
    – Stefan
    Jan 5 '15 at 1:36
1

This gist worked for me:

desktop-load-theme.el

(desktop-save-mode)
(add-to-list 'desktop-globals-to-save 'custom-enabled-themes)
(defun desktop-load-theme () "load custom theme" (interactive)
  (dolist (th custom-enabled-themes) (load-theme th)))
(add-hook 'desktop-after-read-hook 'desktop-load-theme)

But it doesn't prevent the desktop-save-mode from saving the theme in the .desktop file, instead it restores the theme after loading the desktop. For me its a good joice.

1

Just hit this. You'll need to update frameset-filter-alist with the things that you do not want to save. For example:

(push '(foreground-color . :never) frameset-filter-alist)
(push '(background-color . :never) frameset-filter-alist)
(push '(font . :never) frameset-filter-alist)
(push '(cursor-color . :never) frameset-filter-alist)
(push '(background-mode . :never) frameset-filter-alist)
(push '(ns-appearance . :never) frameset-filter-alist)
(push '(background-mode . :never) frameset-filter-alist)
0

Open .desktop file, the color theme configurations saved in frame fields, this can avoided by set desktop-restore-frames to nil.

For more information, see desktop-restore-frames documentation:

When non-nil, save and restore the frame and window configuration.

Complete configurations:

(custom-set-variables
 '(desktop-save t)
 '(desktop-restore-frames nil)
 '(desktop-path (list "~/.emacs.d/"))
 '(desktop-dirname "~/.emacs.d/"))
(desktop-save-mode 1)
2
  • 2
    This is a bit cryptic. Can you add a sentence or two to explain how to use this to solve the problem? from review
    – fixer1234
    Feb 11 '18 at 9:26
  • 1
    @fixer1234 I add some explain, please take a look
    – tangxinfa
    Mar 1 '18 at 8:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.