* progmodes/python.el (python-syntax--context-compiler-macro): New defun.

(python-syntax-context): Use named compiler-macro for backwards
compatibility with Emacs 24.x.
This commit is contained in:
Fabián Ezequiel Gallina 2013-04-16 23:52:50 -03:00
parent ad64b83d9b
commit 619ed6e18a
2 changed files with 20 additions and 12 deletions

View file

@ -1,3 +1,9 @@
2013-04-17 Fabián Ezequiel Gallina <fgallina@gnu.org>
* 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 <sdl.web@gmail.com>
* progmodes/octave-mod.el (octave-mode-map): Fix key binding to

View file

@ -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)))