Skip to main content

Questions tagged [syntax-table]

is an Emacs Lisp data structure in which each character's syntactic role is defined. Other Emacs facilities, such as font lock, navigation, parsing, etc., scan these syntax tables to determine where words, symbols, and other syntactic constructs begin and end. Syntax tables are unique to every major mode. They are customizable and even overridable with text properties.

Filter by
Sorted by
Tagged with
2 votes
0 answers

Emacs Syntax Table Modifications [closed]

I am looking to write my own major mode. The programming language that I need to write it for has //... and /* ... */ style comments. I am having a very hard time getting the syntax tables working ...
Nick's user avatar
  • 21
1 vote
1 answer

how to change C-mode syntax so that the token @' is ignored?

I edit some files that are mostly C code but include a few special extension tokens. The tokens that give c-mode a problem are @' and @". I essentially want c-mode to ignore these two bigrams. The ...
Jonathan Cano's user avatar
0 votes
0 answers

Can't define a glyph as a word constituent

I'd like Emacs to treat this dollar$sign as one word. So I evaluated this line (modify-syntax-entry ?$ "w") to have Emacs treat dollar sign as a word constituent rather than a symbol. However, ...
stacko's user avatar
  • 1,597
8 votes
3 answers

How can I make emacs support javascript ES6 template string literals?

I want to use ES6 template string literals e.g.: `string text line 1 string text line 2 string text ${expression}` However emacs doesn't recognize that their contents are a string, so syntax ...
dshepherd's user avatar
  • 1,281
2 votes
1 answer

Treat shebang as a comment

