From mboxrd@z Thu Jan 1 00:00:00 1970 From: Carsten Dominik Subject: Re: Help with a hook Date: Wed, 18 Oct 2006 10:35:34 +0200 Message-ID: References: Mime-Version: 1.0 (Apple Message framework v624) Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Ga6tr-0002jq-Ls for emacs-orgmode@gnu.org; Wed, 18 Oct 2006 04:35:43 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Ga6to-0002gJ-SN for emacs-orgmode@gnu.org; Wed, 18 Oct 2006 04:35:42 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Ga6to-0002fg-Gk for emacs-orgmode@gnu.org; Wed, 18 Oct 2006 04:35:40 -0400 Received: from [146.50.4.51] (helo=imap.science.uva.nl) by monty-python.gnu.org with esmtp (Exim 4.52) id 1Ga6to-0002PO-74 for emacs-orgmode@gnu.org; Wed, 18 Oct 2006 04:35:40 -0400 In-Reply-To: List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Eddward DeVilla Cc: emacs-orgmode 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