;; Author: Denis Howe <dbh@doc.ic.ac.uk>
;; Maintainer: Denis Howe <dbh@doc.ic.ac.uk>
;; Created: 03 Apr 1995
-;; Version: 0.16 17 May 1995
+;; Version: 0.22 13 Sep 1995
;; Keywords: hypertext
;; X-Home page: http://wombat.doc.ic.ac.uk/
;; each supported browser. If the chosen browser is not running, it
;; is started. Currently there is support for:
-;; Function Browser Earliest version
-;; browse-url-netscape Netscape 1.1b1
-;; browse-url-mosaic XMosaic <= 2.4
-;; browse-url-w3 w3 0
-;; browse-url-iximosaic IXI Mosaic ?
+;; Function Browser Earliest version
+;; browse-url-netscape Netscape 1.1b1
+;; browse-url-mosaic XMosaic <= 2.4
+;; browse-url-cci XMosaic 2.5
+;; browse-url-w3 w3 0
+;; browse-url-iximosaic IXI Mosaic ?
-;; Note that earlier versions of Netscape did not have remote control.
-;; <URL:http://home.netscape.com/newsref/std/x-remote.html> and
-;; <URL:http://home.netscape.com/info/APIs/>.
+;; Note that versions of Netscape before 1.1b1 did not have remote
+;; control. <URL:http://home.netscape.com/newsref/std/x-remote.html>
+;; and <URL:http://home.netscape.com/info/APIs/>.
-;; If using Mosaic, check the definition of browse-url-usr1-signal
-;; below.
+;; Netscape can cache Web pages so it may be necessary to tell it to
+;; reload the current page if it has changed (eg. if you have edited
+;; it). There is currently no perfect automatic solution to this.
+
+;; Netscape allows you to specify the id of the window you want to
+;; control but which window DO you want to control and how do you
+;; discover its id?
+
+;; If using XMosaic before version 2.5, check the definition of
+;; browse-url-usr1-signal below.
;; <URL:http://www.ncsa.uiuc.edu/SDG/Software/XMosaic/remote-control.html>
+;; XMosaic version 2.5 introduced Common Client Interface allowing you
+;; to control mosaic through Unix sockets.
+;; <URL:http://www.ncsa.uiuc.edu/SDG/Software/XMosaic/CCI/cci-spec.html>
+
+
;; William M. Perry's excellent "w3" WWW browser for
;; Emacs <URL:ftp://cs.indiana.edu/pub/elisp/w3/>
;; has a function w3-follow-url-at-point, but that
;; Can you write and test some code for the Macintrash and Windoze
;; Netscape remote control APIs? (See the URL above).
-;; Did earlier versions of Mosaic have remote control?
-
;; Do any other browsers have remote control?
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Installation
-;; In your ~/.emacs, put:
-;;
-;; (setq browse-url-browser-function
-;; (if (eq window-system 'x)
-;; 'browse-url-netscape ; or browse-url-mosaic
-;; 'browse-url-w3))
-;; (autoload browse-url-browser-function "browse-url.el"
-;; "Ask a WWW browser to show a URL." t)
-;; Bind this to control-X w (normally undefined):
-;; (global-set-key "\C-xw" browse-url-browser-function)
-;; ;; Note: no quote ^
-
-;; For viewing current buffer:
+;; Put the following in your ~/.emacs file:
;;
-;; (autoload 'browse-url-of-file "browse-url.el"
-;; "Ask a WWW browser to display the current file." t)
-;; (setq browse-url-save-file t) ; Always save
+;; (autoload 'browse-url-at-point "browse-url"
+;; "Ask a WWW browser to load the URL at or before point." t)
+;; (autoload 'browse-url-at-mouse "browse-url"
+;; "Ask a WWW browser to load a URL clicked with the mouse." t)
+;; (autoload 'browse-url-of-buffer "browse-url"
+;; "Ask a WWW browser to display BUFFER." t)
+;; (autoload 'browse-url-of-file "browse-url"
+;; "Ask a WWW browser to display FILE." t)
+;; (autoload 'browse-url-of-dired-file "browse-url"
+;; "In Dired, ask a WWW browser to display the file named on this line." t)
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; Usage
+
+;; To display the URL at or before point:
+;; M-x browse-url-at-point RET
+
+;; To display a URL by shift-clicking on it, put this in your ~/.emacs
+;; file:
+;; (global-set-key [S-mouse-1] 'browse-url-at-mouse)
+
+;; To display the current buffer in a web browser:
+;; M-x browse-url-of-buffer RET
+
+;; In Dired, to display the file named on the current line:
+;; M-x browse-url-of-dired-file RET
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; Customisation (~/.emacs)
+
+;; To see what variables are available for customization, type `M-x
+;; set-variable browse-url TAB'.
+
+;; To bind the browse-url commands to keys with the `C-c u' prefix:
+;; (global-set-key "\C-cu." 'browse-url-at-point)
+;; (global-set-key "\C-cub" 'browse-url-of-buffer)
+;; (global-set-key "\C-cuf" 'browse-url-of-file)
+;; (add-hook 'dired-mode-hook
+;; (function (lambda ()
+;; (local-set-key "\C-cuf" 'browse-url-of-dired-file))))
+;; (if (boundp 'browse-url-browser-function)
+;; (global-set-key "\C-cuu" browse-url-browser-function)
+;; (eval-after-load
+;; "browse-url"
+;; '(global-set-key "\C-cuu" browse-url-browser-function)))
+
+;; To use the Emacs w3 browser when not running under X11:
+;; (if (not (eq window-system 'x))
+;; (setq browse-url-browser-function 'browse-url-w3))
+
+;; To always save modified buffers before displaying the file in a browser:
+;; (setq browse-url-save-file t)
;; To get round the Netscape caching problem, you could try either of
;; the following (but not both). EITHER write-file in
;; html-helper-mode makes Netscape reload document:
;;
-;; (autoload 'browse-url-netscape-reload "browse-url.el"
+;; (autoload 'browse-url-netscape-reload "browse-url"
;; "Ask a WWW browser to redisplay the current file." t)
;; (add-hook 'html-helper-mode-hook
;; (function (lambda ()
;; t)))) ; append to l-w-f-hooks
;;
;; [Does this work for html-mode too?]
-
+;;
;; OR browse-url-of-file ask Netscape to load and then reload the
;; file:
;;
;; Added browse-url-at-point.
;; Thanks Jonathan Cano <cano@patch.tandem.com>.
-;; Netscape can cache Web pages so it may be necessary to tell it to
-;; reload the current page if it has changed (eg. if you have edited
-;; it). There is currently no perfect automatic solution to this.
+;; 0.18 16 Aug 1995
+;; Fixed call to browse-url-url-at-point in browse-url-at-point.
+;; Thanks Eric Ding <ericding@San-Jose.ate.slb.com>.
-;; Netscape allows you to specify the id of the window you want to
-;; control but which window DO you want to control and how do you
-;; discover its id?
+;; 0.19 24 Aug 1995
+;; Improved documentation.
+;; Thanks Kevin Rodgers <kevin.rodgers@ihs.com>.
+
+;; 0.20 31 Aug 1995
+;; browse-url-of-buffer to handle file-less buffers.
+;; browse-url-of-dired-file browses current file in dired.
+;; Thanks Kevin Rodgers <kevin.rodgers@ihs.com>.
+
+;; 0.21 09 Sep 1995
+;; XMosaic CCI functions.
+;; Thanks Marc Furrer <Marc.Furrer@di.epfl.ch>.
+
+;; 0.22 13 Sep 1995
+;; Fixed new-window documentation and added to browse-url-cci.
+;; Thanks Dilip Sequeira <djs@dcs.ed.ac.uk>.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Code:
(defvar browse-url-browser-function
'browse-url-netscape
"*Function to display the current buffer in a WWW browser.
-Used by function `browse-url-of-file'.")
+Used by the `browse-url-at-point', `browse-url-at-mouse', and
+`browse-url-of-file' commands.")
(defvar browse-url-netscape-arguments nil
"*A list of strings to pass to Netscape as arguments.")
-(defvar browse-url-netscape-new-window-p nil
- "*If non-nil, Netscape always opens a new window.
-Passing an interactive argument to \\[browse-url-netscape] reverses
-the effect of this variable. Requires Netscape version 1.1N or
-later.")
+(defvar browse-url-new-window-p nil
+ "*If non-nil, always open a new browser window.
+Passing an interactive argument to \\[browse-url-netscape] or
+\\[browse-url-cci] reverses the effect of this variable. Requires
+Netscape version 1.1N or later or XMosaic version 2.5 or later.")
(defvar browse-url-mosaic-arguments nil
"*A list of strings to pass to Mosaic as arguments.")
"An alist of (REGEXP . STRING) pairs.
Any substring of a filename matching one of the REGEXPs is replaced by
the corresponding STRING. All pairs are applied in the order given.
-Used by function `browse-url-of-file'.")
+Used by the `browse-url-of-file' command.")
(defvar browse-url-save-file nil
"If non-nil, save the buffer before displaying its file.
-Used by function `browse-url-of-file'.")
+Used by the `browse-url-of-file' command.")
(defvar browse-url-of-file-hook nil
"A hook to be run with run-hook after `browse-url-of-file' has asked
Emacs 19.29 accepts 'sigusr1, earlier versions require an integer
which is 30 on SunOS and 16 on HP-UX and Solaris.")
+(defvar browse-url-CCI-port 3003
+ "Port to access XMosaic via CCI.
+This can be any number between 1024 and 65535 but must correspond to
+the value set in the browser.")
+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; URL input
(list (read-string (or prompt "URL: ") (browse-url-url-at-point))))
(defun browse-url-at-point ()
- "Pass the URL at or before point to a WWW browser."
+ "Ask a WWW browser to load the URL at or before point.
+The URL is loaded according to the value of `browse-url-browser-function'."
(interactive)
- (funcall browse-url-browser-function (browse-url-at-point)))
+ (funcall browse-url-browser-function (browse-url-url-at-point)))
(defun browse-url-at-mouse (event)
- "Ask a browser to load a URL clicked with the mouse.
+ "Ask a WWW browser to load a URL clicked with the mouse.
The URL is the one around or before the position of the mouse click
-but point is not changed. The URL is loaded using variable
+but point is not changed. The URL is loaded according to the value of
`browse-url-browser-function'."
(interactive "e")
(save-excursion
URL to a browser using variable `browse-url-browser-function' then run
`browse-url-of-file-hook'."
(interactive)
- (setq file (or file
- (buffer-file-name)
- (and (boundp 'dired-directory) dired-directory)))
+ (setq file
+ (or file
+ (buffer-file-name)
+ (error "Current buffer has no file")))
(let ((buf (get-file-buffer file)))
- (if buf (save-excursion
- (set-buffer buf)
- (cond
- ((not (buffer-modified-p)))
- (browse-url-save-file (save-buffer))
- (t (message "%s modified since last save" file))))))
- (funcall browse-url-browser-function
- (browse-url-file-url file))
+ (if buf
+ (save-excursion
+ (set-buffer buf)
+ (cond ((not (buffer-modified-p)))
+ (browse-url-save-file (save-buffer))
+ (t (message "%s modified since last save" file))))))
+ (funcall browse-url-browser-function (browse-url-file-url file))
(run-hooks 'browse-url-of-file-hook))
(defun browse-url-file-url (file)
(substring file (match-end 0))))))))
file)
+(defvar browse-url-temp-file-name nil)
+(make-variable-buffer-local 'browse-url-temp-file-name)
+
+(defvar browse-url-temp-file-list '())
+
+(defun browse-url-of-buffer (&optional buffer)
+ "Ask a WWW browser to display BUFFER.
+Display the current buffer if BUFFER is nil."
+ (interactive)
+ (save-excursion
+ (set-buffer (or buffer (current-buffer)))
+ (let ((file-name
+ (or buffer-file-name
+ (and (boundp 'dired-directory) dired-directory))))
+ (if (null file-name)
+ (progn
+ (if (null browse-url-temp-file-name)
+ (progn
+ (setq browse-url-temp-file-name
+ (make-temp-name
+ (expand-file-name (buffer-name)
+ (or (getenv "TMPDIR") "/tmp"))))
+ (setq browse-url-temp-file-list
+ (cons browse-url-temp-file-name
+ browse-url-temp-file-list))))
+ (write-region (point-min) (point-max) browse-url-temp-file-name
+ nil 'no-message)))
+ (browse-url-of-file (or file-name browse-url-temp-file-name)))))
+
+(defun browse-url-delete-temp-file (&optional temp-file-name)
+ ;; Delete browse-url-temp-file-name from the file system and from
+ ;; browse-url-temp-file-list. If optional arg TEMP-FILE-NAME is
+ ;; non-nil, delete it instead, but only from the file system --
+ ;; browse-url-temp-file-list is not affected.
+ (let ((file-name (or temp-file-name browse-url-temp-file-name)))
+ (if (and file-name (file-exists-p file-name))
+ (progn
+ (delete-file file-name)
+ (if (null temp-file-name)
+ (setq browse-url-temp-file-list
+ (delete browse-url-temp-file-name
+ browse-url-temp-file-list)))))))
+
+(defun browse-url-delete-temp-file-list ()
+ ;; Delete all elements of browse-url-temp-file-list.
+ (while browse-url-temp-file-list
+ (browse-url-delete-temp-file (car browse-url-temp-file-list))
+ (setq browse-url-temp-file-list
+ (cdr browse-url-temp-file-list))))
+
+(add-hook 'kill-buffer-hook 'browse-url-delete-temp-file)
+(add-hook 'kill-emacs-hook 'browse-url-delete-temp-file-list)
+
+(defun browse-url-of-dired-file ()
+ "In Dired, ask a WWW browser to display the file named on this line."
+ (interactive)
+ (browse-url-of-file (dired-get-filename)))
+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Browser-specific functions
Default to the URL around or before point. The strings in variable
`browse-url-netscape-arguments' are also passed to Netscape.
-If variable `browse-url-netscape-new-window-p' is non-nil, load the
-document in a new Netscape window, otherwise use a random existing
-one. If optional argument NEW-WINDOW (prefix argument if interactive)
-is non-nil, the effect of browse-url-netscape-new-window-p is
-reversed."
+When called interactively, if variable `browse-url-new-window-p' is
+non-nil, load the document in a new Netscape window, otherwise use a
+random existing one. A non-nil interactive prefix argument reverses
+the effect of browse-url-new-window-p.
+
+When called non-interactively, optional second argument NEW-WINDOW is
+used instead of browse-url-new-window-p."
+
(interactive (append (browse-url-interactive-arg "Netscape URL: ")
- (list (not (eq (null browse-url-netscape-new-window-p)
+ (list (not (eq (null browse-url-new-window-p)
(null current-prefix-arg))))))
(or (zerop
(apply 'call-process "netscape" nil nil nil
(append browse-url-netscape-arguments
(list "-remote" command))))
+
(defun browse-url-mosaic (url)
"Ask the XMosaic WWW browser to load URL.
Default to the URL around or before point."
(apply 'start-process "xmosaic" nil "xmosaic"
(append browse-url-mosaic-arguments (list url))))))
+
+(defun browse-url-cci (url &optional new-window)
+ "Ask the XMosaic WWW browser to load URL.
+Default to the URL around or before point.
+
+This function only works for XMosaic version 2.5 or later. You must
+select `CCI' from XMosaic's File menu, set the CCI Port Address to the
+value of variable `browse-url-CCI-port', and enable `Accept requests'.
+
+When called interactively, if variable `browse-url-new-window-p' is
+non-nil, load the document in a new browser window, otherwise use a
+random existing one. A non-nil interactive prefix argument reverses
+the effect of browse-url-new-window-p.
+
+When called non-interactively, optional second argument NEW-WINDOW is
+used instead of browse-url-new-window-p."
+ (interactive (append (browse-url-interactive-arg "Mosaic URL: ")
+ (list (not (eq (null browse-url-new-window-p)
+ (null current-prefix-arg))))))
+ (open-network-stream "browse-url" " *browse-url*"
+ "localhost" browse-url-CCI-port)
+ ;; Todo: start browser if fails
+ (process-send-string "browse-url"
+ (concat "get url (" url ") output "
+ (if new-window "new" "current") "\r\n"))
+ (process-send-string "browse-url" "disconnect\r\n")
+ (delete-process "browse-url"))
+
+
(defun browse-url-iximosaic (url)
"Ask the IXIMosaic WWW browser to load URL.
Default to the URL around or before point."
(start-process "tellw3b" nil "tellw3b"
"-service WWW_BROWSER ixi_showurl " url))
+
(defun browse-url-w3 (url)
"Ask the w3 WWW browser to load URL.
Default to the URL around or before point."
(interactive (browse-url-interactive-arg "W3 URL: "))
(w3-fetch url))
+
(provide 'browse-url)
;;; browse-url.el ends here
(not (string= gnus-default-nntp-server "")))
gnus-default-nntp-server)
(system-name)))
- (if (equal gnus-nntp-service "nntp") nil (list gnus-nntp-service)))
+ (if (or (null gnus-nntp-service)
+ (equal gnus-nntp-service "nntp"))
+ nil
+ (list gnus-nntp-service)))
"*Default method for selecting a newsgroup.
This variable should be a list, where the first element is how the
news is to be fetched, the second is the address.
"gnus-bug@ifi.uio.no (The Gnus Bugfixing Girls + Boys)"
"The mail address of the Gnus maintainers.")
-(defconst gnus-version "Gnus v5.0.2"
+(defconst gnus-version "Gnus v5.0.3"
"Version number for this version of Gnus.")
(defvar gnus-info-nodes
(autoload 'gnus-mail-send-and-exit "gnus-msg")
(autoload 'gnus-mail-forward-using-mail "gnus-msg")
(autoload 'gnus-mail-other-window-using-mail "gnus-msg")
- (autoload 'gnus-article-mail-with-original "gnus-msg")
(autoload 'gnus-article-mail "gnus-msg")
(autoload 'gnus-bug "gnus-msg" nil t)
(append gnus-newsgroup-marked gnus-newsgroup-dormant)))
;; We actually mark all articles as canceled, which we
;; have to do when using auto-expiry or adaptive scoring.
- (let ((unreads (length gnus-newsgroup-unreads)))
- (gnus-summary-show-all-threads)
- (if (gnus-summary-first-subject (not all))
- (while (and
- (if to-here (< (point) to-here) t)
- (gnus-summary-mark-article-as-read gnus-catchup-mark)
- (gnus-summary-search-subject nil (not all)))))
- (- unreads (length gnus-newsgroup-unreads))
- (or to-here
- (setq gnus-newsgroup-unreads gnus-newsgroup-marked)))))
+ (gnus-summary-show-all-threads)
+ (if (gnus-summary-first-subject (not all))
+ (while (and
+ (if to-here (< (point) to-here) t)
+ (gnus-summary-mark-article-as-read gnus-catchup-mark)
+ (gnus-summary-search-subject nil (not all)))))
+ (or to-here
+ (setq gnus-newsgroup-unreads
+ (append gnus-newsgroup-marked
+ gnus-newsgroup-dormant)))))
(let ((method (gnus-find-method-for-group gnus-newsgroup-name)))
(if (and (not to-here) (eq 'nnvirtual (car method)))
(nnvirtual-catchup-group
(defun gnus-summary-catchup-to-here (&optional all)
"Mark all unticked articles before the current one as read.
If ALL is non-nil, also mark ticked and dormant articles as read."
- (interactive)
+ (interactive "P")
(gnus-set-global-variables)
(save-excursion
(and (zerop (forward-line -1))
(defun gnus-summary-catchup-all (&optional quietly)
"Mark all articles in this newsgroup as read."
- (interactive)
+ (interactive "P")
(gnus-set-global-variables)
(gnus-summary-catchup t quietly))
(defun gnus-summary-catchup-all-and-exit (&optional quietly)
"Mark all articles in this newsgroup as read, and then exit."
- (interactive)
+ (interactive "P")
(gnus-set-global-variables)
(gnus-summary-catchup-and-exit t quietly))
(define-key gnus-article-mode-map "h" 'gnus-article-show-summary)
(define-key gnus-article-mode-map "s" 'gnus-article-show-summary)
(define-key gnus-article-mode-map "\C-c\C-m" 'gnus-article-mail)
- (define-key gnus-article-mode-map
- "\C-c\C-M" 'gnus-article-mail-with-original)
(define-key gnus-article-mode-map "?" 'gnus-article-describe-briefly)
(define-key gnus-article-mode-map gnus-mouse-2 'gnus-article-push-button)
(define-key gnus-article-mode-map "\r" 'gnus-article-press-button)
\\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
\\[gnus-article-show-summary]\t Display the summary buffer
\\[gnus-article-mail]\t Send a reply to the address near point
-\\[gnus-article-mail-with-original]\t Send a reply to the address near point; include the original article
\\[gnus-article-describe-briefly]\t Describe the current mode briefly
\\[gnus-info-find-node]\t Go to the Gnus info node"
(interactive)