[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#37452: 26.3; skip-syntax-forward doesn't work in python-mode
From: |
Noam Postavsky |
Subject: |
bug#37452: 26.3; skip-syntax-forward doesn't work in python-mode |
Date: |
Wed, 18 Sep 2019 18:37:39 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) |
Amai Kinono <amaikinono@gmail.com> writes:
> (defun skip-syntax ()
> (interactive)
> (skip-syntax-forward (char-to-string (char-syntax (char-after)))))
If you look at char-syntax's docstring, you should see
If you’re trying to determine the syntax of characters in the buffer,
this is probably the wrong function to use, because it can’t take
‘syntax-table’ text properties into account. Consider using
‘syntax-after’ instead.
Which is exactly the situation you've encountered here: python-mode sets
the syntax of the quote to string fence ("|") using a text property.
This version of skip-syntax should work:
(defun syntax-class-to-char (syntax-class)
(aref " .w_()'\"$\\/<>@!|" syntax-class))
(defun skip-syntax ()
(interactive)
(skip-syntax-forward (char-to-string
(syntax-class-to-char
(syntax-class (syntax-after (point)))))))
Although I'd say that the function syntax-class-to-char should be added
to Emacs (in syntax.c, so that it can reuse syntax_code_spec).