help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: +1 char strings as open-bracket/close-bracket


From: Andreas Röhler
Subject: Re: +1 char strings as open-bracket/close-bracket
Date: Fri, 26 Jun 2009 08:38:06 +0200
User-agent: Thunderbird 2.0.0.19 (X11/20081227)

Kokor Hekkus wrote:
> Any way of modifying the syntax table to identify a string of more
> than one character as an open-bracket or a close-bracket character.
> For instance, you might do:
>
>      (modify-syntax-entry ?^ "($")
>      (modify-syntax-entry ?$ ")^")
>
> ...to make ^ and $ match each other (from EmacsWiki).  How would I
> make the two character strings '#>' and '<#' match in the same way?
>   

AFAIU relying on syntax-tables will fail if constructs are nested.

In this case have a look at beg-end.el and thingatpt-utils-base.el at

https://code.launchpad.net/s-x-emacs-werkstatt/

There detecting nested comments for example is realised that way:

(put 'comment 'beginning-op-at
     (lambda ()
       (if (string= "" comment-end)
           (beginning-of-form-base comment-start comment-end
(line-beginning-position) t nil t)
         (beginning-of-form-base  comment-end nil t nil t))))

(put 'comment 'end-op-at
     (lambda ()
       (if (string= "" comment-end)
           (when (looking-at comment-start)
             (end-of-line))
         (end-of-form-base comment-start comment-end nil t nil t))))

Replace comment-start/end here by your form,
write "(put 'MY-Form... " it should work.

Afterwards you may define a jump-function similar to match-paren.

HTH

Andreas






> The above doesn't work.
>
> Thanks!
>
>   





reply via email to

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