Skip to content

Commit

Permalink
Fix a problem where an incorrect region would be selected when the
Browse files Browse the repository at this point in the history
block to be selected had no indentation.

Given

|def x():
    print()

print()

where | is point, er/mark-python-block should mark the region
delimited by brackets:

[def x():
    print()]
  • Loading branch information
fgeller committed Jul 18, 2012
1 parent 357cd00 commit bbf9740
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions python-el-fgallina-expansions.el
Expand Up @@ -98,17 +98,10 @@ than NEXT-INDENT-LEVEL."
;; Save indentation and look for the end of this block
(let ((block-indentation (current-indentation)))
(forward-line 1)
(cond
;; When there is no indent, look for next start of a block,
;; without indent, or end of buffer.
((= 0 block-indentation)
(while (and (re-search-forward er--python-block-start-regex (point-max) 'goto-end)
(> (current-indentation) block-indentation))))
;; When indentation > 0, skip empty and lines with more indent
(t
(while (or (> (current-indentation) block-indentation)
(looking-at (rx line-start (* whitespace) line-end)))
(forward-line 1))))
(while (and (or (> (current-indentation) block-indentation)
(looking-at (rx line-start (* whitespace) line-end)))
(not (looking-at er--python-block-start-regex)))
(forward-line 1))
;; Find the end of the block by skipping comments backwards
(beginning-of-line)
(python-util-forward-comment -1)
Expand Down

0 comments on commit bbf9740

Please sign in to comment.