Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use starter kit with desktop.el and other init-dependant functions? #65

Open
lrcg opened this issue Nov 7, 2014 · 1 comment

Comments

@lrcg
Copy link

lrcg commented Nov 7, 2014

First, thank you for making a literate version of starter kit (and Org Babel for that matter). It's been a tremendous learning experience and the structure and literate format makes it much easier to understand what is going on and what I was thinking when I made decisions.

Now, the part that leaves me scratching my head for the past few days is this: is there any way to avoid using emacs's Customize facility and custom.el? The only thing missing from this setup is literate documentation of variables set through M-x customize-*, so I've tried to move as many of them as possible into <username>.org. But some built-in functions seem to rely on variables being set before after-init-hook is called whereas starter kit kicks into action after all packages are loaded.

I submit the following as an example. I'd like to document (desktop-save-mode 1) in <username>.org. I've tried all sorts of tricks to set it and then call (desktop-read), but I always start getting random errors such as:

File mode specification error: (error "Don't know how to make a localized variable an alias")

It seems that desktop.el is designed not to work the way I would like it to as can be seen in the last few lines of the file:

;; ----------------------------------------------------------------------------
;; When `desktop-save-mode' is non-nil and "--no-desktop" is not specified on the
;; command line, we do the rest of what it takes to use desktop, but do it
;; after finishing loading the init file.
;; We cannot use `command-switch-alist' to process "--no-desktop" because these
;; functions are processed after `after-init-hook'.
(add-hook
  'after-init-hook
  (lambda ()
    (let ((key "--no-desktop"))
      (when (member key command-line-args)
        (setq command-line-args (delete key command-line-args))
        (setq desktop-save-mode nil)))
    (when desktop-save-mode
      (desktop-read)
      (setq inhibit-startup-screen t))))

So is there any way of setting desktop.el to load the saved desktop on startup without essentially rewriting that code into <username>.el? And beyond that specific example, is there a particular pattern or technique that would make it possible to document all settings from /Customize/?

I guess a line could be added to init.el which would look for something like starter-kit-init.org and execute that code as part of init.el, but I didn't want to go down that path unless there is no other / better way.

@eschulte
Copy link
Owner

I've occasionally added lines directly to init.el when I need something loaded before the after-init-hook or before the full starter kit. Perhaps adding a couple of lines to init.el to load a starter-kit-init.org or starter-kit-preload.org or somesuch if it exists would be generally useful...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants