Mercurial > emacs
comparison lisp/progmodes/python.el @ 60931:494d942e49fe
(python-close-block-statement-p)
(python-outdent-p, python-current-defun): Use symbol-end.
| author | Stefan Monnier <monnier@iro.umontreal.ca> |
|---|---|
| date | Fri, 25 Mar 2005 14:36:08 +0000 |
| parents | aac0a33f5772 |
| children | 758ff54158e2 |
comparison
equal
deleted
inserted
replaced
| 60930:a6ae354aa8ef | 60931:494d942e49fe |
|---|---|
| 1 ;;; python.el --- silly walks for Python | 1 ;;; python.el --- silly walks for Python |
| 2 | 2 |
| 3 ;; Copyright (C) 2003, 2004 Free Software Foundation, Inc. | 3 ;; Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc. |
| 4 | 4 |
| 5 ;; Author: Dave Love <fx@gnu.org> | 5 ;; Author: Dave Love <fx@gnu.org> |
| 6 ;; Maintainer: FSF | 6 ;; Maintainer: FSF |
| 7 ;; Created: Nov 2003 | 7 ;; Created: Nov 2003 |
| 8 ;; Keywords: languages | 8 ;; Keywords: languages |
| 334 keyword `raise', `break', `continue' or `pass'." | 334 keyword `raise', `break', `continue' or `pass'." |
| 335 (save-excursion | 335 (save-excursion |
| 336 (unless bos (python-beginning-of-statement)) | 336 (unless bos (python-beginning-of-statement)) |
| 337 (back-to-indentation) | 337 (back-to-indentation) |
| 338 (looking-at (rx (and (or "return" "raise" "break" "continue" "pass") | 338 (looking-at (rx (and (or "return" "raise" "break" "continue" "pass") |
| 339 word-end))))) | 339 symbol-end))))) |
| 340 | 340 |
| 341 (defun python-outdent-p () | 341 (defun python-outdent-p () |
| 342 "Return non-nil if current line should outdent a level." | 342 "Return non-nil if current line should outdent a level." |
| 343 (save-excursion | 343 (save-excursion |
| 344 (back-to-indentation) | 344 (back-to-indentation) |
| 345 (and (looking-at (rx (and (or (and (or "else" "finally") word-end) | 345 (and (looking-at (rx (and (or (and (or "else" "finally") symbol-end) |
| 346 (and (or "except" "elif") word-end | 346 (and (or "except" "elif") symbol-end |
| 347 (1+ (not (any ?:))))) | 347 (1+ (not (any ?:))))) |
| 348 (optional space) ":" (optional space) | 348 (optional space) ":" (optional space) |
| 349 (or (syntax comment-start) line-end)))) | 349 (or (syntax comment-start) line-end)))) |
| 350 (progn (end-of-line) | 350 (progn (end-of-line) |
| 351 (not (python-in-string/comment))) | 351 (not (python-in-string/comment))) |
| 353 (zerop (python-previous-statement)) | 353 (zerop (python-previous-statement)) |
| 354 (not (python-close-block-statement-p t)) | 354 (not (python-close-block-statement-p t)) |
| 355 ;; Fixme: check this | 355 ;; Fixme: check this |
| 356 (not (looking-at (rx (and (or (and (or "if" "elif" "except" | 356 (not (looking-at (rx (and (or (and (or "if" "elif" "except" |
| 357 "for" "while") | 357 "for" "while") |
| 358 word-end (1+ (not (any ?:)))) | 358 symbol-end (1+ (not (any ?:)))) |
| 359 (and "try" word-end)) | 359 (and "try" symbol-end)) |
| 360 (optional space) ":" (optional space) | 360 (optional space) ":" (optional space) |
| 361 (or (syntax comment-start) line-end))))) | 361 (or (syntax comment-start) line-end))))) |
| 362 (progn (end-of-line) | 362 (progn (end-of-line) |
| 363 (not (python-in-string/comment)))))) | 363 (not (python-in-string/comment)))))) |
| 364 | 364 |
| 1560 (python-beginning-of-block) | 1560 (python-beginning-of-block) |
| 1561 (end-of-line) | 1561 (end-of-line) |
| 1562 (beginning-of-defun) | 1562 (beginning-of-defun) |
| 1563 (if (looking-at (rx (and (0+ space) (or "def" "class") (1+ space) | 1563 (if (looking-at (rx (and (0+ space) (or "def" "class") (1+ space) |
| 1564 (group (1+ (or word (syntax symbol)))) | 1564 (group (1+ (or word (syntax symbol)))) |
| 1565 word-end))) | 1565 ;; Greediness makes this unnecessary? --Stef |
| 1566 symbol-end))) | |
| 1566 (push (match-string 1) accum))) | 1567 (push (match-string 1) accum))) |
| 1567 (if accum (mapconcat 'identity accum "."))))) | 1568 (if accum (mapconcat 'identity accum "."))))) |
| 1568 | 1569 |
| 1569 (defun python-mark-block () | 1570 (defun python-mark-block () |
| 1570 "Mark the block around point. | 1571 "Mark the block around point. |
| 1700 :group 'python | 1701 :group 'python |
| 1701 (set (make-local-variable 'font-lock-defaults) | 1702 (set (make-local-variable 'font-lock-defaults) |
| 1702 '(python-font-lock-keywords nil nil ((?_ . "w")) nil | 1703 '(python-font-lock-keywords nil nil ((?_ . "w")) nil |
| 1703 (font-lock-syntactic-keywords | 1704 (font-lock-syntactic-keywords |
| 1704 . python-font-lock-syntactic-keywords) | 1705 . python-font-lock-syntactic-keywords) |
| 1705 ;;; This probably isn't worth it. | 1706 ;; This probably isn't worth it. |
| 1706 ;;; (font-lock-syntactic-face-function | 1707 ;; (font-lock-syntactic-face-function |
| 1707 ;;; . python-font-lock-syntactic-face-function) | 1708 ;; . python-font-lock-syntactic-face-function) |
| 1708 )) | 1709 )) |
| 1709 (set (make-local-variable 'parse-sexp-lookup-properties) t) | 1710 (set (make-local-variable 'parse-sexp-lookup-properties) t) |
| 1710 (set (make-local-variable 'comment-start) "# ") | 1711 (set (make-local-variable 'comment-start) "# ") |
| 1711 (set (make-local-variable 'comment-indent-function) #'python-comment-indent) | 1712 (set (make-local-variable 'comment-indent-function) #'python-comment-indent) |
| 1712 (set (make-local-variable 'indent-line-function) #'python-indent-line) | 1713 (set (make-local-variable 'indent-line-function) #'python-indent-line) |
