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

Bug #1662341 reported by Barry Warsaw on 2017-02-06
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
python-mode.el
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)
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

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  Edit
Everyone can see this information.

Other bug subscribers