From 66164d2f176b3f86ee5551b78f705d0fe776c611 Mon Sep 17 00:00:00 2001 From: Fabián Ezequiel Gallina Date: Sat, 29 Dec 2012 08:04:55 -0300 Subject: * progmodes/python.el: Remove cl dependency. (python-syntax-count-quotes): Replace incf call. (python-fill-string): Replace setf call. --- lisp/progmodes/python.el | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'lisp/progmodes/python.el') diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index 67388c0339b..56a971f0c67 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el @@ -204,7 +204,6 @@ (require 'ansi-color) (require 'comint) -(eval-when-compile (require 'cl-lib)) ;; Avoid compiler warnings (defvar view-return-to-alist) @@ -529,7 +528,7 @@ is used to limit the scan." (while (and (< i 3) (or (not limit) (< (+ point i) limit)) (eq (char-after (+ point i)) quote-char)) - (cl-incf i)) + (setq i (1+ i))) i)) (defun python-syntax-stringify () @@ -2487,12 +2486,12 @@ JUSTIFY should be used (if applicable) as in `fill-paragraph'." JUSTIFY should be used (if applicable) as in `fill-paragraph'." (let* ((marker (point-marker)) (str-start-pos - (let ((m (make-marker))) - (setf (marker-position m) - (or (python-syntax-context 'string) - (and (equal (string-to-syntax "|") - (syntax-after (point))) - (point)))) m)) + (set-marker + (make-marker) + (or (python-syntax-context 'string) + (and (equal (string-to-syntax "|") + (syntax-after (point))) + (point))))) (num-quotes (python-syntax-count-quotes (char-after str-start-pos) str-start-pos)) (str-end-pos -- cgit v1.2.1 From 16768034b209fe12a6408866ac31688604b97375 Mon Sep 17 00:00:00 2001 From: Fabián Ezequiel Gallina Date: Sat, 29 Dec 2012 09:33:33 -0300 Subject: * progmodes/python.el (python-shell-send-region): Add blank lines for non sent code so backtraces remain correct. --- lisp/progmodes/python.el | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'lisp/progmodes/python.el') diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index 56a971f0c67..a427e95c037 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el @@ -2008,7 +2008,14 @@ Returns the output. See `python-shell-send-string-no-output'." (defun python-shell-send-region (start end) "Send the region delimited by START and END to inferior Python process." (interactive "r") - (python-shell-send-string (buffer-substring start end) nil t)) + (python-shell-send-string + (concat + (let ((line-num (line-number-at-pos start))) + ;; When sending a region, add blank lines for non sent code so + ;; backtraces remain correct. + (make-string (1- line-num) ?\n)) + (buffer-substring start end)) + nil t)) (defun python-shell-send-buffer (&optional arg) "Send the entire buffer to inferior Python process. -- cgit v1.2.1 From ccb1c17e8bf1aa0d21bddd9fa37154a120657f52 Mon Sep 17 00:00:00 2001 From: Fabián Ezequiel Gallina Date: Sat, 29 Dec 2012 09:57:49 -0300 Subject: * progmodes/python.el: Support other commands triggering python-indent-line so indentation cycling continues to work. (python-indent-trigger-commands): New defcustom. (python-indent-line): Use it. --- lisp/progmodes/python.el | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) (limited to 'lisp/progmodes/python.el') diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index a427e95c037..54a657a2593 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el @@ -607,6 +607,12 @@ It makes underscores and dots word constituent chars.") :group 'python :safe 'booleanp) +(defcustom python-indent-trigger-commands + '(indent-for-tab-command yas-expand yas/expand) + "Commands that might trigger a `python-indent-line' call." + :type '(repeat symbol) + :group 'python) + (define-obsolete-variable-alias 'python-indent 'python-indent-offset "24.3") @@ -905,20 +911,21 @@ Uses the offset calculated in indicated by the variable `python-indent-levels' to set the current indentation. -When the variable `last-command' is equal to -`indent-for-tab-command' or FORCE-TOGGLE is non-nil it cycles -levels indicated in the variable `python-indent-levels' by -setting the current level in the variable -`python-indent-current-level'. - -When the variable `last-command' is not equal to -`indent-for-tab-command' and FORCE-TOGGLE is nil it calculates -possible indentation levels and saves it in the variable -`python-indent-levels'. Afterwards it sets the variable -`python-indent-current-level' correctly so offset is equal -to (`nth' `python-indent-current-level' `python-indent-levels')" +When the variable `last-command' is equal to one of the symbols +inside `python-indent-trigger-commands' or FORCE-TOGGLE is +non-nil it cycles levels indicated in the variable +`python-indent-levels' by setting the current level in the +variable `python-indent-current-level'. + +When the variable `last-command' is not equal to one of the +symbols inside `python-indent-trigger-commands' and FORCE-TOGGLE +is nil it calculates possible indentation levels and saves it in +the variable `python-indent-levels'. Afterwards it sets the +variable `python-indent-current-level' correctly so offset is +equal to (`nth' `python-indent-current-level' +`python-indent-levels')" (or - (and (or (and (eq this-command 'indent-for-tab-command) + (and (or (and (memq this-command python-indent-trigger-commands) (eq last-command this-command)) force-toggle) (not (equal python-indent-levels '(0))) -- cgit v1.2.1