skeeto / impatient-mode

Impatient html mode. See your changes in the browser as you type
215 stars 19 forks source link

`imp-visit-buffer` opens a wrong URL #19

Closed mphojele closed 4 years ago

mphojele commented 5 years ago

I'm loving this plugin, very much. However, imp-visit-buffer seems to be confused about hosting because instead of a URL like this localhost:8080/boo/boo/ it puts the name of my machine as host. There's nothing served there but writing the URL with localhost replacing my machine name works fine. Please help:)

hackerb9 commented 4 years ago

It's a bug where impatient mode is not using the proper httpd-host address. Here's a patch that fixes it:

(defun imp-visit-buffer (&optional arg)
  "Visit the current buffer in a browser.
If given a prefix argument, visit the buffer listing instead."
  (interactive "P")
  (unless (process-status "httpd")
    (httpd-start))
  (unless impatient-mode
    (impatient-mode))
  (let ((url (format "http://%s:%d/imp/"
             (cl-case httpd-host
               ((nil) "0.0.0.0")
               ((local) "localhost")
               (otherwise httpd-host))
             httpd-port)))
    (unless arg
      (setq url (format "%slive/%s/" url (url-hexify-string (buffer-name)))))
    (browse-url url)))
mphojele commented 4 years ago

Thank you🤗

On Thu, 07 Nov 2019, 09:44 hackerb9, notifications@github.com wrote:

It's a bug where impatient mode is not using the proper httpd-host address. Here's a patch that fixes it:

(defun imp-visit-buffer (&optional arg) "Visit the current buffer in a browser.If given a prefix argument, visit the buffer listing instead." (interactive "P") (unless (process-status "httpd") (httpd-start)) (unless impatient-mode (let ((url (format "http://%s:%d/imp/" (cl-case httpd-host ((nil) "0.0.0.0") ((local) "localhost") (otherwise httpd-host)) (system-name) httpd-port))) (unless arg (setq url (format "%slive/%s/" url (url-hexify-string (buffer-name))))) (browse-url url))))

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/skeeto/impatient-mode/issues/19?email_source=notifications&email_token=AKSYGBCRNL5E5VCN2EBV333QSPBOJA5CNFSM4ISHPQB2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEDLQNKQ#issuecomment-550962858, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKSYGBHWNCGPGHKXSXZRXHDQSPBOJANCNFSM4ISHPQBQ .

mphojele commented 4 years ago

I should have closed this issue a long time ago. Sorry.