emacs-orgmode
[Top][All Lists]
Advanced

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

[O] Error handling in org-make-link-string


From: Bob Newell
Subject: [O] Error handling in org-make-link-string
Date: Fri, 13 Apr 2018 16:40:56 -1000
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux)

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 via email to

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