Commit Graph

28 Commits

Author SHA1 Message Date
Robin Jarry 9bd2e0c84f msgpart: factorize mime type and filename construction
Reduce code duplication.

Signed-off-by: Robin Jarry <robin@jarry.cc>
Acked-by: Moritz Poldrack <moritz@poldrack.dev>
2022-10-16 11:35:24 +02:00
Robin Jarry 45bff88515 open: allow overriding default program
Instead of xdg-open (or open on MacOS), allow forcing a program to open
a message part. The program is determined in that order of priority:

1) If :open has arguments, they will be used as command to open the
   attachment. If the arguments contain the {} placeholder, the
   temporary file will be substituted, otherwise the file path is added
   at the end of the arguments.

2) If a command is specified in the [openers] section of aerc.conf for
   the part MIME type, then it is used with the same rules of {}
   substitution.

3) Finally, fallback to xdg-open/open with the file path as argument.

Update the docs and default config accordingly with examples.

Fixes: https://todo.sr.ht/~rjarry/aerc/64
Co-authored-by: Jason Stewart <support@eggplantsd.com>
Signed-off-by: Robin Jarry <robin@jarry.cc>
Tested-by: Tim Culverhouse <tim@timculverhouse.com>
Acked-by: Moritz Poldrack <moritz@poldrack.dev>
2022-10-01 15:47:25 +02:00
Robin Jarry 92ba132d70 open: simplify code
There is no need for convoluted channels and other async fanciness.
Expose a single XDGOpen static function that runs a command and returns
an error if any.

Caller is responsible of running this in an async goroutine if needed.

Signed-off-by: Robin Jarry <robin@jarry.cc>
Tested-by: Tim Culverhouse <tim@timculverhouse.com>
Acked-by: Moritz Poldrack <moritz@poldrack.dev>
2022-10-01 15:46:49 +02:00
Moritz Poldrack 9cffc45f03 go: removed io/ioutil
Since the minimum required version of Go has been bumped to 1.16, the
deprecation of io/ioutil can now be acted upon. This Commit removes the
remaining dependencies on ioutil and replaces them with their io or os
counterparts.

Signed-off-by: Moritz Poldrack <git@moritz.sh>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-08-22 09:30:19 +02:00
Robin Jarry c841f36513 tabs: rename SelectedTab to SelectedTabContent
This function returns an ui.Drawable. Use a more explicit name. This
prepares for adding a new SelectedTab function which will return
an ui.Tab.

Signed-off-by: Robin Jarry <robin@jarry.cc>
Acked-by: Koni Marti <koni.marti@gmail.com>
2022-07-23 22:00:21 +02:00
Tim Culverhouse 96db50c4f0 open: fix mimetype discovery for encrypted or signed messages
Mimetype discovery for the :open command is based on the BodyStructure
of the message. This patch fixes the method which got the BodyStructure
of the message to a more generalized one, which is set post-encryption
and post-validation. This allows encrypted or signed message parts to
have their proper mimetype discovered.

Fixes: https://todo.sr.ht/~rjarry/aerc/50
Reported-by: ~ph14nix
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
Acked-by: Koni Marti <koni.marti@gmail.com>
2022-06-26 12:07:44 +02:00
Tim Culverhouse 8f9bb2b289 pgp: fix pipe|open|save command behavior
Signed and/or encrypted PGP messages did not behave properly for pipe,
open, and save commands. Specifically, the proper Message Part would not
be passed to the command in the MessageViewer. This is due to the
encapsulation of the body structure. This patch fixes the behavior for
piping|opening|saving of message parts.

Fixes: https://todo.sr.ht/~rjarry/aerc/47
Reported-by: ~ph14nix
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
Tested-by: Moritz Poldrack <moritz@poldrack.dev>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-06-24 21:08:21 +02:00
Koni Marti e1d8bc4d17 msgviewer: open http links from messages
Parse http links from a message and display them as completions in the
:open-link command.

Add the following binds to the [view] section in your binds.conf:
<C-l> = :open-link <space>

Parsing can be disabled in aerc.conf by setting parse-http-links to
false in the viewer section.

Thanks to Moritz for the help with the regular expression.

