From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Pascal Bourguignon Newsgroups: gmane.emacs.help Subject: Re: Emacs mode to do automatic version numbering? Date: 25 Jan 2003 10:38:08 +0100 Organization: informatimago.com Sender: help-gnu-emacs-bounces+gnu-help-gnu-emacs=m.gmane.org@gnu.org Message-ID: <87vg0dr2m7.fsf@thalassa.informatimago.com> References: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: main.gmane.org 1043487550 27419 80.91.224.249 (25 Jan 2003 09:39:10 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Sat, 25 Jan 2003 09:39:10 +0000 (UTC) Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 18cMmK-000787-00 for ; Sat, 25 Jan 2003 10:39:08 +0100 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 18cMns-00006R-04 for gnu-help-gnu-emacs@m.gmane.org; Sat, 25 Jan 2003 04:40:44 -0500 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!nntp.cs.ubc.ca!fu-berlin.de!uni-berlin.de!thalassa.informatimago.COM!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 31 Original-NNTP-Posting-Host: thalassa.informatimago.com (212.87.205.57) Original-X-Trace: fu-berlin.de 1043487488 30881882 212.87.205.57 (16 [41911]) User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 Original-Xref: shelby.stanford.edu gnu.emacs.help:109431 Original-To: help-gnu-emacs@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1b5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Help: List-Post: List-Subscribe: , List-Archive: List-Unsubscribe: , Errors-To: help-gnu-emacs-bounces+gnu-help-gnu-emacs=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.help:5952 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:5952 Andrew Ferrier 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