help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Help with PHP setup


From: Jean-Christophe Helary
Subject: Re: Help with PHP setup
Date: Sun, 22 Jul 2018 22:56:43 +0900


> On Jul 21, 2018, at 12:53, Bob Proulx <bob@proulx.com> wrote:
> 
> Jean-Christophe Helary wrote:
>> So we can actually have a function that replaces the path part of
>> the file by a localhost url and run a command that opens that in the
>> default browser.
> 
> Won't that stack up new tabs endlessly?  Or at least every time the
> function runs, which as I understand it would be every time the buffer
> was saved to a file?
> 
>> Nothing icky about it, we just need the correct parameters to put
>> that together.
> 
> As I said, someone will prove that it is possible.  :-)

On macOS it seems the "open " command targets the same tab so I don't seem to 
have to be worried about that:

(defun myLocalhostTest ()
    "saves and opens the file opened in the current buffer into localhost"
  (interactive)
  (save-excursion
  (save-buffer)
  (setq myRoot "http://localhost:8888/";)
  (setq myFile (file-name-nondirectory (buffer-file-name)))
  (setq myTestCommand (concat "open " myRoot myFile))
  (shell-command myTestCommand)))

The above trivial code needs improvements to handle cases where the file is not 
at the root of localhost, but that can wait for now :)

Jean-Christophe Helary
-----------------------------------------------
http://mac4translators.blogspot.com @brandelune




reply via email to

[Prev in Thread] Current Thread [Next in Thread]