[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Questions regarding char-table-range RANGE arg
From: |
Federico Tedin |
Subject: |
Questions regarding char-table-range RANGE arg |
Date: |
Thu, 31 Aug 2023 23:54:01 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 |
Hi everyone,
I was trying to understand better how char tables work but I got stuck
at the following:
In the docs for `char-table-range'
(https://www.gnu.org/software/emacs/manual/html_node/elisp/Char_002dTables.html),
it is mentioned
that it is possible to specify (from . to) as the value for RANGE. This
already seemed a bit unexpected for me, as the function
is supposed to retrieve a single value from the char table - how could
it do it for a range, where potentially many different values
could be defined? I did some tests:
(setq tt (make-char-table nil))
(set-char-table-range tt (cons 10 20) "foo")
(set-char-table-range tt (cons 21 25) "bar")
(char-table-range tt (cons 5 15)) ; includes some "foo" values?
-> nil ; no
(char-table-range tt (cons 10 15)) ; includes some "foo" values?
-> "foo" ; yes, makes sense
(char-table-range tt (cons 15 22)) ; includes some "foo" and "bar" values?
-> "foo" ; ok, only the first range was considered
(char-table-range tt (cons 15 0)) ; what if I set `to' to a nonsensical
value?
-> "foo"
(char-table-range tt (cons 15 99999)) ; or this one
-> "foo"
(char-table-range tt (cons 26 30)) ; should return nil
-> nil ; ok
So from my tests it seems like only `from' is considered? Similar to the
case where RANGE is just a character. I was hoping someone
with a better understanding of character tables could maybe explain the
behaviour observed above. It is possible it could me just
missinterpreting the documentation (I am trying to keep a more end-user
perspective for this, i.e. not look at the Emacs source code
and only use documentation). I did try looking also into
chartab-tests.el though but could not find more information there.
Thanks!
- Questions regarding char-table-range RANGE arg,
Federico Tedin <=