]> git.neil.brown.name Git - edlib.git/log
edlib.git
2 years agoconfig: allocate a local data
NeilBrown [Sat, 17 Jun 2023 23:27:57 +0000 (09:27 +1000)]
config: allocate a local data

config will need to store data, so it needs storage.
So create that storage with the command the first
time config:load is called.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agoIntroduce strstarts()
NeilBrown [Sun, 18 Jun 2023 00:44:39 +0000 (10:44 +1000)]
Introduce strstarts()

It is a common pattern to check if a string starts with a fixed string.
So match this a #defined thing.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agodoc: allow key to be passed to doc:set: in ->str2
NeilBrown [Sun, 18 Jun 2023 00:03:25 +0000 (10:03 +1000)]
doc: allow key to be passed to doc:set: in ->str2

If "doc:set:" or "doc:append:" is called with an empty key appended to
the name, find the key in ->str2.
This avoids the need for string allocation if the key is in a variable.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agoIntroduce ->root pointer in panes.
NeilBrown [Mon, 12 Jun 2023 00:47:27 +0000 (10:47 +1000)]
Introduce ->root pointer in panes.

pane->root gets straight to the root, so we can efficiently access
global state.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agoIntroduce pane_register_root()
NeilBrown [Sat, 10 Jun 2023 04:03:34 +0000 (14:03 +1000)]
Introduce pane_register_root()

pane_register_root() is an internal interface, called only by
editor_new(), which creates a root pane, with ->parent pointing to
itself.
pane_register() and doc_register() must now be given a non-NULL parent.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agoRevise pane_reparent()
NeilBrown [Thu, 15 Jun 2023 06:12:35 +0000 (16:12 +1000)]
Revise pane_reparent()

Treating a disconnected pane (p->parent == p) as a special cas in
pane_reparent() is unpleasant as disconnected panes are not something I
want.

So change pane_reparent() to have a different rule for determining
whether the new parent needs to be attached below p->parent first.

Also ensure Child-Notify notifications are consistant.

If the reparent fails, LOG an error and teach python interface to
trigger an exception.

Finally, only notmuch depended on the special meaning of disconnected
panes, so change it to fit the new model and add better explanations.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agoIntroduce Child-Notify
NeilBrown [Sat, 17 Jun 2023 06:40:39 +0000 (16:10 +0930)]
Introduce Child-Notify

Child-Notify replaces
  ChildClosed
  ChildRegistered
  ChildMoved
  ChildReplaced

as a pane that handles one typically needs to handle them all.
The difference notifications are reflected in ->num:

 1 : new child registered - ->focus is the child
-1 : existing child is being closed - ->focus is that child
-2 : existing child is being moved away - ->focus is tha child
 2 : existing child replaced - ->focus in the new child
     This follows a "-2" where the old was moved away.

Several handlers are extended to handle all possibilities.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agoCombine doc_attach() and do_doc_assign()
NeilBrown [Sat, 17 Jun 2023 11:41:49 +0000 (21:41 +1000)]
Combine doc_attach() and do_doc_assign()

These are always called together, so make them one function.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agoAllow do_doc_assign() to fail.
NeilBrown [Sat, 17 Jun 2023 11:34:26 +0000 (21:34 +1000)]
Allow do_doc_assign() to fail.

do_doc_assign() can fail.  If it does, point will be NULL and can get
derefed.
So allow it to fail and close the pane.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agotile: be extra careful when merging a tile into it's parent.
NeilBrown [Fri, 16 Jun 2023 11:19:15 +0000 (21:19 +1000)]
tile: be extra careful when merging a tile into it's parent.

When a parent tile gets down to just one child, the child is subsumed
into the parent.
This requires that the parent really is a tile pane.  As pane_reparent()
and change parantage, it is possible that it isn't.
So add extra checks before assuming the types of things.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agoAdd a config-file parser.
NeilBrown [Wed, 14 Jun 2023 10:21:58 +0000 (20:21 +1000)]
Add a config-file parser.

An "ini" style file can be read to set global attributes, configure
auto-loading of modules (listing commands that they define) and
eventually per-doc configurations based on file name.

All module loading requests are now in edlib.ini.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agoglobal-set-attr: support append.
NeilBrown [Wed, 14 Jun 2023 10:27:51 +0000 (20:27 +1000)]
global-set-attr: support append.

