~rjarry/aerc-devel

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
5 5

[PATCH aerc v2] commands: add configuration for open-link

Details
Message ID
<20230308202209.487459-1-contact@kchibisov.com>
DKIM signature
missing
Download raw message
Patch: +8 -5
This should provide a way to configure link opener for users not having
xdg-open or similarly named script in the first place.

Signed-off-by: Kirill Chibisov <contact@kchibisov.com>
---
 CHANGELOG.md          | 1 +
 config/aerc.conf      | 3 ++-
 doc/aerc-config.5.scd | 7 ++++---
 lib/open.go           | 2 +-
 4 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index cc22944..08023ae 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,6 +7,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

### Added

- Configuration for `:open-link` via `[openers]` section in `aerc.conf`.
- New column-based message list format with `index-columns`.
- Add a `msglist_answered` style for answered messages.
- Compose `Format=Flowed` messages with `format-flowed=true` in `aerc.conf`.
diff --git a/config/aerc.conf b/config/aerc.conf
index cb6e864..9a8c0d5 100644
--- a/config/aerc.conf
+++ b/config/aerc.conf
@@ -488,13 +488,14 @@ message/rfc822=colorize
[openers]
#
# Openers allow you to specify the command to use for the :open action on a
# per-MIME-type basis.
# per-MIME-type basis and for the :open-link command by using `open-link` key.
#
# {} is expanded as the temporary filename to be opened. If it is not
# encountered in the command, the temporary filename will be appened to the end
# of the command.
#
# Examples:
# open-link=firefox
# text/html=surf -dfgms
# text/plain=gvim {} +125
# message/rfc822=thunderbird
diff --git a/doc/aerc-config.5.scd b/doc/aerc-config.5.scd
index 4d64a6f..b69f404 100644
--- a/doc/aerc-config.5.scd
+++ b/doc/aerc-config.5.scd
@@ -803,9 +803,9 @@ customizations of the built-in filters.

# OPENERS

Openers allow you to specify the command to use for the *:open* action on a
per-MIME-type basis. They are configured in the *[openers]* section of
_aerc.conf_.
Openers allow you to specify the command to use for the *:open* action on
a per-MIME-type basis and for *:open-link* with the open-link key. They are
configured in the *[openers]* section of _aerc.conf_.

_{}_ is expanded as the temporary filename to be opened. If it is not
encountered in the command, the temporary filename will be appened to the end
@@ -815,6 +815,7 @@ Example:

