all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Emacs mode to do automatic version numbering?
@ 2003-01-24 16:46 Andrew Ferrier
  2003-01-25  9:38 ` Pascal Bourguignon
  0 siblings, 1 reply; 2+ messages in thread
From: Andrew Ferrier @ 2003-01-24 16:46 UTC (permalink / raw)


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.

Regards,
Andrew.

-- 
Andrew Ferrier,
andrew.ferrier@uk.ibm.com

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Emacs mode to do automatic version numbering?
  2003-01-24 16:46 Emacs mode to do automatic version numbering? Andrew Ferrier
@ 2003-01-25  9:38 ` Pascal Bourguignon
  0 siblings, 0 replies; 2+ messages in thread
From: Pascal Bourguignon @ 2003-01-25  9:38 UTC (permalink / raw)


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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2003-01-25  9:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-01-24 16:46 Emacs mode to do automatic version numbering? Andrew Ferrier
2003-01-25  9:38 ` Pascal Bourguignon

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.