Make it easy to append to a global attr.  Note the semantics are a bit
different to appending to a pane attr. I wonder what is best.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agocore-keymap: handle map changing when command is run.
NeilBrown [Wed, 14 Jun 2023 10:25:33 +0000 (20:25 +1000)]
core-keymap: handle map changing when command is run.

Even if a command returns Efallthrough, it could have changed the map
(by auto-loading a module).
So we cannot assume the "pos" is still correct.  So recalculate it each
time when scanning all commands with a given prefix.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agomergeview: auto-position on merge at first visit.
NeilBrown [Tue, 13 Jun 2023 22:22:21 +0000 (08:22 +1000)]
mergeview: auto-position on merge at first visit.

When first visiting a file with a merge, auto-find that merge.

I'm not sure this is a good idea, and won't know until I try.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agomergeview: handle mode-swap-mark
NeilBrown [Tue, 13 Jun 2023 22:08:20 +0000 (08:08 +1000)]
mergeview: handle mode-swap-mark

Intercept the swap-mark command and instead cycle among corresponding
places in the three branches.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agoemacs: handle cx:c-x by resending the equivalent command.
NeilBrown [Mon, 12 Jun 2023 12:01:45 +0000 (22:01 +1000)]
emacs: handle cx:c-x by resending the equivalent command.

This allows the command to be intercepted without encode emacs code
bindings elsewhere.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agowiggle: include merge number in attached attributes.
NeilBrown [Mon, 12 Jun 2023 11:53:37 +0000 (21:53 +1000)]
wiggle: include merge number in attached attributes.

By including the merge number, it is possible to find corresponding
locations in the different branches.

Also add a leading 'M' if this is the start of a merge, or 'L' if the
start of a line within a merge.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agodetect and limit recursion
NeilBrown [Mon, 12 Jun 2023 22:42:31 +0000 (08:42 +1000)]
detect and limit recursion

If depth of recursion every reaches 100, fail any request.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agomergeview: capture < and > on marker lines.
NeilBrown [Mon, 12 Jun 2023 11:46:01 +0000 (21:46 +1000)]
mergeview: capture < and > on marker lines.

When cursor is on a marker line, capture < and > for manipulating the
merge.

On the first marker: lines are moved between top of orig and preceding
content.
On the second marker: lines are moved between bottom of orig and
following content.

I don't know what I want on other marker lines.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agomergeview/wiggle: improvements for space-only conflicts.
NeilBrown [Mon, 12 Jun 2023 09:40:56 +0000 (19:40 +1000)]
mergeview/wiggle: improvements for space-only conflicts.

1/ change how the "wiggle" is reported.  It is no longer reported
   by "set-wiggle".  Instead a new "get-result" function returns
   various results including the "wiggle".
2/ count how many conflicts only involve white space.  If that is
   all the conflicts, then still calculate the wiggle.
3/ If a merge only has space conflicts, use blue for the merge
   markers rather the red (or green).
4/ mark the green merge markers bold so they stand out more
5/ When adding attrs, annotate conflicts which are space only,
   and respond to that with underlines instead of inverse red.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agomergeview: add commands to apply the merge.
NeilBrown [Mon, 12 Jun 2023 05:14:01 +0000 (15:14 +1000)]
mergeview: add commands to apply the merge.

If :A-m has a numeric arg, then it now behaves differently and often
edits the merge rather than finding another:

-ve: discard the patch and just keep the original.
0 : if no conflicts remain, apply the patch
1 : discard the original and just keep the "after" part.

9 : if there is a selected merge, cut the path and leave the original
    if there is no selected merge, paste the recently cut diff,
     using the selection as the original.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agowiggle: return the wiggled result from set-wiggle.
NeilBrown [Mon, 12 Jun 2023 05:11:24 +0000 (15:11 +1000)]
wiggle: return the wiggled result from set-wiggle.

If set-wiggle is given ->comm2, and if there are no conflicts, return
the successful wiggle as a string.
Also if the attribute passed is an empty string, don't add any markup.
This can be used to only get the wiggle.

The intention of the "wiggle" command was to return the wiggle, but
there is some much commonality with set-wiggle that it seemed easiest to
add the functionality there.
So discard the unimplemented 'wiggle' command.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agorexel: remove abort() calls not in #ifdef DEBUG
NeilBrown [Mon, 12 Jun 2023 01:26:41 +0000 (11:26 +1000)]
rexel: remove abort() calls not in #ifdef DEBUG

