From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nick Dokos Subject: Re: I wrote code to reverse top-level entries order within region Date: Sat, 18 Apr 2009 21:15:14 -0400 Message-ID: <11675.1240103714@gamaville.dokosmarshall.org> References: Reply-To: nicholas.dokos@hp.com Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LvM3c-0002oB-10 for emacs-orgmode@gnu.org; Sat, 18 Apr 2009 21:42:56 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LvM3a-0002nz-Fg for emacs-orgmode@gnu.org; Sat, 18 Apr 2009 21:42:54 -0400 Received: from [199.232.76.173] (port=59800 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LvM3a-0002nw-BN for emacs-orgmode@gnu.org; Sat, 18 Apr 2009 21:42:54 -0400 Received: from qmta15.emeryville.ca.mail.comcast.net ([76.96.27.228]:57832) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1LvM3Z-0005Dd-Px for emacs-orgmode@gnu.org; Sat, 18 Apr 2009 21:42:54 -0400 In-Reply-To: Message from dericbytes of "Sat, 18 Apr 2009 15:38:48 -0000." 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: dericbytes Cc: emacs-orgmode@gnu.org dericbytes wrote: > > > I want to reverse the entries of my logs. So the newest is at the top. I know > > there is the C-c ^ sort function, but I'm not sure if any are applicable. (Not > > all of my entries are dated) > > > Here's a link to the code I wrote to reverse top-level entries on region. > http://dericbytes.blogspot.com/2009/04/emacs-orgmode-my-code-to-reverse.html > > NOTE: its my first attempt at elisp, any tips for improving future code welcome. > I took a quick look and a few things jumped out: o indentation - but maybe that's the result of publishing it on the web? If not, emacs knows a lot about that, so let it help! o If you do C-h f beginning-of-buffer , it'll tell you: ".... Don't use this command in Lisp programs! (goto-char (point-min)) is faster and avoids clobbering the mark." o In fact, the last bit of the program ; delete old contents of buffer (let ((buffer-beg) (buffer-end)) (beginning-of-buffer) (setq buffer-beg (point)) (end-of-buffer) (setq buffer-end (point)) (kill-region buffer-beg buffer-end)) can be simplified to (kill-region (point-min) (point-max) If you have not done so already, you should look at the the "Emacs Lisp Intro" and, after you are familiar with that, at the Elisp manual: both of them should be available through Info - in Emacs, just do C-h i, find the right menu entry and press . On my Ubuntu 8.04 system, they show up like this: ... * Emacs Lisp Intro: (eintr). A simple introduction to Emacs Lisp programming. * Elisp: (elisp). The Emacs Lisp Reference Manual. ... HTH, Nick