The following snippet will make Evil treat an Emacs symbol as a word.
(defalias #'forward-evil-word #'forward-evil-symbol)
;; make evil-search-word look for symbol rather than word boundaries
(setq-default evil-symbol-word-search t))
This has the advantage that it changes depending on the language:
is one ...
The simplest workaround: use ciW to select a whitespace-delimited word.
The bigger issue has to do with the value of the _ character in the syntax table. The issue is that _ is, by default, a symbol constituent in the syntax table, and you want to treat it as a word constituent.
If you're using emacs 24.4, you could try enabling superword-mode. I haven't ...
syntax-ppss might be of help here. It returns a list that also has these elements:
element 0: depth in parens
element 3: non-nil if inside a string
You could use it like this:
(or (> (nth 0 (syntax-ppss)) 0)
(nth 3 (syntax-ppss)))
With a properly set up syntax-table in the buffer (for strings and matching parens) the function should do what you ...
The spacemacs FAQ offers the following language-specific solution:
;; For python
(add-hook 'python-mode-hook #'(lambda () (modify-syntax-entry ?_ "w")))
;; For ruby
(add-hook 'ruby-mode-hook #'(lambda () (modify-syntax-entry ?_ "w")))
(add-hook 'js2-mode-hook #'(lambda () (modify-syntax-entry ?_ "w")))
It also works in regular emacs. With ...
One option is to use the rx macro to construct your expressions using sexps.
Your example becomes (rx "some" (group "regexp"))
Here are a couple more examples from the commentary section in rx.el, to get an idea of how rx works:
(rx (or (and line-start ";;" (0+ space) ?\n)
(and line-start ?\n)))
This [ \t\n]*:\\([^:]...
Well, s-expressions are essentially “abstract syntax”, in the sense that they are merely a concrete syntax for abstract syntax trees, and thus any language can be represented as s-expressions, and manipulated with s-expression commands. Hence, syntax-ppss speaking of “Sexps” is simply the Lisp way to talk about abstract syntax trees.
Practically, though, ...
Take a look at superword-mode and subword-mode. Superword treats underscores as part of a word instead of a boundary, so foo_bar would be treated as a single word.
Subword does the opposite but for camelCase, so fooBar is treated as two words instead of one.
It sounds like the behavior you want is for cc-mode to use superword-mode.
You can have a look at the built-in library SMIE (stands for Simple-Minded Indentation Engine). Despite the name, indentation is only one of the features it provides. This is the method used by many modes (including ruby-mode, mentioned in a comment), to provide sexp movement and indentation.
Deploying SMIE for a language is roughly a two-steps job:
The [:blank:] character class matches only the SPC and TAB characters. The other two match whitespace based on the active syntax table.
There does not seem to be a difference between [:space:] and \s-. The latter is an instance of the general \scode pattern for matching based on a syntax class.
Ok, let's get some basics straight.
Nesting syntax tables is possible
Syntax tables don't have to be global to the entire buffer.
You can apply them as text properties to specific regions. This means
you can indeed apply the elisp syntax table only to regions
surrounded by backticks.
How do you do that?
Here's one way you can do that. This method does it ...
You don't want to nest one syntax table (which is a vector structure) inside another, you want to set up a buffer where, depending on the position, one syntax table would be used instead of the other.
The other answer describes how to do this using the syntax-table text property. Here's how to do it using one of the "multiple major mode" packages, mmm-mode. ...
No it does not have regexp literals, but many find pcre2el to be a helpful alternative.
Specifically using it from elisp like this:
;; => "\\(\\(?:abc\\|def\\)\\)[_[:alnum:]]+[[:digit:]]+"
This specific behaviour of forward-word can be controlled by the variables word-combining-categories and word-separating-categories. If you want to ignore the script completely, it is sufficient to add the pair (nil . nil) to the first list, e.g.
(let ((word-combining-categories (cons '(nil . nil)
There is no single standard way, because there are different use cases.
If you are writing such code manually, in your init file for example, then you might prefer the (kbd ...) format, because the argument to kbd uses the same notation that Emacs uses when it communicates with you about key bindings (in *Help*, for example).
But if you are creating ...
M-x elisp-index-search RET #$ RET
Internally, the dynamic loading of documentation strings is
accomplished by writing compiled files with a special Lisp reader
construct, ‘#@COUNT’. This construct skips the next COUNT characters.
It also uses the ‘#$’ construct, which stands for “the name of this
file, as a string”. Do not use these ...
Since the answer is picked from the comment from @kaushalmodi, I cannot choose the comment as an answer, so I post this as the right answer.
According to comment from @kaushalmodim, syntax-subword is great, it is exactly what I need. You can install it using package.el.
Here is my configuration in init.el:
Regarding 2, the problem is simple: your major-mode function needs to set comment-start. This part has nothing to do with SMIE.
Regarding 3, I'm not sure exactly what it is you're doing (where is point? what does the buffer contain? what command have you run?). But I suggest to first concentrate on indentation of the non-comment parts of the code.
This answer addresses your question title: "What's the difference between words and symbols". It does not speak only to the body of your question, which is about symbol syntax, which has been answered well by @Nsukami.
There are two very different meanings of the word symbol in Emacs:
symbol syntax, which involves word-constituent characters plus symbol-...
If you want to customize per project basis, you can create a setup.cfg with custom config like this
max-line-length = 160
If you want to change this globally, you can change flake8 config as mentioned here https://flake8.readthedocs.io/en/latest/config.html#global
You have an extra right paren, ), somewhere in your init file. Here's one way to find it:
Start Emacs using emacs -Q (no init file).
Visit this file - the one that Emacs was trying to load when it barfed:
C-x C-f /Users/user/.emacs
Comment out 1/2 of that file (roughly), using M-x comment-region.
Do M-x eval-buffer.
If you get an error, then comment out ...
Adding to @lunaryorn's answer, I think syntax-ppss just rely on the robustness of emacs's syntax table system, which works for comment and string in most languages. But if the language has syntax that syntax table can't capture, and if the mode did't build a parser to add syntax properties to the right places, syntax-ppss would fail.
Try this in html-mode:
Emacs should already use "the appropriate word boundaries for the syntax of the current language". If it does not then file a bug for the major mode for that language.
But maybe you don't really mean words. Maybe you mean symbol syntax, not word syntax. Emacs distinguishes the two.
For symbol syntax, use symbol commands, not word commands: forward-symbol,...
Word constituents: ‘w’
Parts of words in human languages. These are typically used in variable and command names in programs. All upper- and lower-case letters, and the digits, are typically word constituents.
Symbol constituents: ‘_’
Extra characters used in variable and command names along with word constituents. Examples include the characters ‘$&*+...
It's bird, it's a plane, it's superword-mode:
Superword mode is a buffer-local minor mode. Enabling it changes
the definition of words such that symbols characters are treated
as parts of words: e.g., in ‘superword-mode’,
"this_is_a_symbol" counts as one word.
It's a minor mode, so you can set it in a hook the normal way: (add-hook 'python-mode-...
The answer is that you can't do it "right".
But you can do the following:
(syntax-propertize-rules ("\\('\\)[bh]" (1 "."))))
(add-function :before (local 'syntax-propertize-function)
Yes and no. No, because chore-assignment doesn't let you modify what's inside the value of the assignment slot; it only lets you modify the assignment slot itself.
Instead, Lisp has setf, which has some really good tricks up its sleeves. The first argument to setf is a PLACE, which is any expression which can be interpreted as a place to store a value. ...
This appears to be coming from the function org-flag-drawer.
Use C-h f to find where this function is defined, and modify it to also give the buffer name:
(defun org-flag-drawer (flag)
"When FLAG is non-nil, hide the drawer we are within.
Otherwise make it visible."
(when (looking-at "^[ \t]*:[a-zA-Z][a-...
If I understood your question, you could modify the language syntax table, e.g. For c++:
(modify-syntax-entry ?_ "w" c++-mode-syntax-table)
M-x apropos then look up of syntax-table should help you too.