help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Elisp to open a line-wrapped URL


From: Emanuel Berg
Subject: Re: Elisp to open a line-wrapped URL
Date: Sun, 25 Feb 2018 21:01:05 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux)

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


reply via email to

[Prev in Thread] Current Thread [Next in Thread]