53 Commits

Author SHA1 Message Date
36d45b38af avoid nodiscard compiler warnings
We got a lot of the warnings for unchecked Result / tl::expected; let's
handle those.
2026-08-20 15:05:32 -07:00
ac52584562 build: modernize meson usage
Since we require meson 1.3(.2), we can modernize the usage a bit,
as well as improve some logic

- use / instead of join_paths
- use option.allowed() instead of !option.disable()
- use cxx.get_supported_arguments
- use fs.copyfile instead of configure_file
- show a summary at the end of the configuration
2026-08-20 15:05:32 -07:00
4a8b797665 scm: add changed-object, use if-let/when-let
Add a changed-object (to complement changed), and some rework some of
the code with the new if-let/when-let macros.
2026-08-20 15:05:31 -07:00
8c9734066f scm: add if-let/when-let macros
Add if-let/if-let*/when-let/when-let* macros for internal use in
mu-scm.el.
2026-08-20 15:05:31 -07:00
bb57f7a226 scm: add utc-offset and date-object methods
Add methods for getting the utc-offset of message, and get the sent-date
as an SRFI-19 date object.
2026-08-20 15:05:31 -07:00
702da53ad9 scm: implement field / fields procedures
Add procedures field & fields to get information about mu's database
fields, similar to "mu info fields".

Add docs & tests as well.
2026-08-20 15:05:31 -07:00
5235e16f54 scm: support configuration
Support a configuration function, with the system-configuration.

Update docs.

Add a tests for language, using the configuration to see if we support
it.
2026-08-20 15:05:31 -07:00
31b0fd45c2 scm: improve store->alist
Include all non-internal properties in the output alist.

Clean up some of the type-conversion (using concepts)

Fix conversion to bool
2026-08-20 15:05:31 -07:00
ae8607093b scm: avoid finalizer race with message-map
Let guile handle the message-map (with weak-hash-table), so we avoid the
cleanup race.

Better handle the fd handling (and avoid calling gc() each time when
we're nearing the limit)
2026-08-20 15:05:31 -07:00
b29e8cb37b scm: fix some issues in scm implementation
- Fix some comment copy-pasta
- Fix some typos
- Make write-to-file exception safe
- Make plist->alist O(n) rather than O(n*n)
2026-08-20 15:05:31 -07:00
60ed8f1a12 scm/c++: fix review issues in handler code
- Fix comments and some debug strings (copy-pasta)
- Fix mime-stream destruction (g_object_unref)
- Fix type-checking of scm types
2026-08-20 15:05:31 -07:00
4489d513be migrate to std::ranges
Move the various seq_ functions, as well as std::(stable_)sort,
std::accumulate, std::transform, std::find, std::find_if to their C++20
std::ranges counterparts.
2026-08-20 15:05:31 -07:00
a347d3ada0 properties: support system-properties
Support "system" properties, i.e., library versions, whether
language-detection, scm is supported.

Make these more generic (with display strings), so we can handle them
more automatic int mu-cmd-info.
2026-08-20 15:05:30 -07:00
6dca68b989 scm: support --eval
With the ~--eval~ option you can evaluate an expression in mu/scm
environment. For example:

$ mu scm --eval \
  '(format #t "found ~d match(es)\n" (length (mfind "hello")))'
found 7173 match(es)

Add command-line parameter and implement.
2026-08-20 15:05:28 -07:00
6099af565d scm: update example with time->string
Example was still using the obsolete name.

Fixes #2891
2026-08-20 15:04:27 -07:00
043f0ce337 mu-scm: don't depend on dir order in tests
Some of the tests were using (mfind "") to find messages, but since some
messages don't have dates the order is implicitly defined by the directory
order. This usually works, but not always (i.e. guix).

So let's make the behavior deterministic.

Fixes #2888
2026-08-20 15:04:27 -07:00
b855a0dc93 scm: mention guix in manual
Fixes #2889.
2026-08-20 15:04:27 -07:00
8afef75b30 scm: add convenience methods root-maildir, personal-addresses
For a store, so to avoid assoc-ref.
2026-08-20 15:04:27 -07:00
52f44653b0 scm: return empty lists instead of #f for some methods
Some methods that returned lists would return ~#f~ when there were no
results (e.g., to, from, cc, bcc, references, labels); however, it's
nicer to return an empty list instead, which what we now do. Technically a
breaking change, but justified while we are still 'experimental'.
2026-08-20 15:04:27 -07:00
20d18cb7ee scm.texi: some improvements in text 2026-08-20 15:04:26 -07:00
74c0a231b7 scm: small improvements to manual 2026-08-20 15:04:26 -07:00
543c43f078 Replace "the the " with "the " 2026-08-20 15:04:26 -07:00
f8160e152b scm: implement store personal?, rename all-labels->labels
Add a method personal? to check if some string looks like a personal address;
add docs / tests as well.

Rename the all-labels method into simply 'labels'

Make some define* into define-method, for consistency.
2026-08-20 15:04:26 -07:00
013233c041 scm: clean up scm running
Split run_script / run_repl more clearly; update callers.
2026-08-20 15:04:25 -07:00
d66a29cf5e scm: add support for logging
Add functions debug, info, warning, critical which log to the mu logging
facilities.
2025-08-24 17:36:15 +03:00
d5a0fce4cf scm: implement blocking / non-blocking modes
Implement running the REPL on background thread. That way, we can _share_ the
store&.
2025-08-24 11:54:08 +03:00
6b89f4abae scm: message_parts: use cons instead of append
It's faster.
2025-08-22 08:13:55 +03:00
3b7e5507f7 scm: to_scm: use cons, not append
It's faster.
2025-08-22 08:08:32 +03:00
c207921cfa scm: all_labels: use cons instead of append
it's faster.
2025-08-22 08:05:10 +03:00
cd249ffaf0 scm: cfind: use cons instead of append
It's faster.
2025-08-22 09:02:09 +03:00
24e25f9663 scm: mfind: use cons instead of append, eval lazy
For the list building, using cons is much faster. So traverse the results
_backwards_, and then cons gives us the right order.

Don't eval when creating the list, but do so lazily (when requested in the
message, in mu-scm.scm)
2025-08-22 09:01:59 +03:00
b52920bfcf scm: update documentation
Describe the new --listen flag, and give some example of its usage, including
some snippet for using it with Emacs/Geiser.
2025-08-17 12:02:34 +03:00
e56c848952 scm: support --listen flag for uds
Support the --listen flag to mu scm, to start listening on a Unix domain socket.
2025-08-17 12:02:29 +03:00
910cec591f scm: add support for labels + tests
Add procedures 'label' (for a message) and all-labels (for a store).
2025-08-15 21:03:19 +03:00
34d3bf2e28 tests: only build when needed
Build the tests lazily, i.e., not before `meson test`. This helps with
build-times.
2025-08-15 21:01:05 +03:00
f95ae6cffe mu-scm: avoid compiler warning
designated initializers are a C++20 feature.
2025-07-19 10:42:21 +03:00
1b3199a552 mu-scm: implement message->alist
Implement message->alist; i.e. to convert the mu4e-style plist into an idiomatic
alist. Add it as a message slot, initializing it lazily.

