* --no-desktop broken? @ 2006-01-21 0:48 Alfred M. Szmidt 2006-01-21 9:35 ` Eli Zaretskii 2006-01-21 9:38 ` Lars Hansen 0 siblings, 2 replies; 14+ messages in thread From: Alfred M. Szmidt @ 2006-01-21 0:48 UTC (permalink / raw) According to --help, --no-desktop should be a valid option to emacs. But when one does, `emacs --no-desktop', it errors out and complains that it is a unknown option. Happy hacking (sorry for not supplying a patch). ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: --no-desktop broken? 2006-01-21 0:48 --no-desktop broken? Alfred M. Szmidt @ 2006-01-21 9:35 ` Eli Zaretskii 2006-01-21 9:38 ` Lars Hansen 1 sibling, 0 replies; 14+ messages in thread From: Eli Zaretskii @ 2006-01-21 9:35 UTC (permalink / raw) Cc: emacs-devel > From: "Alfred M\. Szmidt" <ams@gnu.org> > Date: Sat, 21 Jan 2006 01:48:41 +0100 > > According to --help, --no-desktop should be a valid option to emacs. > But when one does, `emacs --no-desktop', it errors out and complains > that it is a unknown option. Thanks for reporting this. It turns out that --no-desktop would only be processed if desktop.el was loaded in ~/.emacs or in some other init file. I fixed this for the case, like yours, when desktop.el was not loaded. Please see that the error is gone now. ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: --no-desktop broken? 2006-01-21 0:48 --no-desktop broken? Alfred M. Szmidt 2006-01-21 9:35 ` Eli Zaretskii @ 2006-01-21 9:38 ` Lars Hansen 2006-01-21 23:53 ` Ken Raeburn 1 sibling, 1 reply; 14+ messages in thread From: Lars Hansen @ 2006-01-21 9:38 UTC (permalink / raw) Cc: emacs-devel Alfred M. Szmidt wrote: >According to --help, --no-desktop should be a valid option to emacs. >But when one does, `emacs --no-desktop', it errors out and complains >that it is a unknown option. > > The --no-desktop option is handled in desktop.el, so if desktop.el is not loaded, the option is unknown. If you put (desktop-save-mode 1) in your .emacs, you get no error. I agree that it is confusing that --no-desktop is documented in --help but seems to not work. Maybe --help should not list options that are not loaded by default. Is there some standard or policy here? ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: --no-desktop broken? 2006-01-21 9:38 ` Lars Hansen @ 2006-01-21 23:53 ` Ken Raeburn 2006-01-22 11:32 ` Lars Hansen 0 siblings, 1 reply; 14+ messages in thread From: Ken Raeburn @ 2006-01-21 23:53 UTC (permalink / raw) Cc: ams, emacs-devel On Jan 21, 2006, at 04:38, Lars Hansen wrote: > I agree that it is confusing that --no-desktop is documented in --help > but seems to not work. Maybe --help should not list options that > are not > loaded by default. In the long term (i.e., maybe too much to change right now), perhaps we could have arbitrary command-line options handled via Lisp code, with a table or something indicating the file to be loaded or function to be invoked to process the option, and some mechanism akin to loaddefs.el for collecting the options and their help messages from various Lisp files and making them available to be printed out if --help is given. Aside from actually invoking some Lisp code when --help is given, I think this could mostly be done in new Lisp code. One approach, off the top of my head, might be to designate symbols named "command-line-arg:foo" as handlers for command-line argument "-- foo", "--foo=...", and "--no-foo" (pass the function t, "...", or nil respectively); then the existing loaddefs would have all the info we need to make the list of options. If the startup code didn't recognize an option but the corresponding symbol was defined with a function value, that function object would be invoked, and would perhaps have the ability to gobble up additional arguments that might be needed for the option. Some new Lisp function invoked via --help would walk the obarray atoms looking for such name patterns, make sure the autoloads were performed, and then look for 'command-line- arg-help-string in the property list of each symbol. It could even load the user's .emacs after displaying the standard Emacs packages' options, and see if changes to the load path or autoloads provided any additional options, and display them as well. That wouldn't handle pattern-based argument process, though, like turning "--disable-rmail" into "(put 'rmail 'disabled t)" or short "- x" style names, or other random things people might want to do, but it's a starting point. Just a thought... maybe this is too much effort to put into the Emacs command line... :-) Ken ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: --no-desktop broken? 2006-01-21 23:53 ` Ken Raeburn @ 2006-01-22 11:32 ` Lars Hansen 2006-01-23 1:51 ` Juri Linkov 0 siblings, 1 reply; 14+ messages in thread From: Lars Hansen @ 2006-01-22 11:32 UTC (permalink / raw) Cc: ams, emacs-devel Ken Raeburn wrote: > In the long term (i.e., maybe too much to change right now), perhaps > we could have arbitrary command-line options handled via Lisp code, > with a table or something indicating the file to be loaded or > function to be invoked to process the option, and some mechanism akin > to loaddefs.el for collecting the options and their help messages > from various Lisp files and making them available to be printed out > if --help is given. Aside from actually invoking some Lisp code when > --help is given, I think this could mostly be done in new Lisp code. I agree that some kind of table approach may be considered at some later time. But not now ;-) ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: --no-desktop broken? 2006-01-22 11:32 ` Lars Hansen @ 2006-01-23 1:51 ` Juri Linkov 2006-01-23 5:00 ` Eli Zaretskii 0 siblings, 1 reply; 14+ messages in thread From: Juri Linkov @ 2006-01-23 1:51 UTC (permalink / raw) Cc: ams, raeburn, emacs-devel >> In the long term (i.e., maybe too much to change right now), perhaps >> we could have arbitrary command-line options handled via Lisp code, >> with a table or something indicating the file to be loaded or >> function to be invoked to process the option, and some mechanism akin >> to loaddefs.el for collecting the options and their help messages >> from various Lisp files and making them available to be printed out >> if --help is given. Aside from actually invoking some Lisp code when >> --help is given, I think this could mostly be done in new Lisp code. > > I agree that some kind of table approach may be considered at some later > time. But not now ;-) 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. There is a special variable `command-switch-alist' which is intended exactly for this case, i.e. you could add to desktop.el: ;;;###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? -- Juri Linkov http://www.jurta.org/emacs/ ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: --no-desktop broken? 2006-01-23 1:51 ` Juri Linkov @ 2006-01-23 5:00 ` Eli Zaretskii 2006-01-23 6:18 ` Juri Linkov 0 siblings, 1 reply; 14+ messages in thread From: Eli Zaretskii @ 2006-01-23 5:00 UTC (permalink / raw) Cc: larsh, ams, raeburn, emacs-devel > From: Juri Linkov <juri@jurta.org> > 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. ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: --no-desktop broken? 2006-01-23 5:00 ` Eli Zaretskii @ 2006-01-23 6:18 ` Juri Linkov 2006-01-23 8:24 ` Lars Hansen 2006-01-23 23:00 ` Eli Zaretskii 0 siblings, 2 replies; 14+ messages in thread From: Juri Linkov @ 2006-01-23 6:18 UTC (permalink / raw) Cc: larsh, ams, raeburn, emacs-devel > ;; We cannot use `command-switch-alist' to process "--no-desktop" because these > ;; functions are processed after `after-init-hook'. > > The above comment explains why this is not a good idea. Yes, I'm already aware of this comment. That's why I haven't proposed to use `command-switch-alist' directly to process "--no-desktop". > 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. Only the first solution loads desktop.el, and I agree that it is not a good solution. The remaining two solutions don't load desktop.el. They use the autoload cookie. This means that at the time startup.el starts processing command switches, it already has "--no-desktop" in `command-switch-alist' without loading desktop.el. The effect is exactly the same as adding "--no-desktop" to the local variable `longopts' in `command-line-1'. I think not using package-specific switches in startup.el gives better modularity. -- Juri Linkov http://www.jurta.org/emacs/ ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: --no-desktop broken? 2006-01-23 6:18 ` Juri Linkov @ 2006-01-23 8:24 ` Lars Hansen 2006-01-23 22:54 ` Eli Zaretskii 2006-01-23 23:00 ` Eli Zaretskii 1 sibling, 1 reply; 14+ messages in thread From: Lars Hansen @ 2006-01-23 8:24 UTC (permalink / raw) Cc: Eli Zaretskii, raeburn, ams, emacs-devel [-- Attachment #1: Type: text/plain, Size: 782 bytes --] >Only the first solution loads desktop.el, and I agree that it is not >a good solution. The remaining two solutions don't load desktop.el. >They use the autoload cookie. This means that at the time startup.el >starts processing command switches, it already has "--no-desktop" >in `command-switch-alist' without loading desktop.el. The effect is >exactly the same as adding "--no-desktop" to the local variable >`longopts' in `command-line-1'. I think not using package-specific >switches in startup.el gives better modularity. > I like your last solution. It works right and has better modularity. Also I think the '"--no-desktop" ignored' message is more confusing than helpful. So I suggest the attached patch. If there are no objections, I will install in a couple of days. [-- Attachment #2: patch.diff --] [-- Type: text/x-patch, Size: 2072 bytes --] *** /home/lh/cvsroot/emacs/lisp/desktop.el.~1.97.~ 2006-01-23 08:13:25.000000000 +0100 --- /home/lh/cvsroot/emacs/lisp/desktop.el 2006-01-23 08:28:12.766853621 +0100 *************** *** 1156,1161 **** --- 1156,1162 ---- ;; 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'. + ;;;###autoload (add-hook 'after-init-hook '(lambda () *** /home/lh/cvsroot/emacs/lisp/startup.el.orig 2006-01-23 08:13:25.714942861 +0100 --- /home/lh/cvsroot/emacs/lisp/startup.el 2006-01-23 08:23:20.391560955 +0100 *************** *** 1632,1638 **** (longopts (append '(("--funcall") ("--load") ("--insert") ("--kill") ("--directory") ("--eval") ("--execute") ("--no-splash") ! ("--find-file") ("--visit") ("--file") ("--no-desktop")) (mapcar (lambda (elt) (list (concat "-" (car elt)))) command-switch-alist))) --- 1632,1638 ---- (longopts (append '(("--funcall") ("--load") ("--insert") ("--kill") ("--directory") ("--eval") ("--execute") ("--no-splash") ! ("--find-file") ("--visit") ("--file")) (mapcar (lambda (elt) (list (concat "-" (car elt)))) command-switch-alist))) *************** *** 1732,1744 **** ((equal argi "-kill") (kill-emacs t)) - ;; This is for when they use --no-desktop with -q, or - ;; don't load Desktop in their .emacs. If desktop.el - ;; _is_ loaded, it will handle this switch, and we - ;; won't see it by the time we get here. - ((equal argi "-no-desktop") - (message "\"--no-desktop\" ignored because the Desktop package is not loaded")) - ((string-match "^\\+[0-9]+\\'" argi) (setq line (string-to-number argi))) --- 1732,1737 ---- [-- Attachment #3: Type: text/plain, Size: 142 bytes --] _______________________________________________ Emacs-devel mailing list Emacs-devel@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-devel ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: --no-desktop broken? 2006-01-23 8:24 ` Lars Hansen @ 2006-01-23 22:54 ` Eli Zaretskii 2006-01-23 23:43 ` Lars Hansen 0 siblings, 1 reply; 14+ messages in thread From: Eli Zaretskii @ 2006-01-23 22:54 UTC (permalink / raw) Cc: juri, ams, raeburn, emacs-devel > Date: Mon, 23 Jan 2006 09:24:08 +0100 > From: Lars Hansen <larsh@soem.dk> > CC: Eli Zaretskii <eliz@gnu.org>, ams@gnu.org, raeburn@raeburn.org, > emacs-devel@gnu.org > > Also I think the '"--no-desktop" ignored' message is more confusing than > helpful. You are entitled to your opinion, but before you take the message out, let me first explain why I put it there: it's because if a user says, e.g., "emacs -q --no-desktop", she doesn't really understand what "--no-desktop" does. So I thought it would be good to point out that the option is not supposed to do anything in that situation. If we silently ignore the option, the user might become bewildered as to why Emacs didn't do whatever she thought it should do in this case. ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: --no-desktop broken? 2006-01-23 22:54 ` Eli Zaretskii @ 2006-01-23 23:43 ` Lars Hansen 2006-01-24 4:24 ` Eli Zaretskii 0 siblings, 1 reply; 14+ messages in thread From: Lars Hansen @ 2006-01-23 23:43 UTC (permalink / raw) Cc: juri, ams, raeburn, emacs-devel >If we >silently ignore the option, the user might become bewildered as to why >Emacs didn't do whatever she thought it should do in this case. > > Well, I beleive that the message might make the user think that there was some kind of problem; that Emacs was not abel to do what the --no-desktop is supposed to do. And that's not the case. But maybe it is a matter of taste. ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: --no-desktop broken? 2006-01-23 23:43 ` Lars Hansen @ 2006-01-24 4:24 ` Eli Zaretskii 2006-01-24 15:02 ` Lars Hansen 0 siblings, 1 reply; 14+ messages in thread From: Eli Zaretskii @ 2006-01-24 4:24 UTC (permalink / raw) Cc: juri, ams, raeburn, emacs-devel > Date: Tue, 24 Jan 2006 00:43:41 +0100 > From: Lars Hansen <larsh@soem.dk> > CC: juri@jurta.org, ams@gnu.org, raeburn@raeburn.org, > emacs-devel@gnu.org > > Well, I beleive that the message might make the user think that there > was some kind of problem There _was_ a problem: the user typed --no-desktop in a situation where it makes no sense. ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: --no-desktop broken? 2006-01-24 4:24 ` Eli Zaretskii @ 2006-01-24 15:02 ` Lars Hansen 0 siblings, 0 replies; 14+ messages in thread From: Lars Hansen @ 2006-01-24 15:02 UTC (permalink / raw) Cc: juri, ams, raeburn, emacs-devel >There _was_ a problem: the user typed --no-desktop in a situation >where it makes no sense. > > I don't see it as a problem to turn something off that was already turned off. But if we give a message in such cases, we should be consistent and also give a message when desktop _is_ loaded but desktop-save-mode is turned off. ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: --no-desktop broken? 2006-01-23 6:18 ` Juri Linkov 2006-01-23 8:24 ` Lars Hansen @ 2006-01-23 23:00 ` Eli Zaretskii 1 sibling, 0 replies; 14+ messages in thread From: Eli Zaretskii @ 2006-01-23 23:00 UTC (permalink / raw) Cc: larsh, ams, raeburn, emacs-devel > From: Juri Linkov <juri@jurta.org> > Date: Mon, 23 Jan 2006 08:18:31 +0200 > Cc: larsh@soem.dk, ams@gnu.org, raeburn@raeburn.org, emacs-devel@gnu.org > > Only the first solution loads desktop.el, and I agree that it is not > a good solution. The remaining two solutions don't load desktop.el. > They use the autoload cookie. Are you sure? I didn't have time to try your proposal, but the hook it uses references 2 desktop.el symbols which are both autoloaded from desktop.el. Even if today it won't load desktop.el at startup, some future change in that hook might cause it to be loaded, especially if we don't even say in a comment there that the hook is supposed to ignore "--no-desktop" without loading the package. ^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2006-01-24 15:02 UTC | newest] Thread overview: 14+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2006-01-21 0:48 --no-desktop broken? Alfred M. Szmidt 2006-01-21 9:35 ` Eli Zaretskii 2006-01-21 9:38 ` Lars Hansen 2006-01-21 23:53 ` Ken Raeburn 2006-01-22 11:32 ` Lars Hansen 2006-01-23 1:51 ` Juri Linkov 2006-01-23 5:00 ` Eli Zaretskii 2006-01-23 6:18 ` Juri Linkov 2006-01-23 8:24 ` Lars Hansen 2006-01-23 22:54 ` Eli Zaretskii 2006-01-23 23:43 ` Lars Hansen 2006-01-24 4:24 ` Eli Zaretskii 2006-01-24 15:02 ` Lars Hansen 2006-01-23 23:00 ` Eli Zaretskii
Code repositories for project(s) associated with this external index https://git.savannah.gnu.org/cgit/emacs.git https://git.savannah.gnu.org/cgit/emacs/org-mode.git This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.