diff lisp/progmodes/python.el @ 90780:ec58e5c426ef

Merge from emacs--devo--0 Patches applied: * emacs--devo--0 (patch 653-661) - Update from CVS - Merge from gnus--rel--5.10 * gnus--rel--5.10 (patch 203-206) - Merge from emacs--devo--0 - Update from CVS Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-180
author Miles Bader <miles@gnu.org>
date Sun, 04 Mar 2007 06:19:40 +0000
parents 95d0cdf160ea 985cc73beb79
children 91bf6e05918b
line wrap: on
line diff
--- a/lisp/progmodes/python.el	Fri Mar 02 01:43:44 2007 +0000
+++ b/lisp/progmodes/python.el	Sun Mar 04 06:19:40 2007 +0000
@@ -163,7 +163,7 @@
 	       (= (match-beginning 1) (match-end 1))) ; prefix is null
 	  (and (= n 1)			; prefix
 	       (/= (match-beginning 1) (match-end 1)))) ; non-empty
-      (unless (eq 'string (syntax-ppss-context (syntax-ppss)))
+      (unless (nth 3 (syntax-ppss))
         (eval-when-compile (string-to-syntax "|"))))
      ;; Otherwise (we're in a non-matching string) the property is
      ;; nil, which is OK.
@@ -1743,12 +1743,11 @@
 	       (orig (point))
 	       (start (nth 8 syntax))
 	       end)
-	  (cond ((eq t (nth 3 syntax))	    ; in fenced string
-		 (goto-char (nth 8 syntax)) ; string start
-		 (condition-case ()	    ; for unbalanced quotes
-		     (progn (forward-sexp)
-			    (setq end (point)))
-		   (error (setq end (point-max)))))
+	  (cond ((eq t (nth 3 syntax))	      ; in fenced string
+		 (goto-char (nth 8 syntax))   ; string start
+		 (setq end (condition-case () ; for unbalanced quotes
+                               (progn (forward-sexp) (point))
+                             (error (point-max)))))
 		((re-search-backward "\\s|\\s-*\\=" nil t) ; end of fenced
 							   ; string
 		 (forward-char)
@@ -1756,13 +1755,17 @@
 		 (condition-case ()
 		     (progn (backward-sexp)
 			    (setq start (point)))
-		   (error nil))))
+		   (error (setq end nil)))))
 	  (when end
 	    (save-restriction
 	      (narrow-to-region start end)
 	      (goto-char orig)
-	      (fill-paragraph justify))))))
-      t)
+              (let ((paragraph-separate
+                     ;; Make sure that fenced-string delimiters that stand
+                     ;; on their own line stay there.
+                     (concat "[ \t]*['\"]+[ \t]*$\\|" paragraph-separate)))
+                (fill-paragraph justify))))))
+      t))
 
 (defun python-shift-left (start end &optional count)
   "Shift lines in region COUNT (the prefix arg) columns to the left.