unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* How to set Emacs as default app on Windows (10)
@ 2022-05-22  1:08 Angelo Graziosi
  2022-05-22  5:52 ` Eli Zaretskii
  0 siblings, 1 reply; 8+ messages in thread
From: Angelo Graziosi @ 2022-05-22  1:08 UTC (permalink / raw)
  To: emacs-devel@gnu.org

Usually I start Emacs with a link in the task bar which has as target:

C:\Users\utente>C:\Windows\System32\cmd.exe /c "SET path=C:\msys64\mingw64\bin;%path%&& SET PRELOAD_WINSOCK=1&& START /D ^"C:\Apps\Emacs\bin^" runemacs.exe"

So trying to open a .tex file from explorer, when it asks with which application I want to open that file, I browsed until the bin folder of Emacs and chose emacs.exe. But in this way, if I had stated Emacs from the above link, it opens another frame (and loses also a bit of graphics) and the result is not very good...

Reading https://www.emacswiki.org/emacs/EmacsMsWindowsIntegration I tried this

From a DOS box I started the Emacs client adapting the above target:

C:\Users\utente>C:\Windows\System32\cmd.exe /c "SET path=C:\msys64\mingw64\bin;%path%&& SET PRELOAD_WINSOCK=1&& START /D ^"C:\Apps\Emacs\bin^" emacsclientw.exe -c -n -a C:\Apps\Emacs\bin\runemacs.exe"

and from a DOS box started as administrator, I did

ftype CodeFile=emacsclientw -na runemacs "%1"

assoc .tex=CodeFile

then tried to open the .tex file from explorer. But the result is as above, with another frame and losing graphics.

So, how one can set Emacs as default app on Windows 10? (the next step would be Gnu/Linux and macOS...)

It should open the new file in a new tab in Emacs (already running with the tab-line enabled) as many apps do (consider a browser with a few tabs opened and double clicking in explorer on a .html file..)


Ciao,
 Angelo.



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: How to set Emacs as default app on Windows (10)
  2022-05-22  1:08 How to set Emacs as default app on Windows (10) Angelo Graziosi
@ 2022-05-22  5:52 ` Eli Zaretskii
  2022-05-22  8:53   ` Angelo Graziosi
  0 siblings, 1 reply; 8+ messages in thread
From: Eli Zaretskii @ 2022-05-22  5:52 UTC (permalink / raw)
  To: Angelo Graziosi; +Cc: emacs-devel

> Date: Sun, 22 May 2022 03:08:43 +0200 (CEST)
> From: Angelo Graziosi <angelo.g0@libero.it>
> 
> Usually I start Emacs with a link in the task bar which has as target:
> 
> C:\Users\utente>C:\Windows\System32\cmd.exe /c "SET path=C:\msys64\mingw64\bin;%path%&& SET PRELOAD_WINSOCK=1&& START /D ^"C:\Apps\Emacs\bin^" runemacs.exe"
> 
> So trying to open a .tex file from explorer, when it asks with which application I want to open that file, I browsed until the bin folder of Emacs and chose emacs.exe. But in this way, if I had stated Emacs from the above link, it opens another frame (and loses also a bit of graphics) and the result is not very good...
> 
> Reading https://www.emacswiki.org/emacs/EmacsMsWindowsIntegration I tried this
> 
> >From a DOS box I started the Emacs client adapting the above target:
> 
> C:\Users\utente>C:\Windows\System32\cmd.exe /c "SET path=C:\msys64\mingw64\bin;%path%&& SET PRELOAD_WINSOCK=1&& START /D ^"C:\Apps\Emacs\bin^" emacsclientw.exe -c -n -a C:\Apps\Emacs\bin\runemacs.exe"

I don't understand why you needed to change that target.  What was it
supposed to achieve, and how is that related to the issue at hand,
which is setting up the default application to open *.tex files?

> and from a DOS box started as administrator, I did
> 
> ftype CodeFile=emacsclientw -na runemacs "%1"
> 
> assoc .tex=CodeFile
> 
> then tried to open the .tex file from explorer. But the result is as above, with another frame and losing graphics.

"Another frame" or "another instance of Emacs"?  How many Emacs
processes do you have running after you click on a .tex file in the
Explorer?

> It should open the new file in a new tab in Emacs (already running with the tab-line enabled) as many apps do (consider a browser with a few tabs opened and double clicking in explorer on a .html file..)

The tab bar conceptually holds window configurations, not buffers or
individual windows.  AFAICT, server.el and emacsclient currently don't
have an option to visit files in a new tab, they can only visit it
either in an existing frame (the default) or in a new frame, if
invoked with the -c command-line option.



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: How to set Emacs as default app on Windows (10)
  2022-05-22  5:52 ` Eli Zaretskii
