From: Fabián Ezequiel Gallina Date: Thu, 17 May 2012 03:03:46 +0000 (-0300) Subject: Migrated python-font-lock-syntactic-keywords to python-syntax-propertize-function X-Git-Tag: emacs-24.2.90~1199^2~479 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=aeadd9a4699f7606bb2ff5fe04a927cf68e5e211;p=emacs.git 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 --- 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." (set-match-data nil))))) (1 font-lock-variable-name-face nil nil)))) -(defconst python-font-lock-syntactic-keywords +(defconst python-syntax-propertize-function ;; Make outer chars of matching triple-quote sequences into generic ;; string delimiters. Fixme: Is there a better way? ;; First avoid a sequence preceded by an odd number of backslashes. - `((,(concat "\\(?:\\([RUru]\\)[Rr]?\\|^\\|[^\\]\\(?:\\\\.\\)*\\)" ;Prefix. - "\\(?:\\('\\)'\\('\\)\\|\\(?2:\"\\)\"\\(?3:\"\\)\\)") - (3 (python-quote-syntax))))) + (syntax-propertize-rules + (;; ¡Backrefs don't work in syntax-propertize-rules! + (concat "\\(?:\\([RUru]\\)[Rr]?\\|^\\|[^\\]\\(?:\\\\.\\)*\\)" ;Prefix. + "\\(?:\\('\\)'\\('\\)\\|\\(?2:\"\\)\"\\(?3:\"\\)\\)") + (3 (ignore (python-quote-syntax)))))) (defun python-quote-syntax () "Put `syntax-table' property correctly on triple quote. @@ -1444,11 +1446,10 @@ variable. (define-key inferior-python-mode-map (kbd "") 'python-shell-completion-complete-or-indent) (when python-shell-enable-font-lock - (set - (make-local-variable 'font-lock-defaults) - '(python-font-lock-keywords - nil nil nil nil - (font-lock-syntactic-keywords . python-font-lock-syntactic-keywords)))) + (set (make-local-variable 'font-lock-defaults) + '(python-font-lock-keywords nil nil nil nil)) + (set (make-local-variable 'syntax-propertize-function) + python-syntax-propertize-function)) (compilation-shell-minor-mode 1)) (defun python-shell-make-comint (cmd proc-name &optional pop) @@ -2805,9 +2806,10 @@ if that value is non-nil." (set (make-local-variable 'parse-sexp-ignore-comments) t) (set (make-local-variable 'font-lock-defaults) - '(python-font-lock-keywords - nil nil nil nil - (font-lock-syntactic-keywords . python-font-lock-syntactic-keywords))) + '(python-font-lock-keywords nil nil nil nil)) + + (set (make-local-variable 'syntax-propertize-function) + python-syntax-propertize-function) (set (make-local-variable 'indent-line-function) #'python-indent-line-function)