all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: ken <gebser@mousecar.com>
To: rpd <richard@dickinson350.freeserve.co.uk>,
	 GNU Emacs List <help-gnu-emacs@gnu.org>
Subject: Re: html browser preview help
Date: Thu, 03 Sep 2009 17:14:27 -0400	[thread overview]
Message-ID: <4AA031B3.1060908@mousecar.com> (raw)
In-Reply-To: <25283740.post@talk.nabble.com>


Hey, it looks like you're almost there.

Go to the command prompt ("Start | Run | cmd"... something like that)
and try to get explorer to open a local html file.  From what you're
telling me something like:

> start iexplore.exe filename.html

should work.  I don't know... don't use explorer much.  There might be
an option to tell it to pop a new window and/or not to.

Seems to me that since your function is getting through to explorer but
it doesn't know it's supposed to open a particular file, you need to
change something in that "(concat ..." line.  For one thing, since
explorer doesn't use tabs (or does it?), take out the "-new-tab" stuff;
that's a firefox option.  You also have that string in the final "(setq
..." line.

Once you figure out how to get explorer to pop a window and load the
file you designate-- *from the command line*-- then you'll be closer to
getting a working emacs function.


hth,
ken


On 09/03/2009 04:42 PM rpd wrote:
> Hi ken-93
> 
> Thanks again for your helpful reply.
> I have tried to follow your advice & code but I still need some help.
> (BTW O/S=Vista & browser=InternetExplorer8)
> 
> To open internet explorer from the shell> start iexplore.exe
> 
> From this I edited your .emacs defun code to:
> 
> (defun browse-file-url-ie-new-tab (url &optional new-window) 
>   "Open the current file, the file associated with the current buffer, 
>  in a new IE tab." 
>   (interactive "i") 
>   (unless 
>       (string= "" 
>                (shell-command-to-string 
>                 (concat "start iexplore.exe" buffer-file-name 
> ", new-tab)'"))) 
>     (message "Opening in IE new tab: " buffer-file-name))) 
> (setq browse-url-browser-function 'browse-file-url-ie-new-tab) 
> 
> When I try this I get a browser to open at my homepage. 
> (I have tried to edit this in other ways but again with no success).
> 
> The code I have which opens my IE browser normally is:
> 
> (setq 
>  browse-url-browser-function 'browse-url-generic
>  browse-url-generic-program "C:\\Program Files\\Internet
> Explorer\\iexplore.exe")
> 
>  (setq gnus-button-url 'browse-url-generic
>  browse-url-generic-program "C:\\Program Files\\Internet
> Explorer\\iexplore.exe"
>  browse-url-browser-function gnus-button-url)
> 
> Any idea how I should proceed/what I can try to fix this please?
> Many thanks & best wishes
> 
> 
> 
> ken-93 wrote:
>>
>> I've been doing this for a long time in html-helper-mode so, yes, it can
>> be done.  I created my own function though... actually two of them: one
>> to open the current (html) buffer in a new tab (for displaying the html
>> file the first time) and another function to open that same current
>> buffer in the same tab (for displaying the html file subsequent times).
>>
>> You don't say which browser you want to do this with and, of course, the
>> emacs function is going to need to know this (unless you use an
>> environmental variable to designate it, in which case you'll need to
>> determine what that is).  In addition, you'll need to know which version
>> of that browser (whichever it is) you have.  I've been using firefox for
>> quite a time and often, when I upgrade it, the command for loading a url
>> into an existing tab or into a new tab changes; of course this means I
>> have to alter my emacs/html-helper-mode function.
>>
>> In short, the first thing to do is to find out what the commands work
>> from your shell to open a new- or a current-tab (or window, if that's
>> what you prefer) in your browser and give it a url.  Then, after you've
>> successfully done these from the cli, then plug these into an emacs
>> function.  The cli input which works for me to open a file in a new tab
>> is:
>>
>> /usr/bin/firefox -new-tab [url]
>>
>> Other commands work also.  Much depends on what your firefox defaults
>> are.  One configuration I have is to "open new urls in a new tab"; this
>> (for some silly reason) prevents me from opening a url in the current
>> firefox tab.  It didn't always do this; earlier Firefox versions had an
>> option to open a url in a current tab.  The lesson from this is that
>> what cli command you use is going to depend upon, not just which browser
>> you use, but also which *version* of that browser as well as what
>> preferences you've set for that browser/version.
>>
>> You also didn't say which OS you're using and that can of course play a
>> role in which command you'll plug into your emacs function.
>>
>> Anyway, once you figure out what command(s) do(es) what you want, plug
>> it into:
>>
>> ;;Works for opening a file in a new firefox tab
>> (defun browse-file-url-firefox-new-tab (url &optional new-window)
>>   "Open the current file, the file associated with the current buffer,
>>  in a new Firefox tab."
>>   (interactive "i")
>>   (unless
>>       (string= ""
>> 	       (shell-command-to-string
>> 		(concat "firefox -a firefox -remote 'openURL(file://" buffer-file-name
>> ", new-tab)'")))
>>     (message "Opening in Firefox new tab: " buffer-file-name)))
>> (setq browse-url-browser-function 'browse-file-url-firefox-new-tab)
>>
>> Just change the "(concat ..." line to reflect the cli command which
>> works for you.
>>
>> Since firefox (nonsensically) did away with a command-line option for
>> opening a url in a current tab, I now have to change focus to firefox
>> and reload the tab to show any editing I've done (in emacs) since
>> previously displaying it in firefox.
>>
>> (If anyone here has the ear of a firefox developer, tell them to gives
>> us back the "-current-tab" option.)
>>
>> hth,
>> ken
>>
>>
>> -- 
>> War is a failure of the imagination.
>>         --William Blake
>>
>>
>>
>> On 09/03/2009 06:47 AM rpd wrote:
>>> Hi
>>> Just encountered this problem previewing html editing in emacs.
>>> When I edit html (I have html-helper-mode file loaded) I want to preview
>>> it
>>> in my browser but cannot yet do so. If I use the 'html' menu item (load
>>> this
>>> buffer in browser) or C-c C-z v I just get browser opening at my homepage
>>> &
>>> not showing the html edit preview I want.
>>>
>>> Does anyone know why this is & can help me get my html emacs edit to
>>> preview
>>> in my browser?
>>>
>>> Again I am most grateful for helpful replies (Emacs is good isn't it?! -I
>>> just wish I could do what I want with it-but I will do it! LOL), many
>>> thanks
>>
>>
>>
> 




  reply	other threads:[~2009-09-03 21:14 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-03 10:47 html browser preview help rpd
2009-09-03 13:48 ` ken
2009-09-03 20:42   ` rpd
2009-09-03 21:14     ` ken [this message]
2009-09-03 22:32       ` rpd
2009-09-04 23:10         ` rpd
2009-09-05 17:11           ` Tyler Smith
2009-09-05 21:27             ` rpd
2009-09-05 21:44               ` Drew Adams
2009-09-06  0:13                 ` rpd
2009-09-06  1:19                   ` Tyler Smith
2009-09-06  9:15                     ` rpd
2009-09-06  1:39                   ` Drew Adams
2009-09-06  9:22                     ` rpd
2009-09-06 11:49                       ` html browser preview help-SORTED (at last!) rpd
2009-09-06 14:17                       ` html browser preview help Drew Adams
     [not found]                     ` <mailman.6097.1252228975.2239.help-gnu-emacs@gnu.org>
2009-09-06  9:50                       ` Xah Lee
2009-09-06  9:56                       ` Xah Lee

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=4AA031B3.1060908@mousecar.com \
    --to=gebser@mousecar.com \
    --cc=help-gnu-emacs@gnu.org \
    --cc=richard@dickinson350.freeserve.co.uk \
    /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.