diff options
| author | Fabián Ezequiel Gallina | 2012-05-17 00:03:46 -0300 |
|---|---|---|
| committer | Fabián Ezequiel Gallina | 2012-05-17 00:03:46 -0300 |
| commit | aeadd9a4699f7606bb2ff5fe04a927cf68e5e211 (patch) | |
| tree | 3eb68ce05a8391e91107541491b01aa505597b1d /lisp/progmodes/python.el | |
| parent | 09268a54ae6f690d0fcfbf8aeb02710b14248d6b (diff) | |
| download | emacs-aeadd9a4699f7606bb2ff5fe04a927cf68e5e211.tar.gz emacs-aeadd9a4699f7606bb2ff5fe04a927cf68e5e211.zip | |
Migrated python-font-lock-syntactic-keywords to python-syntax-propertize-function
This is a backport of Stefan Monnier's migration to the new font-lock
machinery (introduced in 2010-09-10T23:13:42Z!monnier@iro.umontreal.ca).
New Vars:
+ python-syntax-propertize-function
Deleted Vars:
+ python-font-lock-syntactic-keywords
Diffstat (limited to 'lisp/progmodes/python.el')
| -rw-r--r-- | lisp/progmodes/python.el | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index c41d99bdf81..4fa8dff2a72 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el | |||
| @@ -456,13 +456,15 @@ This variant of `rx' supports common python named REGEXPS." | |||
| 456 | (set-match-data nil))))) | 456 | (set-match-data nil))))) |
| 457 | (1 font-lock-variable-name-face nil nil)))) | 457 | (1 font-lock-variable-name-face nil nil)))) |
| 458 | 458 | ||
| 459 | (defconst python-font-lock-syntactic-keywords | 459 | (defconst python-syntax-propertize-function |
| 460 | ;; Make outer chars of matching triple-quote sequences into generic | 460 | ;; Make outer chars of matching triple-quote sequences into generic |
| 461 | ;; string delimiters. Fixme: Is there a better way? | 461 | ;; string delimiters. Fixme: Is there a better way? |
| 462 | ;; First avoid a sequence preceded by an odd number of backslashes. | 462 | ;; First avoid a sequence preceded by an odd number of backslashes. |
| 463 | `((,(concat "\\(?:\\([RUru]\\)[Rr]?\\|^\\|[^\\]\\(?:\\\\.\\)*\\)" ;Prefix. | 463 | (syntax-propertize-rules |
| 464 | "\\(?:\\('\\)'\\('\\)\\|\\(?2:\"\\)\"\\(?3:\"\\)\\)") | 464 | (;; ¡Backrefs don't work in syntax-propertize-rules! |
| 465 | (3 (python-quote-syntax))))) | 465 | (concat "\\(?:\\([RUru]\\)[Rr]?\\|^\\|[^\\]\\(?:\\\\.\\)*\\)" ;Prefix. |
| 466 | "\\(?:\\('\\)'\\('\\)\\|\\(?2:\"\\)\"\\(?3:\"\\)\\)") | ||
| 467 | (3 (ignore (python-quote-syntax)))))) | ||
| 466 | 468 | ||
| 467 | (defun python-quote-syntax () | 469 | (defun python-quote-syntax () |
| 468 | "Put `syntax-table' property correctly on triple quote. | 470 | "Put `syntax-table' property correctly on triple quote. |
| @@ -1444,11 +1446,10 @@ variable. | |||
| 1444 | (define-key inferior-python-mode-map (kbd "<tab>") | 1446 | (define-key inferior-python-mode-map (kbd "<tab>") |
| 1445 | 'python-shell-completion-complete-or-indent) | 1447 | 'python-shell-completion-complete-or-indent) |
| 1446 | (when python-shell-enable-font-lock | 1448 | (when python-shell-enable-font-lock |
| 1447 | (set | 1449 | (set (make-local-variable 'font-lock-defaults) |
| 1448 | (make-local-variable 'font-lock-defaults) | 1450 | '(python-font-lock-keywords nil nil nil nil)) |
| 1449 | '(python-font-lock-keywords | 1451 | (set (make-local-variable 'syntax-propertize-function) |
| 1450 | nil nil nil nil | 1452 | python-syntax-propertize-function)) |
| 1451 | (font-lock-syntactic-keywords . python-font-lock-syntactic-keywords)))) | ||
| 1452 | (compilation-shell-minor-mode 1)) | 1453 | (compilation-shell-minor-mode 1)) |
| 1453 | 1454 | ||
| 1454 | (defun python-shell-make-comint (cmd proc-name &optional pop) | 1455 | (defun python-shell-make-comint (cmd proc-name &optional pop) |
| @@ -2805,9 +2806,10 @@ if that value is non-nil." | |||
| 2805 | (set (make-local-variable 'parse-sexp-ignore-comments) t) | 2806 | (set (make-local-variable 'parse-sexp-ignore-comments) t) |
| 2806 | 2807 | ||
| 2807 | (set (make-local-variable 'font-lock-defaults) | 2808 | (set (make-local-variable 'font-lock-defaults) |
| 2808 | '(python-font-lock-keywords | 2809 | '(python-font-lock-keywords nil nil nil nil)) |
| 2809 | nil nil nil nil | 2810 | |
| 2810 | (font-lock-syntactic-keywords . python-font-lock-syntactic-keywords))) | 2811 | (set (make-local-variable 'syntax-propertize-function) |
| 2812 | python-syntax-propertize-function) | ||
| 2811 | 2813 | ||
| 2812 | (set (make-local-variable 'indent-line-function) | 2814 | (set (make-local-variable 'indent-line-function) |
| 2813 | #'python-indent-line-function) | 2815 | #'python-indent-line-function) |