diff --git a/eaf.el b/eaf.el index 8ccf241..ba3dab4 100644 --- a/eaf.el +++ b/eaf.el @@ -7,7 +7,7 @@ ;; Copyright (C) 2018, Andy Stewart, all rights reserved. ;; Created: 2018-06-15 14:10:12 ;; Version: 0.5 -;; Last-Updated: Mon Jan 13 00:14:30 2020 (-0500) +;; Last-Updated: Mon Jan 13 02:32:58 2020 (-0500) ;; By: Mingde (Matthew) Zeng ;; URL: http://www.emacswiki.org/emacs/download/eaf.el ;; Keywords: @@ -879,26 +879,6 @@ of `eaf--buffer-app-name' inside the EAF buffer." (rename-buffer title) (throw 'find-buffer t)))))))) -(defun eaf-browser-goto-history () - "Search and open a link from the EAF Browser history. - -This function works best if a fuzzy searh package is enabled." - (interactive) - (let ((browser-history-file-path - (concat user-emacs-directory - (file-name-as-directory "eaf") - (file-name-as-directory "browser") - (file-name-as-directory "history") - "log.txt"))) - (when (file-exists-p browser-history-file-path) - (let* ((history-list (with-temp-buffer (insert-file-contents browser-history-file-path) - (split-string (buffer-string) "\n" t))) - (history (completing-read "[EAF/browser] Goto History: " history-list)) - (history-url (progn (string-match "[^\s]+$" history) - (match-string 0 history)))) - (when history-url - (eaf-open-browser history-url)))))) - (dbus-register-signal :session "com.lazycat.eaf" "/com/lazycat/eaf" "com.lazycat.eaf" "open_buffer_url" @@ -1071,6 +1051,26 @@ In that way the corresponding function will be called to retrieve the HTML (eaf-open url "browser" arguments)) (message "[EAF/browser] %s is an invalid URL." url))) +;;;###autoload +(defun eaf-open-browser-with-history () + "A wrapper around `eaf-open-browser' that provides browser history candidates. + +This function works best if paired with a fuzzy search package." + (interactive) + (let ((browser-history-file-path + (concat user-emacs-directory + (file-name-as-directory "eaf") + (file-name-as-directory "browser") + (file-name-as-directory "history") + "log.txt"))) + (when (file-exists-p browser-history-file-path) + (let* ((history-list (with-temp-buffer (insert-file-contents browser-history-file-path) + (split-string (buffer-string) "\n" t))) + (history (completing-read "[EAF/browser] Enter URL or Goto History: " history-list)) + (history-url (when (string-match "[^\s]+$" history) + (match-string 0 history)))) + (eaf-open-browser history-url))))) + ;;;###autoload (define-obsolete-function-alias 'eaf-open-url #'eaf-open-browser)