all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Davide Masserut via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: Po Lu <luangruo@yahoo.com>
Cc: Eli Zaretskii <eliz@gnu.org>,
	Stefan Kangas <stefankangas@gmail.com>,
	65509@debbugs.gnu.org
Subject: bug#65509: [PATCH] Use correct env var when opening frames with freedesktop menu entries
Date: Wed, 06 Sep 2023 16:01:58 +0200	[thread overview]
Message-ID: <87il8ncruu.fsf@mssdvd.com> (raw)
In-Reply-To: <s0d7cp4p3k5.fsf@yahoo.com>

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

Po Lu <luangruo@yahoo.com> writes:

> Davide Masserut <dm@mssdvd.com> writes:
>
>> Correct.  However, that TTY is occupied by the X window manager,
>> which hides the Emacs interface.
>>
>> When the argument of --display doesn't exits or is empty, should we
>> check if $DISPLAY is present in the environment and use its value?
>>
>> When PGTK is enabled, we could check $WAYLAND_DISPLAY and then
>> $DISPLAY before resorting to displaying the frame in a terminal or in
>> a TTY.
>>
>> I tested this with Gnome and i3, both started from a TTY using
>> startx. I'm not sure how this behaves when using a display manager.
>
> Display selection is GTK's territory, and we basically give it carte
> blanche to judge which displays are suitable, since we can't account
> for every present and future GDK backend.
>
> Only subsequent to the establishment of the display connection are we
> capable of taking display-specific action, such as displaying a
> warning message.

It turns out that Emacs 29 has new CLI option that solves exactly these problems.

The attached patch replaces the usage of --display=$DISPLAY with --reuse-frame.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Avoid-using-display-to-reuse-frames.patch --]
[-- Type: text/x-patch, Size: 2569 bytes --]

From bb7ba852c9add6ed5b3c1edd783aaf07eca08a46 Mon Sep 17 00:00:00 2001
From: Davide Masserut <dm@mssdvd.com>
Date: Wed, 6 Sep 2023 15:35:47 +0200
Subject: [PATCH] Avoid using --display to reuse frames

Using hard-coded display values can cause graphical frames to open
using the wrong backend or not open at all.

* etc/emacsclient-mail.desktop, etc/emacsclient.desktop: Use
--reuse-frame instead of --display.
---
 etc/emacsclient-mail.desktop | 4 ++--
 etc/emacsclient.desktop      | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/etc/emacsclient-mail.desktop b/etc/emacsclient-mail.desktop
index 0a2420ddead..819e3855567 100644
--- a/etc/emacsclient-mail.desktop
+++ b/etc/emacsclient-mail.desktop
@@ -2,9 +2,9 @@
 Categories=Network;Email;
 Comment=GNU Emacs is an extensible, customizable text editor - and more
 # We want to pass the following commands to the shell wrapper:
-# u=$(echo "$1" | sed 's/[\"]/\\&/g'); exec emacsclient --alternate-editor= --display="$DISPLAY" --eval "(message-mailto \"$u\")"
+# u=$(echo "$1" | sed 's/[\"]/\\&/g'); exec emacsclient --alternate-editor= --reuse-frame --eval "(message-mailto \"$u\")"
 # Special chars '"', '$', and '\' must be escaped as '\\"', '\\$', and '\\\\'.
-Exec=sh -c "u=\\$(echo \\"\\$1\\" | sed 's/[\\\\\\"]/\\\\\\\\&/g'); exec emacsclient --alternate-editor= --display=\\"\\$DISPLAY\\" --eval \\"(message-mailto \\\\\\"\\$u\\\\\\")\\"" sh %u
+Exec=sh -c "u=\\$(echo \\"\\$1\\" | sed 's/[\\\\\\"]/\\\\\\\\&/g'); exec emacsclient --alternate-editor= --reuse-frame --eval \\"(message-mailto \\\\\\"\\$u\\\\\\")\\"" sh %u
 Icon=emacs
 Name=Emacs (Mail, Client)
 MimeType=x-scheme-handler/mailto;
diff --git a/etc/emacsclient.desktop b/etc/emacsclient.desktop
index 4395d3b02bc..cfbd4d97979 100644
--- a/etc/emacsclient.desktop
+++ b/etc/emacsclient.desktop
@@ -3,7 +3,7 @@ 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++;x-scheme-handler/org-protocol;
-Exec=sh -c "if [ -n \\"\\$*\\" ]; then exec emacsclient --alternate-editor= --display=\\"\\$DISPLAY\\" \\"\\$@\\"; else exec emacsclient --alternate-editor= --create-frame; fi" sh %F
+Exec=sh -c "if [ -n \\"\\$*\\" ]; then exec emacsclient --alternate-editor= --reuse-frame \\"\\$@\\"; else exec emacsclient --alternate-editor= --create-frame; fi" sh %F
 Icon=emacs
 Type=Application
 Terminal=false
-- 
2.42.0


  reply	other threads:[~2023-09-06 14:01 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-24 18:32 bug#65509: [PATCH] Use correct env var when opening frames with freedesktop menu entries Davide Masserut via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-08-31  9:34 ` Eli Zaretskii
2023-08-31 11:32   ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-01 18:43     ` Stefan Kangas
2023-09-01 19:04       ` Eli Zaretskii
2023-09-02 16:24         ` Davide Masserut via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-02 16:58           ` Eli Zaretskii
2023-09-03  0:59             ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-03  5:34               ` Eli Zaretskii
2023-09-03  6:07                 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-03 12:13                   ` Davide Masserut via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-03 12:41                     ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-03 12:48                       ` Davide Masserut via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-03 12:51                       ` Stefan Kangas
2023-09-03 13:00                         ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-03 13:31                           ` Stefan Kangas
2023-09-03 13:42                           ` Davide Masserut via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-04  0:38                             ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-05 14:46                               ` Davide Masserut via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-06  0:07                                 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-06 14:01                                   ` Davide Masserut via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2023-09-07  8:26                                     ` Eli Zaretskii
2023-09-07  9:26                                       ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-07  9:37                                         ` Davide Masserut via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-08 15:49                                         ` Davide Masserut via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-15  7:05                                           ` Eli Zaretskii
2023-09-15  7:12                                             ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-15  7:32                                               ` Eli Zaretskii
2023-09-15  7:44                                                 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-15 11:34                                                   ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87il8ncruu.fsf@mssdvd.com \
    --to=bug-gnu-emacs@gnu.org \
    --cc=65509@debbugs.gnu.org \
    --cc=dm@mssdvd.com \
    --cc=eliz@gnu.org \
    --cc=luangruo@yahoo.com \
    --cc=stefankangas@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.