From: David Maus <dmaus@ictsoc.de>
To: Magnus Nilsson <magnus.nilsson@alumni.chalmers.se>
Cc: emacs-orgmode@gnu.org
Subject: Re: Check for broken links in org-mode?
Date: Tue, 09 Nov 2010 21:58:43 +0100 [thread overview]
Message-ID: <87lj52w6ws.wl%dmaus@ictsoc.de> (raw)
In-Reply-To: <AANLkTinPfRhVbcPVDH+8neth8SD5YmTH-_RTbDAihwGf@mail.gmail.com>
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.... dmjena@jabber.org
Email..... dmaus@ictsoc.de
prev parent reply other threads:[~2010-11-09 21:06 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-11-06 8:22 Check for broken links in org-mode? Magnus Nilsson
2010-11-09 20:58 ` David Maus [this message]
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=87lj52w6ws.wl%dmaus@ictsoc.de \
--to=dmaus@ictsoc.de \
--cc=emacs-orgmode@gnu.org \
--cc=magnus.nilsson@alumni.chalmers.se \
/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).