Questions tagged [syntax]

is for grammar, structure, and order of language elements. Emacs provides many facilities for correcting syntax errors, building complex syntactic structures from simpler ones, and applying rules of composition with syntactical correctness.

Filter by
Sorted by
Tagged with
35
votes
7answers
9k views

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 ...
0
votes
1answer
79 views

helm-mu on macOS throws Invalid read syntax: (")

Hej guys, I get an error when searching through my mails with helm-mu. Messages gives Invalid face reference: helm-grep-finish [96 times] error in process filter: helm-mu-candidate-parser: End of ...
0
votes
1answer
28 views

Completing underscored words without making _ a word character

I would like to use evil-complete-previous (or whatever) to complete strings_such_as_this, which is by default not possible. It is possible after (modify-syntax-entry ?_ "w"), but this has the ...
1
vote
1answer
33 views

Syntax coloring: Unable to color special syntax

I am writing a mode to color a few common syntax in a symbolic language called FORM. I am a new user of emacs and I took the help of this website to write down the following code. I modified the ...
5
votes
2answers
403 views

How to 'modify-syntax-entry' for a major mode?

Following this answer, when I type (modify-syntax-entry ?_ "w") and do M-x eval-region, it has the effect I'm looking for, albeit only for that buffer. I've put (modify-syntax-entry ?_ "w") in my ....
2
votes
2answers
54 views

Can syntax parsing recognize the SQL '' (escape apostrophe/single quote) construct within SQL strings?

I am trying to enhance SQL mode such that editing of files of SQL code becomes more convenient, especially as far as jumping around is concerned (e.g. things like sql-goto-end-of-string etc.). I have ...
1
vote
1answer
46 views

Why needs syntax highlighting often a `revert-buffer`?

Quite frequently, syntax highlighting in a given buffer is broken (i.e., a big fraction of the code is not highlighted). This is definitely not due to syntax errors, and the point at which ...
4
votes
1answer
198 views

Circular list use of “#”

Looking at this, I see (setq x '#1=(a #1#)) but this evaluates to (a #0). As I understand, this should be (a #1=(a #1#)). But then what syntax makes #0 mean #1=(a #1#)? In general what is # doing in ...
1
vote
1answer
262 views

“Symbol's value as variable is void: *” using load-file

I have this function in my config file and for some reason, I'm getting this error: Symbol's value as variable is void: *. (defun reload-config() "Reload config.org" (interactive) (load-...
1
vote
1answer
224 views

python interpreter within emacs fails on simple test on __main__ (syntax error)

This small program runs well in Terminal : mac2011% cat bug.py print(__name__ == "__main__") #if True: if __name__ == "__main__": print("main") else: print("not main") mac2011% python bug.py ...
1
vote
1answer
84 views

How to find the matching bracket at a point in elisp?

What is a reliable way to find the matching balanced bracket (eg: {}, [], () in C or Python), which doesn't get confused by brackets in strings, or escaped brackets for e.g. Example: ["Foo]" ?\] 0 [...
1
vote
1answer
28 views

forward-word and non-letter “words”

Using forward-word with this line: foo *** *** bar, I want to have the folowing behavior: foo| ***| ***| bar|, Not: foo| *** *** bar|, So, if between spaces there are only non-letter symbols, ...
2
votes
1answer
133 views

Debugger entered--Lisp error: (invalid-read-syntax “)”) read(#<buffer *load*>)

Launch Emacs using runemacs --debug-init and the following error occurred. any idea on how to locate the file/script of the error or how to fix it? Thanks in advance. Debugger entered--Lisp error: (...
1
vote
1answer
105 views

Accessing next/previous parenthesis instead of just the outermost one? (as with `syntax-ppss`)

syntax-ppss gives the surrounding parenthesis. Is it possible to get the next/previous parenthesis using this API? (which has the advantage of caching the syntax tree and working with multiple ...
1
vote
0answers
37 views

Test if I am inside a paired delimiter

I have been having a problem where I want an up-sexp command that treats paired delimiters like $ in LaTeX-mode just as if they were pairs of balanced parentheses. There are hacks I can use that get ...
0
votes
1answer
160 views

Switch syntax highlighting of open buffer from web-mode (freemarker) to sql

we use web-mode (freemarker engine) to edit source files that contain freemarker directives and a lot of SQL. Editing in web-mode (freemarker engine) works fine. It would be very helpful if we could ...
8
votes
2answers
495 views

How can I nest one syntax table in another?

I've written a simple mode for handling JSON. It uses the derived machinery to re-use most of json-mode's code. However one addition is you can insert elisp into the JSON text which is evaluated at ...
2
votes
1answer
60 views

How to use helm-occur to search the whole word?

For example, I got the following lines: 1. abc 2. abc def 3. abc_def 4. _abc 5. abc_ and I want to search only the word abc, so only the 1 and 2 lines matches, I googled a while, it says \babc\b ...
5
votes
2answers
627 views

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 ...
1
vote
0answers
85 views

Keyword as comment ender (and starter)

In my previous question I asked about complex comment-start sequence and I think I figured it out, but now I have another problem. Let say we have this mode: (defconst test-font-lock-keywords '(("\\...
5
votes
7answers
1k views

Easily changing matching quotes

Not infrequently, I want to change the delimiters of a string from single quotes to double quotes, or vice versa. This is so annoying a process I wonder if there's an easier way. What I do now is: ...
1
vote
1answer
93 views

How can I make syntax-propertize skip part of the buffer?

In SPARQL, comments starts with a # and follows to the end of the line. The problem is that URI's, which is a big part of SPARQL, can also contain #, but then they are not the start of a comment. Like ...
1
vote
1answer
1k views

Turn on semantic mode for C/C++

I got these lines: ;; turn on semantic (semantic-mode 1) ;; define a function which adds semantic as backup to auto-complete (defun my:add-semantic-to-autocomplete() (add-to-list 'ac-sources 'ac-...
0
votes
5answers
168 views

Is it possible to define all keywords' function definitions as plist-get?

I really, really like Clojure-style maps: {:keyword "value" :keyword2 'value2} which can be used like (get my-map :keyword) or, even better, (:keyword my-map) Can I teach Elisp how to do this?
2
votes
1answer
87 views

Is there a syntax in Elisp for indexed getters and setters?

I want to define a struct for chores (defstruct chore name sector assignments) where the assignments slot is a vector with seven positions. I know that the above syntax will generate the getters ...
3
votes
2answers
722 views

backward-kill-word kills too much, how to make it more intelligent?

I'm looking for a way to reduce what Emacs kills when I use backward-kill-word. protected virtual void OnPropertyChanged(PropertyChangedEventArgs e) { if (PropertyChanged != null) ...
2
votes
1answer
314 views

add a rule to syntax-propertize-rules

I have an issue outlined here that I was able to find a partial solution for. The problem involved changing perl-modes syntax table. One of the commenters pointed me to the function syntax-propertize-...
3
votes
1answer
194 views

modify syntax table for strings in perl modes

My company uses a version of Perl where you can define by binary number using something like my $var = 'b010110110; etc. Problem is both perl-mode and cperl-mode interpret ' as the start of the string ...
4
votes
1answer
59 views

How to treat region between conflict markers as comment?

While resolving complex conflicts manually, I usually want emacs to treat conflict markers and region between them as comment, since it breaks major-mode's syntactic analysis (fontification, electric-...
1
vote
2answers
390 views

Syntax highlighting (in Emacs) for SQL code in log files

How can we highlight SQL code in some log files, with Emacs? Sample log file: [DEBUG][2016-05-26 09:04:51,714][FileHelper] - [realContextPath=[/server.xml]] [DEBUG][2016-05-26 10:24:22,369][...
9
votes
2answers
127 views

Does word syntax take script into account?

I call count-words-region (M-x =) on US/RU/IPA string: HelloПривheləʊ The following message is printed: Region has 1 line, 4 words, and 14 characters. All symbols have w syntax, but differ in ...
2
votes
0answers
47 views

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 ...
3
votes
1answer
3k views

How to customize the line character length in elpy?

I am using elpy for my Python development, but I would like to set the per-line character limit to 120 instead of the default 80 used by PEP8. Any suggestions on how I can do this? Even better, it ...
4
votes
1answer
172 views

Is the sharp dollar (#$) sign the same as load-file-name in Emacs?

I see Emacs use #$ in autoload files, but I don't known if there are any difference between #$ and load-file-name. When I use them in a file, they looks like the same and when I print them by M-: they ...
0
votes
0answers
26 views

Why does forward-word stop at this quotation mark? [duplicate]

Minimal example code, run it from emacs -Q. Note the use of unicode RIGHT SINGLE QUOTATION MARK (’) not APOSTROPHE ('). (modify-syntax-entry ?’ "w p" text-mode-syntax-table) ; that's the same syntax ...
12
votes
2answers
561 views

For what languages is `syntax-ppss` appropriate?

I've been looking at a way of detecting whether point is on a comment by looking at how the current buffer is fontified. Smartparens defines sp-point-in-comment, which relies on syntax-ppss. However, ...
1
vote
0answers
36 views

Consistent way to represent key sequences? [duplicate]

The macro kbd doesn't work for all desired input. For example, this results in an error: (kbd "C-H-left") edmacro-parse-keys: C-H- must prefix a single character, not left and should be written as: ...
1
vote
2answers
125 views

How to make $ not part of a symbol in tcl-mode?

Recently I found out about isearch-forward-symbol-at-point but in tcl it's rather useless, because when dereferencing a variable the $ is part of the symbol and so the symbol-at-point $var does not ...
2
votes
1answer
172 views

Using SMIE for language without comment syntax

I'm making a major mode for json (which has no comments), and using SMIE for 'free' indenting. I've currently got a half-baked grammar called json-grammar, and no rules-function. Consequently, I'm ...
1
vote
0answers
110 views

Auto-indent problems related to syntax in Haxe-Mode

In the Haxe programming language, you can specify the type of the return value of a function with a colon. function funcName() : ReturnType { } This becomes a problem when using emacs with haxe-mode....
0
votes
1answer
35 views

Strip arbitrary characters from a string?

Q: How can I strip non-word characters from a string? For an arbitrary string, how do I strip all characters with non-word syntax? Alternately, using a regexp, how do I strip out the non-alphabetic ...
5
votes
0answers
604 views

ps-print-buffer-with-faces with color-theme'ed dark background

Similar to Change syntax highlighting when doing ps-print-buffer-with-faces I typically use emacs with a dark background, but I'd like to print my buffer onto a white background (i.e. white paper). ...
3
votes
1answer
82 views

How can I configure imenu to ignore comments?

To configure imenu in my major mode, I need to set imenu-generic-expression to have regexps for functions. However, this is incorrectly detects things inside comments and strings that look like ...
10
votes
2answers
171 views

Is there a standard/recommended syntax for defining a keyboard binding?

I have seen all of the following for defining a keyboard binding. All of these work (at least on MS Windows). I don't know if there is another way to do the same thing. I am wondering if there is a ...
16
votes
2answers
492 views

how to detect if inside a matched pair?

Q: is there a general way to detect whether or not point is inside a matched pair of characters? That is: is there a general predicate function (or something) that can determine if point is in-...
4
votes
1answer
523 views

Change syntax highlighting when doing ps-print-buffer-with-faces

Hopefully a simple question. I code in c++ in emacs with a dark background and the syntax highlighting is perfect for viewing that way, however when I print on white paper, some of the colours like ...
1
vote
1answer
97 views

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 ...
4
votes
3answers
300 views

Is is possible to treat any symbol in the buffer as word when moving around?

When I move around specifically using M-f/b, I want to treat any symbol such as ", ', ., -, _, ?, !, *... as one word, so M-f/b will move around them instead of skipping them and jump to the next/...
7
votes
3answers
702 views

What's the difference between words and symbols?

When defining a syntax table for a major mode, I can define both word constituents and symbol constituents. When should I use each? For example, given a programming language that writes variables in ...
4
votes
1answer
218 views

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 ...