HELP, PLEASE! Syntax problem!
Aidan Kehoe
kehoea at parhasard.net
Sat Nov 28 04:38:32 EST 2009
Ar an seachtú lá is fiche de mí na Samhain, scríobh Aidan Kehoe:
> Ar an seachtú lá is fiche de mí na Samhain, scríobh Alan Mackenzie:
>
> > On Fri, Nov 27, 2009 at 10:56:34AM +0100, David Kastrup wrote:
> >
> > > You are underestimating XEmacs. It has a function iterating over all
> > > extents (their equivalent of both overlays and text properties) in a
> > > half-/open/closed range that have a particular set or state of
> > > properties. So you can say something like "give me all extents for
> > > which the property 'category happens to be 'text".
> >
> > > Something like
> > > (map-extents (lambda (extent) ...) some-flag (point-min)
> > > (point-max) another-flag and-yet-another 'category 'text)
> >
> > Yes, I've underestimated XEmacs. But that map-extents is still
> > hopelessly slow by 2(?) orders of magnitude. I need to "switch off
> > macros" each time I call `c-parse-state'. In Emacs, I comment them out
> > with exactly this form:
> >
> > (put 'c-cpp-delimiter 'syntax-table '(14)) ; 14 is "generic comment".
> >
> > The rogue file I'm making this change for has 4131 #defines in it.
> > map-extents would be hopeless for this out-commenting.
>
> I’m not sure exactly what you’re doing in XEmacs, but is there anything
> stopping you keeping the list representing the syntax table for
> c-cpp-delimiters around (using it on creation of each such extent) and
> modifying and reverting its car every time you want to do this? The
> ‘inherit’ value (13, as it happens) should be sufficient to have it take its
> syntax table from the surrounding text, if that’s what you want. So,
>
> (defvar c-cpp-delimiter-syntax-table '(13))
>
> (put-text-property START END 'category 'text)
> (put-text-property START END 'syntax-table c-cpp-delimiter-syntax-table)
>
> (setcar c-cpp-delimiter-syntax-table 14) ;; on entry to c-parse-state
> (setcar c-cpp-delimiter-syntax-table 13) ;; on exit from c-parse-state
>
> Now, it’s probably foolhardy of me to suggest this without having tested it
> (maybe the syntax-table property is broken ...) but in my defence, I can’t
> find your code online.
Looks like one would need to invalidate the syntax cache with that approach,
though. So something like:
(defmacro c-set-cpp-delimiter-syntax-generic-comment (from to)
(if (featurep 'xemacs)
`(symbol-macrolet
((generic-comment-syntax 14)) ;; A lot easier to grep for
(setcar c-cpp-delimiter-syntax-table generic-comment-syntax)
(map-extents #'(lambda (extent maparg)
;; Force invalidation of the syntax cache:
(set-extent-property extent 'syntax-table nil)
(set-extent-property extent 'syntax-table
c-cpp-delimiter-syntax-table)
t) ; give up after the first extent
nil ,from ,to nil 'syntax-table
c-cpp-delimiter-syntax-table))
`(put 'c-cpp-delimiter 'syntax-table '(14))))
(defmacro c-set-cpp-delimiter-syntax-inherit (from to)
(if (featurep 'xemacs)
`(symbol-macrolet
((inherit-syntax 13))
(setcar c-cpp-delimiter-syntax-table inherit-syntax)
(map-extents #'(lambda (extent maparg)
;; Force invalidation of the syntax cache:
(set-extent-property extent 'syntax-table nil)
(set-extent-property extent 'syntax-table
c-cpp-delimiter-syntax-table)
t) ; give up after the first extent
nil ,from ,to nil 'syntax-table
c-cpp-delimiter-syntax-table))
`(put 'c-cpp-delimiter 'syntax-table '(14))))
--
“Apart from the nine-banded armadillo, man is the only natural host of
Mycobacterium leprae, although it can be grown in the footpads of mice.”
-- Kumar & Clark, Clinical Medicine, summarising improbable leprosy research
More information about the XEmacs-Beta
mailing list