(res nil))
(while (and (setq res (re-search-forward re limit t))
(or (python-syntax-context 'paren)
- (equal (char-after (point-marker)) ?=))))
+ (equal (char-after (point)) ?=))))
res))
(1 font-lock-variable-name-face nil nil))
;; support for a, b, c = (1, 2, 3)
"De-indent current line."
(interactive "*")
(when (and (not (python-syntax-comment-or-string-p))
- (<= (point-marker) (save-excursion
+ (<= (point) (save-excursion
(back-to-indentation)
- (point-marker)))
+ (point)))
(> (current-column) 0))
(python-indent-line t)
t))
python-comint-postoutput-scroll-to-bottom))
(set (make-local-variable 'compilation-error-regexp-alist)
python-shell-compilation-regexp-alist)
- (define-key inferior-python-mode-map [remap complete-symbol]
- 'completion-at-point)
(add-hook 'completion-at-point-functions
- 'python-shell-completion-at-point nil 'local)
- (add-to-list (make-local-variable 'comint-dynamic-complete-functions)
- 'python-shell-completion-at-point)
+ #'python-shell-completion-at-point nil 'local)
(define-key inferior-python-mode-map "\t"
'python-shell-completion-complete-or-indent)
(make-local-variable 'python-pdbtrack-buffers-to-kill)
"Do completion at point using PROCESS for IMPORT or INPUT.
When IMPORT is non-nil takes precedence over INPUT for
completion."
- (let* ((prompt
- (with-current-buffer (process-buffer process)
- (let ((prompt-boundaries (python-util-comint-last-prompt)))
+ (with-current-buffer (process-buffer process)
+ (let* ((prompt
+ ;; Get last prompt of the inferior process buffer (this
+ ;; intentionally avoids using `comint-last-prompt' because
+ ;; of incompatibilities with Emacs 24.x).
+ (save-excursion
(buffer-substring-no-properties
- (car prompt-boundaries) (cdr prompt-boundaries)))))
- (completion-code
- ;; Check whether a prompt matches a pdb string, an import
- ;; statement or just the standard prompt and use the
- ;; correct python-shell-completion-*-code string
- (cond ((and (string-match
- (concat "^" python-shell-prompt-pdb-regexp) prompt))
- ;; Since there are no guarantees the user will remain
- ;; in the same context where completion code was sent
- ;; (e.g. user steps into a function), safeguard
- ;; resending completion setup continuously.
- (concat python-shell-completion-setup-code
- "\nprint (" python-shell-completion-string-code ")"))
- ((string-match
- python-shell--prompt-calculated-input-regexp prompt)
- python-shell-completion-string-code)
- (t nil)))
- (subject (or import input)))
- (and completion-code
- (> (length input) 0)
- (with-current-buffer (process-buffer process)
+ (line-beginning-position) ;End of prompt.
+ (re-search-backward "^"))))
+ (completion-code
+ ;; Check whether a prompt matches a pdb string, an import
+ ;; statement or just the standard prompt and use the
+ ;; correct python-shell-completion-*-code string
+ (cond ((and (string-match
+ (concat "^" python-shell-prompt-pdb-regexp) prompt))
+ ;; Since there are no guarantees the user will remain
+ ;; in the same context where completion code was sent
+ ;; (e.g. user steps into a function), safeguard
+ ;; resending completion setup continuously.
+ (concat python-shell-completion-setup-code
+ "\nprint (" python-shell-completion-string-code ")"))
+ ((string-match
+ python-shell--prompt-calculated-input-regexp prompt)
+ python-shell-completion-string-code)
+ (t nil)))
+ (subject (or import input)))
+ (and completion-code
+ (> (length input) 0)
(let ((completions
(python-util-strip-string
(python-shell-send-string-no-output
(interactive)
(if (string-match "^[[:space:]]*$"
(buffer-substring (comint-line-beginning-position)
- (point-marker)))
+ (point)))
(indent-for-tab-command)
(completion-at-point)))
(save-restriction
(narrow-to-region (progn
(while (python-syntax-context 'paren)
- (goto-char (1- (point-marker))))
- (point-marker)
+ (goto-char (1- (point))))
(line-beginning-position))
(progn
(when (not (python-syntax-context 'paren))
(end-of-line)
(when (not (python-syntax-context 'paren))
(skip-syntax-backward "^)")))
- (while (python-syntax-context 'paren)
- (goto-char (1+ (point-marker))))
- (point-marker)))
+ (while (and (python-syntax-context 'paren)
+ (not (eobp)))
+ (goto-char (1+ (point))))
+ (point)))
(let ((paragraph-start "\f\\|[ \t]*$")
(paragraph-separate ",")
(fill-paragraph-function))
(while (not (eobp))
(forward-line 1)
(python-indent-line)
- (goto-char (line-end-position)))) t)
+ (goto-char (line-end-position))))
+ t)
\f
;;; Skeletons
(add-to-list 'hs-special-modes-alist
`(python-mode "^\\s-*\\(?:def\\|class\\)\\>" nil "#"
,(lambda (_arg)
- (python-nav-end-of-defun)) nil))
+ (python-nav-end-of-defun))
+ nil))
(set (make-local-variable 'outline-regexp)
(python-rx (* space) block-start))