@ 2022-05-22  8:53   ` Angelo Graziosi
  2022-05-22  9:04     ` Eli Zaretskii
  0 siblings, 1 reply; 8+ messages in thread
From: Angelo Graziosi @ 2022-05-22  8:53 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 2654 bytes --]

> Il 22/05/2022 07:52 Eli Zaretskii ha scritto:
> 
>  
> > Date: Sun, 22 May 2022 03:08:43 +0200 (CEST)
> > From: Angelo Graziosi
> > 
> > Usually I start Emacs with a link in the task bar which has as target:
> > 
> > C:\Users\utente>C:\Windows\System32\cmd.exe /c "SET path=C:\msys64\mingw64\bin;%path%&& SET PRELOAD_WINSOCK=1&& START /D ^"C:\Apps\Emacs\bin^" runemacs.exe"
> > 
> > So trying to open a .tex file from explorer, when it asks with which application I want to open that file, I browsed until the bin folder of Emacs and chose emacs.exe. But in this way, if I had stated Emacs from the above link, it opens another frame (and loses also a bit of graphics) and the result is not very good...
> > 
> > Reading https://www.emacswiki.org/emacs/EmacsMsWindowsIntegration I tried this
> > 
> > >From a DOS box I started the Emacs client adapting the above target:
> > 
> > C:\Users\utente>C:\Windows\System32\cmd.exe /c "SET path=C:\msys64\mingw64\bin;%path%&& SET PRELOAD_WINSOCK=1&& START /D ^"C:\Apps\Emacs\bin^" emacsclientw.exe -c -n -a C:\Apps\Emacs\bin\runemacs.exe"
> 
> I don't understand why you needed to change that target.  What was it
> supposed to achieve, and how is that related to the issue at hand,
> which is setting up the default application to open *.tex files?

The link above seems to suggest to use emacsclientw which uses runemacs instead to use directly runemacs..


> 
> > and from a DOS box started as administrator, I did
> > 
> > ftype CodeFile=emacsclientw -na runemacs "%1"
> > 
> > assoc .tex=CodeFile
> > 
> > then tried to open the .tex file from explorer. But the result is as above, with another frame and losing graphics.
> 
> "Another frame" or "another instance of Emacs"?  How many Emacs
> processes do you have running after you click on a .tex file in the
> Explorer?

I would say: another frame and two processes (from task manager). See the screenshot 
> 
> > It should open the new file in a new tab in Emacs (already running with the tab-line enabled) as many apps do (consider a browser with a few tabs opened and double clicking in explorer on a .html file..)
> 
> The tab bar conceptually holds window configurations, not buffers or
> individual windows.  AFAICT, server.el and emacsclient currently don't
> have an option to visit files in a new tab, they can only visit it
> either in an existing frame (the default) or in a new frame, if
> invoked with the -c command-line option.

OK, I rephrase the question: How to set Emacs as default app to open .tex, .text, .c. .f90 etc. files similarly to a browser (if Emacs uses tabs...)?

If it is not implemented you should add it in ToDo list..

