:version "24.3"
:link '(emacs-commentary-link "python"))
-
-;;; 24.x Compat
-\f
-
-(unless (fboundp 'prog-widen)
- (defun prog-widen ()
- (widen)))
-
-(unless (fboundp 'prog-first-column)
- (defun prog-first-column ()
- 0))
-
\f
;;; Bindings
(interactive)
(save-excursion
(save-restriction
- (prog-widen)
+ (widen)
(goto-char (point-min))
(let ((block-end))
(while (and (not block-end)
- Point is on a line starting a dedenter block.
- START is the position where the dedenter block starts."
(save-restriction
- (prog-widen)
+ (widen)
(let ((ppss (save-excursion
(beginning-of-line)
(syntax-ppss))))
happening for :at-dedenter-block-start context since the
possibilities can be narrowed to specific indentation points."
(save-restriction
- (prog-widen)
+ (widen)
(save-excursion
(pcase (python-indent-context)
- (`(:no-indent . ,_) (prog-first-column)) ; usually 0
+ (`(:no-indent . ,_) 0)
(`(,(or :after-line
:after-comment
:inside-string
(let ((opening-block-start-points
(python-info-dedenter-opening-block-positions)))
(if (not opening-block-start-points)
- (prog-first-column) ; if not found default to first column
+ 0 ; if not found default to first column
(mapcar (lambda (pos)
(save-excursion
(goto-char pos)
case INDENTATION is a list, this order is enforced."
(if (listp indentation)
(sort (copy-sequence indentation) #'<)
- (nconc (number-sequence (prog-first-column) (1- indentation)
+ (nconc (number-sequence 0 (1- indentation)
python-indent-offset)
(list indentation))))
(python-indent--previous-level levels (current-indentation))
(if levels
(apply #'max levels)
- (prog-first-column)))))
+ 0))))
(defun python-indent-line (&optional previous)
"Internal implementation of `python-indent-line-function'.
This function can be used as the value of `add-log-current-defun-function'
since it returns nil if point is not inside a defun."
(save-restriction
- (prog-widen)
+ (widen)
(save-excursion
(end-of-line 1)
(let ((names)
(let ((point (python-info-dedenter-opening-block-position)))
(when point
(save-restriction
- (prog-widen)
+ (widen)
(message "Closes %s" (save-excursion
(goto-char point)
(buffer-substring
With optional argument LINE-NUMBER, check that line instead."
(save-excursion
(save-restriction
- (prog-widen)
+ (widen)
(when line-number
(python-util-goto-line line-number))
(while (and (not (eobp))
Optional argument LINE-NUMBER forces the line number to check against."
(save-excursion
(save-restriction
- (prog-widen)
+ (widen)
(when line-number
(python-util-goto-line line-number))
(when (python-info-line-ends-backslash-p)
where the continued line ends."
(save-excursion
(save-restriction
- (prog-widen)
+ (widen)
(let* ((context-type (progn
(back-to-indentation)
(python-syntax-context-type)))