* Patch to allow -nw to runemacs on w32
@ 2006-11-15 13:44 Lennart Borgman
2006-11-15 15:22 ` Jason Rumney
2006-11-15 17:41 ` Eli Zaretskii
0 siblings, 2 replies; 16+ messages in thread
From: Lennart Borgman @ 2006-11-15 13:44 UTC (permalink / raw)
[-- Attachment #1: Type: text/plain, Size: 209 bytes --]
In some situations you may want to be able to use the -nw option with
runemacs.exe. All other options to emacs can be given to runemacs, but
-nw currently gives a fatal error. The attached patch fixes this.
[-- Attachment #2: runemacs-allow-nw.patch --]
[-- Type: text/plain, Size: 2876 bytes --]
Index: runemacs.c
===================================================================
RCS file: /cvsroot/emacs/emacs/nt/runemacs.c,v
retrieving revision 1.13
diff -u -r1.13 runemacs.c
--- runemacs.c 29 Oct 2006 22:43:37 -0000 1.13
+++ runemacs.c 15 Nov 2006 13:30:18 -0000
@@ -51,11 +51,12 @@
SECURITY_ATTRIBUTES sec_attrs;
PROCESS_INFORMATION child;
int wait_for_child = FALSE;
- DWORD priority_class = NORMAL_PRIORITY_CLASS;
+ DWORD creation_flags = NORMAL_PRIORITY_CLASS;
DWORD ret_code = 0;
char *new_cmdline;
char *p;
char modname[MAX_PATH];
+ BOOL create_console = FALSE;
if (!GetModuleFileName (NULL, modname, MAX_PATH))
goto error;
@@ -113,12 +114,12 @@
}
else if (strncmp (cmdline+1, "high", 4) == 0)
{
- priority_class = HIGH_PRIORITY_CLASS;
+ creation_flags = HIGH_PRIORITY_CLASS;
cmdline += 5;
}
else if (strncmp (cmdline+1, "low", 3) == 0)
{
- priority_class = IDLE_PRIORITY_CLASS;
+ creation_flags = IDLE_PRIORITY_CLASS;
cmdline += 4;
}
else
@@ -129,6 +130,27 @@
strcat (new_cmdline, cmdline);
+ /* Look for -nw since it requires the console flag */
+ while (cmdline[0] == '-' || cmdline[0] == '/')
+ {
+ if (strncmp (cmdline+1, "nw", 2) == 0)
+ {
+ creation_flags = creation_flags | CREATE_NEW_CONSOLE;
+ create_console = TRUE;
+ cmdline += 5;
+ }
+ else if (strncmp (cmdline+1, "-no-window-system", 17) == 0)
+ {
+ creation_flags = creation_flags | CREATE_NEW_CONSOLE;
+ create_console = TRUE;
+ cmdline += 18;
+ }
+ else
+ break;
+ /* Look for next argument. */
+ while (*++cmdline == ' ');
+ }
+
/* Set emacs_dir variable if runemacs was in "%emacs_dir%\bin". */
if ((p = strrchr (modname, '\\')) && stricmp (p, "\\bin") == 0)
{
@@ -140,18 +162,20 @@
memset (&start, 0, sizeof (start));
start.cb = sizeof (start);
- start.dwFlags = STARTF_USESHOWWINDOW | STARTF_USECOUNTCHARS;
- start.wShowWindow = SW_HIDE;
- /* Ensure that we don't waste memory if the user has specified a huge
- default screen buffer for command windows. */
- start.dwXCountChars = 80;
- start.dwYCountChars = 25;
+ if (!create_console) {
+ start.dwFlags = STARTF_USESHOWWINDOW | STARTF_USECOUNTCHARS;
+ start.wShowWindow = SW_HIDE;
+ /* Ensure that we don't waste memory if the user has specified a huge
+ default screen buffer for command windows. */
+ start.dwXCountChars = 80;
+ start.dwYCountChars = 25;
+ }
sec_attrs.nLength = sizeof (sec_attrs);
sec_attrs.lpSecurityDescriptor = NULL;
sec_attrs.bInheritHandle = FALSE;
- if (CreateProcess (NULL, new_cmdline, &sec_attrs, NULL, TRUE, priority_class,
+ if (CreateProcess (NULL, new_cmdline, &sec_attrs, NULL, TRUE, creation_flags,
NULL, NULL, &start, &child))
{
if (wait_for_child)
[-- 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] 16+ messages in thread
* Re: Patch to allow -nw to runemacs on w32
2006-11-15 13:44 Patch to allow -nw to runemacs on w32 Lennart Borgman
@ 2006-11-15 15:22 ` Jason Rumney
2006-11-15 15:34 ` Lennart Borgman
2006-11-15 17:41 ` Eli Zaretskii
1 sibling, 1 reply; 16+ messages in thread
From: Jason Rumney @ 2006-11-15 15:22 UTC (permalink / raw)
Cc: Emacs Devel
Lennart Borgman wrote:
> In some situations you may want to be able to use the -nw option with
> runemacs.exe. All other options to emacs can be given to runemacs, but
> -nw currently gives a fatal error. The attached patch fixes this.
I don't see any error, OTOH, it launches emacs in a hidden console that
you cannot get at, so isn't much use.
I don't see any reason why someone would want to use runemacs to launch
emacs -nw, since the sole purpose of runemacs is to suppress the console
window when launching emacs from an icon on Windows, so I don't think
this needs fixing urgently. If we are going to fix this though, it would
be better if emacs was run in the same console window rather than
launching another one, as the latter may not be an option if the user is
using telnet/ssh, or a full screen command prompt. Also we need to
handle --no-window-system and the case where no GUI is available as well
as -nw.
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Patch to allow -nw to runemacs on w32
2006-11-15 15:22 ` Jason Rumney
@ 2006-11-15 15:34 ` Lennart Borgman
2006-11-15 15:47 ` Juanma Barranquero
0 siblings, 1 reply; 16+ messages in thread
From: Lennart Borgman @ 2006-11-15 15:34 UTC (permalink / raw)
Cc: Emacs Devel
Jason Rumney wrote:
> Lennart Borgman wrote:
>> In some situations you may want to be able to use the -nw option with
>> runemacs.exe. All other options to emacs can be given to runemacs,
>> but -nw currently gives a fatal error. The attached patch fixes this.
>
> I don't see any error, OTOH, it launches emacs in a hidden console
> that you cannot get at, so isn't much use.
>
> I don't see any reason why someone would want to use runemacs to
> launch emacs -nw, since the sole purpose of runemacs is to suppress
> the console window when launching emacs from an icon on Windows, so I
> don't think this needs fixing urgently. If we are going to fix this
> though, it would be better if emacs was run in the same console window
> rather than launching another one, as the latter may not be an option
> if the user is using telnet/ssh, or a full screen command prompt. Also
> we need to handle --no-window-system and the case where no GUI is
> available as well as -nw.
I get a fatal error, not just a hidden window. I think we should avoid
the fatal error since the cost is low (just this little patch).
It sounds elegant to use the same console window if possible, but can we
get that?
The code already handles --no-window-system.
Does runemacs run at all without a GUI system? Are situations where this
occurs perhaps situations where it seems right to assume that the user
is knowledgeable enough to just use emacs.exe instead?
The reason I looked into this was actually your little program to run
emacsclient or emacs depending on if emacs server was available or not.
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Patch to allow -nw to runemacs on w32
2006-11-15 15:34 ` Lennart Borgman
@ 2006-11-15 15:47 ` Juanma Barranquero
2006-11-15 15:55 ` Juanma Barranquero
2006-11-15 16:12 ` Lennart Borgman
0 siblings, 2 replies; 16+ messages in thread
From: Juanma Barranquero @ 2006-11-15 15:47 UTC (permalink / raw)
Cc: Emacs Devel, Jason Rumney
On 11/15/06, Lennart Borgman <lennart.borgman.073@student.lu.se> wrote:
> I get a fatal error, not just a hidden window.
I get the same result that Jason: no error of any kind, just Emacs runs hidden.
BTW, the same happens with your patch if -nw is not the first
argument, for example:
runemacs -xrm "Emacs.Background:red" -nw
/L/e/k/t/u
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Patch to allow -nw to runemacs on w32
2006-11-15 15:47 ` Juanma Barranquero
@ 2006-11-15 15:55 ` Juanma Barranquero
2006-11-15 16:12 ` Lennart Borgman
1 sibling, 0 replies; 16+ messages in thread
From: Juanma Barranquero @ 2006-11-15 15:55 UTC (permalink / raw)
Cc: Emacs Devel, Jason Rumney
On 11/15/06, Juanma Barranquero <lekktu@gmail.com> wrote:
> BTW, the same happens with your patch if -nw is not the first
> argument, for example:
>
> runemacs -xrm "Emacs.Background:red" -nw
Which, I'd add, it's not easy to fix. You can
strstr (command, "-nw")
for example, but you will never be sure the user isn't doing
runemacs --eval "(setq my-nw 7)"
etc. To be sure that you're getting the right -nw you'd have to do a
more sophisticate command-line parsing (detecting quotes, arguments
with spaces, etc.). I don't think is worth the hassle. But it is your
time.
Though I'm with Jason that it is weird to "runemacs -nw".
/L/e/k/t/u
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Patch to allow -nw to runemacs on w32
2006-11-15 15:47 ` Juanma Barranquero
2006-11-15 15:55 ` Juanma Barranquero
@ 2006-11-15 16:12 ` Lennart Borgman
2006-11-15 16:37 ` Juanma Barranquero
1 sibling, 1 reply; 16+ messages in thread
From: Lennart Borgman @ 2006-11-15 16:12 UTC (permalink / raw)
Cc: Emacs Devel, Jason Rumney
Juanma Barranquero wrote:
> On 11/15/06, Lennart Borgman <lennart.borgman.073@student.lu.se> wrote:
>
>> I get a fatal error, not just a hidden window.
>
> I get the same result that Jason: no error of any kind, just Emacs
> runs hidden.
You are right. I also just get a hidden emacs.exe if I add -Q. Though I
would not say a sometimes hidden, sometimes crashing emacs is very good ;-)
And at a second thought it seems natural that runemacs creates a new
window - even if it is a console window. That is what runemacs is for,
isn't it?
>
> BTW, the same happens with your patch if -nw is not the first
> argument, for example:
>
> runemacs -xrm "Emacs.Background:red" -nw
That is by intent. I handle this argument like the other arguments that
are handled in runemacs. Or, it is much easier doing it that way.
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Patch to allow -nw to runemacs on w32
2006-11-15 16:12 ` Lennart Borgman
@ 2006-11-15 16:37 ` Juanma Barranquero
2006-11-15 18:57 ` Juanma Barranquero
2006-11-15 21:20 ` Lennart Borgman
0 siblings, 2 replies; 16+ messages in thread
From: Juanma Barranquero @ 2006-11-15 16:37 UTC (permalink / raw)
Cc: Emacs Devel, Jason Rumney
On 11/15/06, Lennart Borgman <lennart.borgman.073@student.lu.se> wrote:
> You are right. I also just get a hidden emacs.exe if I add -Q.
Though I
> would not say a sometimes hidden, sometimes crashing emacs is very good ;-)
Hmm, I don't remember saying anything about -Q. runemacs does not
crash for me with -nw; it just runs hidden.
> And at a second thought it seems natural that runemacs creates a new
> window - even if it is a console window. That is what runemacs is for,
> isn't it?
No. Its only purpose is running Emacs *without* a console window. It
says it so in the comment at the very beginning:
Simple program to start Emacs with its console window hidden.
This program is provided purely for convenience, since most users will
use Emacs in windowing (GUI) mode, and will not want to have an extra
console window lying around.
> That is by intent. I handle this argument like the other arguments that
> are handled in runemacs.
The other arguments are not for Emacs. It does not know what to do
with "-high", "-low" or "-wait"; so runemacs processes the argument
and skips it. But -nw is to be understood both by runemacs (if your
patch applies) and Emacs, so processing it only if it's the first is a
no-no (or you'd have to document it).
> Or, it is much easier doing it that way.
Yeah. As H. L. Mencken said: "For every problem, there is a solution
that is simple, neat, and wrong." :)
/L/e/k/t/u
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Patch to allow -nw to runemacs on w32
2006-11-15 13:44 Patch to allow -nw to runemacs on w32 Lennart Borgman
2006-11-15 15:22 ` Jason Rumney
@ 2006-11-15 17:41 ` Eli Zaretskii
2006-11-15 20:05 ` Lennart Borgman
1 sibling, 1 reply; 16+ messages in thread
From: Eli Zaretskii @ 2006-11-15 17:41 UTC (permalink / raw)
Cc: emacs-devel
> Date: Wed, 15 Nov 2006 14:44:25 +0100
> From: Lennart Borgman <lennart.borgman.073@student.lu.se>
>
> In some situations you may want to be able to use the -nw option with
> runemacs.exe.
What are those situations? We cannot judge the importance of applying
this patch without knowing when the current behavior is an annoyance.
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Patch to allow -nw to runemacs on w32
2006-11-15 16:37 ` Juanma Barranquero
@ 2006-11-15 18:57 ` Juanma Barranquero
2006-11-15 21:35 ` Jason Rumney
2006-11-15 21:20 ` Lennart Borgman
1 sibling, 1 reply; 16+ messages in thread
From: Juanma Barranquero @ 2006-11-15 18:57 UTC (permalink / raw)
On 11/15/06, Juanma Barranquero <lekktu@gmail.com> wrote:
> This program is provided purely for convenience, since most users will
> use Emacs in windowing (GUI) mode, and will not want to have an extra
> console window lying around.
Now that I re-read that... Why does not Emacs hide its own console
when started in windowing mode? Why is runemacs.exe needed at all?
Hmm... I guess the answer is: it can, but there's no way to avoid the
"flash" of the console being created and then hidden.
/L/e/k/t/u
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Patch to allow -nw to runemacs on w32
2006-11-15 17:41 ` Eli Zaretskii
@ 2006-11-15 20:05 ` Lennart Borgman
2006-11-15 21:38 ` Jason Rumney
0 siblings, 1 reply; 16+ messages in thread
From: Lennart Borgman @ 2006-11-15 20:05 UTC (permalink / raw)
Cc: emacs-devel
Eli Zaretskii wrote:
>> Date: Wed, 15 Nov 2006 14:44:25 +0100
>> From: Lennart Borgman <lennart.borgman.073@student.lu.se>
>>
>> In some situations you may want to be able to use the -nw option with
>> runemacs.exe.
>>
>
> What are those situations? We cannot judge the importance of applying
> this patch without knowing when the current behavior is an annoyance.
>
The situation where I thought the current behaviour was a problem was
when specifying --alternate-editor to emacsclient. If the user for some
reason (which I might not understand ;-) wants to run emacs in a
console, and this should be started through the use of
--alternate-editor then the simplest way (from a user perspective) to
get this working might be to do something like
set alternate_editor=runemacs.exe -nw
If my patch is applied of course. Otherwise the user just gets into the
trouble we discussed before (hidden emacs or a crashing emacs).
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Patch to allow -nw to runemacs on w32
2006-11-15 16:37 ` Juanma Barranquero
2006-11-15 18:57 ` Juanma Barranquero
@ 2006-11-15 21:20 ` Lennart Borgman
2006-11-15 21:29 ` Juanma Barranquero
1 sibling, 1 reply; 16+ messages in thread
From: Lennart Borgman @ 2006-11-15 21:20 UTC (permalink / raw)
Cc: Emacs Devel, Jason Rumney
Juanma Barranquero wrote:
>> You are right. I also just get a hidden emacs.exe if I add -Q.
> Though I
>> would not say a sometimes hidden, sometimes crashing emacs is very
>> good ;-)
>
> Hmm, I don't remember saying anything about -Q. runemacs does not
> crash for me with -nw; it just runs hidden.
No you did not. I just wanted to say it seems to be something in my
startup files.
>
>> And at a second thought it seems natural that runemacs creates a new
>> window - even if it is a console window. That is what runemacs is for,
>> isn't it?
>
> No. Its only purpose is running Emacs *without* a console window. It
> says it so in the comment at the very beginning:
Oh, I did not read that. But what it does from a user perspective is to
create a new visible window running Emacs. It would not be any big
surprise if it did the same with a console window in my opinion.
> The other arguments are not for Emacs. It does not know what to do
> with "-high", "-low" or "-wait"; so runemacs processes the argument
> and skips it. But -nw is to be understood both by runemacs (if your
> patch applies) and Emacs, so processing it only if it's the first is a
> no-no (or you'd have to document it).
Yes, that is right. But it is quite normal for the options to come
first. See for example grep:
Usage: grep [OPTION]... PATTERN [FILE] ...
I think most users will put the options first even if emacs does not
require it.
> Yeah. As H. L. Mencken said: "For every problem, there is a solution
> that is simple, neat, and wrong." :)
I believe that is a surprisingly simple, net and right solution to
something.
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Patch to allow -nw to runemacs on w32
2006-11-15 21:20 ` Lennart Borgman
@ 2006-11-15 21:29 ` Juanma Barranquero
0 siblings, 0 replies; 16+ messages in thread
From: Juanma Barranquero @ 2006-11-15 21:29 UTC (permalink / raw)
Cc: Emacs Devel, Jason Rumney
On 11/15/06, Lennart Borgman <lennart.borgman.073@student.lu.se> wrote:
> No you did not. I just wanted to say it seems to be something in my
> startup files.
Ah. Either you were less than clear, or I was less than crisp.
> Oh, I did not read that. But what it does from a user perspective is to
> create a new visible window running Emacs.
Untrue. Emacs (without runemacs) *already* creates a visible window in
which it runs. It also creates an empty console window. With runemacs,
this additional windows isn't there. So, from a user's POV, runemacs
hides an annoying window.
> Yes, that is right. But it is quite normal for the options to come
> first. See for example grep:
>
> Usage: grep [OPTION]... PATTERN [FILE] ...
Do you mean that in
emacs --no-site-file -nw
"--no-site-file" is NOT an option?
> I think most users will put the options first even if emacs does not
> require it.
I don't think so. Not unless you document it (and even so).
> I believe that is a surprisingly simple, net and right solution to
> something.
I disagree.
/L/e/k/t/u
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Patch to allow -nw to runemacs on w32
2006-11-15 18:57 ` Juanma Barranquero
@ 2006-11-15 21:35 ` Jason Rumney
0 siblings, 0 replies; 16+ messages in thread
From: Jason Rumney @ 2006-11-15 21:35 UTC (permalink / raw)
Cc: Emacs Devel
Juanma Barranquero wrote:
> Now that I re-read that... Why does not Emacs hide its own console
> when started in windowing mode? Why is runemacs.exe needed at all?
If emacs is started from the command prompt in a console window, then
hiding it is the wrong thing to do.
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Patch to allow -nw to runemacs on w32
2006-11-15 20:05 ` Lennart Borgman
@ 2006-11-15 21:38 ` Jason Rumney
2006-11-15 22:02 ` Lennart Borgman
0 siblings, 1 reply; 16+ messages in thread
From: Jason Rumney @ 2006-11-15 21:38 UTC (permalink / raw)
Cc: Eli Zaretskii, emacs-devel
Lennart Borgman wrote:
> The situation where I thought the current behaviour was a problem was
> when specifying --alternate-editor to emacsclient. If the user for
> some reason (which I might not understand ;-) wants to run emacs in a
> console, and this should be started through the use of
> --alternate-editor then the simplest way (from a user perspective) to
> get this working might be to do something like
>
> set alternate_editor=runemacs.exe -nw
The simplest way is emacs -nw. Why would they use runemacs? If they are
used to running emacs -nw, then they would have learnt quickly that
runemacs is not suitable.
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Patch to allow -nw to runemacs on w32
2006-11-15 21:38 ` Jason Rumney
@ 2006-11-15 22:02 ` Lennart Borgman
2006-11-16 4:40 ` Eli Zaretskii
0 siblings, 1 reply; 16+ messages in thread
From: Lennart Borgman @ 2006-11-15 22:02 UTC (permalink / raw)
Cc: Eli Zaretskii, emacs-devel
Jason Rumney wrote:
> Lennart Borgman wrote:
>> The situation where I thought the current behaviour was a problem was
>> when specifying --alternate-editor to emacsclient. If the user for
>> some reason (which I might not understand ;-) wants to run emacs in a
>> console, and this should be started through the use of
>> --alternate-editor then the simplest way (from a user perspective) to
>> get this working might be to do something like
>>
>> set alternate_editor=runemacs.exe -nw
>
> The simplest way is emacs -nw. Why would they use runemacs? If they
> are used to running emacs -nw, then they would have learnt quickly
> that runemacs is not suitable.
I do not think "emacs -nw" will work in all situations. I believe there
should be a GUI version of emacsclient.exe. Does "emacs -nw" work if you
use the GUI version?
Note: I added a GUI version to gnuclient.exe which I called
gnuclientw.exe. The purpose of this was to avoid unnecessary console
windows.
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Patch to allow -nw to runemacs on w32
2006-11-15 22:02 ` Lennart Borgman
@ 2006-11-16 4:40 ` Eli Zaretskii
0 siblings, 0 replies; 16+ messages in thread
From: Eli Zaretskii @ 2006-11-16 4:40 UTC (permalink / raw)
Cc: emacs-devel, jasonr
> Date: Wed, 15 Nov 2006 23:02:33 +0100
> From: Lennart Borgman <lennart.borgman.073@student.lu.se>
> CC: Eli Zaretskii <eliz@gnu.org>, emacs-devel@gnu.org
>
> > The simplest way is emacs -nw. Why would they use runemacs? If they
> > are used to running emacs -nw, then they would have learnt quickly
> > that runemacs is not suitable.
>
> I do not think "emacs -nw" will work in all situations.
When will it not work?
^ permalink raw reply [flat|nested] 16+ messages in thread
end of thread, other threads:[~2006-11-16 4:40 UTC | newest]
Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-11-15 13:44 Patch to allow -nw to runemacs on w32 Lennart Borgman
2006-11-15 15:22 ` Jason Rumney
2006-11-15 15:34 ` Lennart Borgman
2006-11-15 15:47 ` Juanma Barranquero
2006-11-15 15:55 ` Juanma Barranquero
2006-11-15 16:12 ` Lennart Borgman
2006-11-15 16:37 ` Juanma Barranquero
2006-11-15 18:57 ` Juanma Barranquero
2006-11-15 21:35 ` Jason Rumney
2006-11-15 21:20 ` Lennart Borgman
2006-11-15 21:29 ` Juanma Barranquero
2006-11-15 17:41 ` Eli Zaretskii
2006-11-15 20:05 ` Lennart Borgman
2006-11-15 21:38 ` Jason Rumney
2006-11-15 22:02 ` Lennart Borgman
2006-11-16 4:40 ` 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.