diff options
| author | Fabián Ezequiel Gallina | 2012-05-17 00:03:13 -0300 |
|---|---|---|
| committer | Fabián Ezequiel Gallina | 2012-05-17 00:03:13 -0300 |
| commit | 74d7b6051a6392f7de1ef4ef5d6b30e3f582d1b6 (patch) | |
| tree | 5d775d2b7625c2f87413f77dfe35739b89f42d9c /lisp/progmodes/python.el | |
| parent | 053a6c726f8bd871724bcf45978b63926bd5f769 (diff) | |
| download | emacs-74d7b6051a6392f7de1ef4ef5d6b30e3f582d1b6.tar.gz emacs-74d7b6051a6392f7de1ef4ef5d6b30e3f582d1b6.zip | |
Fixed infinite loop on python-info-current-defun
For this python-beginning-of-defun-function has been modified to
return t or nil if a defun was found.
Diffstat (limited to 'lisp/progmodes/python.el')
| -rw-r--r-- | lisp/progmodes/python.el | 35 |
1 files changed, 21 insertions, 14 deletions
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index 0b9d99cbbee..5abfe91809b 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el | |||
| @@ -878,10 +878,12 @@ With numeric ARG, just insert that many colons. With | |||
| 878 | "Move point to `beginning-of-defun'. | 878 | "Move point to `beginning-of-defun'. |
| 879 | When NODECORATORS is non-nil decorators are not included. This | 879 | When NODECORATORS is non-nil decorators are not included. This |
| 880 | is the main part of`python-beginning-of-defun-function' | 880 | is the main part of`python-beginning-of-defun-function' |
| 881 | implementation." | 881 | implementation. Return non-nil if point is moved to the |
| 882 | beginning-of-defun." | ||
| 882 | (let ((indent-pos (save-excursion | 883 | (let ((indent-pos (save-excursion |
| 883 | (back-to-indentation) | 884 | (back-to-indentation) |
| 884 | (point-marker))) | 885 | (point-marker))) |
| 886 | (found) | ||
| 885 | (include-decorators | 887 | (include-decorators |
| 886 | (lambda () | 888 | (lambda () |
| 887 | (when (not nodecorators) | 889 | (when (not nodecorators) |
| @@ -898,27 +900,32 @@ implementation." | |||
| 898 | (looking-at python-nav-beginning-of-defun-regexp))) | 900 | (looking-at python-nav-beginning-of-defun-regexp))) |
| 899 | (progn | 901 | (progn |
| 900 | (goto-char (line-beginning-position)) | 902 | (goto-char (line-beginning-position)) |
| 901 | (funcall include-decorators)) | 903 | (funcall include-decorators) |
| 904 | (setq found t)) | ||
| 902 | (goto-char (line-beginning-position)) | 905 | (goto-char (line-beginning-position)) |
| 903 | (re-search-backward python-nav-beginning-of-defun-regexp nil t) | 906 | (when (re-search-backward python-nav-beginning-of-defun-regexp nil t) |
| 907 | (setq found t)) | ||
| 904 | (goto-char (or (python-info-ppss-context 'string) (point))) | 908 | (goto-char (or (python-info-ppss-context 'string) (point))) |
| 905 | (funcall include-decorators)))) | 909 | (funcall include-decorators)) |
| 910 | found)) | ||
| 906 | 911 | ||
| 907 | (defun python-beginning-of-defun-function (&optional arg nodecorators) | 912 | (defun python-beginning-of-defun-function (&optional arg nodecorators) |
| 908 | "Move point to the beginning of def or class. | 913 | "Move point to the beginning of def or class. |
| 909 | With positive ARG move that number of functions forward. With | 914 | With positive ARG move that number of functions forward. With |
| 910 | negative do the same but backwards. When NODECORATORS is non-nil | 915 | negative do the same but backwards. When NODECORATORS is non-nil |
| 911 | decorators are not included." | 916 | decorators are not included. Return non-nil if point is moved to the |
| 917 | beginning-of-defun." | ||
| 912 | (when (or (null arg) (= arg 0)) (setq arg 1)) | 918 | (when (or (null arg) (= arg 0)) (setq arg 1)) |
| 913 | (if (> arg 0) | 919 | (if (> arg 0) |
| 914 | (dotimes (i arg) | 920 | (dotimes (i arg (python-nav-beginning-of-defun nodecorators))) |
| 915 | (python-nav-beginning-of-defun nodecorators)) | 921 | (let ((found)) |
| 916 | (dotimes (i (- arg)) | 922 | (dotimes (i (- arg) found) |
| 917 | (python-end-of-defun-function) | 923 | (python-end-of-defun-function) |
| 918 | (forward-comment 1) | 924 | (forward-comment 1) |
| 919 | (goto-char (line-end-position)) | 925 | (goto-char (line-end-position)) |
| 920 | (when (not (eobp)) | 926 | (when (not (eobp)) |
| 921 | (python-nav-beginning-of-defun nodecorators))))) | 927 | (setq found |
| 928 | (python-nav-beginning-of-defun nodecorators))))))) | ||
| 922 | 929 | ||
| 923 | (defun python-end-of-defun-function () | 930 | (defun python-end-of-defun-function () |
| 924 | "Move point to the end of def or class. | 931 | "Move point to the end of def or class. |
| @@ -1949,7 +1956,7 @@ not inside a defun." | |||
| 1949 | (goto-char (line-end-position)) | 1956 | (goto-char (line-end-position)) |
| 1950 | (forward-comment -1) | 1957 | (forward-comment -1) |
| 1951 | (while (and (not (equal 0 (current-indentation))) | 1958 | (while (and (not (equal 0 (current-indentation))) |
| 1952 | (not (python-beginning-of-defun-function 1 t))) | 1959 | (python-beginning-of-defun-function 1 t)) |
| 1953 | (when (or (not min-indent) | 1960 | (when (or (not min-indent) |
| 1954 | (< (current-indentation) min-indent)) | 1961 | (< (current-indentation) min-indent)) |
| 1955 | (setq min-indent (current-indentation)) | 1962 | (setq min-indent (current-indentation)) |