emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Carsten Dominik <dominik@science.uva.nl>
To: Eddward DeVilla <eddward@gmail.com>
Cc: emacs-orgmode <emacs-orgmode@gnu.org>
Subject: Re: Help with a hook
Date: Wed, 18 Oct 2006 10:35:34 +0200	[thread overview]
Message-ID: <b8e7154e9a5fa4b0e6a2020730f49f40@science.uva.nl> (raw)
In-Reply-To: <b71b18520610171510n409ada3dpc67646facacb087b@mail.gmail.com>


On Oct 18, 2006, at 0:10, Eddward DeVilla wrote:

> 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)

Do you have several #+CATEGORY lines in the buffer?  If yes, the 
function you
use will always use the last category in the file.  Its hard to 
understand why
it would pick a category from a different file.

Try this:

(defun my-org-buffer-name ()
  (when (string= (file-name-nondirectory buffer-file-name)
		 "projects.org")
    (let ((org-category-table (org-get-category-table)))
      (rename-buffer (format "Org -- %s" (org-get-category 0)) t))))
(add-hook 'org-mode-hook 'my-org-buffer-name)


- Carsten

      reply	other threads:[~2006-10-18  8:35 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-10-17 22:10 Help with a hook Eddward DeVilla
2006-10-18  8:35 ` Carsten Dominik [this message]

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

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b8e7154e9a5fa4b0e6a2020730f49f40@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 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).