all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Marco Maggesi <marco.maggesi@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Question on syntax-propertize-function
Date: Thu, 6 Jun 2013 12:26:28 -0700 (PDT)	[thread overview]
Message-ID: <f09e652a-d60a-49ce-b982-b83e31d9e237@googlegroups.com> (raw)

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


             reply	other threads:[~2013-06-06 19:26 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-06 19:26 Marco Maggesi [this message]
2013-06-06 21:23 ` Question on syntax-propertize-function 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f09e652a-d60a-49ce-b982-b83e31d9e237@googlegroups.com \
    --to=marco.maggesi@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.