[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: M's meaning changed
- From: Katsumi Yamaoka <yamaoka@xxxxxxx>
- Date: Fri, 06 Dec 2013 09:10:38 +0900
- X-ml-name: emacs-w3m
- X-mail-count: 12246
- References: <b4md2lbapr0.fsf@xxxxxxx> <87fvq7e70z.fsf@xxxxxxxxxxx>
In [emacs-w3m : No.12245] jidanni@xxxxxxxxxxx wrote:
> Oh no, my
> (global-set-key "\C-xw" 'browse-url-of-buffer)
> is also now browsing externally all of the sudden.
> How can I make it browse externally only if given a C-u prefix, and
> otherwise always browse internally? This is more complicated than
KY> (let ((ffap-url-fetcher (if current-prefix-arg
KY> #'browse-url-firefox
KY> #'w3m-browse-url))
There will be two ways to do that:
;;; 1 ;;;
(defun my-browse-url-of-buffer (&optional buffer firefox)
"Run `browse-url-of-buffer' by `w3m-browse-url' or `browse-url-firefox'.
The prefix argument controls which to use."
(interactive (list nil current-prefix-arg))
(let ((browse-url-browser-function (if firefox
#'browse-url-firefox
#'w3m-browse-url)))
(browse-url-of-buffer buffer)))
(global-set-key "\C-xw" 'my-browse-url-of-buffer)
;;; 2 ;;;
(defadvice browse-url-of-buffer (around switch-browser activate)
"Run `browse-url-of-buffer' by `w3m-browse-url' or `browse-url-firefox'.
The prefix argument controls which to use."
(let ((browse-url-browser-function (if current-prefix-arg
#'browse-url-firefox
#'w3m-browse-url)))
ad-do-it))
(global-set-key "\C-xw" 'browse-url-of-buffer)
BTW,
I realized I need to have the following advice in order to make
`browse-url-firefox' run Windows' Firefox on Cygwin:
(defadvice browse-url-firefox (before use-cygpath activate)
"Convert Cygwin filename to Windows filename."
(if (string-match "\\`file:/+" (ad-get-arg 0))
(ad-set-arg
0
(concat (substring (ad-get-arg 0) 0 (match-end 0))
(substring
(with-output-to-string
(call-process
"cygpath" nil standard-output
nil "-m"
(substring (ad-get-arg 0) (1- (match-end 0)))))
0 -1)))))