From 619ed6e18a4231c9d9c8e50b21eb1e870e7e6853 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Fabi=C3=A1n=20Ezequiel=20Gallina?= Date: Tue, 16 Apr 2013 23:52:50 -0300 Subject: [PATCH] * progmodes/python.el (python-syntax--context-compiler-macro): New defun. (python-syntax-context): Use named compiler-macro for backwards compatibility with Emacs 24.x. --- lisp/ChangeLog | 6 ++++++ lisp/progmodes/python.el | 26 ++++++++++++++------------ 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 23b873d0047..cbb63e3ff87 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,9 @@ +2013-04-17 Fabián Ezequiel Gallina + + * progmodes/python.el (python-syntax--context-compiler-macro): New defun. + (python-syntax-context): Use named compiler-macro for backwards + compatibility with Emacs 24.x. + 2013-04-17 Leo Liu * progmodes/octave-mod.el (octave-mode-map): Fix key binding to diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index fde7fadd061..b0c00a309eb 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el @@ -368,22 +368,24 @@ This variant of `rx' supports common python named REGEXPS." ;;; Font-lock and syntax +(eval-when-compile + (defun python-syntax--context-compiler-macro (form type &optional syntax-ppss) + (pcase type + (`'comment + `(let ((ppss (or ,syntax-ppss (syntax-ppss)))) + (and (nth 4 ppss) (nth 8 ppss)))) + (`'string + `(let ((ppss (or ,syntax-ppss (syntax-ppss)))) + (and (nth 3 ppss) (nth 8 ppss)))) + (`'paren + `(nth 1 (or ,syntax-ppss (syntax-ppss)))) + (_ form)))) + (defun python-syntax-context (type &optional syntax-ppss) "Return non-nil if point is on TYPE using SYNTAX-PPSS. TYPE can be `comment', `string' or `paren'. It returns the start character address of the specified TYPE." - (declare (compiler-macro - (lambda (form) - (pcase type - (`'comment - `(let ((ppss (or ,syntax-ppss (syntax-ppss)))) - (and (nth 4 ppss) (nth 8 ppss)))) - (`'string - `(let ((ppss (or ,syntax-ppss (syntax-ppss)))) - (and (nth 3 ppss) (nth 8 ppss)))) - (`'paren - `(nth 1 (or ,syntax-ppss (syntax-ppss)))) - (_ form))))) + (declare (compiler-macro python-syntax--context-compiler-macro)) (let ((ppss (or syntax-ppss (syntax-ppss)))) (pcase type (`comment (and (nth 4 ppss) (nth 8 ppss))) -- 2.39.2