emacs-devel
[Top][All Lists]
Advanced

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

Re: [PATCH] ffap.el: Exclude angle brackets from file names in XML


From: Yuri Khan
Subject: Re: [PATCH] ffap.el: Exclude angle brackets from file names in XML
Date: Sun, 10 Mar 2024 19:17:27 +0700

On Sun, 10 Mar 2024 at 17:46, Eli Zaretskii <eliz@gnu.org> wrote:

> > > > there is no way for either a
> > > > doctype definition or an XML Schema to say “elements named X
> > > > definitely contain file names”. The closest is XML Schema’s anyURI
> > > > datatype, but it might refer not necessarily to a local file but
> > > > possibly to any other URI-addressed resource.

> I was surprised that you didn't (and AFAIU still
> don't) suggest that we interpret the tags according to the schema.

I think I explained that: because there is nothing in the XML Schema
meta-schema that talks specifically of files and file names.

It might be possible to consider element content or attributes typed
as ‘anyURI’ to contain file names. It will incur false positives (when
an anyURI attribute actually contains a non-file URI) and false
negatives (when the schema of a document is not known to Emacs, or
when it does not specifically designate an element or attribute as
‘anyURI’ even though it contains file names in practice).

> AFAIR, we do have an XML mode which can parse the schema, so it seems
> reasonable to expect that we could recognize file names using the
> information in the schema without any guesswork.  If this is
> impossible, please explain why not, but please be specific: refer to
> what Emacs can know about an XML document using the existing XML
> mode(s), and how that affects our ability to know which tags specify
> file names.

I assume you’re referring to ‘rnc-validate-mode’ minor mode and the
few schemas it knows about out of the box?

The OP is working with an unspecified, possibly proprietary, XML-based
format. Likely, its schema is not included in Emacs, and possibly not
even readily available to the OP. If available, it might not be in the
RELAX NG Compact format, requiring conversion. If not available, the
OP would have to derive a schema from observed document instances.

Meanwhile, the generic approach “the longest sequence of characters
allowed in file names, subject to restrictions of your buffer’s
syntax, starting from the point where you type M-RET and extending
both ways, is potentially a file name”, is easy to implement and
usable without any preliminary setup, although probably biased towards
false positives (attempting to produce a file name when the element or
attribute is not intended as such).



reply via email to

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