On Mon, Aug 29, 2011 at 11:36:19AM +0200, Nicolas Goaziou wrote: > Maybe we should define a consistent link search: ignore the narrowing > but first search in current sub-tree, if that fails (any error, I guess) > search in current tree and if that one fails too, search in the whole > buffer.
So something with the same semantics as this: (defun find-nearest-heading-named (l) (unless (find-heading-in-current-subtree l) (up-one-level) (find-nearest-heading-named l))) i.e find the target with its parent headings list sharing the longest prefix with current point's. * A ** B * C ** B ** D *** B *** E A link to B inside E would go to C/D/B because (C D B) shares longer prefix with (C D E) than (C B) and (A B) does. anders