I am trying to get js-mode to highlight a "shebang" (#!/usr/bin/env node) as a comment, but my code is not working. Instead, the entire buffer is colored like a comment. I've read the documentation ...
Jackson Ray Hamilton's user avatar
3 votes
0 answers

Treating \[...] nicely in Wolfram mode

In the Wolfram language, special characters such as ∂, ∫ and ζ can be displayed nicely in Mathematica and in the source, appear as \[PartialD], \[Integral] and \[Zeta]. In wolfram mode, the special ...
JP-Ellis's user avatar
  • 131
1 vote
1 answer

How to fix coffee mode symbol?

While trying to use highlight-symbol in coffee mode (especially, cjsx), it interprets Something and <Something as two different symbols, while I expect < to be not part of a symbol. Tried to ...
Roman Susi's user avatar
2 votes
1 answer

Changing evil-forward-word behavior by modifying a syntax table

Currently in Emacs Lisp files I have the following behavior when I run evil-forward-word-begin |some-lisp-function some|-lisp-function some-|lisp-function some-lisp|-function some-lisp-|function In ...
Russ Kiselev's user avatar
1 vote
1 answer

Highlighting YAML comments correctly

See for more background. YAML defines a comment as a # either preceded by the beginning of the line or whitespace (more ...
wasamasa's user avatar
  • 22.2k
3 votes
1 answer

Is there a way to set arbitrary characters as the word boundary?

I know I can do this kind of thing with the sentence boundary, using (setq sentence-end "[regexp]"), but how can I do this with the word boundary? I'd like to add capital letters to the default word ...
stacko's user avatar
  • 1,597
4 votes
0 answers

Help with advanced syntax rules

How can I express syntax rules like "[0-9/.:*+!_'?-] are valid symbol constituent, but not as the first char"? Or "/ is a valid symbol constituent, but can only appear once and in the middle of a ...
expez's user avatar
  • 381
5 votes
0 answers

Paired string delimiters?

Red and Rebol have multiline strings that start with { and end with }. Reading through Elisp docs I don't see any simple way to define this in the syntax table. The string quotes class matches the ...
xificurC's user avatar
  • 151
3 votes
1 answer

Adding tilde to electric pairs in org mode

I am trying to add the verbatim character ~ (tilde) as an electric-pair character in org-mode. Here is my attempt: (with-eval-after-load 'org (modify-syntax-entry ?/ "(/" org-mode-syntax-table) (...
Matthew Piziak's user avatar
5 votes
2 answers

How to keep underscores in Python within a word boundary?

When writing code in python-mode my preference would be to include underscores within a word boundary, so variable_with_underscores is treated as a single word. How would I limit my word preference ...
Jeffrey Bauer's user avatar
2 votes
2 answers

Why do we have [:word:] but not [:symbol:]?

I'd like to use [[:symbol:]]+ in a regular expression but this does not exist in Emacs, see ad-hoc section in the manual. Q1: what is the rationale behind this? I'm always happy to understand the ...
phs's user avatar
  • 1,239
2 votes
0 answers

Is it possible to detect C/C++/Java variable declarations.?

I'm writing a minor mode to handle automatic spacing of operator characters, but I'm having some trouble with C/C++. The problem is that I can't figure out how to tell in general whether a * is a ...
dshepherd's user avatar
  • 1,281
9 votes
2 answers

What is a string fence or comment fence?

The docstring for modify-syntax-entry says the following: (modify-syntax-entry CHAR NEWENTRY &optional SYNTAX-TABLE) ... The first character of NEWENTRY should be one of the following: ... / ...
Wilfred Hughes's user avatar
0 votes
1 answer

remove delimiter and comment typing from [Ljava.lang.String; in clojure-mode

Parsing parentheses: smie vs syntax table gives one example of how to use syntax-propertize-function but I wonder if someone could help me with another example. I'm working with clojure-mode. Here's ...
Joe Corneli's user avatar
  • 1,808
1 vote
1 answer

Is there a possibility to close the right syntax for another languages?

When I was watching Emacs Rocks, there was a feature showed, called sgml-close-tag. You can see an example here. When called that command, he will close the tag for you if there is a tag missing. I ...
ReneFroger's user avatar
  • 3,890
5 votes
1 answer

Change character syntax temporarily?

Q: how can I change the syntax of a character for a single function? In text-mode and its derivatives, the ' character has word syntax rather than, say punctuation or string quote syntax. That's a ...
Dan's user avatar
  • 33.2k
6 votes
2 answers

Three-characters comment syntax

Emacs supports syntax flags for 1- and 2-characters comment delimiters. Can it be made to recognize and properly highlight 3-characters delimiters? For example: In Emacs Lisp: ;;; Headings In C#...
Clément's user avatar
  • 3,995
9 votes
2 answers

How to change comment character from # (hash) to % (percent sign) for Octave major mode

By default, comment-region inserts # for comments in Octave major mode: # foo I want to modify the behavior so that it inserts the percent sign % foo I used the following (setq octave-mode-hook ...
osolmaz's user avatar
  • 455
0 votes
1 answer

Word delimiters in standard syntax table

I'm trying to configure other programs to emulate Emacs. I know Emacs' word delimiters are: User configurable Mode dependent But I'd still like to know what the default word boundary characters ...
PythonNut's user avatar
  • 10.4k
52 votes
8 answers

How to treat underscore as part of the word?

I use Emacs + evil mode. When I position the cursor on e (in normal state) in a chunk of text such as abc_def_ghi, ciw (change inner word) changes only the def part of the string, while Vim would ...
Kossak's user avatar
  • 1,159
1 vote
0 answers

How does forward-list work for "<>" in c++-mode?

I am trying to understand how forward-list matches template delimiters <> in c++-mode. forward-list in lisp.el calls scan-lists with the appropriate arguments. The documentation for scan-lists ...
Pradhan's user avatar
  • 2,370
3 votes
4 answers

Sorting words with hyphens (e.g. in a Lisp mode)

SortWords in the EmacsWiki suggests this function as a way to sort words: (defun sort-words (reverse beg end) "Sort words in region alphabetically, in REVERSE if negative. When prefixed with ...
David J.'s user avatar
  • 1,869
12 votes
3 answers

How can I detect if the current character is a comment character for that major mode?

I am working on this little function that pulls up the next line to the current line. I want to add a functionality so that if the current line is a line comment and the next line is also a line ...
Kaushal Modi's user avatar
  • 25.7k
7 votes
1 answer

Parsing parentheses: smie vs syntax table

I am maintaining a mode for a programming language with... let's say "annoying" syntax constructs. For example, the angle brackets (no idea if it is the correct word) < and > are parentheses. ...
T. Verron's user avatar
  • 4,293