emacs-devel
[Top][All Lists]
Advanced

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

Re: --no-desktop broken?


From: Eli Zaretskii
Subject: Re: --no-desktop broken?
Date: Mon, 23 Jan 2006 07:00:49 +0200

> From: Juri Linkov <address@hidden>
> Date: Mon, 23 Jan 2006 03:51:16 +0200
> Cc: address@hidden, address@hidden, address@hidden
> 
> There is already such table approach implemented in Emacs long ago,
> and I think desktop.el should use it instead of handling --no-desktop
> in startup.el.

??? Did you look at what desktop.el does with --no-desktop?  It has
this code:

  ;; 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))))

> There is a special variable `command-switch-alist' which is intended
> exactly for this case

The above comment explains why this is not a good idea.

> ;;;###autoload
> (add-hook 'command-switch-alist
>           '("--no-desktop" . (lambda (argi) (load "desktop"))))
> 
> However, loading desktop.el is not a good solution.  Perhaps better would be:
> 
> ;;;###autoload
> (add-hook 'command-switch-alist
>           '("--no-desktop" .
>             (lambda (argi)
>              (message "\"--no-desktop\" ignored because the Desktop package 
> is not loaded"))))
> 
> Still not ideal.  Another solution is to add an autoload cookie before
> `add-hook' adding a lambda to `after-init-hook' in desktop.el:
> 
> ;;;###autoload
> (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))))
> 
> This would work as well.  Or maybe the lambda from `after-init-hook'
> should be duplicated in command-switch-alist?

All of these solutions will load desktop.el (and what's worse, load it
unconditionally, I think), which I think is not a good design.  What
startup.el does now is simply ignore the "--no-desktop" switch (we
could remove the informative message if people think it's too
annoying).  But it avoids loading desktop.el, which I think is the
right way of handling such cases.




reply via email to

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