all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Philip <phil.ganchev@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Re: Strings as opening/closing delimiters in the syntax table?
Date: Wed, 27 Oct 2010 00:40:40 -0700 (PDT)	[thread overview]
Message-ID: <7ac43d43-0e5e-4099-a7bc-4313a33ef550@a37g2000yqi.googlegroups.com> (raw)
In-Reply-To: 87aam0nnsh.fsf@rapttech.com.au

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	other threads:[~2010-10-27  7:40 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [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 [this message]
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

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=7ac43d43-0e5e-4099-a7bc-4313a33ef550@a37g2000yqi.googlegroups.com \
    --to=phil.ganchev@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.