--- python.OLD.el 2021-04-19 16:18:39.840528000 -0700 +++ python.NEW.el 2021-04-19 16:22:37.874439000 -0700 @@ -3945,16 +3945,21 @@ (defun python-fill-string (&optional jus (set-marker (make-marker) (or (python-syntax-context 'string) (and (equal (string-to-syntax "|") (syntax-after (point))) (point))))) (num-quotes (python-syntax-count-quotes (char-after str-start-pos) str-start-pos)) + (str-line-start-pos + (save-excursion + (goto-char str-start-pos) + (beginning-of-line) + (point-marker))) (str-end-pos (save-excursion (goto-char (+ str-start-pos num-quotes)) (or (re-search-forward (rx (syntax string-delimiter)) nil t) (goto-char (point-max))) (point-marker))) (multi-line-p ;; Docstring styles may vary for oneliners and multi-liners. @@ -3968,17 +3973,17 @@ (defun python-fill-string (&optional jus ;; graphic idea of each style. (`django (cons 1 1)) (`onetwo (and multi-line-p (cons 1 2))) (`pep-257 (and multi-line-p (cons nil 2))) (`pep-257-nn (and multi-line-p (cons nil 1))) (`symmetric (and multi-line-p (cons 1 1))))) (fill-paragraph-function)) (save-restriction - (narrow-to-region str-start-pos str-end-pos) + (narrow-to-region str-line-start-pos str-end-pos) (fill-paragraph justify)) (save-excursion (when (and (python-info-docstring-p) python-fill-docstring-style) ;; Add the number of newlines indicated by the selected style ;; at the start of the docstring. (goto-char (+ str-start-pos num-quotes)) (delete-region (point) (progn (skip-syntax-forward "> ")