Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

emacsclient not integrated into modern window systems

113 views
Skip to first unread message

Rusi

unread,
Jul 10, 2015, 11:24:22 PM7/10/15
to
Student of mine asked me if its possible to have emacs open from the file browser. [By default it opens with gedit]
For 1/2 hour we tried to find properties/open-with etc to make it emacsclient
but to no avail

After a lot of struggle the best I came up with was the below steps.
So... If installing emacs (using say apt) makes emacs an established app to open
(some) mimetypes, why is emacsclient not setup similarly?

[I realize that this question may be more suitable for ubuntu/gnome/ etc folks...
Still thought I'd ask]

-------------------------
0. Put (server-start) into init.el
Check that now 'emacsclient somefile' from a shell starts the same emacs

1. Put the following (between the --------- and ------------- )
into the file ~/.local/share/applications/emacs.desktop
---------
[Desktop Entry]
Name=EmacsClient
GenericName=Text Editor
Comment=Edit text
MimeType=text/english;text/plain;text/x-makefile;text/x-c++hdr;text/x-c++src;text/x-chdr;text/x-csrc;text/x-java;text/x-moc;text/x-pascal;text/x-tcl;text/x-tex;application/x-shellscript;text/x-c;text/x-c++;
Exec=emacsclient -n -a emacs %F
Icon=emacs
Type=Application
Terminal=false
Categories=Development;TextEditor;
StartupWMClass=Emacs
---------

2. Now in file browser, click on a file you want opened in emacs and
click properties -> open-with
Here you should find 'EmacsClient' somewhere down.
You can make it default

Note: Between 1 and 2 you may need to reboot (actually logout of X-windows is enough)

Rasmus

unread,
Jul 11, 2015, 6:54:52 AM7/11/15
to help-gn...@gnu.org
Rusi <rusto...@gmail.com> writes:

> Student of mine asked me if its possible to have emacs open from the
> file browser. [By default it opens with gedit]
> For 1/2 hour we tried to find properties/open-with etc to make it emacsclient
> but to no avail
>
> After a lot of struggle the best I came up with was the below steps.
> So... If installing emacs (using say apt) makes emacs an established app to open
> (some) mimetypes, why is emacsclient not setup similarly?

You can basically replace call to Emacs with emacsclient -ca ''. I also
use various .desktop files for starting Emacs, Gnus, EMMS etc in Gnome-3.

Rasmus

--
Don't panic!!!


Rusi

unread,
Jul 11, 2015, 7:12:52 AM7/11/15
to
On Saturday, July 11, 2015 at 4:24:52 PM UTC+5:30, Rasmus wrote:
The setup I described is working (best that I know).
I am asking not how-to but why-to.

Vaidheeswaran C

unread,
Jul 11, 2015, 8:20:12 AM7/11/15
to help-gn...@gnu.org

I am on Debian Wheezy and I can "Open With" both emacs or gnuclient.

/usr/share/applications/gnuserv.desktop
/usr/share/applications/emacs23.desktop

I also remember playing around with text editor alternatives sometime
back.

https://wiki.debian.org/DebianAlternatives

Shouldn't you raise the issue with your specific distribution?

Rusi

unread,
Jul 11, 2015, 8:24:58 AM7/11/15
to
Thanks
If you can open with emacsclient then probably some distros get it right and some dont.
But can you open with emacsclient (not gnuclient)?

Raffaele Ricciardi

unread,
Jul 11, 2015, 12:34:48 PM7/11/15
to
On 11/07/15 13:12, Rusi wrote:
> The setup I described is working (best that I know).
> I am asking not how-to but why-to.

This is not a problem of Emacs, but rather of "modern" window systems,
that make simple customizations like this cumbersome.

If Emacs was already installed, or it was installed via a package
manager, then the operating system should have had taken care of this.
If instead you built Emacs from source, then you would have faced this
problem with any other editor.

Vaidheeswaran C

unread,
Jul 11, 2015, 3:00:02 PM7/11/15
to help-gn...@gnu.org
On Saturday 11 July 2015 08:54 AM, Rusi wrote:
> [Desktop Entry]
> Name=EmacsClient
> GenericName=Text Editor
> Comment=Edit text
> MimeType=text/english;text/plain;text/x-makefile;text/x-c++hdr;text/x-c++src;text/x-chdr;text/x-csrc;text/x-java;text/x-moc;text/x-pascal;text/x-tcl;text/x-tex;application/x-shellscript;text/x-c;text/x-c++;
> Exec=emacsclient -n -a emacs %F
> Icon=emacs
> Type=Application
> Terminal=false
> Categories=Development;TextEditor;
> StartupWMClass=Emacs

There is __already__ an emacs.desktop file in emacs repo. If
emacsclient.desktop gets in to repo and in the NEWS file, it will
induce packagers to bundle emacsclient.desktop as well.

Why not file a bug report and see what happens...

~/src/emacs.git/etc$ cat emacs.desktop
[Desktop Entry]
Name=Emacs
GenericName=Text Editor
Comment=Edit text
MimeType=text/english;text/plain;text/x-makefile;text/x-c++hdr;text/x-c++src;text/x-chdr;text/x-csrc;text/x-java;text/x-moc;text/x-pascal;text/x-tcl;text/x-tex;application/x-shellscript;text/x-c;text/x-c++;
Exec=emacs %F
Icon=emacs
Type=Application
Terminal=false
Categories=Development;TextEditor;
StartupWMClass=Emacs
Keywords=Text;Editor;

----------------------------------------------------------------

This is the diff between the repo version and the debian version. I
feel the debian version is built on top of the repo version.

[Desktop Entry]
-Name=Emacs
+Version=1.0
+Name=GNU Emacs 23
GenericName=Text Editor
-Comment=Edit text
+Comment=View and edit files
MimeType=text/english;text/plain;text/x-makefile;text/x-c++hdr;text/x-c++src;text/x-chdr;text/x-csrc;text/x-java;text/x-moc;text/x-pascal;text/x-tcl;text/x-tex;application/x-shellscript;text/x-c;text/x-c++;
-Exec=emacs %F
-Icon=emacs
+Exec=/usr/bin/emacs23 %F
+TryExec=emacs23
+Icon=/usr/share/icons/hicolor/scalable/apps/emacs23.svg
Type=Application
Terminal=false
-Categories=Development;TextEditor;
-StartupWMClass=Emacs
-Keywords=Text;Editor;
+Categories=Utility;Development;TextEditor;

----------------------------------------------------------------

Btw, once I open *.txt file with emacsclient any susbsequent opens on
that file happens with emacsclient.

$ xdg-mime query default text/plain
userapp-emacsclient.emacs23-00DX1X.desktop

$ cat ~/.local/share/applications/userapp-emacsclient.emacs23-00DX1X.desktop
[Desktop Entry]
Encoding=UTF-8
Version=1.0
Type=Application
NoDisplay=true
Exec=/usr/bin/emacsclient.emacs23 %f
Name=emacsclient.emacs23
Comment=Custom definition for emacsclient.emacs23

The above desktop files are created automatically by my XFCE desktop.



Vaidheeswaran C

unread,
Jul 11, 2015, 3:08:05 PM7/11/15
to help-gn...@gnu.org
On Saturday 11 July 2015 08:54 AM, Rusi wrote:
> emacsclient -n -a emacs %F

For my first invocation, I just did the following....

$ emacsclient --alternate-editor="" file.txt

emacsclient: can't find socket; have you started the server?
To start the server in Emacs, type "M-x server-start".

Warning: due to a long standing Gtk+ bug
http://bugzilla.gnome.org/show_bug.cgi?id=85715
Emacs might crash when run in daemon mode and the X11 connection is
unexpectedly lost.
Using an Emacs configured with --with-x-toolkit=lucid does not have this
problem.
Loading desktop...



Rusi

unread,
Jul 11, 2015, 10:57:15 PM7/11/15
to
On Sunday, July 12, 2015 at 12:30:02 AM UTC+5:30, Vaidheeswaran C wrote:

> There is __already__ an emacs.desktop file in emacs repo. If
...
...

Hi Vaidheeswaran

You are giving some useful data and making some interesting points.
However what it all adds up to is not clear to me: Should a bug-report be filed?
With debian/ubuntu/emacs?

Just to be clear I understand next to nothing about XDG, desktop files etc.
Also I am fine filing bug-reports that are welcome
Not so fine when not so welcome; see
http://debbugs.gnu.org/cgi/bugreport.cgi?bug=18431

which is why I asked this here in the first place

Vaidheeswaran C

unread,
Jul 12, 2015, 12:28:56 AM7/12/15
to help-gn...@gnu.org
On Sunday 12 July 2015 08:27 AM, Rusi wrote:
> On Sunday, July 12, 2015 at 12:30:02 AM UTC+5:30, Vaidheeswaran C wrote:

> http://debbugs.gnu.org/cgi/bugreport.cgi?bug=18431

From http://debbugs.gnu.org/cgi/bugreport.cgi?bug=18431#8

> Error (warning) message as follows is given:
>
> emacsclient: can't find socket; have you started the server?
> To start the server in Emacs, type "M-x server-start".
>
> After printing which, it starts ok, editing the file!!

It it is letting you know that it tried to contact an existing
Emacs instance but failed, and it shares the message text with the
non --alternate-editor case. Yes, the message could be
special-cased for --alternate-editor, but it doesn't seem like a
big deal.

LOL.

Emacsclient talks like my wife. When it says one thing, it means
totally different thing. My wife is just my wife and not a big deal
to me, whatever she says to me. That is how I deal with her.

IMNSHO, "not a big deal", is not an argument but an emotional appeal.
If I were in your place, I would feel unwelcome and reluctant as well.

Why is it hard for you to say "No big deal!" and move on. "No big
deal!" is panacea for all the ailments.

"(All this is) No big deal" -- That is what Upanishads say anyway,
don't you agree?


Rusi

unread,
Jul 12, 2015, 1:06:32 AM7/12/15
to
:-)
Well really... This is not a big deal
If the devs who handle 10,000 more big deals want to relegate this to a wishlist
its really quite ok.

