diff options
author | Yuchen Pei <id@ypei.org> | 2025-01-29 09:51:41 +1100 |
---|---|---|
committer | Yuchen Pei <id@ypei.org> | 2025-01-29 09:51:41 +1100 |
commit | 80fbb1ee3f4951308fdbe49045abc1539927f5f3 (patch) | |
tree | 430bd59030cbb7d86c3ac3c77d4de10937f9d730 /emacs/.emacs.d | |
parent | 8c8a175bfe767013186cdd92b13b3ad18d841f05 (diff) |
[emacs] Adding a function to get firefox bookmarks and history
Diffstat (limited to 'emacs/.emacs.d')
-rw-r--r-- | emacs/.emacs.d/lisp/my/my-web.el | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/emacs/.emacs.d/lisp/my/my-web.el b/emacs/.emacs.d/lisp/my/my-web.el index aeb5a6d..3d1f9d3 100644 --- a/emacs/.emacs.d/lisp/my/my-web.el +++ b/emacs/.emacs.d/lisp/my/my-web.el @@ -202,5 +202,26 @@ https://emacs.stackexchange.com/questions/40887/in-org-mode-how-do-i-link-to-int (setq files (delq var files))))) (apply orig-fun files client args)) +(defvar my-firefox-profile-dir nil "Firefox profile dir") +(defvar my-firefox-place-limit 1000 "Firefox urls result limit") + +(defun my-firefox-places (&optional query) + (let ((where + (mapconcat + (lambda (word) (format "(url LIKE '%%%s%%' OR title LIKE '%%%s%%')" word word)) + (split-string (or query "")) + " AND "))) + (unless (string-empty-p where) (setq where (format "WHERE %s" where))) + (with-temp-buffer + (call-process "sqlite3" nil t nil + (format "file://%s/places.sqlite?immutable=1" + my-firefox-profile-dir) + (format + "SELECT url,title FROM moz_places %s ORDER BY visit_count desc limit %d" + where + my-firefox-place-limit)) + (buffer-string) + ))) + (provide 'my-web) ;;; my-web.el ends here |