Skip to content

Commit

Permalink
fallback to eaf-open-browser if history file doesn't exist
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthewZMD committed Jan 30, 2020
1 parent f8a2d3c commit 6560449
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions eaf.el
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
;; Copyright (C) 2018, Andy Stewart, all rights reserved.
;; Created: 2018-06-15 14:10:12
;; Version: 0.5
;; Last-Updated: Thu Jan 30 09:38:24 2020 (-0500)
;; Last-Updated: Thu Jan 30 13:29:30 2020 (-0500)
;; By: Mingde (Matthew) Zeng
;; URL: http://www.emacswiki.org/emacs/download/eaf.el
;; Keywords:
Expand Down Expand Up @@ -1079,16 +1079,17 @@ This function works best if paired with a fuzzy search package."
(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] Search || URL || History: " history-list))
(history-url (when (string-match "[^\s]+$" history)
(match-string 0 history))))
(if (and history-url
(string-match "^\\(https?://\\)?[a-z0-9]+\\([-.][a-z0-9]+\\)*.+\\..+[a-z0-9.]\\{2,5\\}\\(:[0-9]{1,5}\\)?\\(/.*\\)?$" history-url))
(eaf-open-browser history-url)
(eaf-open-browser history))))))
(if (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] Search || URL || History: " history-list))
(history-url (when (string-match "[^\s]+$" history)
(match-string 0 history))))
(if (and history-url
(string-match "^\\(https?://\\)?[a-z0-9]+\\([-.][a-z0-9]+\\)*.+\\..+[a-z0-9.]\\{2,5\\}\\(:[0-9]{1,5}\\)?\\(/.*\\)?$" history-url))
(eaf-open-browser history-url)
(eaf-open-browser history)))
(call-interactively 'eaf-open-browser))))

(defun eaf-search-it (&optional search-string)
"Search SEARCH-STRING using a search engine.
Expand Down

0 comments on commit 6560449

Please sign in to comment.