Recently, I have met one dilemma in Emacs. Since I'm using Emacs for my blog writing, Firefox is used for previewing. Also as an Common Lisp user, I use emacs-w3m to read HyperSpec. Here comes the problem: I can only set one browser for browse-url-browser-function. How can I suit my requirements simultaneously?
Fortunately, Emacs is highly extensible. I just write one simple interactive function toggle-browser, which can toggle between Firefox and emacs-w3m when pressing M-x toggle-browser. Following is the code:
(defun toggle-browser () "Toggle browser between Firefox and emacs-w3m." (interactive) (setq browse-url-browser-function (if (eql browse-url-browser-function 'browse-url-firefox) 'w3m-browse-url 'browse-url-firefox)) (message "%s" browse-url-browser-function))
Update: please look at the 1st comment from pedro for a better solution.