[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Orgmode] elisp code takes CPU too much
From: |
Eric Schulte |
Subject: |
Re: [Orgmode] elisp code takes CPU too much |
Date: |
Mon, 27 Dec 2010 07:17:48 -0700 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) |
My only guess would be repeatedly calling the `org-table-put' function
from inside of your inner while loop. Specifically including the ALIGN
option to the function is repeatedly re-aligning your table. Maybe
performance would be improved by calling `org-table-align' once after
the end of your while loop, rather than in every loop execution.
Also, as a style point I would recommend using `map' rather than while
to iterate through the elements of the word-list.
For an additional performance gain, you may want to remove the call to
`org-table-put' altogether, and instead simply insert the word directly
and then manually adjust the location of `point' in the buffer.
Hope this helps -- Eric
ishi soichi <address@hidden> writes:
> 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. I do not believe that this little code requires such a
> work-load for the computer. There must be my wrong-doing.
>
> Could anyone help me for fixing it?
>
> soichi
>
> 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)
> "test to see if org-table-put works well"
> (find-file-noselect (concat "~/Dropbox/language/word.org"))
> (set-buffer "word.org")
> (save-excursion
> (goto-char (point-min))
> (search-forward "word")
> (goto-char (match-beginning 0))
> (let ((i 1))
> (while word-list
> (org-table-put i 3 (nth (- i 1) word-list) t)
> (setq i (1+ i))))))
>
> (test-table alist) ;;execute it here
> _______________________________________________
> Emacs-orgmode mailing list
> Please use `Reply All' to send replies to the list.
> address@hidden
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode