emacs-devel
[Top][All Lists]
Advanced

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

`map-char-table' bug?


From: Ben North
Subject: `map-char-table' bug?
Date: Tue, 13 May 2003 16:41:05 +0100 (IST)

According to the Elisp Reference Manual documentation for
`map-char-table':

] This function calls FUNCTION for each element of CHAR-TABLE.
] FUNCTION is called with two arguments, a key and a value. The
] key is a possible RANGE argument for CHAR-TABLE-RANGE---either
] a valid character or a generic character--and the value is
] (char-table-range char-table key).

However, I was trying to scan a syntax table to extract all
parenthesis pairs, and didn't see the documented behaviour.  A
small bit of experimenting produced the following.

The code

(let ((st (syntax-table)))
  (map-char-table (lambda (k v)
                    (if (= k ?\()
                        (progn (print k)
                               (print (char-table-range st k))
                               (print (aref st k))
                               (print v))))
                  st))

produces

40

(4 . 41)

(4 . 41)

nil

whereas that last `nil' should be `(4 . 41)'.  I think the
problem is that Fmap_char_table() calls map_char_table(), which
does

      for (i = 0; i < CHAR_TABLE_SINGLE_BYTE_SLOTS; i++)
        {
          Lisp_Object elt = XCHAR_TABLE (subtable)->contents[i];
          if (c_function)
            (*c_function) (arg, make_number (i), elt);
          else
            call2 (function, make_number (i), elt);
        }

As far as I can see, this passes, as the VALUE argument to the
FUNCTION argument of `map-char-table', the `i'th entry of the
syntax table, whereas the documentation suggests it will use
default values and parent `char-table's.  This is what
`char-table-range' does, by calling `aref'.

Without having tried it, would it make sense to change
Fmap_char_table() to call Faref() when setting elt?  Something
like

          Lisp_Object elt = Faref(subtable, i);

maybe?  Lower down in map_char_table(), it does seem that the
default value is used but I'm not familiar enough with the
workings of this code to know what's going on I'm afraid.

Even if my suggestions about the C code are misinformed, I think
this is a real mismatch between documented and actual behaviour.

Thanks,

Ben.









reply via email to

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