diff options
| author | Fabián Ezequiel Gallina | 2012-05-17 00:03:15 -0300 |
|---|---|---|
| committer | Fabián Ezequiel Gallina | 2012-05-17 00:03:15 -0300 |
| commit | 9fff18585a75ad540aedc84b1147a4a327d1dbdf (patch) | |
| tree | e9280057e20ea0c4d7d2f5ebd60a751728fb5f0d | |
| parent | 3697b5314ae77a50e12972b70f8367d8d3ba7853 (diff) | |
| download | emacs-9fff18585a75ad540aedc84b1147a4a327d1dbdf.tar.gz emacs-9fff18585a75ad540aedc84b1147a4a327d1dbdf.zip | |
Implemented python-nav-backward-sentence, python-nav-forward-sentence
Also small fixes to python-nav-sentence-start and
python-nav-sentence-end were added.
| -rw-r--r-- | lisp/progmodes/python.el | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index aa20c20fae6..b45b22c139c 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el | |||
| @@ -189,6 +189,13 @@ | |||
| 189 | 189 | ||
| 190 | (defvar python-mode-map | 190 | (defvar python-mode-map |
| 191 | (let ((map (make-sparse-keymap))) | 191 | (let ((map (make-sparse-keymap))) |
| 192 | ;; Movement | ||
| 193 | (substitute-key-definition 'backward-sentence | ||
| 194 | 'python-nav-backward-sentence | ||
| 195 | map global-map) | ||
| 196 | (substitute-key-definition 'forward-sentence | ||
| 197 | 'python-nav-forward-sentence | ||
| 198 | map global-map) | ||
| 192 | ;; Indent specific | 199 | ;; Indent specific |
| 193 | (define-key map "\177" 'python-indent-dedent-line-backspace) | 200 | (define-key map "\177" 'python-indent-dedent-line-backspace) |
| 194 | (define-key map (kbd "<backtab>") 'python-indent-dedent-line) | 201 | (define-key map (kbd "<backtab>") 'python-indent-dedent-line) |
| @@ -957,6 +964,7 @@ Returns nil if point is not in a def or class." | |||
| 957 | (save-excursion | 964 | (save-excursion |
| 958 | (forward-line -1) | 965 | (forward-line -1) |
| 959 | (python-info-line-ends-backslash-p)) | 966 | (python-info-line-ends-backslash-p)) |
| 967 | (python-info-ppss-context 'string) | ||
| 960 | (python-info-ppss-context 'paren)) | 968 | (python-info-ppss-context 'paren)) |
| 961 | (forward-line -1))))) | 969 | (forward-line -1))))) |
| 962 | 970 | ||
| @@ -967,9 +975,35 @@ Returns nil if point is not in a def or class." | |||
| 967 | (not (eobp)) | 975 | (not (eobp)) |
| 968 | (when (or | 976 | (when (or |
| 969 | (python-info-line-ends-backslash-p) | 977 | (python-info-line-ends-backslash-p) |
| 978 | (python-info-ppss-context 'string) | ||
| 970 | (python-info-ppss-context 'paren)) | 979 | (python-info-ppss-context 'paren)) |
| 971 | (forward-line 1))))) | 980 | (forward-line 1))))) |
| 972 | 981 | ||
| 982 | (defun python-nav-backward-sentence (&optional arg) | ||
| 983 | "Move backward to start of sentence. With arg, do it arg times. | ||
| 984 | See `python-nav-forward-sentence' for more information." | ||
| 985 | (interactive "^p") | ||
| 986 | (or arg (setq arg 1)) | ||
| 987 | (python-nav-forward-sentence (- arg))) | ||
| 988 | |||
| 989 | (defun python-nav-forward-sentence (&optional arg) | ||
| 990 | "Move forward to next end of sentence. With argument, repeat. | ||
| 991 | With negative argument, move backward repeatedly to start of sentence." | ||
| 992 | (interactive "^p") | ||
| 993 | (or arg (setq arg 1)) | ||
| 994 | (while (> arg 0) | ||
| 995 | (forward-comment 9999) | ||
| 996 | (python-nav-sentence-end) | ||
| 997 | (forward-line 1) | ||
| 998 | (setq arg (1- arg))) | ||
| 999 | (while (< arg 0) | ||
| 1000 | (python-nav-sentence-end) | ||
| 1001 | (forward-comment -9999) | ||
| 1002 | (python-nav-sentence-start) | ||
| 1003 | (forward-line -1) | ||
| 1004 | (setq arg (1+ arg)))) | ||
| 1005 | |||
| 1006 | |||
| 973 | 1007 | ||
| 974 | ;;; Shell integration | 1008 | ;;; Shell integration |
| 975 | 1009 | ||