[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Orgmode] Help with a hook

From: Eddward DeVilla
Subject: [Orgmode] Help with a hook
Date: Tue, 17 Oct 2006 17:10:05 -0500


   I assume this is a simple question and I should probably take it
somewhere else.  I hope you'll forgive me.  I'm still very new to
elisp and emacs code conventions.  I'm trying to create a custom hook
to set the buffer name for org-mode buffers.  Here's what I have so

(defun my-org-buffer-name ()
 (when (string= (file-name-nondirectory buffer-file-name)
   (rename-buffer (format "Org -- %s" (org-get-category)) t)))
(add-hook 'org-mode-hook 'my-org-buffer-name)

The intention is to get the category into the modeline.  I tend to
name all of my org file the same.  At first I had a directory for
every project, and they all had an info.org.  Now I've started using
agenda and I just have a projects.org file and directory tree for
different components/areas of responsibility.  The first line of every
org file is "#+CATEGORY: ..." but if I've scrolled down in the buffer
I can easily tell which file I'm looking at.

The hook above seems to work at first, but certain things like
restarting org-mode in a buffer seems to cause it to grab the wrong
category.  It grab a valid category, just not (the) one from the
current file.  So I'll get Cat<2> or some other number where Cat is
not a category in the current file.  It doesn't seem to get it wrong
every time either.  It's never corrected itself yet either once it was
wrong.  It always picks the same category regardless of the order of
the agenda files.  I'm guessing I need to pass something special to

Any thoughts?


reply via email to

[Prev in Thread] Current Thread [Next in Thread]