From ccb1c17e8bf1aa0d21bddd9fa37154a120657f52 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Fabi=C3=A1n=20Ezequiel=20Gallina?= Date: Sat, 29 Dec 2012 09:57:49 -0300 Subject: [PATCH] * 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/ChangeLog | 7 +++++++ lisp/progmodes/python.el | 33 ++++++++++++++++++++------------- 2 files changed, 27 insertions(+), 13 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 9a54639a30b..b79d174d35e 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,10 @@ +2012-12-29 Fabián Ezequiel Gallina + + * 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. + 2012-12-29 Fabián Ezequiel Gallina * progmodes/python.el (python-shell-send-region): Add blank lines 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))) -- 2.39.5