if DEBUG is set, it is OK to abort.  If not, don't.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agoMark various 'static' values as 'const'.
NeilBrown [Mon, 12 Jun 2023 01:21:37 +0000 (11:21 +1000)]
Mark various 'static' values as 'const'.

Anything that can be const now it.

 git grep -nH 'static[^(]*[=;]' | grep -v const | grep -v 'struct map'

can help find things that should be const, or maybe should put moved to
the 'editor' pane.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agoTODO.md: various revisions.
NeilBrown [Fri, 9 Jun 2023 23:27:16 +0000 (09:27 +1000)]
TODO.md: various revisions.

Remove things that are done
Choose things to do next
give more detail for mergeview changes

Signed-off-by: NeilBrown <neil@brown.name>
2 years agoautospell: use pane_too_long() to limit background work.
NeilBrown [Fri, 9 Jun 2023 08:26:02 +0000 (18:26 +1000)]
autospell: use pane_too_long() to limit background work.

Rather than an arbitrary count limit, use pane_too_long() to limit how
much work is done in the background.

But keep the low limit when TESTING so the test has something
interesting too see.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agolinecount: use pane_too_long() to break up line count
NeilBrown [Fri, 9 Jun 2023 08:18:13 +0000 (18:18 +1000)]
linecount: use pane_too_long() to break up line count

Rather than arbitrary numbers of lines to be counted before we take a
break and check for user activity, use pane_too_long() to decide when to
drop a mark, and when to take a break.

Also reduce the default and minimum timeout to 100ms which should help
interactivity a bit.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agoUse event:on-idle for short-timeout background tasks.
NeilBrown [Fri, 9 Jun 2023 03:41:35 +0000 (13:41 +1000)]
Use event:on-idle for short-timeout background tasks.

Background tasks like linecount, spell check, and make parsing now use
the background queue of event:on-idle

Signed-off-by: NeilBrown <neil@brown.name>
2 years agoDrop the on_idle- multicall.
NeilBrown [Fri, 9 Jun 2023 03:25:15 +0000 (13:25 +1000)]
Drop the on_idle- multicall.

event:on-idle is doing all on-idle stuff, so we don't need the on_idle-
multicall any more.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agoeditor: use event:on-idle to delayed-free the store.
NeilBrown [Fri, 9 Jun 2023 03:23:22 +0000 (13:23 +1000)]
editor: use event:on-idle to delayed-free the store.

Now there is nothing for editor_clean_up to do, so discard that.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agoeditor: use event:on-idle to free marks.
NeilBrown [Fri, 9 Jun 2023 03:21:27 +0000 (13:21 +1000)]
editor: use event:on-idle to free marks.

Delayed-free of marks now happens with event:on-idle

Signed-off-by: NeilBrown <neil@brown.name>
2 years agoeditor: move delayed free of panes to event:on-idle
NeilBrown [Fri, 9 Jun 2023 03:18:33 +0000 (13:18 +1000)]
editor: move delayed free of panes to event:on-idle

Schedule an on-idle event when we queue the first pane to free, and use
it to free them all.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agodiscard editor-on-idle in favour of event:on-idle.
NeilBrown [Fri, 9 Jun 2023 03:08:25 +0000 (13:08 +1000)]
discard editor-on-idle in favour of event:on-idle.

editor-on-idle calls now use event:on-idle.  Priority 1 for closing
panes, priority 0 for other things.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agoCall pane_refresh() from event:on-idle
NeilBrown [Fri, 9 Jun 2023 03:05:55 +0000 (13:05 +1000)]
Call pane_refresh() from event:on-idle

pane_refresh is now integral to core-pane - external code cannot call it.

When the root pane is first damaged, we schedule the refresh to happen
on-idle at priority 1 - before any background task.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agoevent: add on-idle support
NeilBrown [Fri, 9 Jun 2023 02:12:36 +0000 (12:12 +1000)]
event: add on-idle support

The event: library now supports event:on-idle.

There are 3 priorities.

2 - fast immediate action, typically freeing memory that might be been
    in use during previous action
1 - slow immediate action, typically pane_refresh()
0 - slow background action, only one of these is performed per loop

