At Sat, 6 Nov 2010 09:22:25 +0100,
Magnus Nilsson wrote:
> Is there any nice way to check for broken links of different kinds in org
> files?

Well, you would have to write it by yourself but the functions are
available.

You can use `org-next-link' to make point jump to the next
link in buffer.  This function will throw an error if there is no next
link, so wrap it in a (condition case ...) statement.

For each link, look what type of link it is.  Assuming all links in
question are bracket links, use `org-bracket-link-analytic-regexp', a
variable with a regexp that breaks down the parsed link into its
parts.

(when (looking-at org-bracket-link-analytic-regexp)
  ...
)

Check the link type (it is a match string, check the doc string of
org-bracket-link-analytic-regexp), grab the link (another match
string).  Now normalize the link to the file by stripping a possible
fragment part (e.g. it might be: foo.org#id, strip the #id)

(if (string-match "\\([^#]*\\)#" <path>)
 (setq <path> (match-string 1 <path>)))

Now use (file-exist-p <path>) to check if the file exist and do
something.

HTH,
  -- David
-- 
OpenPGP... 0x99ADB83B5A4478E6
Jabber.... dmj...@jabber.org
Email..... dm...@ictsoc.de

_______________________________________________
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

Reply via email to