emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Bob Newell <bobnewell@bobnewell.net>
To: emacs-orgmode@gnu.org
Subject: Re: Error handling in org-make-link-string
Date: Sat, 14 Apr 2018 06:54:23 -1000	[thread overview]
Message-ID: <CADoYgq-DNs5QTEgoQm8YNWL_aneRDcq-9uv7tqXCQoOtnbtr7w@mail.gmail.com> (raw)
In-Reply-To: <87sh7ynd0i.fsf@nicolasgoaziou.fr>

Aloha,

Either of your suggested solutions would work, of course, and limit
effects to org-xxx-copy-for-org-mode. I didn't go that way because I
didn't want to have to continually modify the core product on my own
:)

The idea of

(if (org-string-nw-p link-location

etc. may be best because we can have a guaranteed nil on a bad link,
rather than ignore-errors which (I think?) may have a different
return. I didn't put an error message in my 'advice' workaround but it
would be a good idea.

Regards,


Bob


On Sat, Apr 14, 2018 at 3:17 AM, Nicolas Goaziou <mail@nicolasgoaziou.fr> wrote:
> Hello,
>
> Bob Newell <bobnewell@bobnewell.net> writes:
>
>> The problem? When org-make-link-string encounters an empty link (it
>> doesn't happen often but it does happen), it uses the 'error' function
>> to say that the link is empty. This means that the entire call to
>> org-xxx-copy-for-org-mode is aborted, and consequently nothing is
>> captured.
>>
>> Should this be the desired behavior?
>
> Your question is twofold.
>
> OTOH, it seems sane to expect `org-make-link-string' to throw an error
> if you try to apply it on garbage. OTOH, I agree it is not desirable to
> throw away all captured information because of a bad link.
>
> I think the problem lies in the logic of `org-eww-copy-for-org-mode' and
> `org-w3m-copy-for-org-mode', which should handle better errors from
> `org-make-link-string'.
>
> For example,
>
>    (if (stringp link-location)
>        ;; hint: link-location is different for form-elements.
>        (org-make-link-string link-location link-title)
>     link-title)
>
> could be replaced with
>
>   (if (org-string-nw-p link-location)
>       ...)
>
> or even
>
>   (or (ignore-errors (org-make-link-string ...))
>       link-title)
>
> WDYT?
>
> Regards,
>
> --
> Nicolas Goaziou



-- 
Bob Newell
Honolulu, Hawai`i

Sent via Linux Mint 17.

  reply	other threads:[~2018-04-14 16:54 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-14  2:40 Error handling in org-make-link-string Bob Newell
2018-04-14 13:17 ` Nicolas Goaziou
2018-04-14 16:54   ` Bob Newell [this message]
2018-04-14 17:32     ` Nicolas Goaziou

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CADoYgq-DNs5QTEgoQm8YNWL_aneRDcq-9uv7tqXCQoOtnbtr7w@mail.gmail.com \
    --to=bobnewell@bobnewell.net \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).