Signed-off-by: NeilBrown <neil@brown.name>
2 years agolibevent: split out run_list()
NeilBrown [Thu, 8 Jun 2023 23:38:14 +0000 (09:38 +1000)]
libevent: split out run_list()

I'll want more places that run a list of events, so split out this
functionality.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agolibevent: split event_list
NeilBrown [Thu, 8 Jun 2023 23:21:00 +0000 (09:21 +1000)]
libevent: split event_list

Rather than keeping poll events on the same list as events handled by
libevent, split the list in two.
This means we don't need POLL_FD to identify the poll events.
That, combined with the use of event_get_fd() means we don't need to
store the fd in the event struct.  Just the 'num' is sufficient.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agolibevent: minor fixes.
NeilBrown [Thu, 8 Jun 2023 23:15:04 +0000 (09:15 +1000)]
libevent: minor fixes.

1/ event_del can be called unconditionally.  It is a no-op if it has
already been called.
2/ missing event_free calls.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agolibevent: don't store mseconds separate from num.
NeilBrown [Thu, 8 Jun 2023 11:44:11 +0000 (21:44 +1000)]
libevent: don't store mseconds separate from num.

When mseconds is used it is alway identical to num.
So just use num.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agonotmuch: when moving among messages, set focus to query pane.
NeilBrown [Thu, 8 Jun 2023 10:47:34 +0000 (20:47 +1000)]
notmuch: when moving among messages, set focus to query pane.

Leaving the focus in the message pane feels clumsy.  So let's try always
moving back to the query pane.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agoemacs: add CX-< and CX-> to scroll left or right.
NeilBrown [Thu, 8 Jun 2023 05:54:34 +0000 (15:54 +1000)]
emacs: add CX-< and CX-> to scroll left or right.

The first CX-< switch from wrapping to no-wrapping.  Then it shifts 8
units at a time, unless a number is given.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agolib-url: only follow link one it has been shown in message-line
NeilBrown [Wed, 7 Jun 2023 22:36:45 +0000 (08:36 +1000)]
lib-url: only follow link one it has been shown in message-line

The first time a url is activated, only display it and don't follow it.
The second time it can be followed.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agorender-lines: add "Activate" support.
NeilBrown [Wed, 7 Jun 2023 22:30:58 +0000 (08:30 +1000)]
render-lines: add "Activate" support.

When render-lines gets "Activate" it looks up the attrs at the mark and
if there is an active-tag, it calls "Activate:tag".

This makes email:select unnecessary.

lib-url uses Activate to respond to K:Enter

Signed-off-by: NeilBrown <neil@brown.name>
2 years agoChange "Mouse-Activate:" to simply "Activate:"
NeilBrown [Wed, 7 Jun 2023 22:03:58 +0000 (08:03 +1000)]
Change "Mouse-Activate:" to simply "Activate:"

I want to activate buttons with the keyboard, so change the command to
drop the "Mouse-" prefix.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agoIntroduce lib-url
NeilBrown [Sun, 4 Jun 2023 11:28:12 +0000 (21:28 +1000)]
Introduce lib-url

lib-url isolates the url-handling: finding in a document, adding
markup,a and responding to that markup to highlight and activate.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agolinecount: when async needs a full count - do it.
NeilBrown [Tue, 6 Jun 2023 20:54:23 +0000 (06:54 +1000)]
linecount: when async needs a full count - do it.

If async linecount is asked to find a mark, and we don't have a full
line count, then we aren't going to find the mark (because async
handlers forget about it).
So be honest up front and just forget about it.  This ensure
consistency.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agolinecount: make it possible to disable
NeilBrown [Sun, 4 Jun 2023 23:40:48 +0000 (09:40 +1000)]
linecount: make it possible to disable

Make it possible to disable linecount ...  because sometime it is too
slow.

Also make it easier to tune the timing.
And slow it down a bit because it sometimes impacts usability.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agodoc-email: ensure doc:get-boundary skips invisible parts
NeilBrown [Sun, 4 Jun 2023 03:41:00 +0000 (13:41 +1000)]
doc-email: ensure doc:get-boundary skips invisible parts

A boundary must be at the start of a VISIBLE part to be useful.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agomarkup: do boundary checks *before* getting a char.
NeilBrown [Sun, 4 Jun 2023 03:40:09 +0000 (13:40 +1000)]
markup: do boundary checks *before* getting a char.