However what this obscures is the clash between emacs-philosophy and
'more-modern' system philosophies.
The classic emacs way of doing things is to live mostly inside emacs.
The modern way is to have a concert of various apps working in cooperation.

Unfortunately as soon as this is enunciated someone or other will pipe up:
"The emacs way is BETTER or even THE ONLY WAY"
which is (to me) just too tiresome an argument to get into.

Just for context, the kids I deal with are 20 year olds who know nothing about
anything other than the modern way.
They (and I) have no problem if there is a reasonable path from the modern way
to the more classic way..

And to me finding a desktop file somewhere on the net, almost none of which
I understand, and setting it up somewhere may be a necessary evil, thanks to
it falling between stools of emacs-devs and distro-packagers jurisdictions.

To a contemporary kid however its just one more data point that emacs is not really usable.

Vaidheeswaran C

unread,
Jul 12, 2015, 2:02:57 AM7/12/15
to help-gn...@gnu.org
On Sunday 12 July 2015 10:36 AM, Rusi wrote:

> the kids I deal with are 20 year olds

A small suggestion...

Point them to this list and encourage them to post their issues
directly to help-gn...@gnu.org.

"Help GNU Emacs" is tolerant. Here everything -- you and your issues
-- are a big deal atleast to someone else. This other person is also
grappling with just the same isssue as you do.



