Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better handle history #60

Open
romainfrancois opened this issue Dec 7, 2023 · 0 comments
Open

Better handle history #60

romainfrancois opened this issue Dec 7, 2023 · 0 comments

Comments

@romainfrancois
Copy link
Collaborator

Right now (as of #59), we handle history with a xeus::make_in_memory_history_manager() but this sort of bypass the way R would usually deal with history, which would e.g. give access to history() etc ...

One way to contribute to the history is by calling the C_addhistory routine from the utils:: package, just like what timestamp() does:

> utils::timestamp
function (stamp = date(), prefix = "##------ ", suffix = " ------##", 
    quiet = FALSE) 
{
    stamp <- paste0(prefix, stamp, suffix)
    .External2(C_addhistory, stamp)
    if (!quiet) 
        cat(stamp, sep = "\n")
    invisible(stamp)
}

IIUC, we might have to define these:

extern void (*ptr_R_loadhistory)(SEXP, SEXP, SEXP, SEXP);
extern void (*ptr_R_savehistory)(SEXP, SEXP, SEXP, SEXP);
extern void (*ptr_R_addhistory)(SEXP, SEXP, SEXP, SEXP);

and then probably inherit from history_manager:

History manager
---------------

The ``xhistory_manager`` class is used to store the ``execute_request`` messages sent by the
frontend. Typical usage is when the console client connects to a kernel that has already executed
some code: it asks the ``history_manager`` for its records and prints them so that the user knows
what happened before.

``xeus`` provides a default implementation of ``xhistory_manager`` that stores the messages in
memory. It is possible to provide a different history manager by defining a class that inherits
from ``xhistory_manager`` and implements the abstract methods:
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

No branches or pull requests

1 participant