emacs-devel
[Top][All Lists]
Advanced

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

RE: /srv/bzr/emacs/trunk r101338: * lisp/emacs-lisp/syntax.el (syntax-pp


From: Drew Adams
Subject: RE: /srv/bzr/emacs/trunk r101338: * lisp/emacs-lisp/syntax.el (syntax-ppss): More sanity check to catch
Date: Fri, 14 Feb 2014 09:22:22 -0800 (PST)

eli>> Emacs can use text properties to switch syntax tables or
eli>> categories or even keymaps in mid-buffer.  Maybe switching the
eli>> whole mode would be feasible in a similar manner.
sm> 
sm> Yes, something like that.  Basically, somehow present to major-mode
sm> features only a portion of the buffer (e.g., by narrowing
sm> internally).

and

eli> One possibility would be a special text property, whose value is
eli> the major mode in effect for the text covered by that property.
eli> (I'm not saying this is the best idea, I'm just trying to explain
eli> what kind of infrastructure would be needed.)

FWIW -

Lennart Borgman's MuMaMo multiple-major-mode code uses/used a text
property, `mumamo-major-mode', to distinguish zones mapped to particular
major modes.

I know very little about MuMaMo.  The reason I know about this property
is that my library `isearch-prop.el' takes this into account, to allow
isearching (only) the zones ("chunks") that are mapped to a particular
major mode.

The value of property `mumamo-major-mode' is handled as a special case
by `isearch-prop.el'.  Properties `face' and `font-lock-face' are also
handled specially by default, and customization allows special handling
of others. 

Normally, searching uses `equal' to check whether a property value
matches a value specified by the user.  For `face', `font-lock-face',
and `mumamo-major-mode', the matching check is not `equal'.

For the first two, text is searched that has a face property value
that includes any of the faces specified by the user.  For
`mumamo-major-mode', the user-specified major-mode name is matched
against the car of the `mumamo-major-mode' property value.

IOW, this is the default matching function:

(defun isearchp-property-default-match-fn (property)
  "Return the default match function for text or overlay PROPERTY.
Properties `face', `font-lock-face', and `mumamo-major-mode' are
handled specially.  For other properties the values are matched
using `equal'."
  (case property
    ((face font-lock-face)
     (lambda (val rprop)
       (if (consp rprop)
           (condition-case nil    ; Allow for dotted cons.
               (member val rprop)
             (error nil))
         (eq val rprop))))
    ((mumamo-major-mode)
     (lambda (val rprop) (equal val (car rprop))))
    (t
     #'equal)))





reply via email to

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