If we do the boundary check after, we drop a character.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agoChange rules for mark passed to doc:content
NeilBrown [Sun, 4 Jun 2023 02:34:59 +0000 (12:34 +1000)]
Change rules for mark passed to doc:content

The 'start' mark passed to doc:content must not now be changed.
Some handlers did change it, others didn't.
Several callers didn't want it changed (so passed dup), a few didn't
care.

Due to the extra chars that can be passed, it might be awkward to return
a precise mark, and the caller might not care.
So leave it up to the callback to report any marks needed, and always
dup the mark before moving it.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agolinecount: enable for make-viewer
NeilBrown [Sun, 4 Jun 2023 02:08:08 +0000 (12:08 +1000)]
linecount: enable for make-viewer

I don't remember exactly why it was a problem to line-count make-viewer,
possible because make out for the kernel could get very big.
But as linecount is faster and better, re-enable it.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agotests: 02-grep failure should not be fatal.
NeilBrown [Sun, 4 Jun 2023 01:59:29 +0000 (11:59 +1000)]
tests: 02-grep failure should not be fatal.

02-grep has been flakey for a while and now it never succeeds.
Fix it a bit so it sometimes passes, and make it non-fatal until I can
fix the problem.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agolinecount: use extra-text in doc:content
NeilBrown [Sun, 4 Jun 2023 01:53:01 +0000 (11:53 +1000)]
linecount: use extra-text in doc:content

When a doc:content callback is given extra text, use that to expedite
linecount.
This makes it even faster, and justifies doing more work per iteration
for async counting.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agolinecount: use doc:content to scan more quickly.
NeilBrown [Sun, 4 Jun 2023 01:41:12 +0000 (11:41 +1000)]
linecount: use doc:content to scan more quickly.

Rather than calling doc:char repeatedly, use doc:content.  It is faster.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agodoc: fix doc_default_content
NeilBrown [Sun, 4 Jun 2023 01:18:42 +0000 (11:18 +1000)]
doc: fix doc_default_content

We were ignoring ->mark2 (endpoint) and sending a CHAR_RET() rather than
a char.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agorender-format: fix off-by-one in doc:content
NeilBrown [Sun, 4 Jun 2023 01:17:50 +0000 (11:17 +1000)]
render-format: fix off-by-one in doc:content

When an end mark was given we didn't collect the last character.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agoformat: handle line-count properly for format2
NeilBrown [Sun, 4 Jun 2023 00:33:07 +0000 (10:33 +1000)]
format: handle line-count properly for format2

There is along standing bug that the linecount appears to be elevated in
a formatted view anywhere but at the start of the line.
Also word counts don't work properly.

Now that we can attach line counting to a view, this can be fixed.

Also: allow view-based linecount to be disabled by parent.  It is
notably slower and for notmuch search view it is too slow.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agolinecount: enable async line-counts
NeilBrown [Sat, 3 Jun 2023 02:38:03 +0000 (12:38 +1000)]
linecount: enable async line-counts

When requested, linecounts progress about 300 lines at a time with only
the first 1000 done sync.  The rest happen on a timer.

Don't test the async line count though - it is too hard to match the timing.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agolinecount: intro option of sync/async counting.
NeilBrown [Sat, 3 Jun 2023 01:32:55 +0000 (11:32 +1000)]
linecount: intro option of sync/async counting.

lib-view doesn't need a completely up-to-date number.  Other callers do.
So add a flag to support this.
CountLines will always be async when no mark is given.
When a mark is given, only async if num==1
CountLinesAsync is always async.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agolinecount: fix need_recalc()
NeilBrown [Sat, 3 Jun 2023 06:13:25 +0000 (16:13 +1000)]
linecount: fix need_recalc()

I was testing the wrong thing - or freeing the wrong thing.

If a range is small - clear the first mark and discard the second.  Then
from the first to whatever comes next will be recalculated.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agolinecount: ensure counts are uptodate for goto-line
NeilBrown [Sat, 3 Jun 2023 01:27:56 +0000 (11:27 +1000)]
linecount: ensure counts are uptodate for goto-line

We need fully up-to-date counts for goto.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agolinecount: optimise when no counting needed.
NeilBrown [Sat, 3 Jun 2023 01:20:51 +0000 (11:20 +1000)]
linecount: optimise when no counting needed.

