(= (match-beginning 1) (match-end 1))) ; prefix is null
(and (= n 1) ; prefix
(/= (match-beginning 1) (match-end 1)))) ; non-empty
- (unless (eq 'string (syntax-ppss-context (syntax-ppss)))
+ (unless (nth 3 (syntax-ppss))
(eval-when-compile (string-to-syntax "|"))))
;; Otherwise (we're in a non-matching string) the property is
;; nil, which is OK.
(_ (if (python-comment-line-p)
(python-skip-comments/blanks t)))
(ci (current-indentation))
- (open (python-open-block-statement-p)))
+ (open (python-open-block-statement-p))
+ opoint)
(if (and (zerop ci) (not open))
(not (goto-char point))
(catch 'done
- (while (zerop (python-next-statement))
+ (setq opoint (point))
+ (while (and (zerop (python-next-statement))
+ (not (= opoint (point))))
+ (setq opoint (point))
(when (or (and open (<= (current-indentation) ci))
(< (current-indentation) ci))
(python-skip-comments/blanks t)
is used by `run-python' et al.")
(defvar python-buffer nil
- "*The current python process buffer.
+ "*The current Python process buffer.
Commands that send text from source buffers to Python processes have
to choose a process to send to. This is determined by buffer-local
COMMAND should be a single statement."
;; (assert (not (string-match "\n" command)))
;; (let ((end (marker-position (process-mark (python-proc)))))
- (with-current-buffer python-buffer (goto-char (point-max)))
+ (with-current-buffer (process-buffer (python-proc))
+ (goto-char (point-max))
(compilation-forget-errors)
(python-send-string command)
- (with-current-buffer python-buffer
- (setq compilation-last-buffer (current-buffer)))
+ (setq compilation-last-buffer (current-buffer)))
;; No idea what this is for but it breaks the call to
;; compilation-fake-loc in python-send-region. -- Stef
;; Must wait until this has completed before re-setting variables below.
;; isn't one for `python-buffer'.
(unless (comint-check-proc python-buffer)
(run-python nil t))
- (get-buffer-process (or (if (derived-mode-p 'inferior-python-mode)
- (current-buffer)
- python-buffer))))
+ (get-buffer-process (if (derived-mode-p 'inferior-python-mode)
+ (current-buffer)
+ python-buffer)))
(defun python-set-proc ()
"Set the default value of `python-buffer' to correspond to this buffer.
(orig (point))
(start (nth 8 syntax))
end)
- (cond ((eq t (nth 3 syntax)) ; in fenced string
- (goto-char (nth 8 syntax)) ; string start
- (condition-case () ; for unbalanced quotes
- (progn (forward-sexp)
- (setq end (point)))
- (error (setq end (point-max)))))
+ (cond ((eq t (nth 3 syntax)) ; in fenced string
+ (goto-char (nth 8 syntax)) ; string start
+ (setq end (condition-case () ; for unbalanced quotes
+ (progn (forward-sexp) (point))
+ (error (point-max)))))
((re-search-backward "\\s|\\s-*\\=" nil t) ; end of fenced
; string
(forward-char)
(condition-case ()
(progn (backward-sexp)
(setq start (point)))
- (error nil))))
+ (error (setq end nil)))))
(when end
(save-restriction
(narrow-to-region start end)
(goto-char orig)
- (fill-paragraph justify))))))
- t)
+ (let ((paragraph-separate
+ ;; Make sure that fenced-string delimiters that stand
+ ;; on their own line stay there.
+ (concat "[ \t]*['\"]+[ \t]*$\\|" paragraph-separate)))
+ (fill-paragraph justify))))))
+ t))
(defun python-shift-left (start end &optional count)
"Shift lines in region COUNT (the prefix arg) columns to the left.
> _ \n)
(defvar python-default-template "if"
- "Default template to expand by `python-insert-template'.
+ "Default template to expand by `python-expand-template'.
Updated on each expansion.")
(defun python-expand-template (name)
;; . python-font-lock-syntactic-face-function)
))
(set (make-local-variable 'parse-sexp-lookup-properties) t)
+ (set (make-local-variable 'parse-sexp-ignore-comments) t)
(set (make-local-variable 'comment-start) "# ")
(set (make-local-variable 'indent-line-function) #'python-indent-line)
(set (make-local-variable 'indent-region-function) #'python-indent-region)