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
  • 78k
9 votes
Accepted

How to customize the line character length in elpy?

If you want to customize per project basis, you can create a setup.cfg with custom config like this [flake8] max-line-length = 160 If you want to change this globally, you can change flake8 config as ...
Chillar Anand's user avatar
7 votes
Accepted

Why can't I compose commands `mark-whole-buffer` and `copy-region-as-kill` in Elisp code?

What's wrong with your attempt (copy-region-as-kill (mark-whole-buffer)) This calls the function copy-region-as-kill with one argument, which is the value returned by mark-whole-buffer. All Emacs ...
Gilles 'SO- stop being evil''s user avatar
6 votes
Accepted

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

Here's a quick attempt at a custom function that may do what you want: (defun backward-kill-char-or-word () "Delete the character or word before point." (interactive) (if (looking-back "\\w" 1) ...
glucas's user avatar
  • 20.7k
6 votes
Accepted

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

Ask Emacs. 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’. ...
phils's user avatar
  • 51.8k
6 votes
Accepted

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

Use C-u C-c C-c. See python-shell-buffer-substring function docstring: When optional argument NOMAIN is non-nil everything under an if __name__ == '__main__' block will be removed. And python-...
muffinmad's user avatar
  • 2,330
5 votes
Accepted

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

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 ...
Drew's user avatar
  • 78k
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
  • 12.9k
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.5k
4 votes
Accepted

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

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 ...
db48x's user avatar
  • 18.5k
4 votes
Accepted

Circular list use of "#"

The lisp printer needs to be set up to print Circular Objects. To do so you need to eval: (setq print-circle t) Then the output of eval (setq x '#1=(a #1#)) will print as #1=(a #1#) (as expected). ...
jue's user avatar
  • 4,636
3 votes

Easily changing matching quotes

Try embrace. It’s easy to use and does what you want and more.
InHarmsWay's user avatar
  • 1,339
3 votes

Easily changing matching quotes

I knew this was going to take some time, but in the end I couldn't resist the temptation to figure out how it's done properly. :) Enjoy! (defun toggle-quotes (uarg) "Toggle single and double ...
Heikki's user avatar
  • 3,076
3 votes

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

Emacs uses syntax tables to decide what is and is not a word. Each major mode will have its own syntax table. Commands that move over or delete words will use the values in this table to determine how ...
Tyler's user avatar
  • 22.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
Accepted

Why does a stray period cause an error I associate with mismatched parens?

The period is part of the read syntax for a cons. (a b) is a list, while (a . b) is a cons. The difference is that the list is made of two conses, so the first is equivalent to (a . (b . nil)). The ...
db48x's user avatar
  • 18.5k
3 votes
Accepted

Why dividing long line (with lambda/interactive) in the (general.el) breaks off the Syntax coloring?

If you move to the red text and type C-h. (display-local-help), or alternatively hover the mouse pointer over the text, you will see the following message: Easy to misread; consider moving the ...
phils's user avatar
  • 51.8k
2 votes

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

The following will highlight the fields of the log file. The first three fields are highlighted using plain highlight rules, the fourth use an anchored rule to highlight multiple lines. To use this, ...
Lindydancer's user avatar
  • 6,180
2 votes
Accepted

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

First, define a mode for this log file. Put the following somewhere in emacs and eval it: (define-derived-mode sql-log-mode text-mode "sql-log" "Hack" (setq font-lock-multiline t) (font-lock-...
omajid's user avatar
  • 508
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

Easily changing matching quotes

To continue this thread of alternatives... A better workflow than the one you describe is to use electric-pair-mode the way it is meant to so that it works for you instead of against you: Place the ...
Heikki's user avatar
  • 3,076
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

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

From C-h f load-file RET: Load the Lisp file named FILE. I'm assuming ~/.emacs.d/config.org is an org file, not a Lisp file. That is, it starts something like: * all my amazing settings #+BEGIN_SRC ...
zck's user avatar
  • 9,112
2 votes

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

It is more usual to search for sexps than for embraced expressions. Maybe that is the reason why you did not get a fast answer. The usual way to search for stuff within program code avoiding comments ...
Tobias's user avatar
  • 33.4k
2 votes

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

When there is an error in the syntax highlighting code, it is silently ignored by the font-lock package. When this happens, the buffer can be left in an unhighlighted state. You can use the package ...
Lindydancer's user avatar
  • 6,180
2 votes
Accepted

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

The syntax tables themselves can't handle this right, but Emacs offers syntax-propertize to circumvent this kind of limitation by giving special syntax to specific occurrences of characters in buffers....
Stefan's user avatar
  • 26.5k
2 votes
Accepted

How can I make `forward-sexp` handle other balanced character-pairs such as < and > or << and >>?

I have been able to get forward-sexp to recognize the < and > pair by modifying the syntax table the erlang-mode uses: The erlang.el file has a function that sets the syntax table when the ...
PRouleau's user avatar
  • 831
2 votes

How to support `<` and `>` as balanced parens without impacting ability to use them as comparison operators?

Yes. The syntax of a character in a buffer defaults to the value indicated by the buffer's syntax table, but this can be overridden by setting the syntax-table text property on a character in a buffer,...
Gilles 'SO- stop being evil''s user avatar

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