emacs-orgmode
[Top][All Lists]
Advanced

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

Re: [Orgmode] Check for broken links in org-mode?


From: David Maus
Subject: Re: [Orgmode] Check for broken links in org-mode?
Date: Tue, 09 Nov 2010 21:58:43 +0100
User-agent: Wanderlust/2.15.9 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (Goj┼Ź) APEL/10.8 Emacs/23.2 (i486-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO)

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.... address@hidden
Email..... address@hidden



reply via email to

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