all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Question on syntax-propertize-function
@ 2013-06-06 19:26 Marco Maggesi
  2013-06-06 21:23 ` Stefan Monnier
       [not found] ` <mailman.1117.1370553840.22516.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 4+ messages in thread
From: Marco Maggesi @ 2013-06-06 19:26 UTC (permalink / raw)
  To: help-gnu-emacs

Hi,

I'm trying to improve an old emacs major mode I wrote some years ago (http://web.math.unifi.it/users/maggesi/holl-mode-2006-10-24.tar.gz) for editing HOL Light proof scripts (HOL Light is a theorem prover http://www.cl.cam.ac.uk/~jrh13/hol-light/, its syntax is close to OCaml and SML but with lots of idiosyncrasies).

I have two problems:

1. Comments are delimited by (* and *).  However, (*) should not open nor close a comment.

2. Anything enclosed in blackquotes `...` is a HOL term and follows a different syntax.

I suppose that this kind of issues are normally solved by setting text properties, but so far my attempts failed miserably.  I left aside problem 2 for now because I'm undecided on what to do exactly (e.g., should I set the syntax-table property for the quoted text or should I use syntax-entry "$   "?).

Here is what I did for problem 1.  I set a syntax table for holl mode which includes the following entries:

    (modify-syntax-entry ?\( "()1" st)
    (modify-syntax-entry ?\) ")(4" st)
    (modify-syntax-entry ?\* ". 23n" st)

This works as expected in most cases, but (*) open and close comments.
Then I defined a "propertize" function:

(defun holl-syntax-propertize (start end)
  (goto-char start)
  (funcall
   (syntax-propertize-rules
    ("\\((\\)\\(\\*\\)\\()\\)"
     (1 "()  ")
     (2 ".   ")
     (3 ")(  "))
    )
   start end))

and I set syntax-propertize-function in the initialization of the major mode:

  (set (make-local-variable 'syntax-propertize-function)
       #'holl-syntax-propertize)

However, this doesn't seems to have any effect.  I also played with syntax-propertize-extend-region-functions but with no success.

Can you see what's wrong with this approach?  Or can you suggest a debugging technique?  E.g., how can I run interactively syntax-property-rules?  I defined an interactive function

(defun holl-propertize (start end)
  (interactive "r")
  (funcall
   (syntax-propertize-rules
    ("\\((\\)\\(\\*\\)\\()\\)"
     (1 "()  ")
     (2 ".   ")
     (3 ")(  "))
    )
   start end))

and if I run it on a region containing (*) I get no effect.

Thanks,
Marco


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-06-08  0:46 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-06-06 19:26 Question on syntax-propertize-function Marco Maggesi
2013-06-06 21:23 ` Stefan Monnier
     [not found] ` <mailman.1117.1370553840.22516.help-gnu-emacs@gnu.org>
2013-06-07  9:13   ` Marco Maggesi
2013-06-08  0:46     ` Stefan Monnier

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.