* Re: Strings as opening/closing delimiters in the syntax table?
[not found] <573afe15-f5c3-4ed9-8d30-1d0775e20aa7@f33g2000yqh.googlegroups.com>
@ 2010-10-27 6:38 ` Tim X
2010-10-27 7:40 ` Philip
2010-10-27 11:50 ` Ilya Zakharevich
2010-10-29 18:56 ` Stefan Monnier
2 siblings, 1 reply; 5+ messages in thread
From: Tim X @ 2010-10-27 6:38 UTC (permalink / raw)
To: help-gnu-emacs
Philip <phil.ganchev@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!
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 ....?
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
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Strings as opening/closing delimiters in the syntax table?
2010-10-27 6:38 ` Strings as opening/closing delimiters in the syntax table? Tim X
@ 2010-10-27 7:40 ` Philip
0 siblings, 0 replies; 5+ messages in thread
From: Philip @ 2010-10-27 7:40 UTC (permalink / raw)
To: help-gnu-emacs
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
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Strings as opening/closing delimiters in the syntax table?
[not found] <573afe15-f5c3-4ed9-8d30-1d0775e20aa7@f33g2000yqh.googlegroups.com>
2010-10-27 6:38 ` Strings as opening/closing delimiters in the syntax table? Tim X
@ 2010-10-27 11:50 ` Ilya Zakharevich
2010-10-29 18:56 ` Stefan Monnier
2 siblings, 0 replies; 5+ messages in thread
From: Ilya Zakharevich @ 2010-10-27 11:50 UTC (permalink / raw)
To: help-gnu-emacs
On 2010-10-27, Philip <phil.ganchev@gmail.com> wrote:
> 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!]
You should mark "i" in "if" and the final "e" in "else" by
corresponding matching `syntax-type' text-property.
Hope this helps,
Ilya
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Strings as opening/closing delimiters in the syntax table?
[not found] <573afe15-f5c3-4ed9-8d30-1d0775e20aa7@f33g2000yqh.googlegroups.com>
2010-10-27 6:38 ` Strings as opening/closing delimiters in the syntax table? Tim X
2010-10-27 11:50 ` Ilya Zakharevich
@ 2010-10-29 18:56 ` Stefan Monnier
[not found] ` <buo4obqhnst.fsf@dhlpc061.dev.necel.com>
2 siblings, 1 reply; 5+ messages in thread
From: Stefan Monnier @ 2010-10-29 18:56 UTC (permalink / raw)
To: help-gnu-emacs
> 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!]
FWIW, octave-mode does it. Now that doesn't help you for sh scripts,
but the octave-mode in the Emacs development trunk does it in a new way
which uses a new generic navigation&indentation package called SMIE.
So "all" you need to do is to describe the sh syntax to SMIE and you'll
get that behavior (and you'll also get indentation with it, tho sh-mode
already provides it in a different way).
Stefan
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Strings as opening/closing delimiters in the syntax table?
[not found] ` <buo4obqhnst.fsf@dhlpc061.dev.necel.com>
@ 2010-11-10 17:52 ` Stefan Monnier
0 siblings, 0 replies; 5+ messages in thread
From: Stefan Monnier @ 2010-11-10 17:52 UTC (permalink / raw)
To: help-gnu-emacs
>> which uses a new generic navigation&indentation package called SMIE.
> Hmm, nice ... I didn't know about that...
New in Emacs-23.3.
Stefan
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2010-11-10 17:52 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <573afe15-f5c3-4ed9-8d30-1d0775e20aa7@f33g2000yqh.googlegroups.com>
2010-10-27 6:38 ` Strings as opening/closing delimiters in the syntax table? Tim X
2010-10-27 7:40 ` Philip
2010-10-27 11:50 ` Ilya Zakharevich
2010-10-29 18:56 ` Stefan Monnier
[not found] ` <buo4obqhnst.fsf@dhlpc061.dev.necel.com>
2010-11-10 17:52 ` Stefan Monnier
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).