```
[openers]
open-link=firefox
text/html=surf -dfgms
text/plain=gvim {} +125
message/rfc822=thunderbird
diff --git a/lib/open.go b/lib/open.go
index 8477b8f..c25472e 100644
--- a/lib/open.go
+++ b/lib/open.go
@@ -11,7 +11,7 @@ import (
)

func XDGOpen(uri string) error {
	return XDGOpenMime(uri, "", nil)
	return XDGOpenMime(uri, "open-link", nil)
}

func XDGOpenMime(
-- 
2.39.2

[aerc/patches] build success

builds.sr.ht <builds@sr.ht>
Details
Message ID
<CR1AAKZ6POUJ.5WWD3M7NXI2T@cirno2>
In-Reply-To
<20230308202209.487459-1-contact@kchibisov.com> (view parent)
DKIM signature
missing
Download raw message
aerc/patches: SUCCESS in 6m22s

[commands: add configuration for open-link][0] v2 from [Kirill Chibisov][1]

[0]: https://lists.sr.ht/~rjarry/aerc-devel/patches/39570
[1]: contact@kchibisov.com

✓ #953991 SUCCESS aerc/patches/openbsd.yml     https://builds.sr.ht/~rjarry/job/953991
✓ #953990 SUCCESS aerc/patches/alpine-edge.yml https://builds.sr.ht/~rjarry/job/953990
Details
Message ID
<CR1BZT40FKEG.3GID6JRW3VLS1@hades.moritz.sh>
In-Reply-To
<20230308202209.487459-1-contact@kchibisov.com> (view parent)
DKIM signature
missing
Download raw message
Reviewed-by: Moritz Poldrack <moritz@poldrack.dev>
-- 
Moritz Poldrack
https://moritz.sh
Details
Message ID
<CR1UBSXAYSVM.1N1MSMXONYFA8@nano>
In-Reply-To
<20230308202209.487459-1-contact@kchibisov.com> (view parent)
DKIM signature
missing
Download raw message
On Wed Mar 8, 2023 at 12:22 PM PST, Kirill Chibisov wrote:
> This should provide a way to configure link opener for users not having
> xdg-open or similarly named script in the first place.
>
> Signed-off-by: Kirill Chibisov <contact@kchibisov.com>
> ---
>  CHANGELOG.md          | 1 +
>  config/aerc.conf      | 3 ++-
>  doc/aerc-config.5.scd | 7 ++++---
>  lib/open.go           | 2 +-
>  4 files changed, 8 insertions(+), 5 deletions(-)
>
> diff --git a/CHANGELOG.md b/CHANGELOG.md
> index cc22944..08023ae 100644
> --- a/CHANGELOG.md
> +++ b/CHANGELOG.md
> @@ -7,6 +7,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
>  
>  ### Added
>  
> +- Configuration for `:open-link` via `[openers]` section in `aerc.conf`.
>  - New column-based message list format with `index-columns`.
>  - Add a `msglist_answered` style for answered messages.
>  - Compose `Format=Flowed` messages with `format-flowed=true` in `aerc.conf`.
> diff --git a/config/aerc.conf b/config/aerc.conf
> index cb6e864..9a8c0d5 100644
> --- a/config/aerc.conf
> +++ b/config/aerc.conf
> @@ -488,13 +488,14 @@ message/rfc822=colorize
>  [openers]
>  #
>  # Openers allow you to specify the command to use for the :open action on a
> -# per-MIME-type basis.
> +# per-MIME-type basis and for the :open-link command by using `open-link` key.

if my rationale below makes sense, i think this would be better phrased as
"... by using the `open-link` value."

>  #
>  # {} is expanded as the temporary filename to be opened. If it is not
>  # encountered in the command, the temporary filename will be appened to the end
>  # of the command.
>  #
>  # Examples:
> +# open-link=firefox
>  # text/html=surf -dfgms
>  # text/plain=gvim {} +125
>  # message/rfc822=thunderbird
> diff --git a/doc/aerc-config.5.scd b/doc/aerc-config.5.scd
> index 4d64a6f..b69f404 100644
> --- a/doc/aerc-config.5.scd
> +++ b/doc/aerc-config.5.scd
> @@ -803,9 +803,9 @@ customizations of the built-in filters.
>  
>  # OPENERS
>  
> -Openers allow you to specify the command to use for the *:open* action on a
> -per-MIME-type basis. They are configured in the *[openers]* section of
> -_aerc.conf_.
> +Openers allow you to specify the command to use for the *:open* action on
> +a per-MIME-type basis and for *:open-link* with the open-link key. They are

i know Moritz was the one that gave advice in this case.  forgive me if
this sounds pedantic, but is it a key, or a value?

ie the open-link=<...> config option is to hold a value presumably.  in
this case the value is a string with the name of the program used to
open links.  does that sound more accurate?  in which case the phrasing
could be "...the `open-link` value...".

> +configured in the *[openers]* section of _aerc.conf_.
>  
>  _{}_ is expanded as the temporary filename to be opened. If it is not
>  encountered in the command, the temporary filename will be appened to the end
> @@ -815,6 +815,7 @@ Example:
>  
>  ```
>  [openers]
> +open-link=firefox
>  text/html=surf -dfgms
>  text/plain=gvim {} +125
>  message/rfc822=thunderbird
> diff --git a/lib/open.go b/lib/open.go
> index 8477b8f..c25472e 100644
> --- a/lib/open.go
> +++ b/lib/open.go
> @@ -11,7 +11,7 @@ import (
>  )
>  
>  func XDGOpen(uri string) error {
> -	return XDGOpenMime(uri, "", nil)
> +	return XDGOpenMime(uri, "open-link", nil)
>  }
>  
>  func XDGOpenMime(
> -- 
> 2.39.2
Details
Message ID
<CR1V3GOPXUDP.1HKUPY000VL2Q@Zodiac>
In-Reply-To
<CR1UBSXAYSVM.1N1MSMXONYFA8@nano> (view parent)
DKIM signature
missing
Download raw message
 > +a per-MIME-type basis and for *:open-link* with the open-link key. They are
>
> i know Moritz was the one that gave advice in this case.  forgive me if
> this sounds pedantic, but is it a key, or a value?
>
> ie the open-link=<...> config option is to hold a value presumably.  in
> this case the value is a string with the name of the program used to
> open links.  does that sound more accurate?  in which case the phrasing
> could be "...the `open-link` value...".
>

The value though is the `firefox` in and the key is `open-link` in my example.
The section is `[openers]` which goes like

```
[openers]
key = value
```

Where the key is mime type/open-link and the value is the program to execute
for this key.

-- 
Kind Regards,
Kirill Chibisov
Details
Message ID
<CR1YB4VDSQLL.128IC1NKZSI4J@ringo>
In-Reply-To
<20230308202209.487459-1-contact@kchibisov.com> (view parent)
DKIM signature
missing
Download raw message
Hi Kirill,

thanks for your patch. I have a few remarks. Please see below:

Kirill Chibisov, Mar 08, 2023 at 21:22:
> This should provide a way to configure link opener for users not having
> xdg-open or similarly named script in the first place.
>
> Signed-off-by: Kirill Chibisov <contact@kchibisov.com>
> ---
>  CHANGELOG.md          | 1 +
>  config/aerc.conf      | 3 ++-
>  doc/aerc-config.5.scd | 7 ++++---
>  lib/open.go           | 2 +-
>  4 files changed, 8 insertions(+), 5 deletions(-)
>
> diff --git a/CHANGELOG.md b/CHANGELOG.md
> index cc22944..08023ae 100644
> --- a/CHANGELOG.md
> +++ b/CHANGELOG.md
> @@ -7,6 +7,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
>  
>  ### Added
>  
> +- Configuration for `:open-link` via `[openers]` section in `aerc.conf`.

These entries should usually be added at the end of the list unless you
have a good reason to add them on top.

>  - New column-based message list format with `index-columns`.
>  - Add a `msglist_answered` style for answered messages.
>  - Compose `Format=Flowed` messages with `format-flowed=true` in `aerc.conf`.
> diff --git a/config/aerc.conf b/config/aerc.conf
> index cb6e864..9a8c0d5 100644
> --- a/config/aerc.conf
> +++ b/config/aerc.conf
> @@ -488,13 +488,14 @@ message/rfc822=colorize
>  [openers]
>  #
>  # Openers allow you to specify the command to use for the :open action on a
> -# per-MIME-type basis.
> +# per-MIME-type basis and for the :open-link command by using `open-link` key.

This "open-link" MIME type feels a bit weird. It would be more natural
to use a generic URI MIME type such as "x-scheme-handler/*". The only
issue with that "/*" is that it may give the impression that wild cards
are supported so we need to make this explicit.

https://specifications.freedesktop.org/shared-mime-info-spec/shared-mime-info-spec-latest.html#idm45530160413952

> diff --git a/lib/open.go b/lib/open.go
> index 8477b8f..c25472e 100644
> --- a/lib/open.go
> +++ b/lib/open.go
> @@ -11,7 +11,7 @@ import (
>  )
>  
>  func XDGOpen(uri string) error {
> -	return XDGOpenMime(uri, "", nil)
> +	return XDGOpenMime(uri, "open-link", nil)

This will break calling XDGOpen("/path/to/file.foo") if you have an
"open-link" opener defined. I would prefer dropping that XDGOpen
function and replacing the calls by XDGOpenMIME with an explicit MIME
type.
Reply to thread Export thread (mbox)