Commit 34381a13 authored by Andy Stewart's avatar Andy Stewart
Browse files

Avoid eaf open non-exists file as url

parent 331253fa
Loading
Loading
Loading
Loading
+36 −22
Original line number Diff line number Diff line
@@ -443,6 +443,7 @@ We need calcuate render allocation to make sure no black border around render co

(defun eaf-open (url &optional app-name)
  (interactive "FOpen with EAF: ")
  ;; Try set app-name along with url if app-name is set.
  (unless app-name
    (cond ((string-equal url "eaf-demo")
           (setq app-name "demo"))
@@ -474,10 +475,15 @@ We need calcuate render allocation to make sure no black border around render co
                  (eaf-split-preview-windows)
                  (setq app-name "orgpreviewer")
                  )))
          (t
          ((and (not (string-prefix-p "/" url))
                (not (string-prefix-p "~" url))
                (string-match thing-at-point-short-url-regexp url))
           (setq app-name "browser")
           (unless (string-prefix-p "http" url)
             (setq url (concat "http://" url))))))
             (setq url (concat "http://" url)))
           )))
  (if app-name
      ;; Open url with eaf application if app-name is not empty.
      (if (process-live-p eaf-process)
          (let (exists-eaf-buffer)
            ;; Try to opened buffer.
@@ -497,7 +503,15 @@ We need calcuate render allocation to make sure no black border around render co
        ;; Record user input, and call `eaf-open-internal' after receive `start_finish' signal from server process.
        (setq eaf-first-start-url url)
        (setq eaf-first-start-app-name app-name)
    (eaf-start-process)))
        (eaf-start-process)
        (message (format "Opening %s with eaf.%s" url app-name)))
    ;; Output something to user if app-name is empty string.
    (if (or (string-prefix-p "/" url)
            (string-prefix-p "~" url))
        (if (not (file-exists-p url))
            (message (format "EAF: %s is not exists." url))
          (message (format "EAF Don't know how to open %s" url)))
      (message (format "EAF Don't know how to open %s" url)))))

(defun eaf-split-preview-windows ()
  (delete-other-windows)