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

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

Re: DWIM region


From: Stefan Monnier
Subject: Re: DWIM region
Date: Mon, 08 Jan 2018 09:08:42 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

> (defun w3m-bookmark-dwim (url &optional title)
>   (interactive
>    (if (use-region-p)
>        (list w3m-current-url (buffer-substring (region-beginning) 
> (region-end)))
>      (let ((url-at-point (thing-at-point 'url)))
>        (if url-at-point (list url-at-point) ; perhaps these two can...
>          (let ((link-url (w3m-url-valid (w3m-anchor)))) ; be flipped!
>            (if link-url (list link-url) ; (w3m-anchor-title) here DNC
>              (list w3m-current-url w3m-current-title) ))))))
>   (w3m-bookmark-add url title) )

You could get pretty much the same result by changing the `interactive`
spec of w3m-bookmark-add.  E.g. by changing w3m's source code, or with
an advice, or with

    (put 'w3m-bookmark-add
         'interactive-form
         `(funcall ',(lambda ()
            (if (use-region-p)
                (list w3m-current-url (buffer-substring (region-beginning) 
(region-end)))
              (let ((url-at-point (thing-at-point 'url)))
                (if url-at-point (list url-at-point) ; perhaps these two can...
                  (let ((link-url (w3m-url-valid (w3m-anchor)))) ; be flipped!
                    (if link-url (list link-url) ; (w3m-anchor-title) here DNC
                      (list w3m-current-url w3m-current-title) ))))))))

-- Stefan




reply via email to

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