* bug#8141: 23.2.94; python-fill-paragraph
@ 2011-02-28 20:56 Andreas Röhler
2011-03-01 2:59 ` Christoph Scholtes
2012-10-07 13:26 ` Fabián Ezequiel Gallina
0 siblings, 2 replies; 8+ messages in thread
From: Andreas Röhler @ 2011-02-28 20:56 UTC (permalink / raw)
To: 8141
[-- Attachment #1: Type: text/plain, Size: 302 bytes --]
Hi,
attached a test file, revealing a bug in python-fill-paragraph already
reported at lp, which pertains to python.el and python-mode.el likewise.
Patch attached.
Andreas
--
https://code.launchpad.net/~a-roehler/python-mode/python-mode-components
https://code.launchpad.net/s-x-emacs-werkstatt/
[-- Attachment #2: fill-paragraph-problems-lp710373-test.el --]
[-- Type: text/x-emacs-lisp, Size: 2277 bytes --]
(defun py-fill-paragraph-problems-lp:710373-test (&optional arg load-branch-function)
(interactive "p")
(when load-branch-function (funcall load-branch-function))
(py-fill-paragraph-problems-lp:710373-test-intern arg))
(defun py-fill-paragraph-problems-lp:710373-test-intern (&optional arg)
"If no `load-branch-function' is specified, make sure the appropriate branch is loaded. Otherwise default python-mode will be checked. "
(let ((tmp-dir "/tmp/")
(fpp-exec-buffer "fill-paragraph-problems-lp:710373")
(diff-buffer "fpp-lp:710373-old")
(fpp-teststring "
\"\"\"
triple-quoted string containing \"quotation\" marks.
triple-quoted string containing \"quotation\" marks.
triple-quoted string containing \"quotation\" marks.
triple-quoted string containing \"quotation\" marks.
triple-quoted string containing \"quotation\" marks.
\"\"\"
")
erg)
(set-buffer (get-buffer-create diff-buffer))
(erase-buffer)
(insert fpp-teststring)
(write-file (concat tmp-dir diff-buffer))
(if arg
(progn
(set-buffer (get-buffer-create fpp-exec-buffer))
(when arg (switch-to-buffer (current-buffer)))
(erase-buffer)
(py-fill-paragraph-problems-lp:710373-test-base))
(with-temp-buffer (py-fill-paragraph-problems-lp:710373-test-base)))))
(defun py-fill-paragraph-problems-lp:710373-test-base ()
(python-mode)
(insert fpp-teststring)
(set-buffer fpp-exec-buffer)
(font-lock-mode 1)
(font-lock-fontify-buffer)
(goto-char (point-min))
(forward-line 3)
(message "I'm here: %s" (point))
(set-buffer-modified-p nil)
;; (describe-function 'py-fill-paragraph)
(setq fill-column 55)
(if (functionp 'py-fill-paragraph)
(py-fill-paragraph)
(python-fill-paragraph))
(write-file (concat tmp-dir fpp-exec-buffer))
(setq erg (diff (concat tmp-dir fpp-exec-buffer) (concat tmp-dir diff-buffer) "-u"))
(if (featurep 'xemacs)
(progn
(set-buffer "*Diff Output*")
(switch-to-buffer (current-buffer)))
(set-buffer erg)
(sit-for 1)
(assert (numberp (progn (goto-char (point-min))(search-forward "no differences" nil t 1))) t)
(message "%s" "py-fill-paragraph-problems-lp:710373 passed")))
[-- Attachment #3: python.el.diff --]
[-- Type: text/x-patch, Size: 597 bytes --]
--- python.el 2011/02/28 20:22:31 1.1
+++ python.el 2011/02/28 20:24:23
@@ -2022,7 +2022,9 @@
;; current line.
((eq t (nth 3 syntax)) ; in fenced string
(goto-char (nth 8 syntax)) ; string start
- (setq start (line-beginning-position))
+ (if (looking-at "\\(?:'''\\|\"\"\"\\|'\\|\"\\)\\\\?\n?")
+ (setq start (match-end 0))
+ (setq start (line-beginning-position)))
(setq end (condition-case () ; for unbalanced quotes
(progn (forward-sexp)
(- (point) 3))
^ permalink raw reply [flat|nested] 8+ messages in thread
* bug#8141: 23.2.94; python-fill-paragraph
2011-02-28 20:56 bug#8141: 23.2.94; python-fill-paragraph Andreas Röhler
@ 2011-03-01 2:59 ` Christoph Scholtes
2011-03-01 10:45 ` Andreas Röhler
2012-10-07 13:26 ` Fabián Ezequiel Gallina
1 sibling, 1 reply; 8+ messages in thread
From: Christoph Scholtes @ 2011-03-01 2:59 UTC (permalink / raw)
To: Andreas Röhler; +Cc: 8141
Andreas Röhler <andreas.roehler@easy-emacs.de> writes:
> attached a test file, revealing a bug in python-fill-paragraph already
> reported at lp, which pertains to python.el and python-mode.el
> likewise.
>
> Patch attached.
Thanks for the bug report and the patch.
However, I would like to understand first what the problem is/was. The
initial bug report on Launchpad included a file (kn.py), whose
doc-string caused problems, right?
I can open this file and use python-fill-paragraph and fill-paragraph
with no problem in emacs 23.2 and the latest trunk. There is no error
and the doc string looks formatted correctly, also.
What is the problem with the code in python.el/python-mode.el?
Regards,
Christoph
^ permalink raw reply [flat|nested] 8+ messages in thread
* bug#8141: 23.2.94; python-fill-paragraph
2011-03-01 2:59 ` Christoph Scholtes
@ 2011-03-01 10:45 ` Andreas Röhler
2011-03-08 2:08 ` Stefan Monnier
0 siblings, 1 reply; 8+ messages in thread
From: Andreas Röhler @ 2011-03-01 10:45 UTC (permalink / raw)
To: Christoph Scholtes; +Cc: 8141
Am 01.03.2011 03:59, schrieb Christoph Scholtes:
> Andreas Röhler<andreas.roehler@easy-emacs.de> writes:
>
>> attached a test file, revealing a bug in python-fill-paragraph already
>> reported at lp, which pertains to python.el and python-mode.el
>> likewise.
>>
>> Patch attached.
>
> Thanks for the bug report and the patch.
>
> However, I would like to understand first what the problem is/was. The
> initial bug report on Launchpad included a file (kn.py), whose
> doc-string caused problems, right?
>
> I can open this file and use python-fill-paragraph and fill-paragraph
> with no problem in emacs 23.2 and the latest trunk. There is no error
> and the doc string looks formatted correctly, also.
>
> What is the problem with the code in python.el/python-mode.el?
>
> Regards,
> Christoph
>
Hi,
with M-q resp. fill-paragraph it's fine here too.
python-fill-paragraph displays the bug.
Did you try the test delivered?
AFAIS bug basically might reside in
fill-paragraph, where
;; 2. Try fill-paragraph-function.
(and (not (eq fill-paragraph-function t))
(or fill-paragraph-function
(and (minibufferp (current-buffer))
(= 1 (point-min))))
(let ((function (or fill-paragraph-function
should be written like
(cond (fill-paragraph-function
DTRT)
(t everything else
Unless I'm wrong...
Thanks
Andreas
^ permalink raw reply [flat|nested] 8+ messages in thread
* bug#8141: 23.2.94; python-fill-paragraph
2011-03-01 10:45 ` Andreas Röhler
@ 2011-03-08 2:08 ` Stefan Monnier
2011-03-08 12:26 ` Andreas Röhler
0 siblings, 1 reply; 8+ messages in thread
From: Stefan Monnier @ 2011-03-08 2:08 UTC (permalink / raw)
To: Andreas Röhler; +Cc: Christoph Scholtes, 8141
> with M-q resp. fill-paragraph it's fine here too.
> python-fill-paragraph displays the bug.
[...]
> AFAIS bug basically might reside in
> fill-paragraph, where
If calling fill-paragraph works while python-fill-paragraph doesn't, it
would rather seem to indicate that the bug is in python-fill-paragraph
(maybe the bug is that python-fill-paragraph should never be called
directly as a command, for example).
> ;; 2. Try fill-paragraph-function.
> (and (not (eq fill-paragraph-function t))
> (or fill-paragraph-function
> (and (minibufferp (current-buffer))
> (= 1 (point-min))))
> (let ((function (or fill-paragraph-function
> should be written like
> (cond (fill-paragraph-function
> DTRT)
> (t everything else
No, the current definition is on purpose. As the docstring of
fill-paragraph-function indicates:
...
If the function returns nil, then `fill-paragraph' does its normal work.
...
-- Stefan
^ permalink raw reply [flat|nested] 8+ messages in thread
* bug#8141: 23.2.94; python-fill-paragraph
2011-03-08 2:08 ` Stefan Monnier
@ 2011-03-08 12:26 ` Andreas Röhler
2011-03-08 21:18 ` Stefan Monnier
0 siblings, 1 reply; 8+ messages in thread
From: Andreas Röhler @ 2011-03-08 12:26 UTC (permalink / raw)
To: Stefan Monnier; +Cc: Christoph Scholtes, 8141
Am 08.03.2011 03:08, schrieb Stefan Monnier:
>> with M-q resp. fill-paragraph it's fine here too.
>> python-fill-paragraph displays the bug.
> [...]
>> AFAIS bug basically might reside in
>> fill-paragraph, where
>
> If calling fill-paragraph works while python-fill-paragraph doesn't, it
> would rather seem to indicate that the bug is in python-fill-paragraph
> (maybe the bug is that python-fill-paragraph should never be called
> directly as a command, for example).
>
>> ;; 2. Try fill-paragraph-function.
>> (and (not (eq fill-paragraph-function t))
>> (or fill-paragraph-function
>> (and (minibufferp (current-buffer))
>> (= 1 (point-min))))
>> (let ((function (or fill-paragraph-function
>
>
>> should be written like
>
>> (cond (fill-paragraph-function
>> DTRT)
>
>> (t everything else
>
> No, the current definition is on purpose.
Hi Stefan,
IMHO that introduces complexity, even if there are reasons for.
If modes introduce their own fill-function, it's better to leave them
than. If the modes need some later stuff from fill.el, they may take it.
Andreas
As the docstring of
> fill-paragraph-function indicates:
>
> ...
> If the function returns nil, then `fill-paragraph' does its normal work.
> ...
>
>
> -- Stefan
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* bug#8141: 23.2.94; python-fill-paragraph
2011-03-08 12:26 ` Andreas Röhler
@ 2011-03-08 21:18 ` Stefan Monnier
2012-06-19 2:19 ` Glenn Morris
0 siblings, 1 reply; 8+ messages in thread
From: Stefan Monnier @ 2011-03-08 21:18 UTC (permalink / raw)
To: Andreas Röhler; +Cc: Christoph Scholtes, 8141
>> No, the current definition is on purpose.
> IMHO that introduces complexity, even if there are reasons for.
> If modes introduce their own fill-function, it's better to leave them
> than. If the modes need some later stuff from fill.el, they may take it.
What complexity? If the mode's fill function wants to do it all itself,
than it just needs to return a non-nil value.
Stefan
^ permalink raw reply [flat|nested] 8+ messages in thread
* bug#8141: 23.2.94; python-fill-paragraph
2011-03-08 21:18 ` Stefan Monnier
@ 2012-06-19 2:19 ` Glenn Morris
0 siblings, 0 replies; 8+ messages in thread
From: Glenn Morris @ 2012-06-19 2:19 UTC (permalink / raw)
To: 8141
I have no idea what this report was supposed to be about.
It may have been about filling the following:
"""
triple-quoted string containing "quotation" marks.
triple-quoted string containing "quotation" marks.
triple-quoted string containing "quotation" marks.
triple-quoted string containing "quotation" marks.
triple-quoted string containing "quotation" marks.
"""
In 24.1, using M-x fill-paragraph and M-x python-fill-paragraph give
slightly different results.
In the current trunk, using M-x fill-paragraph and M-x
python-fill-paragraph-function (why is this interactive?) obviously give
the same results. However, the result is not the same as either form in
24.1. It looks like this, with an empty line at the end that presumably
should not be there?
"""triple-quoted string containing "quotation" marks. triple-quoted
string containing "quotation" marks. triple-quoted string containing
"quotation" marks. triple-quoted string containing "quotation" marks.
triple-quoted string containing "quotation" marks.
"""
^ permalink raw reply [flat|nested] 8+ messages in thread
* bug#8141: 23.2.94; python-fill-paragraph
2011-02-28 20:56 bug#8141: 23.2.94; python-fill-paragraph Andreas Röhler
2011-03-01 2:59 ` Christoph Scholtes
@ 2012-10-07 13:26 ` Fabián Ezequiel Gallina
1 sibling, 0 replies; 8+ messages in thread
From: Fabián Ezequiel Gallina @ 2012-10-07 13:26 UTC (permalink / raw)
To: 8141
This works fine on current trunk, notice there's a new option that allow
users to set the style for docstrings.
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2012-10-07 13:26 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-02-28 20:56 bug#8141: 23.2.94; python-fill-paragraph Andreas Röhler
2011-03-01 2:59 ` Christoph Scholtes
2011-03-01 10:45 ` Andreas Röhler
2011-03-08 2:08 ` Stefan Monnier
2011-03-08 12:26 ` Andreas Röhler
2011-03-08 21:18 ` Stefan Monnier
2012-06-19 2:19 ` Glenn Morris
2012-10-07 13:26 ` Fabián Ezequiel Gallina
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.