py-shift-{left,right} fail if mark is not active

Bug #1662341 reported by Barry Warsaw
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
python-mode.el
Fix Committed
Undecided
Andreas Roehler

Bug Description

Sample code:

def foo(x):
    if x == 1:
        return 0

Put point on the line with `return 0` and hit either C-c C-r (py-shift-right) or C-c C-l (py-shift-left). The line will not be reindented and you get an error that says "The mark is not active now". Make the mark active and both functions work.

The functions should not be dependent on whether the mark is active or not. If it's not active, then the functions should just shift the current line right or left as appropriate.

Changed in python-mode:
assignee: nobody → Andreas Roehler (a-roehler)
Revision history for this message
Andreas Roehler (a-roehler) wrote :

Can't reproduce so far.

However, WRT unexpected region-shift where no mark was set,
the reason might be a previous yank, which does push-mark:

Lately someone wanted to shift a region also without transient-mark-mode
So I replaced (use-region-p) by

(and (mark) (not (eq (mark) (point))))

That might result in unexpected region-shifts maybe.

Solution would be to return to previous behavior as default, but have a boolean

py-shift-requires-transient-mark-mode-p

Have some idea what happened:

Lately enabled to shift a region also without transient-mark-mode
(use-region-p) was replaced by

(and (mark) (not (eq (mark) (point))))

That might result in unexpected region-shifts maybe.

Solution would be to return to previous behavior as default, but have a boolean

py-shift-requires-transient-mark-mode-p

default t, where nil would permit region without TMM

Revision history for this message
Andreas Roehler (a-roehler) wrote :

Oops, sorry for duplication.

Changed in python-mode:
status: New → Fix Committed
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.