unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#12822: python.el, python-indent-guess-indent-offset
@ 2012-11-07 11:05 Andreas Röhler
  2013-01-24  1:40 ` bug#12822: (no subject) Fabián Ezequiel Gallina
  0 siblings, 1 reply; 2+ messages in thread
From: Andreas Röhler @ 2012-11-07 11:05 UTC (permalink / raw)
  To: 12822

Hi,

with current python.el

python-indent-guess-indent-offset proceeds:

(defun python-indent-guess-indent-offset ()
   "Guess and set `python-indent-offset' for the current buffer."
   (interactive)
   (save-excursion
     (save-restriction
       (widen)
       (goto-char (point-min))
       (let ((block-end))
         (while (and (not block-end)
                     (re-search-forward
                      (python-rx line-start block-start) nil t))
                      [...]


IIUC it fetches the first beginning of block in buffer.
As in Python every block might have it's own ideas WRT
volume of indent-step, this must fail when
indent-offset is set differently in current block.

Guessing must not take the first block from BOB, but
the next beginning of block from point upward.

IMO as it's just a guess, where the default-value might
be delivered, it also should not call `widen'.

Best,

Andreas





^ permalink raw reply	[flat|nested] 2+ messages in thread

* bug#12822: (no subject)
  2012-11-07 11:05 bug#12822: python.el, python-indent-guess-indent-offset Andreas Röhler
@ 2013-01-24  1:40 ` Fabián Ezequiel Gallina
  0 siblings, 0 replies; 2+ messages in thread
From: Fabián Ezequiel Gallina @ 2013-01-24  1:40 UTC (permalink / raw)
  To: 12822

The whole idea of python-indent-guess-indent-offset is to provide some 
sane default at find-file. The decision of making the indentation of 
first available block the default indentation is intended and it's not 
going to change. This way indentation guessing behaves consistently all 
the time and the user is able to modify the first block so the command 
plays nice to him after next file visit.

Also, as a side note, all blocks in a python file should be indented the 
same way, the only special case would be an if triggered into multiple 
lines using parens like this but this case is not that common that I'm 
not even worrying about:

     if (something and
         somethingelse and
         otherstuff):
             pass






^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-01-24  1:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-11-07 11:05 bug#12822: python.el, python-indent-guess-indent-offset Andreas Röhler
2013-01-24  1:40 ` bug#12822: (no subject) Fabián Ezequiel Gallina

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).