From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: a machine of awareness Newsgroups: gmane.emacs.help Subject: Re: how 'add-to-ordered-list' use Date: Tue, 18 Oct 2011 21:08:48 +0800 Message-ID: <87pqhu78gv.fsf@gmail.com> References: <87ipnn66ta.fsf@gmail.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=gbk Content-Transfer-Encoding: 8bit X-Trace: dough.gmane.org 1318942630 7988 80.91.229.12 (18 Oct 2011 12:57:10 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 18 Oct 2011 12:57:10 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Oct 18 14:57:06 2011 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1RG9E9-0006H0-Sg for geh-help-gnu-emacs@m.gmane.org; Tue, 18 Oct 2011 14:57:06 +0200 Original-Received: from localhost ([::1]:48655 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RG9E9-0002eb-B6 for geh-help-gnu-emacs@m.gmane.org; Tue, 18 Oct 2011 08:57:05 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:59311) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RG9Dz-0002e8-Ar for help-gnu-emacs@gnu.org; Tue, 18 Oct 2011 08:57:00 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RG9Dx-0002D9-B6 for help-gnu-emacs@gnu.org; Tue, 18 Oct 2011 08:56:55 -0400 Original-Received: from lo.gmane.org ([80.91.229.12]:55312) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RG9Dx-0002Cw-5k for help-gnu-emacs@gnu.org; Tue, 18 Oct 2011 08:56:53 -0400 Original-Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1RG9Dv-0006A6-UM for help-gnu-emacs@gnu.org; Tue, 18 Oct 2011 14:56:51 +0200 Original-Received: from 118.181.109.165 ([118.181.109.165]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 18 Oct 2011 14:56:51 +0200 Original-Received: from machine.of.awareness by 118.181.109.165 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 18 Oct 2011 14:56:51 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 43 Original-X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: 118.181.109.165 User-Agent: Emacs+gnus Cancel-Lock: sha1:mAZd3A49+s3mCaBHummQvj4PC30= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 80.91.229.12 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:82613 Archived-At: a machine of awareness 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