Skip to content

Conversation

@pjungkamp
Copy link
Contributor

Description

The history_since_<id> value expansion allows incremental parsing of a buffer's history.

Resolves #5345

Example

declare-option int my_last_history_id
define-command my-process-history ...

# process the initial buffer history
my-process-history %val{bufname} 0 %val{history}
set-option buffer my_last_history_id 0

# only process new history changes on idle
hook buffer NormalIdle %{
  evaluate-commands %exp{
    my-process-history \
      %%val{bufname} \
      %%opt{my_last_history_id} \
      %%val{history_since_%opt{my_last_history_id}}
  }
  set-option buffer my_last_history_id %val{history_id}
}

The `history_since_<id>` value expansion allows incremental parsing of a
buffer's history.

    declare-option int my_last_history_id
    define-command my-process-history ...

    # process the initial buffer history
    my-process-history %val{bufname} 0 %val{history}
    set-option buffer my_last_history_id 0

    # only process new history changes on idle
    hook buffer NormalIdle %{
        evaluate-commands %exp{
            my-process-history \
                %%val{bufname} \
                %%opt{my_last_history_id} \
                %%val{history_since_%opt{my_last_history_id}}
        }
        set-option buffer my_last_history_id %val{history_id}
    }
@mawww
Copy link
Owner

mawww commented Jul 6, 2025

This looks big enough to warrant a copyright waiver, and I dont think I have one from you, can you add a copyright waiver commit to this PR (see the CONTRIBUTING file)

@pjungkamp
Copy link
Contributor Author

pjungkamp commented Jul 7, 2025

You've already got one! (From my EnterDirectory hook PR)

07000ad

@mawww
Copy link
Owner

mawww commented Jul 8, 2025

Indeed, sorry about that.

@mawww mawww merged commit 2823c5e into mawww:master Jul 8, 2025
4 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[REQUEST] HistoryCommit hook for incremental updates of buffers in external tools.

2 participants