all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* browse-url and "non-webish" URLs
@ 2007-08-22 15:11 Stefan Monnier
  2007-08-22 17:17 ` Johan Bockgård
  0 siblings, 1 reply; 7+ messages in thread
From: Stefan Monnier @ 2007-08-22 15:11 UTC (permalink / raw)
  To: emacs-devel


I haven't had time to look into it yet, but I'd like to see the following in
browse-url: if the URL refers to a "text file" then use
url-insert-file-contents (or if url-handler-mode is ON, just use
find-file-other-window).

I often see this when someone posts a URL to an elisp package, which is much
better displayed in an Emacs buffer with highlighting and all than in
a Firefox/w3m.  This also true of URL to patch files, or tarballs.

One problem is that it's generally not easy to tell what is what and
automatically DTRT, so maybe the browse-url buttons should simply offer the
user the choice to pass the URL to an external app, or pass it to the URL
package.

Patches welcome,


        Stefan

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: browse-url and "non-webish" URLs
  2007-08-22 15:11 browse-url and "non-webish" URLs Stefan Monnier
@ 2007-08-22 17:17 ` Johan Bockgård
  2007-08-22 18:39   ` Stefan Monnier
  2007-08-22 18:52   ` Stefan Monnier
  0 siblings, 2 replies; 7+ messages in thread
From: Johan Bockgård @ 2007-08-22 17:17 UTC (permalink / raw)
  To: emacs-devel

Stefan Monnier <monnier@IRO.UMontreal.CA> writes:

> I haven't had time to look into it yet, but I'd like to see the
> following in browse-url: if the URL refers to a "text file" then use
> url-insert-file-contents (or if url-handler-mode is ON, just use
> find-file-other-window).

Like

    (require 'url-handlers)

    (defun browse-url-emacs (url &optional new-window)
      (let ((file-name-handler-alist
             (cons (cons url-handler-regexp 'url-file-handler)
                   file-name-handler-alist)))
        (if new-window
            (find-file-other-window url)
          (find-file url))))

    (setq browse-url-browser-function
          '(("\\.el\\'" . browse-url-emacs)
            ("."        . browse-url-firefox)))

    (browse-url
     "http://www.emacswiki.org/cgi-bin/emacs/download/eight-puzzle.el")

-- 
Johan Bockgård

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: browse-url and "non-webish" URLs
  2007-08-22 17:17 ` Johan Bockgård
@ 2007-08-22 18:39   ` Stefan Monnier
  2007-08-22 18:52   ` Stefan Monnier
  1 sibling, 0 replies; 7+ messages in thread
From: Stefan Monnier @ 2007-08-22 18:39 UTC (permalink / raw)
  To: emacs-devel

>> I haven't had time to look into it yet, but I'd like to see the
>> following in browse-url: if the URL refers to a "text file" then use
>> url-insert-file-contents (or if url-handler-mode is ON, just use
>> find-file-other-window).

> Like

>     (require 'url-handlers)

>     (defun browse-url-emacs (url &optional new-window)
>       (let ((file-name-handler-alist
>              (cons (cons url-handler-regexp 'url-file-handler)
>                    file-name-handler-alist)))
>         (if new-window
>             (find-file-other-window url)
>           (find-file url))))

>     (setq browse-url-browser-function
>           '(("\\.el\\'" . browse-url-emacs)
>             ("."        . browse-url-firefox)))

>     (browse-url
>      "http://www.emacswiki.org/cgi-bin/emacs/download/eight-puzzle.el")

Wonderful.  I hadn't noticed that browse-url-browser-function can be an
alist of regexp->functions.  How 'bout making it the default?


        Stefan

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: browse-url and "non-webish" URLs
  2007-08-22 17:17 ` Johan Bockgård
  2007-08-22 18:39   ` Stefan Monnier
@ 2007-08-22 18:52   ` Stefan Monnier
  2007-08-23 14:41     ` Johan Bockgård
  1 sibling, 1 reply; 7+ messages in thread
From: Stefan Monnier @ 2007-08-22 18:52 UTC (permalink / raw)
  To: emacs-devel

>     (defun browse-url-emacs (url &optional new-window)

Installed in the 22 branch.  Should we use it by default for .el on
the trunk?


        Stefan

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: browse-url and "non-webish" URLs
  2007-08-22 18:52   ` Stefan Monnier
@ 2007-08-23 14:41     ` Johan Bockgård
  2007-08-23 17:34       ` Stefan Monnier
  0 siblings, 1 reply; 7+ messages in thread
From: Johan Bockgård @ 2007-08-23 14:41 UTC (permalink / raw)
  To: emacs-devel

Stefan Monnier <monnier@IRO.UMontreal.CA> writes:

>>     (defun browse-url-emacs (url &optional new-window)
>
> Installed in the 22 branch.

This was mostly proof-of-concept. Using url-file-handler was convenient
since it sets the mode automatically after fetching the file. The
downside to the above code is that it requires `url-handlers' and that
it only works for urls that match url-handler-regexp.

-- 
Johan Bockgård

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: browse-url and "non-webish" URLs
  2007-08-23 14:41     ` Johan Bockgård
@ 2007-08-23 17:34       ` Stefan Monnier
  2007-08-23 21:18         ` Johan Bockgård
  0 siblings, 1 reply; 7+ messages in thread
From: Stefan Monnier @ 2007-08-23 17:34 UTC (permalink / raw)
  To: emacs-devel

>>> (defun browse-url-emacs (url &optional new-window)
>> Installed in the 22 branch.
> This was mostly proof-of-concept.  Using url-file-handler was convenient
> since it sets the mode automatically after fetching the file.

Yes, it does exactly what we want ;-)

> The downside to the above code is that it requires `url-handlers'

That's OK: if you look at the code I installed, it only requires
url-handlers when the function is called, at which point we're going to use
the URL package anyway.

> and that it only works for urls that match url-handler-regexp.

Similar limitations apply to every other browse-url function.


        Stefan

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: browse-url and "non-webish" URLs
  2007-08-23 17:34       ` Stefan Monnier
@ 2007-08-23 21:18         ` Johan Bockgård
  0 siblings, 0 replies; 7+ messages in thread
From: Johan Bockgård @ 2007-08-23 21:18 UTC (permalink / raw)
  To: emacs-devel

Stefan Monnier <monnier@iro.umontreal.ca> writes:

>> and that it only works for urls that match url-handler-regexp.
>
> Similar limitations apply to every other browse-url function.

`url' knows about more protocols than does `url-handler-regexp' (there
are handlers for irc, mailto, news, ...). browse-url-emacs could pass
them on (if it doesn't it should at least signal an error).


Btw, browse-url-w3 runs inside Emacs and it obeys the `new-window'
argument

    [...]
    (if (browse-url-maybe-new-window new-window)
        (w3-fetch-other-window url)
      (w3-fetch url)))

-- 
Johan Bockgård

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2007-08-23 21:18 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-08-22 15:11 browse-url and "non-webish" URLs Stefan Monnier
2007-08-22 17:17 ` Johan Bockgård
2007-08-22 18:39   ` Stefan Monnier
2007-08-22 18:52   ` Stefan Monnier
2007-08-23 14:41     ` Johan Bockgård
2007-08-23 17:34       ` Stefan Monnier
2007-08-23 21:18         ` Johan Bockgård

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.