From: Jean-Christophe Helary <brandelune@gmail.com>
To: Help Gnu Emacs mailing list <help-gnu-emacs@gnu.org>
Subject: Re: Help with PHP setup
Date: Mon, 23 Jul 2018 00:53:08 +0900 [thread overview]
Message-ID: <9A05B106-B738-44E4-814E-78FD1132D34F@gmail.com> (raw)
In-Reply-To: <978017CF-F2AC-40C0-BC86-8B504872FC8A@gmail.com>
> On Jul 23, 2018, at 0:44, Jean-Christophe Helary <brandelune@gmail.com> wrote:
>
>> On Jul 23, 2018, at 0:36, Noam Postavsky <npostavs@gmail.com> wrote:
>>
>> On 22 July 2018 at 11:20, Jean-Christophe Helary <brandelune@gmail.com> wrote:
>>
>>> (setq myTestCommand (concat "open " myServerRoot myFile)) ;; this "open " command only works on macOS... I don't know equivalents on Linux.
>>
>> By the way, xdg-open is approximately equivalent on many GNU/Linux
>> distros; you might also consider using Emacs'
>> browse-url-default-browser function, which tries looking for other
>> browsers if the former fails.
>
> Nice hint :) Thank you !
So, I guess I have something working for my case now:
(defun myLocalhostTest ()
"saves and opens the file opened in the current buffer into localhost"
(interactive)
(global-set-key (kbd "s-r") 'myLocalhostTest)
(save-excursion
(save-buffer)
(setq myLocalRoot "/Applications/MAMP/htdocs/")
(setq myServerRoot "http://localhost:8888/")
(setq myFile (substring (buffer-file-name) (length myLocalRoot)))
;; the 2 lines below are useful for some WP files, but I'm not sure yet how the whole thing works
(if (equal (car (cdr (split-string myFile "/"))) "wp-content")
(setq myFile (concat (car (split-string myFile "/")) "/" (file-name-nondirectory (buffer-file-name)))))
;; end of the WP special case
(setq myURL (concat myServerRoot myFile))
(browse-url-default-browser myURL)))
That works for all the php/html files I have, at least those that are in similar relative position vs the localhost root.
I'm sure there are better ways to achieve a similar result, but that's good enough for now :) Thank you all.
Jean-Christophe Helary
-----------------------------------------------
http://mac4translators.blogspot.com @brandelune
next prev parent reply other threads:[~2018-07-22 15:53 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-15 20:10 Help with PHP setup taariqq
2018-07-19 23:57 ` Jean-Christophe Helary
2018-07-20 2:32 ` Van L
2018-07-20 4:14 ` Jean-Christophe Helary
2018-07-20 5:47 ` Van L
2018-07-20 7:46 ` Jean-Christophe Helary
2018-07-20 7:52 ` Van L
2018-07-20 23:10 ` Bob Proulx
2018-07-20 23:37 ` Jean-Christophe Helary
2018-07-21 3:53 ` Bob Proulx
2018-07-21 13:17 ` Jean-Christophe Helary
2018-07-22 13:56 ` Jean-Christophe Helary
2018-07-22 15:20 ` Jean-Christophe Helary
2018-07-22 15:36 ` Noam Postavsky
2018-07-22 15:44 ` Jean-Christophe Helary
2018-07-22 15:53 ` Jean-Christophe Helary [this message]
[not found] ` <mailman.3937.1532129854.1292.help-gnu-emacs@gnu.org>
2018-07-21 3:38 ` Rusi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=9A05B106-B738-44E4-814E-78FD1132D34F@gmail.com \
--to=brandelune@gmail.com \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.