emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Nick Dokos <nicholas.dokos@hp.com>
To: dericbytes <dericbytes@gmail.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: I wrote code to reverse top-level entries order within region
Date: Sat, 18 Apr 2009 21:15:14 -0400	[thread overview]
Message-ID: <11675.1240103714@gamaville.dokosmarshall.org> (raw)
In-Reply-To: Message from dericbytes <dericbytes@gmail.com> of "Sat, 18 Apr 2009 15:38:48 -0000." <loom.20090418T153041-411@post.gmane.org>

dericbytes <dericbytes@gmail.com> 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 <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
    (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 <RET>.  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

  reply	other threads:[~2009-04-19  1:42 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-14 20:24 headline entries order dericbytes
2009-04-14 22:09 ` Nick Dokos
2009-04-14 23:17   ` Bernt Hansen
2009-04-18 15:38 ` I wrote code to reverse top-level entries order within region dericbytes
2009-04-19  1:15   ` Nick Dokos [this message]
2009-04-19 11:45     ` thanks nick dericbytes

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=11675.1240103714@gamaville.dokosmarshall.org \
    --to=nicholas.dokos@hp.com \
    --cc=dericbytes@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).