From: Carsten Dominik <dominik@science.uva.nl>
To: Eddward DeVilla <eddward@gmail.com>
Cc: org-mode mailing list <emacs-orgmode@gnu.org>
Subject: Re: file level categories
Date: Thu, 6 Mar 2008 20:23:27 +0100 [thread overview]
Message-ID: <35422FE0-00C4-46B6-9793-B70F72EB8CCC@science.uva.nl> (raw)
In-Reply-To: <b71b18520803060755t6bae7e59ubc562f5822538f93@mail.gmail.com>
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 - <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
>
>
> _______________________________________________
> 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
next prev parent reply other threads:[~2008-03-06 19:23 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-03-06 15:55 file level categories Eddward DeVilla
2008-03-06 19:23 ` Carsten Dominik [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=35422FE0-00C4-46B6-9793-B70F72EB8CCC@science.uva.nl \
--to=dominik@science.uva.nl \
--cc=eddward@gmail.com \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.