[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Orgmode] I wrote code to reverse top-level entries order within reg
Re: [Orgmode] I wrote code to reverse top-level entries order within region
Sat, 18 Apr 2009 21:15:14 -0400
dericbytes <address@hidden> 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.
> NOTE: its my first attempt at elisp, any tips for improving future code
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 <RET>, 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
(setq buffer-beg (point))
(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 <RET>. On my Ubuntu 8.04 system, they
show up like this:
* Emacs Lisp Intro: (eintr). A simple introduction to Emacs Lisp
* Elisp: (elisp). The Emacs Lisp Reference Manual.