From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Eddward DeVilla" Subject: file level categories Date: Thu, 6 Mar 2008 09:55:26 -0600 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JXIRU-0004l8-Dx for emacs-orgmode@gnu.org; Thu, 06 Mar 2008 10:55:36 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JXIRS-0004kD-8Y for emacs-orgmode@gnu.org; Thu, 06 Mar 2008 10:55:35 -0500 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JXIRR-0004k7-Te for emacs-orgmode@gnu.org; Thu, 06 Mar 2008 10:55:34 -0500 Received: from ti-out-0910.google.com ([209.85.142.184]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1JXIRQ-0006dt-Sj for emacs-orgmode@gnu.org; Thu, 06 Mar 2008 10:55:33 -0500 Received: by ti-out-0910.google.com with SMTP id a20so2653795tia.10 for ; Thu, 06 Mar 2008 07:55:28 -0800 (PST) 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: org-mode mailing list 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