If a mark wasn't passed, and the pane count is up to date, there is no
need to do anything, so optimise it all away.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agodoc-email: support linecount
NeilBrown [Sat, 3 Jun 2023 00:59:38 +0000 (10:59 +1000)]
doc-email: support linecount

doc-email-view now intercepts linecount requests and ensures they happen
against the view, rather against the raw document.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agodoc-email: be more subtle with default visibility.
NeilBrown [Sat, 3 Jun 2023 00:55:59 +0000 (10:55 +1000)]
doc-email: be more subtle with default visibility.

We don't want large (base64) attachments to be visible by default, nor
do we want transformations to appear too early.
So mark all spacers, the orig-headers, and the orig first part as
visible, and everything else invisible.

This will, for example, stop LineCount from counting too much of it if
it happens to start before final visibility is configured

Signed-off-by: NeilBrown <neil@brown.name>
2 years agolinecount: ensure we start a visible beginning of document
NeilBrown [Sat, 3 Jun 2023 00:49:37 +0000 (10:49 +1000)]
linecount: ensure we start a visible beginning of document

The document we are counting might be a 'view' and the early lines might
be clipped off.  So use doc:set-ref to move to the beginning as visible
from the focus.
Also simplify the code as two conditions each have exactly the same result.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agoAlways call CountLines on the focus
NeilBrown [Sat, 3 Jun 2023 00:34:08 +0000 (10:34 +1000)]
Always call CountLines on the focus

A view might hide some lines, and might intercept CountLines so exclude
those lines from the count.
As a line count is a particular view on the file, it should be
consistent with other views.
So always use the current focus when calling CountLines.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agolinecount: improve notify:replaced handling
NeilBrown [Fri, 2 Jun 2023 22:25:37 +0000 (08:25 +1000)]
linecount: improve notify:replaced handling

If the region being replaced is large, me might need to discard marks
that are in it.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agolinecount: simplify count_calculate()
NeilBrown [Fri, 2 Jun 2023 22:04:59 +0000 (08:04 +1000)]
linecount: simplify count_calculate()

There is no need to make a special case of m being after end, because m
is always at the start of the file.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agolinecount: remove 'start' arg from count_calculate()
NeilBrown [Fri, 2 Jun 2023 09:32:10 +0000 (19:32 +1000)]
linecount: remove 'start' arg from count_calculate()

We always pass NULL for the 'srart' to count_calculate().  So remove all
code that only runs if start != NULL, and remove 'start'.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agolinecount: don't pass mark to doc:CountLines at startup
NeilBrown [Fri, 2 Jun 2023 09:27:58 +0000 (19:27 +1000)]
linecount: don't pass mark to doc:CountLines at startup

When we create line CountLines pane, we jut want to initialise the line
count.  So don't pass in ->mark.  It is meaningless and is ignored.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agolinecount: ignore Notify:Clip
NeilBrown [Fri, 2 Jun 2023 09:14:03 +0000 (19:14 +1000)]
linecount: ignore Notify:Clip

We cannot possible get a Notify:Clip message, so don't try to handle it.

Notify:Clip comes from a child, and we don't have any.
The only commands we can get are ones we have explicitly requested from
the doc.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agolinecount: use a more natural means of registering Notify:Close
NeilBrown [Fri, 2 Jun 2023 09:10:12 +0000 (19:10 +1000)]
linecount: use a more natural means of registering Notify:Close

Rather than overloading doc:Countlines, use the normal doc:request:
to register for Notify:Close.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agoline-count: limit ranges based on words and chars as well as lines.
NeilBrown [Fri, 2 Jun 2023 08:40:34 +0000 (18:40 +1000)]
line-count: limit ranges based on words and chars as well as lines.

Increase the gap between markers from 50 to 100 - just because.
Also limit to 1000 words or 10,000 chars, just in case there are
some very big lines.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agopython: change how modules are loaded into the interpreter
NeilBrown [Fri, 2 Jun 2023 07:24:00 +0000 (17:24 +1000)]
python: change how modules are loaded into the interpreter

Each edlib module is now a separate python module.
They must all "import edlib" and can find the editor pane in
"edlib.editor"
They must also import any modules they use.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agopython: discard python-load
NeilBrown [Fri, 2 Jun 2023 06:24:25 +0000 (16:24 +1000)]
python: discard python-load