[-- Attachment #2: emacs-screenshot.png --]
[-- Type: image/png, Size: 63678 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: How to set Emacs as default app on Windows (10)
  2022-05-22  8:53   ` Angelo Graziosi
@ 2022-05-22  9:04     ` Eli Zaretskii
  2022-05-22  9:54       ` Angelo Graziosi
  0 siblings, 1 reply; 8+ messages in thread
From: Eli Zaretskii @ 2022-05-22  9:04 UTC (permalink / raw)
  To: Angelo Graziosi; +Cc: emacs-devel

> Date: Sun, 22 May 2022 10:53:42 +0200 (CEST)
> From: Angelo Graziosi <angelo.g0@libero.it>
> Cc: emacs-devel@gnu.org
> 
> > > >From a DOS box I started the Emacs client adapting the above target:
> > > 
> > > C:\Users\utente>C:\Windows\System32\cmd.exe /c "SET path=C:\msys64\mingw64\bin;%path%&& SET PRELOAD_WINSOCK=1&& START /D ^"C:\Apps\Emacs\bin^" emacsclientw.exe -c -n -a C:\Apps\Emacs\bin\runemacs.exe"
> > 
> > I don't understand why you needed to change that target.  What was it
> > supposed to achieve, and how is that related to the issue at hand,
> > which is setting up the default application to open *.tex files?
> 
> The link above seems to suggest to use emacsclientw which uses runemacs instead to use directly runemacs..

That suggestion doesn't make sense to me, and I think it is unrelated
to your issue and the original question.

> > "Another frame" or "another instance of Emacs"?  How many Emacs
> > processes do you have running after you click on a .tex file in the
> > Explorer?
> 
> I would say: another frame and two processes (from task manager). See the screenshot 

Thanks, but the screenshot doesn't say definitively that there are 2
Emacs processes, it only hints on that (via the warning it shows in
one of the frames).  The definitive answer is to see how many Emacs
processes are shown in Task Manager.

I suspect that what you have is a separate Emacs process, and the
reason for that is that the Emacs session that was already up and
running didn't start the server (via "M-x server-start" or an
equivalent in your init file).

IOW, I think the issue you are having has nothing to do with the
shortcut, it is due to how you customize your Emacs sessions: you
should make sure the server is started there, or else it will be
unable to receive client connections from emacsclient.

> > The tab bar conceptually holds window configurations, not buffers or
> > individual windows.  AFAICT, server.el and emacsclient currently don't
> > have an option to visit files in a new tab, they can only visit it
> > either in an existing frame (the default) or in a new frame, if
> > invoked with the -c command-line option.
> 
> OK, I rephrase the question: How to set Emacs as default app to open .tex, .text, .c. .f90 etc. files similarly to a browser (if Emacs uses tabs...)?
> 
> If it is not implemented you should add it in ToDo list..

If that is what you want, then I suggest to submit a feature-request
bug report, since I don't think we have such a feature.  I think we
will need to implement a new directive in our server-client protocol
to support such a feature.



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: How to set Emacs as default app on Windows (10)
  2022-05-22  9:04     ` Eli Zaretskii
@ 2022-05-22  9:54       ` Angelo Graziosi
  2022-05-22 10:27         ` Eli Zaretskii
  0 siblings, 1 reply; 8+ messages in thread
From: Angelo Graziosi @ 2022-05-22  9:54 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel


> Il 22/05/2022 11:04 Eli Zaretskii ha scritto:
> 
>  
> > Date: Sun, 22 May 2022 10:53:42 +0200 (CEST)
> > From: Angelo Graziosi
> > Cc: emacs-devel@gnu.org
> > 
> > > > >From a DOS box I started the Emacs client adapting the above target:
> > > > 
> > > > C:\Users\utente>C:\Windows\System32\cmd.exe /c "SET path=C:\msys64\mingw64\bin;%path%&& SET PRELOAD_WINSOCK=1&& START /D ^"C:\Apps\Emacs\bin^" emacsclientw.exe -c -n -a C:\Apps\Emacs\bin\runemacs.exe"
> > > 
> > > I don't understand why you needed to change that target.  What was it
> > > supposed to achieve, and how is that related to the issue at hand,
> > > which is setting up the default application to open *.tex files?
> > 
> > The link above seems to suggest to use emacsclientw which uses runemacs instead to use directly runemacs..
> 
> That suggestion doesn't make sense to me, and I think it is unrelated
> to your issue and the original question.
> 
> > > "Another frame" or "another instance of Emacs"?  How many Emacs
> > > processes do you have running after you click on a .tex file in the
> > > Explorer?
> > 
> > I would say: another frame and two processes (from task manager). See the screenshot 
> 
> Thanks, but the screenshot doesn't say definitively that there are 2
> Emacs processes, it only hints on that (via the warning it shows in
> one of the frames).  The definitive answer is to see how many Emacs
> processes are shown in Task Manager.

but I already answered this:

> > I would say: another frame and two processes (from task manager). See the screenshot 

However, I can survive even so.. Thank you for your time.

Ciao,
 Angelo.



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: How to set Emacs as default app on Windows (10)
  2022-05-22  9:54       ` Angelo Graziosi
@ 2022-05-22 10:27         ` Eli Zaretskii
  2022-05-22 21:00           ` Angelo Graziosi
  0 siblings, 1 reply; 8+ messages in thread
From: Eli Zaretskii @ 2022-05-22 10:27 UTC (permalink / raw)
  To: Angelo Graziosi; +Cc: emacs-devel

> Date: Sun, 22 May 2022 11:54:37 +0200 (CEST)
> From: Angelo Graziosi <angelo.g0@libero.it>
> Cc: emacs-devel@gnu.org
> 
> > Thanks, but the screenshot doesn't say definitively that there are 2
> > Emacs processes, it only hints on that (via the warning it shows in
> > one of the frames).  The definitive answer is to see how many Emacs
> > processes are shown in Task Manager.
> 
> but I already answered this:
> 
> > > I would say: another frame and two processes (from task manager). See the screenshot 

I don't see any Task Manager on that screenshot.  Apologies if I
missed it.



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: How to set Emacs as default app on Windows (10)
  2022-05-22 10:27         ` Eli Zaretskii
@ 2022-05-22 21:00           ` Angelo Graziosi
  2022-05-23 10:54             ` Eli Zaretskii
  0 siblings, 1 reply; 8+ messages in thread
From: Angelo Graziosi @ 2022-05-22 21:00 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 915 bytes --]


> Il 22/05/2022 12:27 Eli Zaretskii <eliz@gnu.org> ha scritto:
> 
>  
> > Date: Sun, 22 May 2022 11:54:37 +0200 (CEST)
> > From: Angelo Graziosi <angelo.g0@libero.it>
> > Cc: emacs-devel@gnu.org
> > 
> > > Thanks, but the screenshot doesn't say definitively that there are 2
> > > Emacs processes, it only hints on that (via the warning it shows in
> > > one of the frames).  The definitive answer is to see how many Emacs
> > > processes are shown in Task Manager.
> > 
> > but I already answered this:
> > 
> > > > I would say: another frame and two processes (from task manager). See the screenshot 
> 
> I don't see any Task Manager on that screenshot.  Apologies if I
> missed it.

For completeness, I have attached the screenshots. The emacs-one-process.png is taken after I start Emacs normally with the link on the taskbar and emacs-two-processes.png is taken after I double click a .tex file in Explorer..

[-- Attachment #2: emacs-proc.tar.gz --]
[-- Type: application/gzip, Size: 215694 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: How to set Emacs as default app on Windows (10)
  2022-05-22 21:00           ` Angelo Graziosi
@ 2022-05-23 10:54             ` Eli Zaretskii
  0 siblings, 0 replies; 8+ messages in thread
From: Eli Zaretskii @ 2022-05-23 10:54 UTC (permalink / raw)
  To: Angelo Graziosi; +Cc: emacs-devel

> Date: Sun, 22 May 2022 23:00:45 +0200 (CEST)
> From: Angelo Graziosi <angelo.g0@libero.it>
> Cc: emacs-devel@gnu.org
> 
> > I don't see any Task Manager on that screenshot.  Apologies if I
> > missed it.
> 
> For completeness, I have attached the screenshots. The emacs-one-process.png is taken after I start Emacs normally with the link on the taskbar and emacs-two-processes.png is taken after I double click a .tex file in Explorer..

Thanks, that indeed shows 2 separate Emacs processes.

So I think my original guess was correct: the first Emacs process
didn't start the server, so when you click on a .tex file, emacsclient
cannot connect to a server, and therefore starts a new Emacs process.



^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2022-05-23 10:54 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-22  1:08 How to set Emacs as default app on Windows (10) Angelo Graziosi
2022-05-22  5:52 ` Eli Zaretskii
2022-05-22  8:53   ` Angelo Graziosi
2022-05-22  9:04     ` Eli Zaretskii
2022-05-22  9:54       ` Angelo Graziosi
2022-05-22 10:27         ` Eli Zaretskii
2022-05-22 21:00           ` Angelo Graziosi
2022-05-23 10:54             ` Eli Zaretskii

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).