[Date Prev][Date Next][Thread Prev][][Date Index][Thread Index]

Re: jde + emacs-w3m problem

JC> 	If I remember correctly, integration was pretty much a snap.  After
JC> installing emacs-w3m-1.3.4, and w3m 0.4.1, I needed to modify
JC> jde-file-to-url because there seemed to be some discrepancy in how jdee and
JC> w3m handle URL file notation.  (see previous email).  I also added:
JC> (setq browse-url-browser-function 'w3m-browse-url)
JC> to my .emacs.

I integrated w3m javadoc browsing at our site in May and most users
enjoy it.  To avoid pissing off my users, however, I use w3m _only_
for javadoc.  Here is the code I wrote (probably there is a much
easier way, but this was the first thing I tried).  Also, this code
works for both NT Emacs and Cygwin Emacs:

(defun fixup-localhost-browse-url (url &optional new-window)
  (if (string-match "file://localhost/\\(.\\)|\\(/.*jde_meta.html\\)" url)
      (let* ((file (replace-match (if (eq system-type 'cygwin)
				    "\\1:\\2") t nil url nil)))
	  (insert-file-contents file)
	  (if (re-search-forward
	       "^.*file://localhost/\\([a-z]\\)|\\(.*\\.html.*\\)\".*$" (point-max) t nil)
	      (let (string name new-buffer-name existing-buffer)
		(replace-match "file:///\\1\\2" t)
		(setq string (buffer-substring 
		(string-match ".*/\\(.*\\).html.*" string)
		(setq new-buffer-name (concat "*JavaDoc " (match-string 1 string) "*"))
		(setq existing-buffer (get-buffer new-buffer-name))
		(if existing-buffer
		      (pop-to-buffer new-buffer-name)
		      (w3m-goto-url string))
		    (w3m-goto-url-new-session string)
		    (rename-buffer new-buffer-name t)))))))
    (browse-url-default-windows-browser url new-window)))

(setq browse-url-browser-function 'fixup-localhost-browse-url)