* Re: how 'add-to-ordered-list' use
2011-10-17 14:17 how 'add-to-ordered-list' use a machine of awareness
@ 2011-10-17 14:18 ` Tim Landscheidt
2011-10-17 14:21 ` S Boucher
` (3 subsequent siblings)
4 siblings, 0 replies; 8+ messages in thread
From: Tim Landscheidt @ 2011-10-17 14:18 UTC (permalink / raw)
To: help-gnu-emacs
(anonymous) wrote:
> I read elisp manual.I use 'add-to-ordered-list',
> and don't understand.Please look example:
> (setq foo '(1 6 9 10 3 4))
> (1 6 9 10 3 4)
> (add-to-ordered-list 'foo 10)
> (6 9 1 10 3 4)
> Why order is changed?
> From (1 6 9 10 3 4) to (6 9 1 10 3 4)?
I can't reproduce that:
| ELISP> (setq foo '(1 6 9 10 3 4))
| (1 6 9 10 3 4)
| ELISP> (add-to-ordered-list 'foo 10)
| (1 6 9 10 3 4)
Tim
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: how 'add-to-ordered-list' use
2011-10-17 14:17 how 'add-to-ordered-list' use a machine of awareness
2011-10-17 14:18 ` Tim Landscheidt
@ 2011-10-17 14:21 ` S Boucher
2011-10-18 12:49 ` a machine of awareness
2011-10-18 12:53 ` a machine of awareness
2011-10-18 13:08 ` a machine of awareness
` (2 subsequent siblings)
4 siblings, 2 replies; 8+ messages in thread
From: S Boucher @ 2011-10-17 14:21 UTC (permalink / raw)
To: a machine of awareness, help-gnu-emacs@gnu.org
[-- Attachment #1: Type: text/plain, Size: 823 bytes --]
You should provide your version of emacs. I don't see what you see.
(setq foo '(1 6 9 10 3 4))
(1 6 9 10 3 4)
(add-to-ordered-list 'foo 10)
(1 6 9 10 3 4)
(emacs-version)
"GNU Emacs 23.3.1 (x86_64-unknown-linux-gnu, GTK+ Version 2.22.0)
of 2011-05-31 on "
>________________________________
>From: a machine of awareness <machine.of.awareness@gmail.com>
>To: help-gnu-emacs@gnu.org
>Sent: Monday, October 17, 2011 10:17:37 AM
>Subject: how 'add-to-ordered-list' use
>
>I read elisp manual.I use 'add-to-ordered-list',
>and don't understand.Please look example:
>(setq foo '(1 6 9 10 3 4))
>(1 6 9 10 3 4)
>(add-to-ordered-list 'foo 10)
>(6 9 1 10 3 4)
>
>Why order is changed?
>From (1 6 9 10 3 4) to (6 9 1 10 3 4)?
>--
>a machine of awareness
>Debian、Emacs+Gnus
>
>
>
>
>
[-- Attachment #2: Type: text/html, Size: 1588 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: how 'add-to-ordered-list' use
2011-10-17 14:21 ` S Boucher
@ 2011-10-18 12:49 ` a machine of awareness
2011-10-18 12:53 ` a machine of awareness
1 sibling, 0 replies; 8+ messages in thread
From: a machine of awareness @ 2011-10-18 12:49 UTC (permalink / raw)
To: help-gnu-emacs
S Boucher <stbya@yahoo.com> writes:
> You should provide your version of emacs. I don't see what you see.
>
> (setq foo '(1 6 9 10 3 4))
> (1 6 9 10 3 4)
>
> (add-to-ordered-list 'foo 10)
> (1 6 9 10 3 4)
>
> (emacs-version)
> "GNU Emacs 23.3.1 (x86_64-unknown-linux-gnu, GTK+ Version 2.22.0)
> of 2011-05-31 on "
I emacs vesion:
(emacs-version)
"GNU Emacs 23.2.1 (x86_64-pc-linux-gnu, GTK+ Version 2.20.1)
of 2010-12-12 on brahms, modified by Debian"
--
a machine of awareness
Debian、Emacs+Gnus
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: how 'add-to-ordered-list' use
2011-10-17 14:21 ` S Boucher
2011-10-18 12:49 ` a machine of awareness
@ 2011-10-18 12:53 ` a machine of awareness
1 sibling, 0 replies; 8+ messages in thread
From: a machine of awareness @ 2011-10-18 12:53 UTC (permalink / raw)
To: help-gnu-emacs
S Boucher <stbya@yahoo.com> writes:
I rerun it,result is no change.
(progn
(setq foo '(1 6 9 10 3 4))
(add-to-ordered-list1 'foo 10)
)
(9 1 6 10 3 4)
Thanks.
> You should provide your version of emacs. I don't see what you see.
>
> (setq foo '(1 6 9 10 3 4))
> (1 6 9 10 3 4)
>
> (add-to-ordered-list 'foo 10)
> (1 6 9 10 3 4)
>
> (emacs-version)
> "GNU Emacs 23.3.1 (x86_64-unknown-linux-gnu, GTK+ Version 2.22.0)
> of 2011-05-31 on "
--
a machine of awareness
Debian、Emacs+Gnus
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: how 'add-to-ordered-list' use
2011-10-17 14:17 how 'add-to-ordered-list' use a machine of awareness
2011-10-17 14:18 ` Tim Landscheidt
2011-10-17 14:21 ` S Boucher
@ 2011-10-18 13:08 ` a machine of awareness
2011-10-18 13:30 ` a machine of awareness
2011-10-18 13:57 ` a machine of awareness
4 siblings, 0 replies; 8+ messages in thread
From: a machine of awareness @ 2011-10-18 13:08 UTC (permalink / raw)
To: help-gnu-emacs
a machine of awareness <machine.of.awareness@gmail.com> writes:
> I read elisp manual.I use 'add-to-ordered-list',
> and don't understand.Please look example:
> (setq foo '(1 6 9 10 3 4))
> (1 6 9 10 3 4)
> (add-to-ordered-list 'foo 10)
> (6 9 1 10 3 4)
>
> Why order is changed?
> From (1 6 9 10 3 4) to (6 9 1 10 3 4)?
add-to-ordered-list source is:
(defun add-to-ordered-list (list-var element &optional order)
"..."
(let ((ordering (get list-var 'list-order)))
(unless ordering
(put list-var 'list-order
(setq ordering (make-hash-table :weakness 'key :test 'eq))))
(when order
(puthash element (and (numberp order) order) ordering))
(unless (memq element (symbol-value list-var))
(set list-var (cons element (symbol-value list-var))))
(set list-var (sort (symbol-value list-var)
(lambda (a b)
(let ((oa (gethash a ordering))
(ob (gethash b ordering)))
(if (and oa ob)
(< oa ob)
oa)))))))
I think the main part is:
(set list-var (sort (symbol-value list-var)
(lambda (a b)
(let ((oa (gethash a ordering))
(ob (gethash b ordering)))
(if (and oa ob)
(< oa ob)
oa)))))))
I single step run,result is no change.
But I don't understand.
--
a machine of awareness
Debian、Emacs+Gnus
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: how 'add-to-ordered-list' use
2011-10-17 14:17 how 'add-to-ordered-list' use a machine of awareness
` (2 preceding siblings ...)
2011-10-18 13:08 ` a machine of awareness
@ 2011-10-18 13:30 ` a machine of awareness
2011-10-18 13:57 ` a machine of awareness
4 siblings, 0 replies; 8+ messages in thread
From: a machine of awareness @ 2011-10-18 13:30 UTC (permalink / raw)
To: help-gnu-emacs
a machine of awareness <machine.of.awareness@gmail.com> writes:
> I read elisp manual.I use 'add-to-ordered-list',
> and don't understand.Please look example:
> (setq foo '(1 6 9 10 3 4))
> (1 6 9 10 3 4)
> (add-to-ordered-list 'foo 10)
> (6 9 1 10 3 4)
>
> Why order is changed?
> From (1 6 9 10 3 4) to (6 9 1 10 3 4)?
I run another,but is right?!
(progn
(setq foo '(1 6 8 10 3 4))
(add-to-ordered-list1 'foo 10)
)
(1 6 8 10 3 4)
Is a elisp bug?
--
a machine of awareness
Debian、Emacs+Gnus
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: how 'add-to-ordered-list' use
2011-10-17 14:17 how 'add-to-ordered-list' use a machine of awareness
` (3 preceding siblings ...)
2011-10-18 13:30 ` a machine of awareness
@ 2011-10-18 13:57 ` a machine of awareness
4 siblings, 0 replies; 8+ messages in thread
From: a machine of awareness @ 2011-10-18 13:57 UTC (permalink / raw)
To: help-gnu-emacs
a machine of awareness <machine.of.awareness@gmail.com> writes:
> I read elisp manual.I use 'add-to-ordered-list',
> and don't understand.Please look example:
> (setq foo '(1 6 9 10 3 4))
> (1 6 9 10 3 4)
> (add-to-ordered-list 'foo 10)
> (6 9 1 10 3 4)
>
> Why order is changed?
> From (1 6 9 10 3 4) to (6 9 1 10 3 4)?
I know, I am wrong.
Because before run > (add-to-ordered-list 'foo 10) <,
(get 'foo 'list-order) ==>
#s(hash-table size 65 test eq ... data (9 0)),
it lead to problem!
--
a machine of awareness
Debian、Emacs+Gnus
^ permalink raw reply [flat|nested] 8+ messages in thread