1 |
;;; python.el --- silly walks for Python |
;;; python.el --- silly walks for Python |
2 |
|
|
3 |
;; Copyright (C) 2003, 2004 Free Software Foundation, Inc. |
;; Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc. |
4 |
|
|
5 |
;; Author: Dave Love <fx@gnu.org> |
;; Author: Dave Love <fx@gnu.org> |
6 |
;; Maintainer: FSF |
;; Maintainer: FSF |
336 |
(unless bos (python-beginning-of-statement)) |
(unless bos (python-beginning-of-statement)) |
337 |
(back-to-indentation) |
(back-to-indentation) |
338 |
(looking-at (rx (and (or "return" "raise" "break" "continue" "pass") |
(looking-at (rx (and (or "return" "raise" "break" "continue" "pass") |
339 |
word-end))))) |
symbol-end))))) |
340 |
|
|
341 |
(defun python-outdent-p () |
(defun python-outdent-p () |
342 |
"Return non-nil if current line should outdent a level." |
"Return non-nil if current line should outdent a level." |
343 |
(save-excursion |
(save-excursion |
344 |
(back-to-indentation) |
(back-to-indentation) |
345 |
(and (looking-at (rx (and (or (and (or "else" "finally") word-end) |
(and (looking-at (rx (and (or (and (or "else" "finally") symbol-end) |
346 |
(and (or "except" "elif") word-end |
(and (or "except" "elif") symbol-end |
347 |
(1+ (not (any ?:))))) |
(1+ (not (any ?:))))) |
348 |
(optional space) ":" (optional space) |
(optional space) ":" (optional space) |
349 |
(or (syntax comment-start) line-end)))) |
(or (syntax comment-start) line-end)))) |
355 |
;; Fixme: check this |
;; Fixme: check this |
356 |
(not (looking-at (rx (and (or (and (or "if" "elif" "except" |
(not (looking-at (rx (and (or (and (or "if" "elif" "except" |
357 |
"for" "while") |
"for" "while") |
358 |
word-end (1+ (not (any ?:)))) |
symbol-end (1+ (not (any ?:)))) |
359 |
(and "try" word-end)) |
(and "try" symbol-end)) |
360 |
(optional space) ":" (optional space) |
(optional space) ":" (optional space) |
361 |
(or (syntax comment-start) line-end))))) |
(or (syntax comment-start) line-end))))) |
362 |
(progn (end-of-line) |
(progn (end-of-line) |
1562 |
(beginning-of-defun) |
(beginning-of-defun) |
1563 |
(if (looking-at (rx (and (0+ space) (or "def" "class") (1+ space) |
(if (looking-at (rx (and (0+ space) (or "def" "class") (1+ space) |
1564 |
(group (1+ (or word (syntax symbol)))) |
(group (1+ (or word (syntax symbol)))) |
1565 |
word-end))) |
;; Greediness makes this unnecessary? --Stef |
1566 |
|
symbol-end))) |
1567 |
(push (match-string 1) accum))) |
(push (match-string 1) accum))) |
1568 |
(if accum (mapconcat 'identity accum "."))))) |
(if accum (mapconcat 'identity accum "."))))) |
1569 |
|
|
1703 |
'(python-font-lock-keywords nil nil ((?_ . "w")) nil |
'(python-font-lock-keywords nil nil ((?_ . "w")) nil |
1704 |
(font-lock-syntactic-keywords |
(font-lock-syntactic-keywords |
1705 |
. python-font-lock-syntactic-keywords) |
. python-font-lock-syntactic-keywords) |
1706 |
;;; This probably isn't worth it. |
;; This probably isn't worth it. |
1707 |
;;; (font-lock-syntactic-face-function |
;; (font-lock-syntactic-face-function |
1708 |
;;; . python-font-lock-syntactic-face-function) |
;; . python-font-lock-syntactic-face-function) |
1709 |
)) |
)) |
1710 |
(set (make-local-variable 'parse-sexp-lookup-properties) t) |
(set (make-local-variable 'parse-sexp-lookup-properties) t) |
1711 |
(set (make-local-variable 'comment-start) "# ") |
(set (make-local-variable 'comment-start) "# ") |