all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#22765: Missing interfaces for syntax of characters in buffers.
@ 2016-02-22 11:12 Alan Mackenzie
  2017-04-06  0:43 ` npostavs
  0 siblings, 1 reply; 2+ messages in thread
From: Alan Mackenzie @ 2016-02-22 11:12 UTC (permalink / raw)
  To: 22765

Hello, Emacs.

In all versions of Emacs to date, we are missing an interface to return
the syntax of a character in a buffer in a "nice" form.  By a "nice"
form, I mean the characters ?\ , ?., ?w, ?\(, ?\), etc., which programs
should be able to use.

We have `char-syntax', but that takes no account of syntax-table text
properties which might be on a buffer position, and so shouldn't really
be used any more in buffers.  There are still around 160 uses of
`char-syntax' in our sources.

We have `syntax-after', but this returns a raw syntax descriptor (like
(4 . 41)), and we have no means of extracting ?\( from this.

I propose adding the two functions `syntax-class-to-char' which would
convert 4 to ?\(, and `char-syntax-after', which would return ?\(
directly, given a buffer position with such a character under it.

This would greatly aid in the conversion of these old `char-syntax'
calls.

-- 
Alan Mackenzie (Nuremberg, Germany).





^ permalink raw reply	[flat|nested] 2+ messages in thread

* bug#22765: Missing interfaces for syntax of characters in buffers.
  2016-02-22 11:12 bug#22765: Missing interfaces for syntax of characters in buffers Alan Mackenzie
@ 2017-04-06  0:43 ` npostavs
  0 siblings, 0 replies; 2+ messages in thread
From: npostavs @ 2017-04-06  0:43 UTC (permalink / raw)
  To: Alan Mackenzie; +Cc: 22765

Alan Mackenzie <acm@muc.de> writes:

> We have `char-syntax', but that takes no account of syntax-table text
> properties which might be on a buffer position, and so shouldn't really
> be used any more in buffers.  There are still around 160 uses of
> `char-syntax' in our sources.

I'm afraid I added another one in my recent `indent-sexp' changes.  We
should at least add a warning about this to the docstring.

> We have `syntax-after', but this returns a raw syntax descriptor (like
> (4 . 41)), and we have no means of extracting ?\( from this.
>
> I propose adding the two functions `syntax-class-to-char' which would
> convert 4 to ?\(, and `char-syntax-after', which would return ?\(
> directly, given a buffer position with such a character under it.

We do have string-to-syntax which can be used to convert in the other
direction, although code using it would end up a bit more verbose.

    (eq (char-syntax-after POS) ?\()
vs
    (eq (syntax-class (syntax-after POS)) (car (string-to-syntax "(")))





^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-04-06  0:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-02-22 11:12 bug#22765: Missing interfaces for syntax of characters in buffers Alan Mackenzie
2017-04-06  0:43 ` npostavs

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.