[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Orgmode] Help with a hook
From: |
Carsten Dominik |
Subject: |
Re: [Orgmode] Help with a hook |
Date: |
Wed, 18 Oct 2006 10:35:34 +0200 |
On Oct 18, 2006, at 0:10, Eddward DeVilla wrote:
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)
Do you have several #+CATEGORY lines in the buffer? If yes, the
function you
use will always use the last category in the file. Its hard to
understand why
it would pick a category from a different file.
Try this:
(defun my-org-buffer-name ()
(when (string= (file-name-nondirectory buffer-file-name)
"projects.org")
(let ((org-category-table (org-get-category-table)))
(rename-buffer (format "Org -- %s" (org-get-category 0)) t))))
(add-hook 'org-mode-hook 'my-org-buffer-name)
- Carsten