aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/progmodes/python.el
diff options
context:
space:
mode:
authorFabián Ezequiel Gallina2013-04-16 23:52:50 -0300
committerFabián Ezequiel Gallina2013-04-16 23:52:50 -0300
commit619ed6e18a4231c9d9c8e50b21eb1e870e7e6853 (patch)
tree34d7f5cda5c24af0ae27e78d10372eb1b13e03e2 /lisp/progmodes/python.el
parentad64b83d9b7e6b16db0704731097355201f62bfc (diff)
downloademacs-619ed6e18a4231c9d9c8e50b21eb1e870e7e6853.tar.gz
emacs-619ed6e18a4231c9d9c8e50b21eb1e870e7e6853.zip
* progmodes/python.el (python-syntax--context-compiler-macro): New defun.
(python-syntax-context): Use named compiler-macro for backwards compatibility with Emacs 24.x.
Diffstat (limited to 'lisp/progmodes/python.el')
-rw-r--r--lisp/progmodes/python.el26
1 files changed, 14 insertions, 12 deletions
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."
368 368
369;;; Font-lock and syntax 369;;; Font-lock and syntax
370 370
371(eval-when-compile
372 (defun python-syntax--context-compiler-macro (form type &optional syntax-ppss)
373 (pcase type
374 (`'comment
375 `(let ((ppss (or ,syntax-ppss (syntax-ppss))))
376 (and (nth 4 ppss) (nth 8 ppss))))
377 (`'string
378 `(let ((ppss (or ,syntax-ppss (syntax-ppss))))
379 (and (nth 3 ppss) (nth 8 ppss))))
380 (`'paren
381 `(nth 1 (or ,syntax-ppss (syntax-ppss))))
382 (_ form))))
383
371(defun python-syntax-context (type &optional syntax-ppss) 384(defun python-syntax-context (type &optional syntax-ppss)
372 "Return non-nil if point is on TYPE using SYNTAX-PPSS. 385 "Return non-nil if point is on TYPE using SYNTAX-PPSS.
373TYPE can be `comment', `string' or `paren'. It returns the start 386TYPE can be `comment', `string' or `paren'. It returns the start
374character address of the specified TYPE." 387character address of the specified TYPE."
375 (declare (compiler-macro 388 (declare (compiler-macro python-syntax--context-compiler-macro))
376 (lambda (form)
377 (pcase type
378 (`'comment
379 `(let ((ppss (or ,syntax-ppss (syntax-ppss))))
380 (and (nth 4 ppss) (nth 8 ppss))))
381 (`'string
382 `(let ((ppss (or ,syntax-ppss (syntax-ppss))))
383 (and (nth 3 ppss) (nth 8 ppss))))
384 (`'paren
385 `(nth 1 (or ,syntax-ppss (syntax-ppss))))
386 (_ form)))))
387 (let ((ppss (or syntax-ppss (syntax-ppss)))) 389 (let ((ppss (or syntax-ppss (syntax-ppss))))
388 (pcase type 390 (pcase type
389 (`comment (and (nth 4 ppss) (nth 8 ppss))) 391 (`comment (and (nth 4 ppss) (nth 8 ppss)))