From mboxrd@z Thu Jan 1 00:00:00 1970 From: Bob Newell Subject: Re: Error handling in org-make-link-string Date: Sat, 14 Apr 2018 06:54:23 -1000 Message-ID: References: <87o9imh5mv.fsf@bobnewell.net> <87sh7ynd0i.fsf@nicolasgoaziou.fr> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:36654) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f7ORq-0007lo-3v for emacs-orgmode@gnu.org; Sat, 14 Apr 2018 12:54:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f7ORp-0001sG-A7 for emacs-orgmode@gnu.org; Sat, 14 Apr 2018 12:54:46 -0400 Received: from mail-yw0-x231.google.com ([2607:f8b0:4002:c05::231]:42411) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1f7ORp-0001s4-4f for emacs-orgmode@gnu.org; Sat, 14 Apr 2018 12:54:45 -0400 Received: by mail-yw0-x231.google.com with SMTP id z82so5315849ywd.9 for ; Sat, 14 Apr 2018 09:54:44 -0700 (PDT) In-Reply-To: <87sh7ynd0i.fsf@nicolasgoaziou.fr> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: emacs-orgmode@gnu.org 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 wrote: > Hello, > > Bob Newell 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.