Vaidheeswaran C

unread,
Jul 12, 2015, 4:54:14 AM7/12/15
to help-gn...@gnu.org
On Sunday 12 July 2015 12:38 AM, Vaidheeswaran C wrote:
> $ emacsclient --alternate-editor="" file.txt

The below variation seems like a good improvement.

emacsclient --alternate-editor="" -cF "((top . 0) (left . 0) (width
. 99) (height . 28))"


For plugging in the frame parameters, I used

M-: (current-frame-configuration)

and hand picked the few that you see.

For some reasons, including

(fullscreen . maximized)

in the frame parameter has no intended effect on the editor window. It
is not clear to me whether it is a limitation or a bug.

----------------------------------------------------------------

The External Editor plugin (Thunderbird) now uses the above commandline.
In addition, my .emacs has the following line.

(push '("\\.eml\\'" . message-mode) auto-mode-alist)


Eli Zaretskii

unread,
Jul 12, 2015, 10:37:46 AM7/12/15
to help-gn...@gnu.org
> Date: Sat, 11 Jul 2015 19:57:13 -0700 (PDT)
> From: Rusi <rusto...@gmail.com>
>
> On Sunday, July 12, 2015 at 12:30:02 AM UTC+5:30, Vaidheeswaran C wrote:
>
> > There is __already__ an emacs.desktop file in emacs repo. If
> ...
> ...
>
> Hi Vaidheeswaran
>
> You are giving some useful data and making some interesting points.
> However what it all adds up to is not clear to me: Should a bug-report be filed?
> With debian/ubuntu/emacs?

IMO, with those who packaged your system.

> Just to be clear I understand next to nothing about XDG, desktop files etc.
> Also I am fine filing bug-reports that are welcome
> Not so fine when not so welcome; see
> http://debbugs.gnu.org/cgi/bugreport.cgi?bug=18431

Not sure why you say that bug report was "not so welcome". There's
nothing there except polite explanation of the issue.


Stefan Monnier

unread,
Jul 12, 2015, 11:08:31 AM7/12/15
to help-gn...@gnu.org
> IMO, with those who packaged your system.

We could/should also bundle a sample emacsclient.desktop file, since it
seems to be a standardish format nowadays.


Stefan


Vaidheeswaran C

unread,
Jul 12, 2015, 11:28:07 AM7/12/15
to help-gn...@gnu.org
On Sunday 12 July 2015 08:07 PM, Eli Zaretskii wrote:

> There's nothing there except polite explanation of the issue.

"Not a big deal" is a colloquial expression. The text books that we
learn English from doesn't teach us what this expression means. When
this is the case, we need to rely on our subjective judgement to
decide what particular turn of phrase means. It is also a common
experience that a phrase that is polite in a conversation is deemed
otherwise in other cultures.

When talking across cultures, it is generally considered a good
practice to err on the conservative side. It wouldn't have been a big
deal if the bug was just labelled as Minor.




Rusi

unread,
Jul 12, 2015, 12:21:41 PM7/12/15
to
Hey Vaidheeswaran!
We need not personalize (and cuturalize and nationalize and...) this.
Clearly the *bug* was not welcome in the sense that it is accepted as a bug
but not having sufficient importance to correct it. That does not spill over
to the *persons* involved

Analogy: Many large projects have code norms. And large enough (and old enough) projects violate these norms left-right-n-center.
And then some OCD guy will come up and want to correct all the indentation or
misnamings or what-have-you.
So then the others have to tell this super well-meaning but misguided person:
"Thanks but kindly lay off!"

More real example:
Trying to hack inside the python sources I found a bunch of CRLF issues.
[Yeah this is something I am OCD about -- Ive seen 1000s of lines changed because someone used another editor]

Asking around on the mailing lists, people suggested a bug report.
So I filed https://bugs.python.org/issue24507
Then someone suggested making a whole dependency-tree of CRLF bugs.
Now even for an CRLF-OCD this seemed a bit excessive, but I complied...
With https://bugs.python.org/issue24513
which was forthwith closed
[last I knew there is a pdf file checked in as text!]

And in that analogy as here the real issue gets forgotten: things like desktop
files and the emacsclient paradigm generally are neglected by falling in a
no-mans-land between distro packager and upstream devs

Eli Zaretskii

unread,
Jul 12, 2015, 12:25:20 PM7/12/15
to help-gn...@gnu.org
> From: Vaidheeswaran C <vaidheeswara...@gmail.com>
> Date: Sun, 12 Jul 2015 20:58:00 +0530
>
> It wouldn't have been a big deal if the bug was just labelled as
> Minor.

Likewise with wishlist. It just means there's no bug, just an
enhancement request. There's nothing derogatory about that.

Rusi

unread,
Jul 12, 2015, 12:29:49 PM7/12/15
to
Correction: I see now it is marked as 'later' (not closed/wont-fix etc)

Rusi

unread,
Jul 12, 2015, 12:32:11 PM7/12/15
to
Thanks for that Stefan!
If it is easy, I'd also like a different icon for emacsclient

Dan Espen

unread,
Jul 13, 2015, 12:59:12 AM7/13/15
to
I don't see why the .desktop file is important.
If you want to use emacsclient, I think you need Emacs running
as a daemon. In my Fedora installation I find:

/usr/lib/systemd/user/emacs.service

If things work as they should, enable the service with systemctl
and you _should_ find emacs offered as an editor choice.

--
Dan Espen
0 new messages