The "python-load" command has never been used, and might not work.
Discard it until I have a reason to resurrect it.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agoncurses: don't block in nc_external_viewer
NeilBrown [Fri, 2 Jun 2023 03:07:28 +0000 (13:07 +1000)]
ncurses: don't block in nc_external_viewer

Rather than blocking the whole editor while waiting for use to
copy/paste for plain-text screen, set a flag to say that the display is
suspended, and resume on next key stroke collected in the normal way.

Also timeout after 30 seconds.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agonotmuch: reply to first VISIBLE text part
NeilBrown [Thu, 1 Jun 2023 05:40:58 +0000 (15:40 +1000)]
notmuch: reply to first VISIBLE text part

Instead of choosing first text part, choose first visible text part for
interpolating into reply.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agoinput: remove unnecessary 'safe' annotations.
NeilBrown [Thu, 1 Jun 2023 05:20:12 +0000 (15:20 +1000)]
input: remove unnecessary 'safe' annotations.

Marking local vars as 'safe' makes no sense.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agoemacs-search: guard against ->target closing too.
NeilBrown [Thu, 1 Jun 2023 05:10:59 +0000 (15:10 +1000)]
emacs-search: guard against ->target closing too.

If ->target closes, we should get closed first.  But we shouldn't really
depend on that, so explicitly catch the close notification and handle it.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agoemacs-search: get notification when panes close.
NeilBrown [Thu, 1 Jun 2023 04:53:11 +0000 (14:53 +1000)]
emacs-search: get notification when panes close.

If we hold a reference to a pane, we must get Notify:Close notifications
from it, and clear the pointer if that happens.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agonotmuch: improve handling of "%d quoted lines" marker
NeilBrown [Wed, 31 May 2023 21:26:10 +0000 (07:26 +1000)]
notmuch: improve handling of "%d quoted lines" marker

Clicking on the marker now stays on the line.  As few other bits aren't
quite perfect yet.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agorexel: don't accidentally make back-refs with impossible capnum.
NeilBrown [Wed, 31 May 2023 11:12:32 +0000 (21:12 +1000)]
rexel: don't accidentally make back-refs with impossible capnum.

