help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Generate a new buffer name


From: Perry Smith
Subject: Re: Generate a new buffer name
Date: Wed, 22 Nov 2006 08:26:09 -0600

On Nov 22, 2006, at 2:00 AM, mopi wrote:

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?

(defvar next-untitled-buffer-number 0
  "document variable here")

(global-set-key [(control n)]
(lambda()
  (interactive)
  (switch-to-buffer
   (get-buffer-create
    (format "Untitled-%d"
    (setq next-untitled-buffer-number
  (1+ next-untitled-buffer-number)))))))

Perry Smith ( address@hidden )
Ease Software, Inc. ( http://www.easesoftware.com )

Low cost SATA Disk Systems for IBMs p5, pSeries, and RS/6000 AIX systems



reply via email to

[Prev in Thread] Current Thread [Next in Thread]