emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] /srv/bzr/emacs/trunk r110745: * lisp/progmodes/sh-script.e


From: Stefan Monnier
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r110745: * lisp/progmodes/sh-script.el (sh--inside-arithmetic-expression): New func.
Date: Tue, 30 Oct 2012 22:45:34 -0400
User-agent: Bazaar (2.5.0)

------------------------------------------------------------
revno: 110745
fixes bug: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=12770
committer: Stefan Monnier <address@hidden>
branch nick: trunk
timestamp: Tue 2012-10-30 22:45:34 -0400
message:
  * lisp/progmodes/sh-script.el (sh--inside-arithmetic-expression): New func.
  (sh-font-lock-open-heredoc): Use it.
added:
  test/indent/perl.perl
modified:
  lisp/ChangeLog
  lisp/progmodes/sh-script.el
  test/indent/shell.sh
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2012-10-30 08:03:22 +0000
+++ b/lisp/ChangeLog    2012-10-31 02:45:34 +0000
@@ -1,3 +1,8 @@
+2012-10-31  Stefan Monnier  <address@hidden>
+
+       * progmodes/sh-script.el (sh--inside-arithmetic-expression): New func.
+       (sh-font-lock-open-heredoc): Use it (bug#12770).
+
 2012-10-30  Glenn Morris  <address@hidden>
 
        * emacs-lisp/cl-extra.el (cl-mapc): Add autoload cookie.  Doc fix.

=== modified file 'lisp/progmodes/sh-script.el'
--- a/lisp/progmodes/sh-script.el       2012-10-29 00:06:39 +0000
+++ b/lisp/progmodes/sh-script.el       2012-10-31 02:45:34 +0000
@@ -940,6 +940,15 @@
     (concat "<<-?\\s-*\\\\?\\(\\(?:['\"][^'\"]+['\"]\\|\\sw\\|[-/~._]\\)+\\)"
             sh-escaped-line-re "\\(\n\\)")))
 
+(defun sh--inside-arithmetic-expression (pos)
+  (save-excursion
+    (let ((ppss (syntax-ppss pos)))
+      (when (nth 1 ppss)
+        (goto-char (nth 1 ppss))
+        (and (eq ?\( (char-after))
+             (eq ?\( (char-before))
+             (eq ?\$ (char-before (1- (point)))))))))
+
 (defun sh-font-lock-open-heredoc (start string eol)
   "Determine the syntax of the \\n after a <<EOF.
 START is the position of <<.
@@ -948,7 +957,8 @@
 be indented (i.e. a <<- was used rather than just <<).
 Point is at the beginning of the next line."
   (unless (or (memq (char-before start) '(?< ?>))
-             (sh-in-comment-or-string start))
+             (sh-in-comment-or-string start)
+              (sh--inside-arithmetic-expression start))
     ;; We're looking at <<STRING, so we add "^STRING$" to the syntactic
     ;; font-lock keywords to detect the end of this here document.
     (let ((str (replace-regexp-in-string "['\"]" "" string))

=== added file 'test/indent/perl.perl'
--- a/test/indent/perl.perl     1970-01-01 00:00:00 +0000
+++ b/test/indent/perl.perl     2012-10-31 02:45:34 +0000
@@ -0,0 +1,5 @@
+#!/usr/bin/perl
+# -*- eval: (bug-reference-mode 1) -*-
+
+$fileType_filesButNot           # bug#12373?
+    = join( '|', map { quotemeta($_).'$' } @{$fileType->{filesButNot}} );

=== modified file 'test/indent/shell.sh'
--- a/test/indent/shell.sh      2012-10-29 15:14:10 +0000
+++ b/test/indent/shell.sh      2012-10-31 02:45:34 +0000
@@ -5,6 +5,10 @@
 
 # adsgsdg
 
+echo -n $(( 5 << 2 ))
+# This should not be treated as a heredoc (bug#12770).
+2
+
 declare -a VERSION
 for i in $(ls "$PREFIX/sbin") ; do
     echo -e $N')' $i


reply via email to

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