From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: --no-desktop broken? Date: Mon, 23 Jan 2006 07:00:49 +0200 Message-ID: References: <1137804521.206430.18968.nullmailer@Update.UU.SE> <43D2012A.8050406@soem.dk> <2E5FEB1A-6442-41BC-BDEC-60A1B45C13E6@raeburn.org> <43D36D66.9010108@soem.dk> <87mzhnfykz.fsf@jurta.org> Reply-To: Eli Zaretskii NNTP-Posting-Host: main.gmane.org X-Trace: sea.gmane.org 1137992518 17441 80.91.229.2 (23 Jan 2006 05:01:58 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 23 Jan 2006 05:01:58 +0000 (UTC) Cc: larsh@soem.dk, ams@gnu.org, raeburn@raeburn.org, emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Jan 23 06:01:55 2006 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1F0tpy-00051G-Uy for ged-emacs-devel@m.gmane.org; Mon, 23 Jan 2006 06:01:55 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1F0tsb-0004Fe-2a for ged-emacs-devel@m.gmane.org; Mon, 23 Jan 2006 00:04:37 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1F0trs-0003gz-Pw for emacs-devel@gnu.org; Mon, 23 Jan 2006 00:03:52 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1F0tro-0003Uu-UY for emacs-devel@gnu.org; Mon, 23 Jan 2006 00:03:51 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1F0trn-0003SZ-1X for emacs-devel@gnu.org; Mon, 23 Jan 2006 00:03:48 -0500 Original-Received: from [192.114.186.17] (helo=gandalf.inter.net.il) by monty-python.gnu.org with esmtp (Exim 4.34) id 1F0twR-0004w9-QK; Mon, 23 Jan 2006 00:08:36 -0500 Original-Received: from nitzan.inter.net.il (nitzan.inter.net.il [192.114.186.20]) by gandalf.inter.net.il (MOS 3.7.1-GA) with ESMTP id HQS23924; Mon, 23 Jan 2006 07:00:54 +0200 (IST) Original-Received: from HOME-C4E4A596F7 (IGLD-84-228-162-108.inter.net.il [84.228.162.108]) by nitzan.inter.net.il (MOS 3.7.3-GA) with ESMTP id CNL81008 (AUTH halo1); Mon, 23 Jan 2006 07:00:50 +0200 (IST) Original-To: Juri Linkov In-reply-to: <87mzhnfykz.fsf@jurta.org> (message from Juri Linkov on Mon, 23 Jan 2006 03:51:16 +0200) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:49435 Archived-At: > From: Juri Linkov > Date: Mon, 23 Jan 2006 03:51:16 +0200 > Cc: ams@gnu.org, raeburn@raeburn.org, emacs-devel@gnu.org > > 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.