From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Maus Subject: Re: Check for broken links in org-mode? Date: Tue, 09 Nov 2010 21:58:43 +0100 Message-ID: <87lj52w6ws.wl%dmaus@ictsoc.de> References: Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Return-path: Received: from [140.186.70.92] (port=34833 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PFvOC-0005jh-06 for emacs-orgmode@gnu.org; Tue, 09 Nov 2010 16:06:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PFvHC-0004lc-6C for emacs-orgmode@gnu.org; Tue, 09 Nov 2010 15:58:52 -0500 Received: from mailout110.xlhost.de ([213.202.242.110]:44293 helo=mysql1.xlhost.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PFvHC-0004kx-11 for emacs-orgmode@gnu.org; Tue, 09 Nov 2010 15:58:46 -0500 In-Reply-To: List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Magnus Nilsson Cc: emacs-orgmode@gnu.org 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 "\\([^#]*\\)#" ) (setq (match-string 1 ))) Now use (file-exist-p ) to check if the file exist and do something. HTH, -- David -- OpenPGP... 0x99ADB83B5A4478E6 Jabber.... dmjena@jabber.org Email..... dmaus@ictsoc.de