emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Bob Newell <bobnewell@bobnewell.net>
To: emacs-orgmode@gnu.org
Subject: Error handling in org-make-link-string
Date: Fri, 13 Apr 2018 16:40:56 -1000	[thread overview]
Message-ID: <87o9imh5mv.fsf@bobnewell.net> (raw)

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 *

             reply	other threads:[~2018-04-14  2:41 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-14  2:40 Bob Newell [this message]
2018-04-14 13:17 ` Error handling in org-make-link-string Nicolas Goaziou
2018-04-14 16:54   ` Bob Newell
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=87o9imh5mv.fsf@bobnewell.net \
    --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).