waterloo <waterloo2...@gmail.com> wrote: > When I run C-c C-e b , the html file is open in emacs . > > How to make firefox to open html exported automatically ? >
There are probably many ways to do it, depending on where you want to put the customization. I chose (perhaps unwisely - see below) to put it into the lowest layer. Note that there is no warranty, express or implied, of any kind: you do the following of your own free will, and if your computer explodes or kittens die as a result, you cannot hold me responsible! Org uses the function org-open-file(), which by default uses the mailcap method to open the file. The command that is executed is the result of this function call: (mailcap-mime-info "text/html") In my case, this returns "/usr/bin/w3m -T text/html '%s'" where the %s is replaced by the pathname of the file. It turns out that mailcap-mime-info obtains this by looking into a double association list, mailcap-mime-data (in mailcap.el): the first level a-list is indexed by the major mime type ("text" above); the value is a second-level a-list indexed by the minor mime type ("html" above, but it could also be other kinds of text , e.g. "plain"). There can be multiple elements with the same minor mime type: mailcap-mime-info returns the first element of that list. The value in the second level a-list is yet another, third-level a-list, as shown below. So the trick is to add a new element to the appropriate place in the double a-list, so that mailcap-mime-info will return it. First the command for firefox to open a URL remotely is /usr/bin/firefox --remote "openURL(<URL>)" THe element that we need to add to the list is (note that the command has been specialized for a file://-type URL): ("html" (viewer . "/usr/bin/firefox --remote \"openURL(file://'%s')\"") (type . "text/html") ("nametemplate" . "%s.html") ("description" . "HTML Text") ("needsterminal" . nil)) I define a variable whose value is the list above, to simplify the notation: (setq ff '("html" (viewer . "/usr/bin/firefox --remote \"openURL(file://'%s')\"") (type . "text/html") ("nametemplate" . "%s.html") ("description" . "HTML Text") ("needsterminal" . nil))) Then I do surgery on the double a-list, replacing the second-level a-list that is indexed by "text", by a modified one that has the new element ff from above at the front: (rplacd (assoc "text" mailcap-mime-data) (cons ff (cdr (assoc "text" mailcap-mime-data)))) And that's all! After this, (mailcap-mime-info "text/html") returns "/usr/bin/firefox --remote \"openURL(file://'%s')\"" - just what the doctor ordered. And doing C-c C-e b on an org file sends the URL to firefox for display. Horrible, no? If anybody comes up with an easier way, do tell! Nick PS BTW, I was evaluating these things in the *scratch* buffer. That way, if something goes wrong, I kill emacs, restart and all is forgotten. After assuring yourself that this works, then you have to put it in some initialization file. Make sure to (require 'mailcap) before mucking aroung with mailcap-mime-data. _______________________________________________ Emacs-orgmode mailing list Remember: use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode