all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* `map-char-table' bug?
@ 2003-05-13 15:41 Ben North
  2003-05-14 21:04 ` Richard Stallman
  0 siblings, 1 reply; 2+ messages in thread
From: Ben North @ 2003-05-13 15:41 UTC (permalink / raw)


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.

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

end of thread, other threads:[~2003-05-14 21:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-05-13 15:41 `map-char-table' bug? Ben North
2003-05-14 21:04 ` Richard Stallman

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.