all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Pascal Bourguignon <pjb@informatimago.com>
Subject: Re: Emacs mode to do automatic version numbering?
Date: 25 Jan 2003 10:38:08 +0100	[thread overview]
Message-ID: <87vg0dr2m7.fsf@thalassa.informatimago.com> (raw)
In-Reply-To: slrnb32ret.c91.andrew.ferrier@tracey.hursley.ibm.com

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

      reply	other threads:[~2003-01-25  9:38 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-01-24 16:46 Emacs mode to do automatic version numbering? Andrew Ferrier
2003-01-25  9:38 ` Pascal Bourguignon [this message]

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=87vg0dr2m7.fsf@thalassa.informatimago.com \
    --to=pjb@informatimago.com \
    /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.