Signed-off-by: Koni Marti <koni.marti@gmail.com>
Reviewed-by: Moritz Poldrack <git@moritz.sh>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-06-14 22:12:48 +02:00
Moritz Poldrack ae83373fa6 logging: added a log on panic
Since panics still regularly "destroy" the terminal, it is hard to get a
stack trace for panics you do not anticipate. This commit adds a panic
handler that automatically creates a logfile inside the current working
directory.

It has to be added to every goroutine that is started and will repair
the terminal on a panic.

Signed-off-by: Moritz Poldrack <git@moritz.sh>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-03-23 20:56:09 +01:00
Moritz Poldrack 4bc43d2741 all: fix minor issues found by staticcheck
Signed-off-by: Moritz Poldrack <git@moritz.sh>
2022-03-12 21:00:23 +01:00
Robin Jarry 0d645bcebd go.mod: change base git url
I'm not sure what are the implications but it seems required.

Link: https://github.com/golang/go/issues/20883
Signed-off-by: Robin Jarry <robin@jarry.cc>
2021-11-05 10:21:45 +01:00
Reto Brunner 8ea86cea41 Get rid of the aerc.PushError(" " + $string) idiom
The individual callers should not be responsible for padding
2021-01-30 14:04:23 +01:00
Reto Brunner 949781fa0a Refactor lib/open to accept user provided arguments
* Get rid of open_darwin
	It just lead to code duplication for a simple one string change.
	Instead we query it during initialization
* Accept user provided arguments
	"open" on MacOS accepts things like -A to use a specific application
	Pass trough arguments the user provided in order to facilitate this
* Refactor the function to a struct
	This makes it more convenient for the caller and avoids signatures like
	lib.OpenFile(nil, u.String(), nil) which are fairly unreadable
2021-01-30 14:04:23 +01:00
Andrew Jeffery fda3f43e7c Allow open to be asynchronous
This stops the ui being blocked while the resource is opened. The wait
ensures that resources are reclaimed when the process finishes while
aerc is still running.
2020-07-08 09:07:43 +02:00
Drew DeVault caad1b2c06 Revert "Add Style configuration"
This reverts commit 0f78f06610.
2020-05-28 10:32:42 -04:00
Drew DeVault 76a91813d8 Revert "Remove duration from the status methods"
This reverts commit f06d683688.
2020-05-28 10:32:32 -04:00
Reto Brunner f06d683688 Remove duration from the status methods
We always set 10 seconds anyhow, might as well do that without repeating ourselfs.
2020-05-27 08:11:40 +02:00
Reto Brunner 0f78f06610 Add Style configuration
The following functionalities are added to configure aerc ui styles.
- Read stylesets from file with very basic fnmatch wildcard matching
- Add default styleset
- Support different stylesets as part of UiConfig allowing contextual
  styles.
- Move widgets/ui elements to use the stylesets.
- Add configuration manual for the styleset
2020-05-27 07:57:10 +02:00
Reto Brunner 13a6a3fa71 FetchBodyPart doesn't need the parent body structure 2020-05-17 11:44:38 +02:00
Galen Abell 95fb35b701 Try to open attachments with correct extension
The temporary file created when opening an attachment is currently saved
without an extension, which prevents matching on file ending with
xdg-open.
2020-04-06 13:15:56 +02:00
Drew DeVault df20f1cd03 Refactoring: remove store from PartInfo 2020-03-09 09:12:32 -04:00
Reto Brunner 6b0483dd92 msgview/open: remove manual decoding 2020-01-20 09:21:29 -05:00
Reto Brunner 9096049f75 FetchBodyParts: decode source in the workers
Previously the workers returned a mixture of decoded / encoded parts.
This lead to a whole bunch of issues.
This commit changes the msgviewer and the commands to assume parts to already
be decoded
2020-01-05 16:02:45 -05:00
Wagner Riffel 6838c23478 all: purge redundant underscores
Signed-off-by: Wagner Riffel <wgrriffel@gmail.com>
2019-09-04 16:30:57 -10:00
Drew DeVault 363aab5cc1 Make :pipe command more generic 2019-07-05 12:21:12 -04:00
Ben Burwell 1bb1a80156 Use "open" instead of "xdg-open" on Darwin systems 2019-07-04 10:58:33 -04:00
Gregory Mullen 2a0961701c Implement basic tab completion support
Tab completion currently only works on commands. Contextual completion
will be added in the future.
2019-06-29 14:24:19 -04:00
Réouven Assouly ce475e4952 commands/msgview: add open command 2019-06-17 14:52:52 -04:00