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
0
votes
0answers
18 views

How can I modify zone's putz-with-case to print random letters instead?

(I will bold the actual questions.) So here is an old version of the offical zone code that randomly chooses letters and randomly makes them uppercase or lowercase. I did not modify this, and it ...
1
vote
1answer
60 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
27 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
36 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
0answers
75 views

Getting full AST for the source code in the current buffer

How do I get the full AST for the source code in the current buffer? I've looked at a similar question and tried (semantic-fetch-tags) with the below c-mode example: #include <stdlib.h> #...
2
votes
1answer
43 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 ...
1
vote
1answer
57 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 ...
5
votes
7answers
761 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
0answers
78 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 '(("\\...
0
votes
5answers
129 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
66 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 ...
2
votes
2answers
409 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
254 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
156 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
56 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
289 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][...
2
votes
0answers
44 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 ...
2
votes
1answer
2k 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
155 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
22 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 ...
8
votes
2answers
108 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 ...
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-...
1
vote
0answers
33 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
117 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 ...
1
vote
0answers
97 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
31 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 ...
4
votes
0answers
414 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). ...
5
votes
2answers
540 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 ...
2
votes
1answer
65 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
149 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 ...
0
votes
1answer
137 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 ...
3
votes
1answer
150 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 ...
4
votes
1answer
415 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
95 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
216 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/...
4
votes
1answer
175 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 ...
8
votes
0answers
637 views

How do I parse a simple grammar and obtain a syntax tree in Emacs lisp?

How can I construct a parse tree from a string and a simple grammar? Semantic seems very tricky, and SMIE does not seem to produce a parse tree. Here's an example, assuming a language that looks like ...
1
vote
1answer
87 views

Use a variable's value in setq [duplicate]

In emacs.el I am using the following construct to set up an org-remember template: (setq org-remember-templates '(("Todo" ?t "* TODO %^{Brief Description} %^g\n%?\nAdded: %U" "~/GTD/newgtd.org" "...
1
vote
2answers
111 views

Is there any way to configure isearch-forward-regexp invert backslashes usage?

It may be handy to make it shortly, for example use (GET|POST): *\{ instead of \(GET\|POST\): *{
30
votes
5answers
7k 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 ...
14
votes
2answers
461 views

Does elisp have regexp literals?

The sheer number of backslashes my regexps require is pretty crazy. Does elisp have regexp literals, so I can write something like rx"some\(regexp\)" instead of "some\\(regexp\\)"
10
votes
2answers
169 views

Make forward-sexp recognize blocks defined by keywords, not just parentheses

In a language (julia) that has blocks defined by keywords such as for..end, begin..end, as well as parentheses, what is a good way to skip over such a block? Also, end is not only a block keyword, but ...
7
votes
1answer
1k views

In regular expressions, what's the difference between [:blank:], [:space:], and \s-?

I've been playing around with rx lately, and I just noticed there are (at least) 3 different ways of indicating whitespaces in regular expressions. [:blank:] [:space:] \s- What are the differences ...
4
votes
3answers
1k views

File mode specification error: How to find syntax problem: Missing :END: line in org-mode properties?

When I launch my emacs software (Aquamacs.app) I see a message File mode specification error: (error ":END: line missing at position 23740") Unfortunately, I do not know in which file this problem ...
8
votes
2answers
434 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 ...
5
votes
1answer
251 views

Some warnings and unexpected indentation with SMIE

I'm trying SMIE to describe the Nix language. Unfortunately when I use it, I have the following problems: There are 4 messages saying: Warning (smie): token } is both closer and neither. Which I do ...
7
votes
3answers
560 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 ...
12
votes
3answers
1k views

Treat symbols as words in prog modes

There are a number of commands in Emacs which apply to "words." Examples include forward-word, kill-word, upcase-word, mark-word, transpose-words, etc. The definition of "word" seems to vary a bit ...
16
votes
2answers
426 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-...
12
votes
2answers
438 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, ...