Skip to content

Commit

Permalink
Try to find the recentest bmk file and use
Browse files Browse the repository at this point in the history
its directory (#6).

* helm-firefox.el (helm-get-firefox-user-init-dir): Do it.
  • Loading branch information
Thierry Volpiatto committed Mar 6, 2020
1 parent 7bb259f commit 7065e01
Showing 1 changed file with 23 additions and 10 deletions.
33 changes: 23 additions & 10 deletions helm-firefox.el
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,29 @@ On Mac OS X, probably set to \"~/Library/Application Support/Firefox/\"."

(defun helm-get-firefox-user-init-dir ()
"Guess the default Firefox user directory name."
(let* ((moz-dir helm-firefox-default-directory)
(moz-user-dir
(with-current-buffer (find-file-noselect
(expand-file-name "profiles.ini" moz-dir))
(goto-char (point-min))
(prog1
(when (search-forward "Path=" nil t)
(buffer-substring-no-properties (point) (point-at-eol)))
(kill-buffer)))))
(file-name-as-directory (concat moz-dir moz-user-dir))))
(with-temp-buffer
(insert-file-contents
(expand-file-name "profiles.ini" helm-firefox-default-directory))
(goto-char (point-min))
(prog1
(cl-loop with dir
with atime = 0
while (re-search-forward "Path=" nil t)
for tmpdir = (expand-file-name
(buffer-substring-no-properties
(point) (point-at-eol))
helm-firefox-default-directory)
for bmkfile = (expand-file-name "bookmarks.html" tmpdir)
for at = (if (file-exists-p bmkfile)
(float-time (nth 5 (file-attributes bmkfile)))
(max atime 0))
when (> at atime)
do (setq dir tmpdir
atime at)
finally return (file-name-as-directory
(expand-file-name
dir helm-firefox-default-directory)))
(kill-buffer))))

(defcustom helm-firefox-bookmark-user-directory
(helm-get-firefox-user-init-dir)
Expand Down

0 comments on commit 7065e01

Please sign in to comment.