From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jambunathan K Subject: Re: elisp code takes CPU too much Date: Mon, 27 Dec 2010 16:40:46 +0530 Message-ID: <81vd2fzd1l.fsf@gmail.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable Return-path: Received: from [140.186.70.92] (port=53993 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PXAyi-0007vr-O7 for emacs-orgmode@gnu.org; Mon, 27 Dec 2010 06:11:01 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PXAyh-0005tv-JM for emacs-orgmode@gnu.org; Mon, 27 Dec 2010 06:11:00 -0500 Received: from p3plsmtpa01-02.prod.phx3.secureserver.net ([72.167.82.82]:38353) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1PXAyh-0005tm-Av for emacs-orgmode@gnu.org; Mon, 27 Dec 2010 06:10:59 -0500 In-Reply-To: (ishi soichi's message of "Mon, 27 Dec 2010 14:47:30 +0900") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: ishi soichi Cc: emacs-orgmode@gnu.org > hi. I have wrote an elisp code for org-mode, which puts entries in a > table. It is a simple code in my opinion and it does the job I > intended. But when executed, the activation of CPU shoots up and it > will take a while to complete it. =A0I do not believe that this little > code requires such a work-load for the computer. =A0There must be my > wrong-doing. You have an infinite loop. The predicate of the while loop would always evaluate to 'true' and never become 'false'. > Could anyone help me for fixing it? Try the following snippet with suitable variations. (setq word-list (list "apple" "orange" "lemon" "baseball" "football")) (defun test-table (word-list)=20 (let ((line 0) (column 3)) (mapcar (lambda (word) (org-table-put i column word t)) word-list))) Jambunathan K. > > soichi=A0 > > > > P.S. the code follows, and there is "word" in the table so that "search" = command > looks for it. > > ;;--------------------------------------------- > > (require 'org-table) > > (setq alist (list "apple" "orange" "lemon" "baseball" "football")) > > (defun test-table (word-list) > > =A0=A0"test to see if org-table-put works well" > > =A0=A0(find-file-noselect (concat "~/Dropbox/language/word.org")) > > =A0=A0(set-buffer "word.org") > > =A0=A0(save-excursion > > =A0=A0 =A0(goto-char (point-min)) > > =A0=A0 =A0(search-forward "word") > > =A0=A0 =A0(goto-char (match-beginning 0)) > > =A0=A0 =A0(let ((i 1)) > > =A0=A0 =A0 =A0(while word-list > > (org-table-put i 3 (nth (- i 1) word-list) t) > > (setq i (1+ i)))))) > > =A0=A0 =A0 =A0 > > (test-table alist) ;;execute it here > > > _______________________________________________ > Emacs-orgmode mailing list > Please use `Reply All' to send replies to the list. > Emacs-orgmode@gnu.org > http://lists.gnu.org/mailman/listinfo/emacs-orgmode