From mboxrd@z Thu Jan 1 00:00:00 1970 From: Carsten Dominik Subject: Re: file level categories Date: Thu, 6 Mar 2008 20:23:27 +0100 Message-ID: <35422FE0-00C4-46B6-9793-B70F72EB8CCC@science.uva.nl> References: Mime-Version: 1.0 (Apple Message framework v919.2) Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JXLh8-0007bt-3I for emacs-orgmode@gnu.org; Thu, 06 Mar 2008 14:23:58 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JXLh5-0007XK-DJ for emacs-orgmode@gnu.org; Thu, 06 Mar 2008 14:23:57 -0500 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JXLh5-0007X8-9V for emacs-orgmode@gnu.org; Thu, 06 Mar 2008 14:23:55 -0500 Received: from gv-out-0910.google.com ([216.239.58.191]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1JXLh4-0008BI-Qd for emacs-orgmode@gnu.org; Thu, 06 Mar 2008 14:23:55 -0500 Received: by gv-out-0910.google.com with SMTP id y18so14456gvf.17 for ; Thu, 06 Mar 2008 11:23:51 -0800 (PST) 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: org-mode mailing list Hi Eddward, After an Org-mode buffer is initialized, the variable `org-category' contains the value of the *last* #+CATEGORY line in the buffer, as a symbol. You really should have only of these lines in the buffer, if you need multiple categories, use properties. Anyway, you can get the value as a string with (symbol-name org-category) HTH - Carsten On Mar 6, 2008, at 4:55 PM, Eddward DeVilla wrote: > Hi, > > A while back I wrote a function that I call from org-mode-hook to > rename the buffer if it's file name is project.org. It would rename > it to "Org - " based on the category in the file. I did > this because I tend to have different directories for the different > sorts of things I work on and I keep a consistently named file with > the state of the projects working from there. The problem was that > all of my org buffers were call projects.org. > > Anyhow, I wrote that function using org-get-category and > org-get-category-table to determine the category for the file so I > could produce a more useful buffer name. It looks like the category > table is gone now. Would there be a good way to determine the > category of the the first #+CATEGORY entry in the file and get > something like default if there isn't one? Or, does anyone have any > other interesting ideas for giving a unique buffer name to org files > with the same file name? > > If you're curious, the rename function I'm was using is: > > (defun my-org-buffer-name () > (if (buffer-file-name) > (when (string= (file-name-nondirectory buffer-file-name) > "projects.org") > (let* ((org-category-table (org-get-category-table)) ; work around > some dynamic scope issue > (new-buffer-name (format "Org -- %s" (org-get-category))) > (buffer-name-re (concat "^" > new-buffer-name > "\\(<[0-9]+>\\)?"))) > (unless (string-match buffer-name-re (buffer-name)) > (rename-buffer new-buffer-name t) ))))) > (add-hook 'org-mode-hook 'my-org-buffer-name) > > > Thanks, > Edd > > > _______________________________________________ > Emacs-orgmode mailing list > Remember: use `Reply All' to send replies to the list. > Emacs-orgmode@gnu.org > http://lists.gnu.org/mailman/listinfo/emacs-orgmode