* Elisp to open a line-wrapped URL
@ 2018-02-24 23:53 ckhan
2018-02-25 15:07 ` Daniel Herzig
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: ckhan @ 2018-02-24 23:53 UTC (permalink / raw)
To: help-gnu-emacs
Say I like wrapping my code at 80cols.
But say I also occasionally include URLs in comments .
So I might wind up with something like this
# See also Google Drive generated py docs:
# https://developers.google.com/resources/api-libraries/
# documentation/drive/v2/python/latest/
# drive_v2.permissions.html#insert
How do I teach emacs to open the URL that is near my cursor, even though it's split across lines with comment markers in between?
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Elisp to open a line-wrapped URL
2018-02-24 23:53 Elisp to open a line-wrapped URL ckhan
@ 2018-02-25 15:07 ` Daniel Herzig
2018-02-25 20:01 ` Emanuel Berg
2018-02-26 5:02 ` Yuri Khan
2 siblings, 0 replies; 6+ messages in thread
From: Daniel Herzig @ 2018-02-25 15:07 UTC (permalink / raw)
To: help-gnu-emacs@gnu.org
Not an exact answer to your answer, but maybe helpful anyway.
If you slightly restructure the comments to:
# See also Google Drive generated py docs:
'''
https://developers.google.com/resources/api-libraries/
documentation/drive/v2/python/latest/
drive_v2.permissions.html#insert
'''
you can mark the URL and open it with M-x browse-url-<your browser> --
it will appear as default value in the prompt.
Am 25.02.2018 um 00:53 schrieb ckhan:
> Say I like wrapping my code at 80cols.
> But say I also occasionally include URLs in comments .
>
> So I might wind up with something like this
>
> # See also Google Drive generated py docs:
> # https://developers.google.com/resources/api-libraries/
> # documentation/drive/v2/python/latest/
> # drive_v2.permissions.html#insert
>
> How do I teach emacs to open the URL that is near my cursor, even though it's split across lines with comment markers in between?
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Elisp to open a line-wrapped URL
2018-02-24 23:53 Elisp to open a line-wrapped URL ckhan
2018-02-25 15:07 ` Daniel Herzig
@ 2018-02-25 20:01 ` Emanuel Berg
2018-02-25 22:40 ` Emanuel Berg
2018-02-26 5:02 ` Yuri Khan
2 siblings, 1 reply; 6+ messages in thread
From: Emanuel Berg @ 2018-02-25 20:01 UTC (permalink / raw)
To: help-gnu-emacs
ckhan wrote:
> Say I like wrapping my code at 80cols.
> But say I also occasionally include URLs in comments .
>
> So I might wind up with something like this
>
> # See also Google Drive generated py docs:
> # https://developers.google.com/resources/api-libraries/
> # documentation/drive/v2/python/latest/
> # drive_v2.permissions.html#insert
>
> How do I teach emacs to open the URL that is
> near my cursor, even though it's split across
> lines with comment markers in between?
Simple, search for the next URL!
(defun look-for-url ()
(interactive)
(let ((url nil))
(while (not (setq url (thing-at-point 'url t)))
(forward-char 1)) ; will fail at EOB
(w3m-goto-url url) )) ; so here the URL is always fine
Probably searching can be done more efficiently
tho, e.g. a regexp search for the next URL...
--
underground experts united
http://user.it.uu.se/~embe8573
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Elisp to open a line-wrapped URL
2018-02-25 20:01 ` Emanuel Berg
@ 2018-02-25 22:40 ` Emanuel Berg
2018-02-25 22:43 ` Emanuel Berg
0 siblings, 1 reply; 6+ messages in thread
From: Emanuel Berg @ 2018-02-25 22:40 UTC (permalink / raw)
To: help-gnu-emacs
> Probably searching can be done more
> efficiently tho, e.g. a regexp search for the
> next URL...
(require 'cl-lib)
(require 'thingatpt)
(require 'w3m)
(defun goto-next-url ()
(interactive)
(let ((max (point-max)))
(cl-dolist (url-type thing-at-point-uri-schemes)
(when (re-search-forward url-type max t)
(goto-char (match-beginning 0))
(let ((url (thing-at-point 'url)))
(when url
(w3m-goto-url url)
(cl-return) ))))))
--
underground experts united
http://user.it.uu.se/~embe8573
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Elisp to open a line-wrapped URL
2018-02-24 23:53 Elisp to open a line-wrapped URL ckhan
2018-02-25 15:07 ` Daniel Herzig
2018-02-25 20:01 ` Emanuel Berg
@ 2018-02-26 5:02 ` Yuri Khan
2 siblings, 0 replies; 6+ messages in thread
From: Yuri Khan @ 2018-02-26 5:02 UTC (permalink / raw)
To: ckhan; +Cc: help-gnu-emacs
On Sun, Feb 25, 2018 at 6:53 AM, ckhan <charleykhan@gmail.com> wrote:
> Say I like wrapping my code at 80cols.
> But say I also occasionally include URLs in comments .
>
> So I might wind up with something like this
>
> # See also Google Drive generated py docs:
> # https://developers.google.com/resources/api-libraries/
> # documentation/drive/v2/python/latest/
> # drive_v2.permissions.html#insert
>
> How do I teach emacs to open the URL that is near my cursor, even though it's split across lines with comment markers in between?
You might be able to solve this for yourself using Emacs.
What about other people who read your code: using other editors? …in a
mail client? …on the web?
Do them a favor and keep your URLs unwrapped.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2018-02-26 5:02 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-02-24 23:53 Elisp to open a line-wrapped URL ckhan
2018-02-25 15:07 ` Daniel Herzig
2018-02-25 20:01 ` Emanuel Berg
2018-02-25 22:40 ` Emanuel Berg
2018-02-25 22:43 ` Emanuel Berg
2018-02-26 5:02 ` Yuri Khan
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.