Deutsch   English   Français   Italiano  
<20240608172047.502@kylheku.com>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!weretis.net!feeder9.news.weretis.net!feeder8.news.weretis.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Kaz Kylheku <643-408-1753@kylheku.com>
Newsgroups: comp.lang.c
Subject: Re: Running an editor from ANSI C
Date: Sun, 9 Jun 2024 00:27:31 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 44
Message-ID: <20240608172047.502@kylheku.com>
References: <v3pge7$uf2i$1@dont-email.me> <v3r2pl$16mtl$1@dont-email.me>
 <v3r7v8$1b57j$1@dont-email.me> <v3rek5$1c4i5$1@dont-email.me>
 <v3rrtm$1e6g8$1@dont-email.me> <v3ru84$1eafb$1@dont-email.me>
 <87o78dzw1a.fsf@nosuchdomain.example.com> <v3te2i$1ms1q$1@dont-email.me>
 <87frtpznoa.fsf@nosuchdomain.example.com> <v3uimm$20jte$3@dont-email.me>
 <871q59yty1.fsf@nosuchdomain.example.com> <v3uogs$21g4g$6@dont-email.me>
 <20240607142429.0000067b@yahoo.com>
 <87jzizxinh.fsf@nosuchdomain.example.com>
Injection-Date: Sun, 09 Jun 2024 02:27:32 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="b81bca011825a3b359d59c24cbc236be";
	logging-data="3101090"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX197jJPa9JZ4saN2I8ECsD1wjdEemvaySlA="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:16W7BCWoU7A6N2mXdw3lc785SKI=
Bytes: 3091

On 2024-06-08, Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:
> Michael S <already5chosen@yahoo.com> writes:
>> On Fri, 7 Jun 2024 10:47:57 -0000 (UTC)
>> Lawrence D'Oliveiro <ldo@nz.invalid> wrote:
>>> On Fri, 07 Jun 2024 02:37:42 -0700, Keith Thompson wrote:
>>> > As for portability, I'm not aware of the $EDITOR convention being
>>> > used on non-POSIX systems.  
>>> 
>>> Can non-POSIX systems offer anything better? Any worthwhile
>>> alternative?
>>> 
>>> No.
>>
>> Yes. The one below is better.
>> ShellExecute(NULL, "edit", filename, NULL, NULL, SW_NORMAL);
>
> For those not familiar with Windows, "edit" is not a command name, it's
> an "object verb".  The above call invokes the user's configured command
> to edit the specified file.  It might invoke a text editor for foo.txt,
> an image editor for foo.png.  It's similar to right-clicking a file in
> the file explorer and selecting "Edit".  Other verbs include "open",
> "print", and "properties".

That seems poor to use. If we know that the file is a text file
regardless of its suffix, it would make much more sense to use the
Windows APIs necessary to resolve the association between .txt and a
program, if one exists, and then use the indicated program.

Basically this:

1. Call getenv("EDITOR"); if that yields something use it.

2. Else, dig up the association between .txt and a program. 
   If it exists, use that program.

3. Fallback on notepad.exe or error out.

(Using EDITOR on Windows makes sense in a cross-platform tool
oriented toward cross-platform users.)

-- 
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca