Help with GNU Emacs syntax.el and XEmacs buffer-syntactic-context et al?
kehoea at parhasard.net
Sat Jun 4 06:14:10 EDT 2011
Ar an ceathrú lá de mí Meitheamh, scríobh Mats Lidell:
> Been looking again at the task of getting the mode for go work with
> XEmacs and need some help.
> It uses functions from syntax.el which in GNU Emacs contains
> "helper functions to find syntactic context". Oddly(!?) this file
> contains at the bottom commented out XEmacs(!) compatibility functions
> for "buffer-syntactic-contex" and "buffer-syntactic-context-dept"
> which are found in font-lock.c. This could indicate that we have
> overlapping functionality which in its turn might be better handled by
> just using our APIs instead!?
> I ask myself what is the proper thing to do here:
> 1. Ignore that we have these overlap and just get the functions in
> syntax.el into XEmacs as is.
My feeling is that this is the right way to go. In your position I’d create
a new file in XEmacs, call it syntax-ppss.el (notice that #'syntax-ppss is the
main function exported by their syntax.el), and move GNU’s syntax.el into
Note when testing that #'syntax-ppss relies on #'parse-partial-sexp, and I
don’t know how compatible ours is with theirs.
> [...]  The actual offending function used by go-mode is this:
> (syntax-ppss (&optional pos)
> "Parse-Partial-Sexp State at POS, defaulting to point.
> The returned value is the same as `parse-partial-sexp' except that
> the 2nd and 6th values of the returned state cannot be relied upon.
> Point is at POS when this function returns."
> What would be the XEmacs way to implement that?
According to the docstring, a wrapper around #'parse-partial-sexp would do
it. But is #'syntax-ppss faster? Does it not modify some global state? Does
it cache things that #'parse-partial-sexp doesn’t? It’s just about possible
that there’s no point to it, in which case a wrapper would be the way to go.
‘Iodine deficiency was endemic in parts of the UK until, through what has been
described as “an unplanned and accidental public health triumph”, iodine was
added to cattle feed to improve milk production in the 1930s.’
(EN Pearce, Lancet, June 2011)
More information about the XEmacs-Beta