Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f2389a0

Browse files
committed
(py-indent-right, py-outdent-left): fixed placement of point after
adjustments.
1 parent 43ecf8e commit f2389a0

1 file changed

Lines changed: 22 additions & 16 deletions

File tree

Misc/python-mode.el

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -507,13 +507,15 @@ current line."
507507
(if m
508508
(list (min p m) (max p m) arg)
509509
(list p m arg))))
510-
(let ((pos (- (point-max) (point)))
511-
(end (save-excursion
512-
(goto-char (or end (1+ start)))
513-
(and (not (bolp))
514-
(forward-line 1))
515-
(set-marker (make-marker) (point))))
516-
col want indent)
510+
(let* ((dir (= (point) start))
511+
(pos (if dir (point)
512+
(- (point-max) (point))))
513+
(end (save-excursion
514+
(goto-char (or end (1+ start)))
515+
(and (not (bolp))
516+
(forward-line 1))
517+
(set-marker (make-marker) (point))))
518+
col want indent)
517519
(goto-char start)
518520
(beginning-of-line)
519521
(unwind-protect
@@ -528,7 +530,8 @@ current line."
528530
(indent-to (+ col want))))
529531
(forward-line 1))
530532
(set-marker end nil))
531-
(goto-char (- (point-max) pos))
533+
(goto-char (if dir pos
534+
(- (point-max) pos)))
532535
(py-keep-region-active)))
533536

534537
(defun py-outdent-left (start end arg)
@@ -543,13 +546,15 @@ the current line."
543546
(if m
544547
(list (min p m) (max p m) arg)
545548
(list p m arg))))
546-
(let ((pos (- (point-max) (point)))
547-
(end (save-excursion
548-
(goto-char (or end (1+ start)))
549-
(and (not (bolp))
550-
(forward-line 1))
551-
(set-marker (make-marker) (point))))
552-
col want)
549+
(let* ((dir (= (point) start))
550+
(pos (if dir (point)
551+
(- (point-max) (point))))
552+
(end (save-excursion
553+
(goto-char (or end (1+ start)))
554+
(and (not (bolp))
555+
(forward-line 1))
556+
(set-marker (make-marker) (point))))
557+
col want)
553558
(goto-char start)
554559
(beginning-of-line)
555560
(unwind-protect
@@ -563,7 +568,8 @@ the current line."
563568
(indent-to (- col want))))
564569
(forward-line 1))
565570
(set-marker end nil))
566-
(goto-char (- (point-max) pos))
571+
(goto-char (if dir pos
572+
(- (point-max) pos)))
567573
(py-keep-region-active)))
568574

569575

0 commit comments

Comments
 (0)