If we try to make a backref with an impossible CAPture NUMber, it will
look like an invalid opcode, and rexel will abort() (which it
shouldn't...).  So make sure it doesn't happen.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agonotmuch: wait for thread_p
NeilBrown [Wed, 31 May 2023 08:12:43 +0000 (18:12 +1000)]
notmuch: wait for thread_p

I wasn't waiting for this subprocess to exit.  It would sometimes hang
around as a zombie.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agow3m: convert html entities in URL.
NeilBrown [Wed, 31 May 2023 08:08:21 +0000 (18:08 +1000)]
w3m: convert html entities in URL.

I didn't realise that w3m put html entities in the URL - e.g. &amp;

Signed-off-by: NeilBrown <neil@brown.name>
2 years agoTODO: small updates to v1.0 goal.
NeilBrown [Wed, 31 May 2023 00:38:22 +0000 (10:38 +1000)]
TODO: small updates to v1.0 goal.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agoTODO: revise priorities.
NeilBrown [Wed, 31 May 2023 00:36:03 +0000 (10:36 +1000)]
TODO: revise priorities.

Discard priorities that aren't that important, and sort others into
small, medium, and large.

'Trivial' can be things that aren't mentioned elsewhere, should be
trivial, and should done first.  If not done first, copy to proper home.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agoTODO: merge bugs into priorities.
NeilBrown [Tue, 30 May 2023 10:53:43 +0000 (20:53 +1000)]
TODO: merge bugs into priorities.

All "Bugs" are now just "priorities", and exist both in that list, and
in the list for the relevant module.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agoTODO: all current-priorities must be in correct section too
NeilBrown [Tue, 30 May 2023 10:29:55 +0000 (20:29 +1000)]
TODO: all current-priorities must be in correct section too

"current priorities" are now copied from where-ever.  Nothing should be
there that isn't somewhere else.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agoTODO: move the [1] stuff.
NeilBrown [Tue, 30 May 2023 09:54:57 +0000 (19:54 +1000)]
TODO: move the [1] stuff.

Instead of using [1] for high-priority suggestions, just copy them into
the 'Current priorities' section.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agoTODO: remove anything marked [X]
NeilBrown [Tue, 30 May 2023 09:53:29 +0000 (19:53 +1000)]
TODO: remove anything marked [X]

That which is done, is done.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agoWait for processes we fork.
NeilBrown [Mon, 29 May 2023 11:37:26 +0000 (21:37 +1000)]
Wait for processes we fork.

Keep track of the xdg-open processes we fork, and wait for them as
appropriate.

Also make sure we catch the correct TimeoutExpired except when a notmuch
search takes too long, so we can kill and wait for the process.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agopdf,doc: mark urls.
NeilBrown [Sun, 28 May 2023 07:58:03 +0000 (17:58 +1000)]
pdf,doc: mark urls.

Copy the url-marking code from notmuch as use it to mark urls in
converted pdf and doc.
I don't know that this is a good idea.. Let's see if I find it useful.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agomultipart: don't assume sub-panes never disappear.
NeilBrown [Sun, 28 May 2023 07:25:27 +0000 (17:25 +1000)]
multipart: don't assume sub-panes never disappear.

If a part-pane sends a Notify:Close we REALLY mustn't touch it again.
So we must set the pointer to NULL.  Even though we start closing down,
something bad could happen.

I had a crash where the attempt to send "doc:closed" to all panes
crashed on one that had already been closed.

So remove the 'safe' marking, handle the fall-out, and set .pane to NULL
when told to.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agotests: filter out duplicate "Display" lines.
NeilBrown [Sun, 28 May 2023 06:59:54 +0000 (16:59 +1000)]
tests: filter out duplicate "Display" lines.

The 02-grep often duplicates some Display lines, apparently at random.
I don't know why and it doesn't show a display bug.
So filter them out to avoid unnecessary test failure.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agolib-renderline: Introduce word-wrap.
NeilBrown [Sun, 28 May 2023 06:42:29 +0000 (16:42 +1000)]
lib-renderline: Introduce word-wrap.

If word-wrap is set, make all spaces wrap-points, except at the start of
the line.
Enable this in email reading, and in mark-down.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agoChange rules for doc:render-line with mark2
NeilBrown [Sun, 28 May 2023 02:34:01 +0000 (12:34 +1000)]
Change rules for doc:render-line with mark2

When doc:render-line is called with mark2, this doesn't interrupt the
rendering, but simply reports (via ->num in the callback) the offset
where mark2 was found.

Now ->num is either negative, or the number of chars to process.
NO_NUMERIC is no longer relevant and is not tested for.

I think this is simpler as ->num and ->mark2 are not independent.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agorenderline: fix cursor pos after early wrap.
NeilBrown [Sun, 28 May 2023 02:16:21 +0000 (12:16 +1000)]
renderline: fix cursor pos after early wrap.

If a line wraps before he end, due to an early wrap marker, the cursor
will appear where it would have been if the line had been truncated
rather then wrapped.

We need to detect when a "flush" stopped because if found a wrap marker,
and to adjust the cursor pos in that case.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agorenderline: ensure attr lists always start/end with ','
NeilBrown [Sun, 28 May 2023 00:22:46 +0000 (10:22 +1000)]
renderline: ensure attr lists always start/end with ','

Also make sure they *only* contains ",," at a location to pop back too.

Some of the code already put ',' at start, and most put ',' at end, and
some code depended on this more than others.
Make it more uniform.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agomark: separate mark:moving from mark:arrived
NeilBrown [Sat, 27 May 2023 07:46:18 +0000 (17:46 +1000)]
mark: separate mark:moving from mark:arrived

The mark:moving notification was originally for when a specific mark
moved at all.
For b64 I extended it to also notify when *any* mark moved to a specific
mark.
This can cause illegal nested notification if a mark:moving handler
tries to move a (non-specific) mark.  That is bad.

So separate the two: Add mark:arrived for when a mark is moved to a
flagged marks.

Also make sure all new marks aren't flagged.  I invert the sense of the
flag and call it "MARK_FLAG_WATCHED".  This will be clear by default,
and only set once the (renamed) mark_watch() is called.

Signed-off-by: NeilBrown <neil@brown.name>
2 years agow3m: filter out markup when extracting text
NeilBrown [Sat, 27 May 2023 00:39:59 +0000 (10:39 +1000)]
w3m: filter out markup when extracting text

Add a doc:content overlay on w3m docs which strip out markup and convert
html &entities;

Signed-off-by: NeilBrown <neil@brown.name>