zsh-workers
 help / color / mirror / code / Atom feed
From: Jade Fink <zsh@jade.fyi>
To: zsh-workers@zsh.org
Subject: Allowing for replacing the history backing store?
Date: Fri, 16 Jul 2021 17:40:31 -0700	[thread overview]
Message-ID: <6013019d-8746-ebf9-b7aa-e971e6741b7c@jade.fyi> (raw)

Hi!

There's a project I've been thinking about for a long while which is to 
make a new shell history system using Postgres, allowing for keeping 
better metadata such as working directory among other things with the 
history and eliminating the need to use a traditional history file. I 
want to implement it as a native-code ZSH module (maintained out of 
tree), ideally.

 From poking around the zsh codebase briefly, it seems like there is not 
really currently a way to do that as the history functions are built 
into zsh itself rather than a module.

Before I write a patch, I want to run it past you to see if it's 
reasonable and there's not an easier way to do it otherwise.

I was thinking of putting pointers to all the history functions that one 
might need to change out to implement a new back end in a structure and 
have a pointer to it so you can change it out for your own set (that may 
do something else to fulfil the request such as poke a database or 
something else), then replace all the functions with indirections, e.g.:

struct histfuncs {
	char *(*hgetline)(void);
	// ...
}

mod_export struct histfuncs default_histfuncs = {
	.hgetline = default_hgetline,
	// ...
}

mod_export struct histfuncs *histfuncs = &default_histfuncs;

char *
hgetline(void)
{
	return histfuncs->hgetline();
}

If I implemented this approach, would such a patch be taken?

Jade


                 reply	other threads:[~2021-07-17  0:41 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6013019d-8746-ebf9-b7aa-e971e6741b7c@jade.fyi \
    --to=zsh@jade.fyi \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).