* write-file like function help needed
@ 2006-12-13 20:37 keithv
2006-12-13 21:16 ` Leo
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: keithv @ 2006-12-13 20:37 UTC (permalink / raw)
Hi,
I need help writing a function that works like write-file but
first modifies the file name by locating and incrementing
any numbers in the file name. For example, if the buffer
name is "test1.txt", repeatedly invoking this function
would save files with the names "test2.txt", "test3.txt",
"test4.txt", etc.
The goal being to keep all versions of a given file.
My elisp is rusty--I know how I would do the
number locate and increment on the buffer text
but not for an arbitrary string.
Or better yet, is there a package out there
to do something similar?
Thanks in advance,
Keith
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: write-file like function help needed
2006-12-13 20:37 write-file like function help needed keithv
@ 2006-12-13 21:16 ` Leo
2006-12-13 22:24 ` Juanma Barranquero
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Leo @ 2006-12-13 21:16 UTC (permalink / raw)
* Keithv (2006-12-13 12:37 -0800) said:
^^^^^^
> Or better yet, is there a package out there
> to do something similar?
Version control.
,----[ (info "(emacs)Version Control") ]
| The Emacs version control interface is called VC. Its commands work
| with different version control systems--currently, it supports CVS, GNU
| Arch, RCS, Meta-CVS, Subversion, and SCCS. Of these, the GNU project
| distributes CVS, GNU Arch, and RCS; we recommend that you use either
| CVS or GNU Arch for your projects, and RCS for individual files. We
| also have free software to replace SCCS, known as CSSC; if you are
| using SCCS and don't want to make the incompatible change to RCS or
| CVS, you can switch to CSSC.
`----
--
Leo <sdl.web AT gmail.com> (GPG Key: 9283AA3F)
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: write-file like function help needed
2006-12-13 20:37 write-file like function help needed keithv
2006-12-13 21:16 ` Leo
@ 2006-12-13 22:24 ` Juanma Barranquero
[not found] ` <mailman.1845.1166044623.2155.help-gnu-emacs@gnu.org>
2006-12-14 18:12 ` Kevin Rodgers
3 siblings, 0 replies; 5+ messages in thread
From: Juanma Barranquero @ 2006-12-13 22:24 UTC (permalink / raw)
Cc: help-gnu-emacs
On 13 Dec 2006 12:37:17 -0800, keithv <kvetter@gmail.com> wrote:
> I need help writing a function that works like write-file but
> first modifies the file name by locating and incrementing
> any numbers in the file name. For example, if the buffer
> name is "test1.txt", repeatedly invoking this function
> would save files with the names "test2.txt", "test3.txt",
> "test4.txt", etc.
(defun increment-file-name (filename)
(replace-regexp-in-string "\\([0-9]+\\)[^0-9]*\\'"
#'(lambda (num)
(number-to-string (1+ (string-to-number num))))
filename t t 1))
(defadvice write-file (before write-file-increment activate compile)
(ad-set-arg 0 (increment-file-name (ad-get-arg 0))))
/L/e/k/t/u
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: write-file like function help needed
[not found] ` <mailman.1845.1166044623.2155.help-gnu-emacs@gnu.org>
@ 2006-12-14 2:35 ` Dan Sommers
0 siblings, 0 replies; 5+ messages in thread
From: Dan Sommers @ 2006-12-14 2:35 UTC (permalink / raw)
On Wed, 13 Dec 2006 21:16:26 +0000,
Leo <sdl.web@gmail.com> wrote:
> * Keithv (2006-12-13 12:37 -0800) said:
> ^^^^^^
>> Or better yet, is there a package out there
>> to do something similar?
> Version control.
> ,----[ (info "(emacs)Version Control") ]
[snip]
There's also the version-control variable in files.el.
Regards,
Dan
--
Dan Sommers
<http://www.tombstonezero.net/dan/>
"I wish people would die in alphabetical order." -- My wife, the genealogist
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: write-file like function help needed
2006-12-13 20:37 write-file like function help needed keithv
` (2 preceding siblings ...)
[not found] ` <mailman.1845.1166044623.2155.help-gnu-emacs@gnu.org>
@ 2006-12-14 18:12 ` Kevin Rodgers
3 siblings, 0 replies; 5+ messages in thread
From: Kevin Rodgers @ 2006-12-14 18:12 UTC (permalink / raw)
keithv wrote:
> I need help writing a function that works like write-file but
> first modifies the file name by locating and incrementing
> any numbers in the file name. For example, if the buffer
> name is "test1.txt", repeatedly invoking this function
> would save files with the names "test2.txt", "test3.txt",
> "test4.txt", etc.
>
> The goal being to keep all versions of a given file.
>
> My elisp is rusty--I know how I would do the
> number locate and increment on the buffer text
> but not for an arbitrary string.
>
> Or better yet, is there a package out there
> to do something similar?
,----[ C-h v version-control RET ]
| version-control is a variable defined in `files.el'.
| Its value is nil
|
| Documentation:
| *Control use of version numbers for backup files.
| t means make numeric backup versions unconditionally.
| nil means make them for files that have some already.
| `never' means do not make them.
|
| You can customize this variable.
|
| [back]
`----
--
Kevin
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2006-12-14 18:12 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-12-13 20:37 write-file like function help needed keithv
2006-12-13 21:16 ` Leo
2006-12-13 22:24 ` Juanma Barranquero
[not found] ` <mailman.1845.1166044623.2155.help-gnu-emacs@gnu.org>
2006-12-14 2:35 ` Dan Sommers
2006-12-14 18:12 ` Kevin Rodgers
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).