-
Notifications
You must be signed in to change notification settings - Fork 7
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
Some changes (dynamic completion table, etc) #14
Comments
Of course, why wouldn't I? I really love the improvements you've made. Sounds very cool.
Initially, I wanted it to be simple and provide value for every Emacs user, but then I quickly realized that it would be nice to utilize the full potential of Consult. Do you think it would be better to turn it into a separate Consult extension, such as "consult-browser-hist", or should that be done within the package? Or maybe in a different module. Or perhaps you believe that maintaining both the Consult extension and the vanilla search feature within the same package would become harder to maintain and extend later? I'd be down for whatever option you think is best, but I prefer not to break backward compatibility for people who don't use Consult. |
It kinda changes how the package works from the ground up, so I thought I should ask first. Didn't want to break anyone's workflow. I created a PR.
Hmm, this is a tough question. I think it's better to have
Having a base package that uses Please test the fork if you are able to and let me know what you think.
|
I looked into 2 a little more. It looks like the only way to access the DB in its original location is with the I'm using something like this (not part of the PR): (defcustom browser-hist-cache-timeout (* 60 60)
"How often to refresh the browser history cache."
:type 'natnum
:group 'browser-hist)
(defun browser-hist--make-db-copy (browser &optional force-update)
"Copy browser's history db file to a temp dir.
Browser history file is usually locked, in order to connect to
db, we copy the file."
(let* ((db-file (alist-get browser browser-hist-db-paths))
(hist-db (car (file-expand-wildcards
(substitute-in-file-name db-file))))
(new-fname (browser-hist--db-copy-name browser)))
(if (or force-update
(not (file-exists-p new-fname))
(> (time-to-seconds
(time-subtract
(file-attribute-modification-time (file-attributes hist-db))
(file-attribute-modification-time (file-attributes new-fname))))
browser-hist-cache-timeout))
(copy-file hist-db new-fname :overwite :keep-time)
new-fname))) Where the DB is re-copied if it's more than 30 minutes out of date, or if I call |
Yeah, there's definitely a lag (with the PR) between copying the DB and search, the first time I run the command and start typing it almost always invariably ends up with "sqlite-error ("SQL logic error" "no such table: urls" 1 1)" |
Fixed in #15 |
Hi @agzam,
Thanks for this package, I can see it being very handy.
Are you accepting PRs? I tried it out today and noticed a couple of things:
Search is slow:
completing-read
and Emacs don't like collections of 80,000 entries (as returned by the SQL query). It pretty much locks up Emacs on my laptop.It causes a big garbage collection spike afterwards, which makes sense, especially since you double the size the of the results by adding the description to the url.
In my fork I switched to a fully dynamic completion table, which queries the database with each keystroke and updates the results. (This implements #8.)
It's much better at winnowing large collections now, and is more responsive and generates almost no garbage. If responsiveness is still an issue it's easy to add a debounce on top.
It also gives us searching through annotations (descriptions) for free, since that's folded into the SQL query.
There are disadvantages also: completion styles like Orderless won't work, and since everything is passed to sql you can't search for regexps, by initialism or other fancy ways. This is hard to mitigate without using something like Consult, which splits the input into an "external search" string and a "search with completing-read" string and lets you do both.
I also cleaned up the code a bit, made
browser-hist
a feature, avoided runtime checks, and ensured that the db is closed afterwards (too many open connections to the same file messes up or crashes the Emacs session, something to do with sqlite being a C library in Emacs 29.)The text was updated successfully, but these errors were encountered: