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

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

Re: Strings as opening/closing delimiters in the syntax table?


From: Philip
Subject: Re: Strings as opening/closing delimiters in the syntax table?
Date: Wed, 08 Dec 2010 15:33:36 -0000
User-agent: G2/1.0

On Oct 27, 2:38 am, Tim X <t...@nospam.dev.null> wrote:
> Philip <phil.ganc...@gmail.com> writes:
> > I want to make emacs match "if" to "then" in sh mode like it does "("
> > and ")" in other modes. I read the wiki page about syntax tables
> > (http://www.emacswiki.org/emacs/EmacsSyntaxTable) but it only talks
> > about opening and closing delimiter *characters*. Have I
> > misunderstood, or have I found something that emacs cannot do? [ghasp!]
>
> There is nothing emacs cannot do!

Glad to know.

> However, I'm not clear exactly what you want. When you say you want
> emacs to match if to then in sh mode, do you mean work like match-paren
> does i.e. show the match and maybe highlight if you have a then without
> a matching then etc or do you mean you want more 'electric' behavior so
> that when you type if, emacs automatically puts in 'then' and leaves you
> at a pint where you can enter the condition or are you talking about
> some sort of indentation which lines up if and then statements or ....?

OK, I understand now that those are implemented separately, which is
unfortunate. For a start, I want highlighting of matching if-then,
then I want go-to-match-construct similar to what I have for goto-
match-paren, and eventually I was going to consider auto-inserting he
matching construct. The function goto-match-paren that I have uses the
syntax table (I did not write it myself):

(defun goto-match-paren (arg)
  (interactive "p")
  (cond ((looking-at "\\s\(") (forward-list 1) (backward-char 1))
        ((looking-at "\\s\)") (forward-char 1) (backward-list 1))
        ;(t (self-insert-command (or arg 1)))
        (t)))


> For all of the above, you will likely need to write some elisp functions
> to add into the mode via one of its hooks. The syntax table is not what
> you need as this deals primarily with character level syntax. You may be
> able to do what you want with abbrev mode or possibly by modifying how
> sh mode does indenting. More information is really needed that describes
> the behvior you want.
>
> Tim
>
> --
> tcross (at) rapttech dot com dot au



reply via email to

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