From: "Juanma Barranquero" <lekktu@gmail.com>
Cc: help-gnu-emacs@gnu.org
Subject: Re: write-file like function help needed
Date: Wed, 13 Dec 2006 23:24:57 +0100 [thread overview]
Message-ID: <f7ccd24b0612131424k735e6110tb203ff56ce96522e@mail.gmail.com> (raw)
In-Reply-To: <1166042237.856019.98270@n67g2000cwd.googlegroups.com>
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
next prev parent reply other threads:[~2006-12-13 22:24 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
[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
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=f7ccd24b0612131424k735e6110tb203ff56ce96522e@mail.gmail.com \
--to=lekktu@gmail.com \
--cc=help-gnu-emacs@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.