zsh-workers
 help / color / mirror / code / Atom feed
* Allowing for replacing the history backing store?
@ 2021-07-17  0:40 Jade Fink
  0 siblings, 0 replies; only message in thread
From: Jade Fink @ 2021-07-17  0:40 UTC (permalink / raw)
  To: zsh-workers

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


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-07-17  0:41 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-17  0:40 Allowing for replacing the history backing store? Jade Fink

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).