[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: HTML URL viewer for Windows
From: |
Stephen Leake |
Subject: |
Re: HTML URL viewer for Windows |
Date: |
Wed, 08 Dec 2010 15:45:11 -0000 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.1 (windows-nt) |
Slackrat <g-no-ose@azurservers.com> writes:
> The following message is a courtesy copy of an article
> that has been posted to gnu.emacs.gnus as well.
>
> Can someone please clue me in what App I should use for viewing an URL
> embedded in a message when I am using gnus on a Windows machine please
I use this home grown stuff (below). 'sal-find-file-at-point' is bound
to C-F12; position point on the URL, hit C-F12, and your favorite
browser pops up.
(defconst sal-find-file-external-alist
(cond
((equal window-system 'x)
(list
(cons "^ftp://" 'browse-url-at-point)
(cons "^http://" 'browse-url-at-point)
(cons "^https://" 'browse-url-at-point)
(cons "\\.doc$" (lambda (file) (start-process "ooffice" nil "ooffice"
"-doc" file)))
(cons "\\.ods$" (lambda (file) (start-process "ooffice" nil "ooffice"
"-calc" file)))
(cons "\\.pdf$" (lambda (file) (start-process "acroread" nil "acroread"
file)))
(cons "\\.xls$" (lambda (file) (start-process "ooffice" nil "ooffice"
"-calc" file)))
))
((equal window-system 'w32)
;; Tried using .* 'sal-w32-open, but then Makefiles don't open in Emacs
(list
; (cons "^file://" 'browse-url-at-point) uses w32 start; need to strip
'file://'
(cons "^ftp://" 'browse-url-at-point)
(cons "^http://" 'browse-url-at-point)
(cons "^https://" 'browse-url-at-point)
; (cons "\\.adp$" 'sal-w32-open) ; MS Access database, but also Emacs Ada
project file
(cons "\\.bmp$" 'sal-w32-open)
(cons "\\.bz2$" 'sal-w32-open)
(cons "\\.cl5$" 'sal-w32-open) ; Roxio CD projects
(cons "\\.doc$" 'sal-w32-open)
(cons "\\.docx$" 'sal-w32-open)
(cons "\\.dll$" 'sal-w32-open)
(cons "\\.dvi$" 'sal-w32-open)
(cons "\\.exe$" 'sal-w32-open)
(cons "\\.fm$" 'sal-w32-open)
(cons "\\.glade$" 'sal-w32-open)
(cons "\\.gif$" 'sal-w32-open)
(cons "\\.gz$" 'sal-w32-open)
(cons "\\.hlp$" 'sal-w32-open)
(cons "\\.ide$" 'sal-w32-open)
(cons "\\.info$" 'info)
(cons "\\.iss$" 'sal-w32-open)
(cons "\\.jpg$" 'sal-w32-open)
(cons "\\.mdb$" 'sal-w32-open) ; MS Access database
(cons "\\.mdl$" 'sal-w32-open)
(cons "\\.mime$" 'sal-w32-open)
(cons "\\.mp3$" 'sal-w32-open)
(cons "\\.mpp$" 'sal-w32-open)
(cons "\\.nri$" 'sal-w32-open)
(cons "\\.ods$" 'sal-w32-open)
(cons "\\.pdb$" 'sal-w32-open) ; palm database
(cons "\\.pdf$" 'sal-w32-open)
(cons "\\.ps$" 'sal-w32-open)
(cons "\\.png$" 'sal-w32-open)
(cons "\\.ppt$" 'sal-w32-open)
(cons "\\.prc$" 'sal-w32-open)
(cons "\\.qpf$" 'sal-w32-open) ; Quartus project file
(cons "\\.rtf$" 'sal-w32-open)
(cons "\\.tgz$" 'sal-w32-open)
(cons "\\.tiff$" 'sal-w32-open)
(cons "\\.tif$" 'sal-w32-open)
(cons "\\.vsd$" 'sal-w32-open)
(cons "\\.vwf$" 'sal-w32-open)
(cons "\\.xls$" 'sal-w32-open)
(cons "\\.xlsx$" 'sal-w32-open)
(cons "\\.zap$" '(lambda (file) (sal-w32-rename-open file ".zip"))) ;
stupid mail filter workaround
(cons "\\.zip$" 'sal-w32-open)
))
)
"Alist of regexp matching files that should not be opened in emacs.
Association gives defun that does external openning - defun takes one
argument, the filename.")
(defun sal-find-file-at-point ()
"Find file at point. If region is active, use that instead. Prefix
arg means other window. If directory or not found, prompt. Filenames
matching `sal-find-file-external-alist' are handled specially. Also,
strings starting with ! are executed in a shell instead of being
opened."
(interactive)
(require 'ffap)
;; We handle web addresses thru
;; sal-find-file-external-alist rather than thing-at-point 'url,
;; because thing-at-point does not insist on the leading 'http://',
;; which makes web addresses indistinguishable from file paths.
(let* ((file
(if mark-active
(buffer-substring-no-properties (point) (mark))
(ffap-string-at-point)))
(command (sal-assoc-regexp file sal-find-file-external-alist))
(guess (expand-file-name (substitute-in-file-name file))))
(deactivate-mark)
;; allow arbitrary shell commands via leading !.
(cond
((= ?! (aref file 0))
;; this runs the default shell; need a way to specify a shell
(shell-command (substring file 1)))
(command
(funcall command guess))
(t
;; open in emacs
(if (file-directory-p guess)
(setq guess
(ffap-read-file-or-url "Find file: " guess)))
(if current-prefix-arg
(if guess
(find-file-other-window guess)
(call-interactively 'find-file-other-window))
(if (and guess (file-exists-p guess))
(find-file guess)
; FIXME: default prompt to 'guess', so user can add extension (for
example).
(call-interactively 'find-file))
)))))
--
-- Stephe