emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: "Eddward DeVilla" <eddward@gmail.com>
To: emacs-orgmode <emacs-orgmode@gnu.org>
Subject: Help with a hook
Date: Tue, 17 Oct 2006 17:10:05 -0500	[thread overview]
Message-ID: <b71b18520610171510n409ada3dpc67646facacb087b@mail.gmail.com> (raw)

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

             reply	other threads:[~2006-10-17 22:10 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-10-17 22:10 Eddward DeVilla [this message]
2006-10-18  8:35 ` Help with a hook Carsten Dominik

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=b71b18520610171510n409ada3dpc67646facacb087b@mail.gmail.com \
    --to=eddward@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).