[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Emacs mode to do automatic version numbering?
From: |
Pascal Bourguignon |
Subject: |
Re: Emacs mode to do automatic version numbering? |
Date: |
25 Jan 2003 10:38:08 +0100 |
User-agent: |
Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 |
Andrew Ferrier <andrew.ferrier@uk.ibm.com> writes:
> I'm looking for an Emacs mode that will auto-update a version number
> embedded in a buffer when that buffer is saved (similar to the way
> time-stamp auto-updates a time-stamp). I was wondering if anyone knew of
> such a mode or where one could be found? I've looked all around and
> can't find anything similar. Any help would be appreciated.
Either do like time-stamp and add a write-file-hooks, or add an advice
to save-buffer. This is what I've done because I have a function that
determines automatically for all files what to update or not to do
anything from the major mode (the hooks seem to depend on the buffer):
(defadvice save-buffer
(before my-update-version-save-buffer (&optional ARGS))
(interactive "p")
;;; WARNING: Untested code below:
(widen)
(goto-char (point-min))
(when (re-search-forward "^VERSION: \([0-9]+\.[0-9]+\)$" nil t)
(replace-match (format "%.3f" (+ 0.001 (string-to-number (match-string 1))))
t t nil 1))
)
(ad-activate 'save-buffer)
--
__Pascal_Bourguignon__ http://www.informatimago.com/
----------------------------------------------------------------------
There is a fault in reality. Do not adjust your minds. -- Salman Rushdie