Skip to main content
17 votes

How to treat underscore as part of the word?

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 #'(...
ejoubaud's user avatar
  • 279
12 votes
Accepted

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

Each major mode has its own syntax and syntax table. If you just put (modify-syntax-entry ?_ "w") in your init file, it gets evaluated in the buffer that is current when your init file is loaded -- ...
Drew's user avatar
  • 78.5k
5 votes
Accepted

Get thing-at-point to include periods

What about this. (defun dotted-symbol-at-point () (with-syntax-table (make-syntax-table (syntax-table)) (modify-syntax-entry ?. "_") (thing-at-point 'symbol)))
politza's user avatar
  • 3,346
5 votes

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

Rather than modifying the syntax tables, you can instead use the built-in superword-mode: Superword mode is a buffer-local minor mode. Enabling it changes the definition of words such that symbols ...
erikstokes's user avatar
4 votes
Accepted

add a rule to syntax-propertize-rules

The answer is that you can't do it "right". But you can do the following: (defalias 'my/perl-syntax-propertize-function (syntax-propertize-rules ("\\('\\)[bh]" (1 ".")))) (add-hook 'perl-mode-hook ...
Stefan's user avatar
  • 26.6k
4 votes

Rx: Skip commented out lines

How can I make it to completely skip the commented out line? "Skipping lines" is not an inherent capability of regular expressions. Regexps either do or do not match whatever input they are given. ...
Basil's user avatar
  • 12.5k
4 votes
Accepted

How do I hook fundamental-mode and all modes derived from it for modifying syntax for underscores

1st: Dealing with your actual problem of setting the syntax for ?_ in modes derived from fundamental-mode. There are no commands setting the syntax table in fundamental-mode. Therefore, it uses the (...
Tobias's user avatar
  • 33.5k
4 votes
Accepted

How to use a particular syntax table with arbitrary functions?

You say you don't want to have to "manually create a new table and use with-syntax-table for every function in my config or change the current table using modify-syntax-entry." I think you ...
Drew's user avatar
  • 78.5k
3 votes
Accepted

syntax table malfunction

Your approach almost works, but you can't only modify the syntax for the opening { if you want that to match the closing }, so you need both of: (modify-syntax-entry ?{ "(}") (modify-syntax-entry ?} "...
phils's user avatar
  • 52.4k
3 votes

Make `thing-at-point` treat dot as a symbol-constituent character?

To supplement what @phils said - Make . have symbol-constituent syntax in the current syntax table, or in a copy of it. Either define your own replacement function for thing-at-point: (defun my-thg-...
Drew's user avatar
  • 78.5k
3 votes

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

The octave-comment-char was added specifically for your kind of use case, so all you should need is: (setq octave-comment-char ?%) No need to change the syntax table, since % is already recognized ...
Stefan's user avatar
  • 26.6k
3 votes
Accepted

modify syntax entry globally?

If you want to do something in every mode then you can use after-change-major-mode-hook to run your code.
phils's user avatar
  • 52.4k
3 votes

How to treat underscore as part of the word?

Emacs 24 introduced superword-mode, a minor mode that treats underscores as part of words. evil-mode respects this setting. Here is the documentation: (superword-mode &optional ARG) ...
BallpointBen's user avatar
3 votes

Simplest Pattern for matching Identifiers in complex Regular Expressions?

I do not know a shortcut for identifier regexps. Maybe, that is due to the complicated rules that exist for identifiers of some languages. Nevertheless you can define your own format strings and ...
Tobias's user avatar
  • 33.5k
2 votes

How to treat underscore as part of the word?

Doesn't quite answer the OP's question but thought I'd put this here for completeness. I also like evil's default behavior (esp. for python and lisp-dialects where I might only want to change part of ...
Anselm Coogan's user avatar
2 votes
Accepted

modify syntax table for strings in perl modes

So I did some more digging and I was able to find a solution, but not a very clean one. I copied the perl-syntax-propertize-function from perl-mode.el. I then added this to my .emacs and changed the ...
Prgrm.celeritas's user avatar
2 votes
Accepted

Locally modify the syntax-table via text-properties

As mentioned by Tobias, you generally need (set (make-local-variable 'parse-sexp-lookup-properties) t) in order for those properties to have an effect. The reason for it is probably historical and ...
Stefan's user avatar
  • 26.6k
2 votes
Accepted

How come newline does not match [[:space:]] in tex-mode and bibtex-mode?

describe-char tells us that the newline has syntax: (...) character: C-j (displayed as C-j) (codepoint 10, #o12, #xa) (...) syntax: &...
T. Verron's user avatar
  • 4,293
2 votes
Accepted

How to set backslash character "\" to be a word constituent in LaTeX-mode syntax tables

Not heavily tested, but the following lines in your init file should do the trick: (defun pglpm/modify-LaTeX-mode-syntax-table () (modify-syntax-entry (string-to-char TeX-esc) ...
Arash Esbati's user avatar
  • 2,055
2 votes

Syntax/indentation problems with Vue mode in Emacs 27 nightly

The problem has been reported as #99 and already fixed in master of mmm-mode, but since there is no new release, you have to install the newest mmm-mode manually, or add the missing setting to mmm-...
Uwe Koloska's user avatar
  • 1,018
2 votes
Accepted

Making Emacs see ♥ as punctuation

Sentence movement functions use the regexp returned by the (sentence-end) function to find the end of a sentence. The (sentence-end) function returns the value of the sentence-end variable if it is ...
Jordon Biondo's user avatar
2 votes

Tex indentation with TAB

Looks like I somehow managed to switch to Tex mode, instead of LaTex mode. Changing to LaTex mode is easy: M-x latex-mode. Many thanks to @vonbrand for telling me to check the mode!
Yair Daon's user avatar
  • 131
2 votes
Accepted

After setting syntax-propertize-function, comment is not being fontified with comment face

The above code will indeed set something for face. @Lindydancer helped me realize that I had set font-lock-defaults with the second parameter (keywords-only) of the list as t). Unsetting keywords-only ...
ackerleytng's user avatar
1 vote
Accepted

How can I fix shift-select-mode with own syntax-table

You need to say that this command is a navigation command, by replacing your (interactive) with (interactive "^") C-h o interactive RET explains that: [...] If the string begins with ^ and ...
Stefan's user avatar
  • 26.6k
1 vote
Accepted

What do the spaces in the NEWENTRY parameter to modify-syntax-entry mean?

In the above code, "_ " does exactly the same as "_". The second char in that string holds the matching "paren-like char" when the first char is ( or ) but for symbol constituents it's unused. The ...
Stefan's user avatar
  • 26.6k
1 vote
Accepted

`eval-after-load` gets executed, but syntax-table is missing

You are missing quotes ' on many of your examples. i.e., (eval-after-load 'haskell-mode (modify-syntax-entry ?_ "w" haskell-mode-syntax-table)) That means the unquoted bit, i.e., (modify-syntax-...
Tyler's user avatar
  • 22.5k
1 vote
Accepted

How to know what chars are "word constituents" in latex-mode-syntax-table

I think that the loop of the edited version of my question solved my problem. I want to share here the solution temporarily adopted. I'd like to know if there is something better (e.g. a more compact ...
Gabriele's user avatar
  • 1,680
1 vote
Accepted

TeX Mode : making backward-word behaviour take into account Backslashes (\)

I finally found the answer, it was just me forgetting that \ is an escape character. The following works fine: (add-hook 'tex-mode-hook #'(lambda () (modify-syntax-entry ?\\ "w")))
ghilesZ's user avatar
  • 121
1 vote

Move point to just before end of a comment

This can be done, although Emacs doesn't seem to provide useful info about multi-line comment ends, so it needs a hard coded check for */. (defun my-end-of-comment () (interactive) (let ((state (...
ideasman42's user avatar
  • 9,025

Only top scored, non community-wiki answers of a minimum length are eligible