unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#8807: map-char-table alters cons cells used as events
@ 2011-06-06  4:50 Jonathan Ganc
  2011-06-06  6:57 ` Eli Zaretskii
  2011-06-06  7:04 ` Kenichi Handa
  0 siblings, 2 replies; 3+ messages in thread
From: Jonathan Ganc @ 2011-06-06  4:50 UTC (permalink / raw)
  To: 8807

In using map-char-table, I've encountered something which is either a 
bug or at least unexpected to me. Here is a minimal listing producing 
the result:

(let ((ct (make-char-table 'keymap)) permev)
   (set-char-table-range ct '(1 . 2) 'binding)
   (map-char-table
    (lambda (event defn)
      (setq permev event)
      (insert (prin1-to-string permev)))
    ct)
   (insert (concat "\n" (prin1-to-string permev)))
   )

This produces:
(1 . 2)
(3 . 4194303)
, so that map-char-table alters the cons cell being used as an output 
range than producing a new one. I would have expected:
(1 . 2)
(1 . 2)
Is this the desired behavior? (I understand that I can work around this 
behavior by manually copying the cons cell.)

Thanks,
Jonathan


__________ Information from ESET Smart Security, version of virus signature database 6182 (20110605) __________

The message was checked by ESET Smart Security.

http://www.eset.com







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

* bug#8807: map-char-table alters cons cells used as events
  2011-06-06  4:50 bug#8807: map-char-table alters cons cells used as events Jonathan Ganc
@ 2011-06-06  6:57 ` Eli Zaretskii
  2011-06-06  7:04 ` Kenichi Handa
  1 sibling, 0 replies; 3+ messages in thread
From: Eli Zaretskii @ 2011-06-06  6:57 UTC (permalink / raw)
  To: Jonathan Ganc; +Cc: 8807

> Date: Sun, 05 Jun 2011 23:50:19 -0500
> From: Jonathan Ganc <jonpublic2@gmail.com>
> 
> (let ((ct (make-char-table 'keymap)) permev)
>    (set-char-table-range ct '(1 . 2) 'binding)
>    (map-char-table
>     (lambda (event defn)
>       (setq permev event)
>       (insert (prin1-to-string permev)))
>     ct)
>    (insert (concat "\n" (prin1-to-string permev)))
>    )
> 
> This produces:
> (1 . 2)
> (3 . 4194303)
> , so that map-char-table alters the cons cell being used as an output 
> range than producing a new one.

The char-table produced by make-char-table is originally comprised of
a single range of characters with a single value of nil.  After the
call to set-char-table-range, that range is split in 2: character
codes 1 and 2 get the value of 'binding, the rest are left with nil.
Thus, map-char-table calls its 2nd argument twice, one each for every
range of characters in the table that share the same value.

> I would have expected:
> (1 . 2)
> (1 . 2)

??? Why?  And where do you see that map-char-table alters the cons
cell being used as output?  What output?





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

* bug#8807: map-char-table alters cons cells used as events
  2011-06-06  4:50 bug#8807: map-char-table alters cons cells used as events Jonathan Ganc
  2011-06-06  6:57 ` Eli Zaretskii
@ 2011-06-06  7:04 ` Kenichi Handa
  1 sibling, 0 replies; 3+ messages in thread
From: Kenichi Handa @ 2011-06-06  7:04 UTC (permalink / raw)
  To: Jonathan Ganc; +Cc: 8807

In article <4DEC5C8B.3030803@gmail.com>, Jonathan Ganc <jonpublic2@gmail.com> writes:

> In using map-char-table, I've encountered something which is either a 
> bug or at least unexpected to me. Here is a minimal listing producing 
> the result:

> (let ((ct (make-char-table 'keymap)) permev)
>    (set-char-table-range ct '(1 . 2) 'binding)
>    (map-char-table
>     (lambda (event defn)
>       (setq permev event)
>       (insert (prin1-to-string permev)))
>     ct)
>    (insert (concat "\n" (prin1-to-string permev)))
>    )

> This produces:
> (1 . 2)
> (3 . 4194303)
> , so that map-char-table alters the cons cell being used as an output 
> range than producing a new one. I would have expected:
> (1 . 2)
> (1 . 2)
> Is this the desired behavior?

Considering the efficiency (by reducing cons cell creation),
it is the desired behavior.

---
Kenichi Handa
handa@m17n.org





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

end of thread, other threads:[~2011-06-06  7:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-06-06  4:50 bug#8807: map-char-table alters cons cells used as events Jonathan Ganc
2011-06-06  6:57 ` Eli Zaretskii
2011-06-06  7:04 ` Kenichi Handa

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).