Mercurial > emacs
comparison lisp/progmodes/python.el @ 76255:985cc73beb79
(python-quote-syntax): Don't bother with syntax-ppss-context.
(python-fill-paragraph): Make sure that fenced-string delimiters that
stand on their own line stay there
| author | Stefan Monnier <monnier@iro.umontreal.ca> |
|---|---|
| date | Thu, 01 Mar 2007 15:07:45 +0000 |
| parents | e3694f1cb928 |
| children | 05d93f5e8286 ec58e5c426ef |
comparison
equal
deleted
inserted
replaced
| 76254:5ae1368180c3 | 76255:985cc73beb79 |
|---|---|
| 161 ;; Consider property for initial char, accounting for prefixes. | 161 ;; Consider property for initial char, accounting for prefixes. |
| 162 ((or (and (= n 2) ; leading quote (not prefix) | 162 ((or (and (= n 2) ; leading quote (not prefix) |
| 163 (= (match-beginning 1) (match-end 1))) ; prefix is null | 163 (= (match-beginning 1) (match-end 1))) ; prefix is null |
| 164 (and (= n 1) ; prefix | 164 (and (= n 1) ; prefix |
| 165 (/= (match-beginning 1) (match-end 1)))) ; non-empty | 165 (/= (match-beginning 1) (match-end 1)))) ; non-empty |
| 166 (unless (eq 'string (syntax-ppss-context (syntax-ppss))) | 166 (unless (nth 3 (syntax-ppss)) |
| 167 (eval-when-compile (string-to-syntax "|")))) | 167 (eval-when-compile (string-to-syntax "|")))) |
| 168 ;; Otherwise (we're in a non-matching string) the property is | 168 ;; Otherwise (we're in a non-matching string) the property is |
| 169 ;; nil, which is OK. | 169 ;; nil, which is OK. |
| 170 ))) | 170 ))) |
| 171 | 171 |
| 1741 (end-of-line) | 1741 (end-of-line) |
| 1742 (let* ((syntax (syntax-ppss)) | 1742 (let* ((syntax (syntax-ppss)) |
| 1743 (orig (point)) | 1743 (orig (point)) |
| 1744 (start (nth 8 syntax)) | 1744 (start (nth 8 syntax)) |
| 1745 end) | 1745 end) |
| 1746 (cond ((eq t (nth 3 syntax)) ; in fenced string | 1746 (cond ((eq t (nth 3 syntax)) ; in fenced string |
| 1747 (goto-char (nth 8 syntax)) ; string start | 1747 (goto-char (nth 8 syntax)) ; string start |
| 1748 (condition-case () ; for unbalanced quotes | 1748 (setq end (condition-case () ; for unbalanced quotes |
| 1749 (progn (forward-sexp) | 1749 (progn (forward-sexp) (point)) |
| 1750 (setq end (point))) | 1750 (error (point-max))))) |
| 1751 (error (setq end (point-max))))) | |
| 1752 ((re-search-backward "\\s|\\s-*\\=" nil t) ; end of fenced | 1751 ((re-search-backward "\\s|\\s-*\\=" nil t) ; end of fenced |
| 1753 ; string | 1752 ; string |
| 1754 (forward-char) | 1753 (forward-char) |
| 1755 (setq end (point)) | 1754 (setq end (point)) |
| 1756 (condition-case () | 1755 (condition-case () |
| 1757 (progn (backward-sexp) | 1756 (progn (backward-sexp) |
| 1758 (setq start (point))) | 1757 (setq start (point))) |
| 1759 (error nil)))) | 1758 (error (setq end nil))))) |
| 1760 (when end | 1759 (when end |
| 1761 (save-restriction | 1760 (save-restriction |
| 1762 (narrow-to-region start end) | 1761 (narrow-to-region start end) |
| 1763 (goto-char orig) | 1762 (goto-char orig) |
| 1764 (fill-paragraph justify)))))) | 1763 (let ((paragraph-separate |
| 1765 t) | 1764 ;; Make sure that fenced-string delimiters that stand |
| 1765 ;; on their own line stay there. | |
| 1766 (concat "[ \t]*['\"]+[ \t]*$\\|" paragraph-separate))) | |
| 1767 (fill-paragraph justify)))))) | |
| 1768 t)) | |
| 1766 | 1769 |
| 1767 (defun python-shift-left (start end &optional count) | 1770 (defun python-shift-left (start end &optional count) |
| 1768 "Shift lines in region COUNT (the prefix arg) columns to the left. | 1771 "Shift lines in region COUNT (the prefix arg) columns to the left. |
| 1769 COUNT defaults to `python-indent'. If region isn't active, just shift | 1772 COUNT defaults to `python-indent'. If region isn't active, just shift |
| 1770 current line. The region shifted includes the lines in which START and | 1773 current line. The region shifted includes the lines in which START and |
