From mboxrd@z Thu Jan 1 00:00:00 1970 From: Bob Newell Subject: Error handling in org-make-link-string Date: Fri, 13 Apr 2018 16:40:56 -1000 Message-ID: <87o9imh5mv.fsf@bobnewell.net> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:43160) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f7B7g-0003Xb-Gw for emacs-orgmode@gnu.org; Fri, 13 Apr 2018 22:41:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f7B7d-0003cl-Dh for emacs-orgmode@gnu.org; Fri, 13 Apr 2018 22:41:04 -0400 Received: from mail-pf0-x231.google.com ([2607:f8b0:400e:c00::231]:34494) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1f7B7d-0003c3-4t for emacs-orgmode@gnu.org; Fri, 13 Apr 2018 22:41:01 -0400 Received: by mail-pf0-x231.google.com with SMTP id q9so7390835pff.1 for ; Fri, 13 Apr 2018 19:41:00 -0700 (PDT) Received: from localhost (udp073869uds.hawaiiantel.net. [141.239.248.62]) by smtp.gmail.com with ESMTPSA id 133sm12959618pfy.113.2018.04.13.19.40.58 for (version=TLS1_2 cipher=AES128-SHA bits=128/128); Fri, 13 Apr 2018 19:40:58 -0700 (PDT) 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, I've got a subsystem for capturing snippets of information (I mentioned it here, scraps.el, quite some while back). Some information is captured from w3m or eww browser buffers. To do this I use org-w3m-copy-for-org-mode or org-eww-copy-for-org-mode. This is nice in that links are converted to org-mode links, using org-make-link-string. 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? It doesn't quite work for me, but I'm not sure about other uses, side effects, etc. Someone more familiar with org-mode code would have to decide. My workaround, since I don't want to modify org.el directly and have to maintain the mod, is this fairly primitive idea: (defun rjn-around-omls (orig-fun link &rest args) (if (org-string-nw-p link) (apply orig-fun link args) nil)) (advice-add 'org-make-link-string :around #'rjn-around-omls) This works fine for me in that an empty link is simply returned as nil and ignored. (I suppose I could add an error message.) Any thoughts on (a) is the 'error' return the right thing, and (b) this workaround? Mahalo, -- Bob Newell Honolulu, Hawai`i * Via Gnus/BBDB/Org/Emacs/Linux *