emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* file level categories
@ 2008-03-06 15:55 Eddward DeVilla
  2008-03-06 19:23 ` Carsten Dominik
  0 siblings, 1 reply; 7+ messages in thread
From: Eddward DeVilla @ 2008-03-06 15:55 UTC (permalink / raw)
  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 - <category>" 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

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2008-03-07  9:45 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-03-06 15:55 file level categories Eddward DeVilla
2008-03-06 19:23 ` Carsten Dominik
2008-03-06 21:13   ` Joel J. Adamson
2008-03-06 22:14     ` Bastien
2008-03-06 22:47     ` Eddward DeVilla
2008-03-07  8:29       ` Rainer Stengele
2008-03-07  9:45         ` Carsten Dominik

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).