all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Glenn Morris <rgm@gnu.org>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: 753@emacsbugs.donarmstrong.com
Subject: bug#753: [Fwd: sh-script.el: indentation of ( )]
Date: Thu, 08 Jan 2009 21:39:01 -0500	[thread overview]
Message-ID: <7f8wpl430a.fsf@fencepost.gnu.org> (raw)
In-Reply-To: <jwvhc49g3li.fsf-monnier+emacsbugreports@gnu.org> (Stefan Monnier's message of "Thu, 08 Jan 2009 11:39:55 -0500")

Stefan Monnier wrote:

> Basically, what I saw is that it recognized "done|" as a keyword,
> which I fixed by adding ?| to the "not in keywords" chars. By the
> same reasonging "done)" is not a keyword, so I added ?\) (and ?\( as
> well for good measure).

Adding them causes the problem you are trying to avoid.

Applying (skip-chars-forward "^ \t\n;&|")

to "done) "

results in "done)", which is not a recognized keyword.

>  I guess that sh-get-kw should be fixed more robustly by recognizing
> ")" and "(" but not "(done", nor "(done|toto)" for that matter. Can
> you take care of that and make sure it fixes the problem at hand
> without breaking the problem that prompted my misguided fix?

It's tricky. Consider the following two examples:


for f in 1; do
    case $f in
        done) echo t ;;
    esac
done


(for f in 1; do
   echo $f
done)


In the second one, "done)" ends a for loop, in the first one it does not.

Both Emacs 22.3 and the current CVS get both examples wrong, in
different ways.

ii), though valid syntax, seems ugly (and hopefully uncommon) to me,
especially considering that in Bash at least, the same problem cannot
arise with {}, since these must be isolated by whitespace.

A simple fix for i) is as follows. I don't know how to fix both i) and ii).


Did you have any other examples of shell syntax to be considered?



*** sh-script.el	5 Jan 2009 03:23:50 -0000	1.220
--- sh-script.el	9 Jan 2009 02:22:31 -0000
***************
*** 1421,1427 ****
    "Make a regexp which matches WORD as a word.
  This specifically excludes an occurrence of WORD followed by
  punctuation characters like '-'."
!   (concat word "\\([^-[:alnum:]_]\\|$\\)"))
  
  (defconst sh-re-done (sh-mkword-regexpr "done"))
  
--- 1421,1428 ----
    "Make a regexp which matches WORD as a word.
  This specifically excludes an occurrence of WORD followed by
  punctuation characters like '-'."
!   ;; ")}" excludes things like "done)" in case statements.
!   (concat word "\\([^-[:alnum:]_)}]\\|$\\)"))
  
  (defconst sh-re-done (sh-mkword-regexpr "done"))






  reply	other threads:[~2009-01-09  2:39 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <eqr67xumlz.fsf@fencepost.gnu.org>
2008-08-20 21:36 ` bug#753: [Fwd: sh-script.el: indentation of ( )] Daniel Pfeiffer
2008-08-23  0:12   ` Glenn Morris
2008-09-03 17:34     ` Glenn Morris
2009-01-07  4:47       ` Stefan Monnier
     [not found]       ` <jwvy6xnd8rf.fsf-monnier+emacsbugreports@gnu.org>
2009-01-08  8:00         ` Glenn Morris
2009-01-08 16:39           ` Stefan Monnier
2009-01-09  2:39             ` Glenn Morris [this message]
2009-01-09  3:58               ` Stefan Monnier
2009-01-09  5:02                 ` Glenn Morris
2009-01-09 17:24                   ` Stefan Monnier
2015-12-30  0:45                     ` Andrew Hyatt
2016-01-01  2:19                       ` Glenn Morris
2016-01-02 20:55                         ` Andrew Hyatt
2008-09-06 19:10   ` bug#753: marked as done ([Fwd: sh-script.el: indentation of ( )]) Emacs bug Tracking System
2009-05-04 20:30   ` Emacs bug Tracking System

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=7f8wpl430a.fsf@fencepost.gnu.org \
    --to=rgm@gnu.org \
    --cc=753@emacsbugs.donarmstrong.com \
    --cc=monnier@iro.umontreal.ca \
    /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.