all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* shortest amount of keystrokes to see URL in an external browser
@ 2011-06-19 11:12 jidanni
  2011-06-19 18:24 ` Eric Abrahamsen
  0 siblings, 1 reply; 9+ messages in thread
From: jidanni @ 2011-06-19 11:12 UTC (permalink / raw
  To: help-gnu-emacs

Let's say you are viewing or editing file.txt and there is a URL
http://example.org/ that you would like to visit in an external browser.
Well with FFAP installed, C-x C-f upon it would get you there in an
internal browser, but if one wants to see it in an external browser, a
lot more work will be involved. C-u C-x C-f of course does something
different. Note I am talking about .txt files, and not mail messages
like these, where one could use M runs the command browse-url-firefox
etc. At least with my http://jidanni.org/comp/configuration/ .



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

* Re: shortest amount of keystrokes to see URL in an external browser
  2011-06-19 11:12 shortest amount of keystrokes to see URL in an external browser jidanni
@ 2011-06-19 18:24 ` Eric Abrahamsen
  0 siblings, 0 replies; 9+ messages in thread
From: Eric Abrahamsen @ 2011-06-19 18:24 UTC (permalink / raw
  To: help-gnu-emacs

On Sun, Jun 19 2011, jidanni@jidanni.org wrote:

> Let's say you are viewing or editing file.txt and there is a URL
> http://example.org/ that you would like to visit in an external browser.
> Well with FFAP installed, C-x C-f upon it would get you there in an
> internal browser, but if one wants to see it in an external browser, a
> lot more work will be involved. C-u C-x C-f of course does something
> different. Note I am talking about .txt files, and not mail messages
> like these, where one could use M runs the command browse-url-firefox
> etc. At least with my http://jidanni.org/comp/configuration/ .

You've got browse-url-browser-function set to 'w3m-browse-url, and while
that's the case you'll have to do something special to use firefox. If
you only want to use an external browser for .txt files, I suppose you
could use a mode-hook to make browse-url-browser-function buffer local
and set it to browse-url-firefox.

I prefer to set browse-url-browser-function to a list of
regexps/functions. Then the top regexp does this:

"https?:" -> (browse-url-generic) -> browse-url-generic-program ->
"google-chrome".

If you were able to dispatch to an external browser on regexps, that
would make the whole thing simpler. Otherwise, making
browse-url-generic-program buffer local and setting it through hooks
might be less disruptive than re-setting browse-url-browser-function to
a completely new function.

Perhaps you knew all this already…

Eric




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

* Re: shortest amount of keystrokes to see URL in an external browser
       [not found] <mailman.102.1308507902.785.help-gnu-emacs@gnu.org>
@ 2011-06-24 23:14 ` jidanni
  2011-06-24 23:34   ` PJ Weisberg
  2011-06-24 23:15 ` jidanni
  1 sibling, 1 reply; 9+ messages in thread
From: jidanni @ 2011-06-24 23:14 UTC (permalink / raw
  To: help-gnu-emacs

It turns out I need to re-engineer the entire

(defun find-file-at-point (&optional filename)
  "Find FILENAME, guessing a default from text around point.
If `ffap-url-regexp' is not nil, the FILENAME may also be an URL.
With a prefix, this command behaves exactly like `ffap-file-finder'.
If `ffap-require-prefix' is set, the prefix meaning is reversed.
See also the variables `ffap-dired-wildcards', `ffap-newfile-prompt',
and the functions `ffap-file-at-point' and `ffap-url-at-point'."
  (interactive)

to make the prefix to now mean "use and external browser", to achieve
what I want.

Oh woe is me.

There is

no way

old

me

is going to get involved in that.



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

* Re: shortest amount of keystrokes to see URL in an external browser
       [not found] <mailman.102.1308507902.785.help-gnu-emacs@gnu.org>
  2011-06-24 23:14 ` jidanni
@ 2011-06-24 23:15 ` jidanni
  2011-06-24 23:36   ` Richard Riley
  1 sibling, 1 reply; 9+ messages in thread
From: jidanni @ 2011-06-24 23:15 UTC (permalink / raw
  To: help-gnu-emacs

"use and external browser" ->
"use an external browser"



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

* Re: shortest amount of keystrokes to see URL in an external browser
  2011-06-24 23:14 ` jidanni
@ 2011-06-24 23:34   ` PJ Weisberg
  2011-06-25  0:01     ` jidanni
  0 siblings, 1 reply; 9+ messages in thread
From: PJ Weisberg @ 2011-06-24 23:34 UTC (permalink / raw
  To: help-gnu-emacs, jidanni

On Fri, Jun 24, 2011 at 4:14 PM,  <jidanni@jidanni.org> wrote:
> It turns out I need to re-engineer the entire
>
> (defun find-file-at-point (&optional filename)
>  "Find FILENAME, guessing a default from text around point.
> If `ffap-url-regexp' is not nil, the FILENAME may also be an URL.
> With a prefix, this command behaves exactly like `ffap-file-finder'.
> If `ffap-require-prefix' is set, the prefix meaning is reversed.
> See also the variables `ffap-dired-wildcards', `ffap-newfile-prompt',
> and the functions `ffap-file-at-point' and `ffap-url-at-point'."
>  (interactive)
>
> to make the prefix to now mean "use and external browser", to achieve
> what I want.
>
> Oh woe is me.
>
> There is
>
> no way
>
> old
>
> me
>
> is going to get involved in that.

If you got as far as looking at the code for `find-file-at-point',
perhaps it occurred to you to customize `ffap-url-fetcher' to
`browse-url-firefox'?  :-)

-PJ



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

* Re: shortest amount of keystrokes to see URL in an external browser
  2011-06-24 23:15 ` jidanni
@ 2011-06-24 23:36   ` Richard Riley
  0 siblings, 0 replies; 9+ messages in thread
From: Richard Riley @ 2011-06-24 23:36 UTC (permalink / raw
  To: help-gnu-emacs

jidanni@jidanni.org writes:

> "use and external browser" ->
> "use an external browser"
>

dunno if this is any good to you:

,----
| (defun rgr/browse (url)
|   "If prefix is specified use the system default browser else use the configured emacs one"
|   (if current-prefix-arg
|       (if  url
|           (w3m-browse-url url)
|         (call-interactively 'browse-url))
|     (when url (browse-url-generic url))
|     ))
| 
| (defun rgr/browse-url (&optional url)
|   "browse the url passed in"
|   (interactive)
|   (setq url (or url (w3m-url-valid (w3m-anchor)) (browse-url-url-at-point) (region-or-word-at-point)))
|   (setq url (read-string (format "Url \"%s\" :" url) url nil url))
|   (rgr/browse url))
| 
| (global-set-key (kbd "<f4>") 'rgr/browse-url)
`----




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

* Re: shortest amount of keystrokes to see URL in an external browser
  2011-06-24 23:34   ` PJ Weisberg
@ 2011-06-25  0:01     ` jidanni
  2011-06-25  1:15       ` PJ Weisberg
  0 siblings, 1 reply; 9+ messages in thread
From: jidanni @ 2011-06-25  0:01 UTC (permalink / raw
  To: pj; +Cc: help-gnu-emacs

>>>>> "PW" == PJ Weisberg <pj@irregularexpressions.net> writes:
PW> If you got as far as looking at the code for `find-file-at-point',
PW> perhaps it occurred to you to customize `ffap-url-fetcher' to
PW> `browse-url-firefox'?  :-)
Yes I do similar things in http://jidanni.org/comp/configuration/.emacs
I'm just wanting a way to have an external browser function be at the
most just one more keystroke than the internal browser function.

I.e., I want C-x C-f to call the internal browser function,
and      C-u C-x C-f to call the external browser function.
Or some other key
             C-? C-? to call the external browser function.
And with the massive complication of also wanting the power of FFAP,
it is not kid stuff, but also not senior stuff, or senior stiff, which
is where I'm headed...





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

* Re: shortest amount of keystrokes to see URL in an external browser
  2011-06-25  0:01     ` jidanni
@ 2011-06-25  1:15       ` PJ Weisberg
  2011-06-25  2:44         ` jidanni
  0 siblings, 1 reply; 9+ messages in thread
From: PJ Weisberg @ 2011-06-25  1:15 UTC (permalink / raw
  To: help-gnu-emacs, jidanni

On Fri, Jun 24, 2011 at 5:01 PM,  <jidanni@jidanni.org> wrote:
>>>>>> "PW" == PJ Weisberg <pj@irregularexpressions.net> writes:
> PW> If you got as far as looking at the code for `find-file-at-point',
> PW> perhaps it occurred to you to customize `ffap-url-fetcher' to
> PW> `browse-url-firefox'?  :-)
> Yes I do similar things in http://jidanni.org/comp/configuration/.emacs
> I'm just wanting a way to have an external browser function be at the
> most just one more keystroke than the internal browser function.
>
> I.e., I want C-x C-f to call the internal browser function,
> and      C-u C-x C-f to call the external browser function.
> Or some other key
>             C-? C-? to call the external browser function.
> And with the massive complication of also wanting the power of FFAP,
> it is not kid stuff, but also not senior stuff, or senior stiff, which
> is where I'm headed...

It sounds like you don't want to "re-engineer" the whole thing; you
just want to appropriate the prefix argument for your own purposes.
Exactly like `find-file-at-point' does to `ffap-file-finder'. ;-)

So, along those lines, something like:

(defun my-ffap (&optional filename)
  (interactive)
  (let ((ffap-url-fetcher (if current-prefix-arg
                              #'browse-url-firefox
                            ffap-url-fetcher))
        (current-prefix-arg nil))
    (find-file-at-point filename)))

should do the trick.



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

* Re: shortest amount of keystrokes to see URL in an external browser
  2011-06-25  1:15       ` PJ Weisberg
@ 2011-06-25  2:44         ` jidanni
  0 siblings, 0 replies; 9+ messages in thread
From: jidanni @ 2011-06-25  2:44 UTC (permalink / raw
  To: pj; +Cc: help-gnu-emacs

Ah, and now I am indeed back in business. Here's what I now use:

(ffap-bindings)
(defun my-ffap (&optional filename) ;PJ Weisberg
  (interactive)
  (let ((ffap-url-fetcher (if current-prefix-arg
                              #'browse-url-firefox
                            ffap-url-fetcher))
        (current-prefix-arg nil))
    (find-file-at-point filename)))
(global-set-key "\C-x\C-f" 'my-ffap)

Thanks PJ!



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

end of thread, other threads:[~2011-06-25  2:44 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-06-19 11:12 shortest amount of keystrokes to see URL in an external browser jidanni
2011-06-19 18:24 ` Eric Abrahamsen
     [not found] <mailman.102.1308507902.785.help-gnu-emacs@gnu.org>
2011-06-24 23:14 ` jidanni
2011-06-24 23:34   ` PJ Weisberg
2011-06-25  0:01     ` jidanni
2011-06-25  1:15       ` PJ Weisberg
2011-06-25  2:44         ` jidanni
2011-06-24 23:15 ` jidanni
2011-06-24 23:36   ` Richard Riley

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.