Update the message accessors to use the alist.

Add tests, docs.
2025-07-12 09:35:37 +03:00
d24d87336a mu-scm: use cc-prefix for C++ objects
Both in SCM and C++, use cc- for functions and objects defined in C++.
Makes it a little easier to track.
2025-07-12 09:35:37 +03:00
5c52ccc256 mu-scm: add docstrings for symbols
Use some snippet from
  https://git.wolfsden.cz/guile-wolfsden/tree/wolfsden/documentation.scm
and document some symbols (variables, classes etc.)
2025-07-12 09:35:37 +03:00
6d72aa5c7f mu-scm: implement store->alist
Get information about the store as an alist.

Scm + cc + test + doc.
2025-07-12 09:35:37 +03:00
7b4aea432e mu-scm: add filename procedure for mime-part 2025-07-12 09:35:37 +03:00
b02aa57686 mu-scm: implement mime-part handling, refact
Implement accessing the MIME-parts + docs  + test.

Implement saving attachments to file.

Implement creating messages from files.

Refactor / rename functions to be more uniform.
2025-07-07 10:57:13 +03:00
3f53e4b439 mu-scm-message: don't require c++ >= 17 2025-06-30 22:52:13 +03:00
9360a641a9 mu-scm: add string->time and time->string
Replace the iso-date->time-t and v.v. functions with something more
customizable. Add more tests.

Use some (internal for now) %preferences variable for the defaults. TBD... maybe
should become a fluid?
2025-06-30 22:11:46 +03:00
f2699a4b95 mu-scm: add support for thread-id
Code + doc + test
2025-06-30 21:57:29 +03:00
cc39c9cae6 mu-scm: add support for mailing-list
method + doc + test
2025-06-30 21:57:29 +03:00
f66172db3b mu-scm: add support for references
Message method + test + docs.
2025-06-30 21:57:29 +03:00
123c0c1bc8 mu-scm: defer scm exceptions with c++ throw/catch
SCM exception are "non-local exits", which mean that c++ objects don't get their
DTOR called when leaving the scope.... this break RAII, leaks mem etc.

So instead, we avoid SCM exceptions (where we can), and throw C++ exceptions,
and only use SCM-expections in the catch block.
2025-06-30 21:57:29 +03:00
ca46c09ccb mu-scm: add full-message support (body/header)
Implement support for "header" and "body" procedures, with require loading the
message file from disk, and create a foreign object for the message.

We keep those alive in a vector, and hook up a finalizer.

Update docs & tests as well.
2025-06-30 21:57:29 +03:00
812d78be49 mu-scm: add options, some tweaks
Add the (options) procedure + docs.

Some internal tweaks / clean-ups.
2025-06-30 21:57:29 +03:00