Everything I mentioned so far has been my Bionic desktop.  Which, incidentally was an upgrade from Xenial, not a clean install.  But... in my Focal headless container, if I run:
>$ run-mailcap myscript
it invokes emacs.  Yay!  It works!  DISPLAY, EDITOR, and VISUAL are all unset or empty.  There's nothing in /etc/mailcap for emacs, and what *IS* in /etc/mailcap is (amongst others of course):
application/x-shellscript; vim %s; needsterminal
So I really need to spend some time reading man pages about mailcap, mime, etc because that's not what I would expect, and I'm really confused.

On 5/23/22 8:59 AM, Craig STCR wrote:
I guess maybe I should have given a little better description of what I tried that did NOT work?  But it's a little off-topic for this mailing list.  Nevertheless, here it is...

I created a ~/.mailcap file and put this in it, which I cut and pasted from /etc/mailcap:

application/x-shellscript; emacs27 %s; test=test -n "$DISPLAY"
But obviously that's not going to change anything, since it's already in the system mailcap file, /etc/mailcap.  DOH!  And sure enough, running '>$ run-mailcap myscript' invokes 'less'.  But what I wasn't expecting is that running '>$ update-mime -- local' gives me: "Error: '/home/user/.mailcap' is not in required format -- not updated".   Not sure why I'm getting that when I cut-and-pasted from /etc/mailcap.

No worries.  I'll look in more depth later.


On 5/23/22 8:40 AM, Craig STCR wrote:
Thanks all for your help!

On 5/20/22 9:44 PM, Ihor Radchenko wrote:
Dear Craig, ... or provide plain/text handler in ~/.mailcap.

OK, I did a first-try on this and was unsuccessful, but I'm sure it's user error.  I need to refresh my knowledge on how to customize user-local mime database, and that will write-out a new ~/.mailcap, etc, I think?  I've done it before, but it was awhile ago, and I wasn't paying attention to ~/.mailcap when I did it.  I know for Gnome I can create a .desktop file.  But I know there's a way to customize user-local mime database without Gnome desktop.  I'll take a closer look when I have a little more time.


On 5/20/22 9:44 PM, Ihor Radchenko wrote:
However, I am not sure what to do on Windows/Mac.
Maybe try a quick-and-dirty, cross-platform solution that checks non-binary files for a first-line shebang?  Could use existing Emacs hooks that determine major-mode when opening files.

Again, thanks all for your help!

Best,
-Craig