unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Mathias Dahl <brakjoller@gmail.com>
Subject: Re: Generate a new buffer name
Date: Wed, 22 Nov 2006 11:33:10 +0100	[thread overview]
Message-ID: <upsbfsrdl.fsf@gmail.com> (raw)
In-Reply-To: 1164182420.160993.146620@b28g2000cwb.googlegroups.com

"mopi" <52hands@gmail.com> writes:

> Hello friends
>
> I use a lot of different buffers during a normal day. Often I don't
> care what their names are, actually I feel that being forced to name
> them interrupts me. I'm perfectly happy with the default naming that
> other text editors use (Untitled-1, Untitled-2 etc).
>
> I'm trying to replicate this behaviour in emacs. So far I have placed
> this in my .emacs:
>
> (global-set-key [(control n)]
> 		(lambda() (interactive)(switch-to-buffer(get-buffer-create
> "Untitled1"))))
>
> This gives me a new buffer named Untitled1. How can I make a variable
> that increments so when I press C-n again I get a buffer named
> Untitled2 and so on?

Maybe you could use `make-temp-name'?

Example:

 (make-temp-name "Untitled-")

  => "Untitled-3744WiN"

It is certainly possible to write a more advanced function that looks
for old "Untitled" buffers and increases the suffix with 1, but the
above might work for you.

  reply	other threads:[~2006-11-22 10:33 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-11-22  8:00 Generate a new buffer name mopi
2006-11-22 10:33 ` Mathias Dahl [this message]
2006-11-22 12:30   ` mopi
2006-11-22 14:26 ` Perry Smith
2006-11-22 16:40 ` Kevin Rodgers

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.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=upsbfsrdl.fsf@gmail.com \
    --to=brakjoller@gmail.com \
    /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.
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).