emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Emacs launched from Firefox


From: Max Nikulin
Subject: Re: Emacs launched from Firefox
Date: Mon, 2 May 2022 15:26:09 +0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.7.0

On 02/05/2022 09:03, Samuel Wales wrote:
thank you.  there is no emacs in my ~/.config/mimeapps.list.  where
are those desktop files found or put?  i use fluxbox.
[i realize this is not org related.  non-list email ok.]

Perhaps emacs-help is more suitable for this discussion, but I do not read that mail list due to rather high traffic there. On the other hand I do not know if there is a resource describing such configuration taking into account details specific to Emacs (I have not tried to find it though).

I am not sure from which site you downloaded that attachment, MIME type may vary depending on the HTTP server configuration. You yay check Content-Type response header in the browser development tools or using

    curl -I '<URL>'

command. It may be "text/plain", "text/x-patch", "application/x-patch", etc.

In Firefox settings (about:preferences page) check that "Applications" section either does not contain an entry for the MIME type (is unlikely in your case since you already opened a file) or its handler is configured to "Always ask" till you select your new handler.

System-wide .desktop file may reside e.g. in "/usr/share/applications/emacs.desktop". You can put your customized file in e.g. "~/.local/share/applications/" directory ("$XDG_DATA_HOME/applications/") or into "applications" subdirectory of "$XDG_DATA_DIRS" entry. For details see
https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html

Customize "Exec" entry in the .desktop file to add your options, e.g. create "emacs-a11y.desktop"

---- >8 ----
[Desktop Entry]
Version=1.0
Name=Accessible Emacs (GUI)
GenericName=Text Editor
Comment=GNU Emacs is an extensible, customizable text editor - and more
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++;
TryExec=/usr/bin/emacs
Exec=/usr/bin/emacs %F
Icon=emacs
Type=Application
Terminal=false
Categories=Utility;Development;TextEditor;
StartupWMClass=Emacs
Keywords=Text;Editor;
---- 8< ----

It is better to set unique "Name" to distinguish it from the default Emacs launcher. Desktop file format reference:
https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html

Notice that browser launcher script may reset PATH environment to some safe value, so executables from custom directories may be unavailable without specifying of the full path.

MIME type should be among the values of the MimeType field inside the ".desktop" file or in the "mimeapps.list" file. In the former case run (with proper directory)

    update-desktop-database ~/.local/share/applications

In the latter case add to "~/config/mimeapps.list" mapping from the MIME type to your .desktop file

---- >8 ----
[Added Associations]
text/plain=emacs-a11y.desktop;
---- 8< ----

And maybe

---- >8 ----
[Default Applications]
text/plain=emacs-a11y.desktop;
---- 8< ----

With such recipe a new instance of Emacs will be launched for each downloaded file. Likely you would prefer to use you main Emacs session or a special session of Emacs for untrusted content fetched from web. In such case you can use "emacsclient" command in the ".desktop" file and maybe systemd user socket+service units pair to run Emacs on demand.

If you are still using emacs-25 then e.g. "--fg-daemon" option is unavailable and related files are not included in the package. For inspiration you may check
http://git.savannah.gnu.org/cgit/emacs.git/tree/etc/emacsclient.desktop
http://git.savannah.gnu.org/cgit/emacs.git/tree/etc/emacs.service
https://www.gnu.org/software/emacs/manual/html_node/emacs/Emacs-Server.html

Finally a rather unrelated question. Do you find accessibility tools in Gnome or KDE inconvenient? I believed that it should be more difficult to arrange setup from scratch for fluxbox. However I never tried any of these options.

On 5/1/22, Max Nikulin wrote:
On 01/05/2022 11:53, Samuel Wales wrote:

[firefox did not offer to allow a command line to run my shell script
which sets up emacs correctly, and idk if it even ran with my .emacs.
does it do -q?  not sure because emacs is too unusable to even find
that out.  so firefox fails to be accessible in that dialog box.

Samuel, I think, firefox does exactly what it can find in MIME
associations (e.g. ~/.config/mimeapps.list) and in the .desktop file of
the selected application.

There is an emacsclient.desktop file in Emacs git master that tries to
connect to the existing Emacs session. It is a relatively new addition,
so packages for Linux distributions may miss it.

You can either use standard Emacs initialization to get all your
customization available through default emacs.desktop or create a custom
.desktop file that contain all CLI options specific to your setup.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]