help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Defining functions on the fly


From: Tassilo Horn
Subject: Re: Defining functions on the fly
Date: Mon, 15 Jun 2015 13:52:27 +0200
User-agent: Gnus/5.130014 (Ma Gnus v0.14) Emacs/25.0.50 (gnu/linux)

Andreas Röhler <andreas.roehler@easy-emacs.de> writes:

> It's not about duplication, but derivation. The original DTRT in most
> cases.
>
> Point of interest are the exceptions - see for example in Elixir
>
> https://github.com/elixir-lang/emacs-elixir/issues/185
>
> "\"foo\""  |>  String.strip(?")
>
> Where the doublquote after question mark makes Emacs think it's a
> string-start - which isn't.

String recognition in emacs is usually done using syntax tables, so get
the elixir syntax table right and then you don't need any workarounds.
In this case, it seems plain syntax tables aren't enough, though, so the
elisp docs explain how to override certain characters' syntax on demand.

,----[ (info "(elisp)Syntax Properties") ]
| When the syntax table is not flexible enough to specify the syntax of a
| language, you can override the syntax table for specific character
| occurrences in the buffer, by applying a ‘syntax-table’ text property.
| *Note Text Properties::, for how to apply text properties.
`----

So basically, you (or elixir-mode) will want to define a
`syntax-propertize-function' which finds occurrences of ?" and gives "/"
(character quote) syntax to the ? in which the usual "\"" (string
quotes) syntax of `"' would be ineffective for this single double quote.

,----[ (info "(elisp)Syntax Class Table") ]
| Character quotes: ‘/’
|      Characters used to quote the following character so that it loses
|      its normal syntactic meaning.  This differs from an escape
|      character in that only the character immediately following is ever
|      affected.
| 
|      Characters in this class count as part of words if
|      ‘words-include-escapes’ is non-‘nil’.  *Note Word Motion::.
`----

Bye,
Tassilo



reply via email to

[Prev in Thread] Current Thread [Next in Thread]