emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Help with a hook
@ 2006-10-17 22:10 Eddward DeVilla
  2006-10-18  8:35 ` Carsten Dominik
  0 siblings, 1 reply; 2+ messages in thread
From: Eddward DeVilla @ 2006-10-17 22:10 UTC (permalink / raw)
  To: emacs-orgmode

Hi.

    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
far:

(defun my-org-buffer-name ()
  (when (string= (file-name-nondirectory buffer-file-name)
		 "projects.org")
    (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
org-get-category.

Any thoughts?

Edd

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2006-10-18  8:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-10-17 22:10 Help with a hook Eddward DeVilla
2006-10-18  8:35 ` Carsten Dominik

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).