[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
elisp and rewrite url for firefox
From: |
Hugh Lawson |
Subject: |
elisp and rewrite url for firefox |
Date: |
Sat, 16 Apr 2005 17:28:41 GMT |
User-agent: |
Gnus/5.09 (Gnus v5.9.0) Emacs/21.4 |
What are the functions in elisp that do the below?
change from to
----------- ----------------
ftp.debian.org ftp://debian.org
www.debian.org http://www.debian.org
'browse-url-at-point' makes this happen, but the elisp code is too
advanced for me to follow. I made up my own homemade function to do
this, but I'd like to know if I can just send a string to an already
existing elisp function that would do it for me. Here's my code:
;; variable url is already set, so it adds "http://" etc
;; as necessary
(cond ((string-match "http://\\|https://\\|ftp://" url 0) url)
((string-match "ftp\\." url 0) (setq url (concat "ftp://"url)) )
(t(setq url (concat "http://" url))))
To make firefox open an url in a new tab I must send it the full url.
Here is the whole function, which seems to work OK.
(defun my-browser (url &optional new-window)
"Open URL in a new tab in firefox. To use this, set
browse-url-browser-function to my-browser"
(interactive (browse-url-interactive-arg "URL: "))
(cond ((string-match "http://\\|https://\\|ftp://" url 0) url)
((string-match "ftp\\." url 0) (setq url (concat "ftp://"url)) )
(t(setq url (concat "http://" url))))
;;
;; remainder adapted from Xning Lee code
;; see
;; http://lists.gnu.org/archive/html/info-gnus-english/2004-07/msg00193.html
;;
(when
(string-match ".*No running window found.*"
(shell-command-to-string
(concat "firefox -remote 'openurl(" url ",new-tab)'")))
(message "Starting Firefox...")
(start-process (concat "firefox " url) nil
"/bin/sh" "-c" (concat "firefox " url "|| true"))
(message "Starting Firefox...done")))
;; to make make my-browser default, add the below.
(setq browse-url-browser-function 'my-browser)
--
Hugh Lawson
hlawson@triad.rr.com
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- elisp and rewrite url for firefox,
Hugh Lawson <=