unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Re: GUI X-FreeDesktop integration
@ 2021-05-25 21:34 Peter Oliver
  2021-05-26  8:49 ` Robert Pluim
                   ` (2 more replies)
  0 siblings, 3 replies; 27+ messages in thread
From: Peter Oliver @ 2021-05-25 21:34 UTC (permalink / raw)
  To: emacs-devel

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

On Sunday 16th May, Robin Tarsiger wrote:

> In fact, the _least_ surprising from
> an XDG/FDO perspective would actually be to _only_ expose
> a "client+autolaunch" desktop entry and just call that the
> point of integration for Emacs.

Agreed.  Attached is a patch which achieves this.

-- 
Peter Oliver

[-- Attachment #2: Type: text/plain, Size: 3708 bytes --]

From 84508dbc948038f9b7c797b3ec012c00379df7ee Mon Sep 17 00:00:00 2001
From: Peter Oliver <git@mavit.org.uk>
Date: Tue, 25 May 2021 22:06:43 +0100
Subject: [PATCH] From a GUI, lauch via emacsclient by default

* etc/emacs-mail.desktop, etc/emacs.desktop: Call emacsclient not
  emacs by default.  Provide plain emacs as an alternative action.
---
 etc/NEWS                |  7 +++++++
 etc/emacs-mail.desktop  | 13 ++++++++++---
 etc/emacs.desktop       | 11 ++++++++++-
 etc/emacsclient.desktop | 12 ------------
 4 files changed, 27 insertions(+), 16 deletions(-)
 delete mode 100644 etc/emacsclient.desktop

diff --git a/etc/NEWS b/etc/NEWS
index 1541b74a3b..0605c8b46c 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -108,6 +108,13 @@ avoid security issues when executing untrusted code.  See the manual
 page for 'seccomp' system call, for details about Secure Computing
 filters.
 
+** Launching Emacs from a GUI now defaults to trying emacsclient.
+When launching Emacs via a freedesktop.org-compatible GUI, it is now
+the default to try to use emacsclient to open the file in an existing
+Emacs frame.  Opening a new frame in an existing Emacs or a separate
+instance of Emacs are available as an alternative action (performed,
+for example, by right-clicking on the icon).
+
 \f
 * Changes in Emacs 28.1
 
diff --git a/etc/emacs-mail.desktop b/etc/emacs-mail.desktop
index 0c5fab1dd1..e949b7f1ed 100644
--- a/etc/emacs-mail.desktop
+++ b/etc/emacs-mail.desktop
@@ -1,12 +1,19 @@
 [Desktop Entry]
 Categories=Network;Email;
 Comment=GNU Emacs is an extensible, customizable text editor - and more
-Exec=emacs -f message-mailto %u
-# If you prefer to use emacsclient, use this instead
-#Exec=emacsclient -e '(message-mailto "%u")'
+Exec=emacsclient --alternate-editor= --eval '(message-mailto "%u")'
 Icon=emacs
 Name=Emacs (Mail)
 MimeType=x-scheme-handler/mailto;
 NoDisplay=false
 Terminal=false
 Type=Application
+Actions=new-window;new-instance;
+
+[Desktop Action new-window]
+Name=New Window
+Exec=emacsclient --alternate-editor= --create-frame --eval '(message-mailto "%u")'
+
+[Desktop Action new-instance]
+Name=New Instance
+Exec=emacs -f message-mailto %u
diff --git a/etc/emacs.desktop b/etc/emacs.desktop
index 2e6496e58c..d21bba0e10 100644
--- a/etc/emacs.desktop
+++ b/etc/emacs.desktop
@@ -3,10 +3,19 @@ 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
+Exec=emacsclient --alternate-editor= %F
 Icon=emacs
 Type=Application
 Terminal=false
 Categories=Development;TextEditor;
 StartupWMClass=Emacs
 Keywords=Text;Editor;
+Actions=new-window;new-instance;
+
+[Desktop Action new-window]
+Name=New Window
+Exec=emacsclient --alternate-editor= --create-frame %F
+
+[Desktop Action new-instance]
+Name=New Instance
+Exec=emacs %F
diff --git a/etc/emacsclient.desktop b/etc/emacsclient.desktop
deleted file mode 100644
index 3feb83c729..0000000000
--- a/etc/emacsclient.desktop
+++ /dev/null
@@ -1,12 +0,0 @@
-[Desktop Entry]
-Name=Emacs (Client)
-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 -c %F
-Icon=emacs
-Type=Application
-Terminal=false
-Categories=Development;TextEditor;
-StartupWMClass=Emacsd
-Keywords=Text;Editor;
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 27+ messages in thread
* Re: GUI X-FreeDesktop integration
@ 2021-08-12 12:42 Manuel Uberti
  2021-08-12 12:51 ` Eli Zaretskii
  0 siblings, 1 reply; 27+ messages in thread
From: Manuel Uberti @ 2021-08-12 12:42 UTC (permalink / raw)
  To: eliz, emacs-devel

 > I hear quite a few people run at least two instances of Emacs, for
 > example if they don't want Gnus fetching new articles and email to
 > freeze the interactive session for prolonged times.  And there can > be other 
similar reasons to do the same.
 >
 > We don't automatically make new options be the default unless the
 > old behavior makes absolutely no sense or is otherwise dangerous or > not 
useful.  I don't see this case matching any of that, so IMO we
 > shouldn't make this behavior the default right away.
 >
 > Does anyone else have an opinion on this aspect?

Sorry if I did not follow this thread before and ended up opening bug #49505. As 
stated there, if possible I'd like to keep the old behaviour on left-click (new 
Emacs instance) and offering an 'Emacs (client)' option on right-click.

The change was a bit of surprise for me, and it took some adjustments on my side:

- I have two launchers now in GNOME Activities overview when I type 'emacs': 
'Emacs' and 'Emacs (Client)'
- Whichever I add to my favourites, the dock bar shows 'Emacs (Client)'
- It's only by right-clicking on that 'Emacs (Client)' and picking 'New 
Instance' that I get the Emacs instance I was used to. Another way is not using 
the launcher in the dock, but left-clicking on the 'Emacs' launcher in GNOME 
Activities overview.
- For now my workaround has been using a keyboard shortcut ('s-e') to open 
'emacs', but yes, this was kind of an undesired change.

-- 
Manuel Uberti
www.manueluberti.eu



^ permalink raw reply	[flat|nested] 27+ messages in thread
* GUI X-FreeDesktop integration
@ 2021-05-14  3:18 Boruch Baum
  2021-05-14  3:46 ` Stefan Monnier
  2021-05-14  6:45 ` Eli Zaretskii
  0 siblings, 2 replies; 27+ messages in thread
From: Boruch Baum @ 2021-05-14  3:18 UTC (permalink / raw)
  To: Emacs-Devel List

I found myself today using GUI emacs 27.1, and was surprised that it
wasn't at all integrated with the (debian) linux desktop. It doesn't
seem like a big deal to make part of a standard install, but in the
context of 'trying to make emacs easier' it would go a long way. I never
know when I post on this list whether something has already been either
done or flat-out rejected sometime in the past, oh, 30 years?, but
here's a simple two-step proposal to accomplish the type of integration
I think *ALL* newcomers would expect when installing GUI emacs (ie. when
one selects file(s) in a file manager, they are opened in Emacs).

Step 1: New file: /usr/share/applications/emacsclient.desktop
#+begin_src conf
[Desktop Entry]
Name=Emacsclient
GenericName=Connect to an Emacs server
X-GNOME-FullName=Connect to an Emacs server
Encoding=UTF-8
Version=1.0
Comment=Connect to an Emacs server using emacsclient
NoDisplay=false
Exec=\emacsclient -c --alternate-editor="" --eval "(pick-a-suitable-name \"%F\")"
Terminal=false
X-MultipleArgs=false
Type=Application
Icon=emacs
Categories=Office;Development
StartupWMClass=Emacs
StartupNotify=true
# MimeType=
#+end_src

Step 2: New function: pick-a-suitable-name
#+BEGIN_SRC emacs-lisp
  (defun pick-a-suitable-name (&optional files)
    "Integrate GUI Emacs with XFreeDesktop"
    ;; Do optional 'stuff'
    ;; Do other optional 'stuff'
    (dolist (file (split-string (substring files 1 -1) "' '"))
      (find-file file))
    ;; Do more optional 'stuff'
    )
#+END_SRC

I'll cross-post this on the debian list for their own independent consideration.
--
hkp://keys.gnupg.net
CA45 09B5 5351 7C11 A9D1  7286 0036 9E45 1595 8BC0



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

end of thread, other threads:[~2021-08-12 12:58 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-25 21:34 GUI X-FreeDesktop integration Peter Oliver
2021-05-26  8:49 ` Robert Pluim
2021-05-26 12:14 ` Peter Oliver
2021-05-26 12:19 ` Eli Zaretskii
2021-05-28 12:54   ` Peter Oliver
2021-05-28 13:03     ` Eli Zaretskii
2021-05-28 18:49       ` chad
2021-05-28 19:16         ` Eli Zaretskii
2021-05-28 20:05           ` chad
2021-05-29  6:01             ` Eli Zaretskii
  -- strict thread matches above, loose matches on Subject: below --
2021-08-12 12:42 Manuel Uberti
2021-08-12 12:51 ` Eli Zaretskii
2021-08-12 12:58   ` Lars Ingebrigtsen
2021-05-14  3:18 Boruch Baum
2021-05-14  3:46 ` Stefan Monnier
2021-05-16  3:26   ` Boruch Baum
2021-05-14  6:45 ` Eli Zaretskii
2021-05-14  7:20   ` Joost Kremers
2021-05-14  7:41     ` Eli Zaretskii
2021-05-14  7:53       ` Joost Kremers
2021-05-14 11:29         ` Yuri Khan
2021-05-14 13:51         ` Stefan Monnier
2021-05-16  3:33   ` Boruch Baum
2021-05-16  4:25     ` Eli Zaretskii
2021-05-16  4:36       ` Boruch Baum
2021-05-16 10:46         ` Robin Tarsiger
2021-05-16 20:07           ` Matthias Meulien

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).