From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Eddward DeVilla" Subject: Help with a hook Date: Tue, 17 Oct 2006 17:10:05 -0500 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1GZx8Y-0002S0-Gh for emacs-orgmode@gnu.org; Tue, 17 Oct 2006 18:10:14 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1GZx8S-0002Dy-D3 for emacs-orgmode@gnu.org; Tue, 17 Oct 2006 18:10:12 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GZx8R-0002CN-PH for emacs-orgmode@gnu.org; Tue, 17 Oct 2006 18:10:07 -0400 Received: from [66.249.92.171] (helo=ug-out-1314.google.com) by monty-python.gnu.org with esmtp (Exim 4.52) id 1GZx8R-0003Sa-BK for emacs-orgmode@gnu.org; Tue, 17 Oct 2006 18:10:07 -0400 Received: by ug-out-1314.google.com with SMTP id 36so63769uga for ; Tue, 17 Oct 2006 15:10:06 -0700 (PDT) Content-Disposition: inline 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: 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