annotate lisp/time-stamp.el @ 7291:373b9db3c71c

Removed some keystrokes for obscure toggle commands: C-c C-v C-a, C-c C-v C-p, C-c C-v C-q and C-c C-v C-k. (gnus-uu-decode-and-save-all-unread-articles-and-mark): Fn deleted. (gnus-uu-decode-and-save-all-articles-and-mark): Fn deleted. (gnus-uu-do-sloppy-uudecode): Variable deleted. (gnus-uu-decode-and-save-articles): Rewritten. (gnus-uu-grab-articles, gnus-uu-uustrip-article-as): Rewritten to properly handle multiple encoded files in one gulp. (gnus-uu-uustrip-article-as): Replace spaces in file names with underscores before giving the file to uudecode. (gnus-uu-save-in-digest): Doc fix. (gnus-uu-save-articles, gnus-uu-save-article, gnus-uu-digest-and-forward, gnus-uu-marked-digest-and-forward): Changed old functions and added new functions to digest and forward articles. (gnus-uu-mark-thread): New function to mark a thread for later treatment. (gnus-uu-mark-by-regexp): Changed to add articles instead of clearing before adding. (gnus-uu-check-for-generated-files): First delete files, then directories. (gnus-uu-edit-begin-line, gnus-uu-decode-and-show-in-buffer): Select the current article before starting work. (gnus-uu-decode-and-view-all-unread-articles) (gnus-uu-decode-and-view-all-articles): Two new functions for decoding and viewing all (unread) articles in a newsgroup. (gnus-uu-view-directory, gnus-uu-unpack-archives, gnus-uu-treat-archive): gnus-uu will now treat archives in archives (etc) properly when viewing. (gnus-uu-threaded-multi-decode-and-save, gnus-uu-threaded-multi-decode-and-view): New interactive functions for decoding/saving threads. Bound to `C-c C-v C-j'. (gnus-uu-save-article): Added RFC1153-compliant digest saving. (gnus-uu-initialize): Does some checks and expands relative temp dir names. (gnus-uu-decode-and-show-in-buffer) (gnus-uu-decode-and-strip, gnus-uu-grab-articles) (gnus-uu-decode-and-view-or-save): Allow multiple encoded files to be decoded (and viewed) in one fell swoop. (gnus-uu-work-dir): New variable. (gnus-uu-view-file): Changed to work with metamail. (gnus-uu-get-action, gnus-uu-toggle-view-with-metamail): New functions. (gnus-uu-ext-to-mime, gnus-uu-view-with-metamail): New variables. (gnus-uu-ctl-map): Add C-a binding. (gnus-uu-summary-next-subject): Ensures that the next unread article is moved to. (gnus-uu-default-interactive-view-rules-end): New variable to provide a "catch-all" when using interactive mode. (gnus-uu-get-action): Changed viewing rules in interactive mode. (gnus-uu-uustrip-article-as): Disabled case-fold-search and changed gnus-uu-body-line to be more restrictive. (gnus-uu-multi-decode-and-view-or-save, gnus-uu-uustrip-article-as): Changed hard returns to \r. (gnus-uu-post-reply-mode): New mode for sending encoded files. (gnus-uu-post-news, gnus-uu-post-insert-binary-in-article) (gnus-uu-post-encode-uuencode, gnus-uu-post-encode-mime-uuencode) (gnus-uu-post-encode-mime, gnus-uu-post-make-mime) (gnus-uu-post-encode-file, gnus-uu-post-news-inews) (gnus-uu-post-insert-binary, gnus-uu-post-encoded): New functions. (gnus-uu-post-encode-method, gnus-uu-post-include-before-composing) (gnus-uu-post-threaded, gnus-uu-post-binary-separator): New variables.
author Richard M. Stallman <rms@gnu.org>
date Tue, 03 May 1994 06:05:48 +0000
parents f97f4938fffa
children 4fd40bd394fe
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3854
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1 ;;; time-stamp.el --- Maintain last change time stamps in files edited by Emacs
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2 ;;; Copyright 1989, 1993 Free Software Foundation, Inc.
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4 ;; Maintainer: Stephen Gildea <gildea@lcs.mit.edu>
5971
f97f4938fffa (time-stamp-start): Allow more white space
Richard M. Stallman <rms@gnu.org>
parents: 5632
diff changeset
5 ;; Time-stamp: <94/02/14 15:02:07 gildea>
3854
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6 ;; Keywords: tools
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8 ;; This file is free software; you can redistribute it and/or modify
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
9 ;; it under the terms of the GNU General Public License as published by
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
10 ;; the Free Software Foundation; either version 2, or (at your option)
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
11 ;; any later version.
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
12
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
13 ;; This file is distributed in the hope that it will be useful,
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
14 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
16 ;; GNU General Public License for more details.
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
17
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
18 ;; You should have received a copy of the GNU General Public License
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
19 ;; along with GNU Emacs; see the file COPYING. If not, write to
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
20 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
21
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
22 ;;; Commentary:
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
23
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
24 ;;; If you put a time stamp template anywhere in the first 8 lines of a file,
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
25 ;;; it can be updated every time you save the file. See the top of
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
26 ;;; time-stamp.el for a sample. The template looks like one of the following:
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
27 ;;; Time-stamp: <>
4325
afdc363a0c9b Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 3855
diff changeset
28 ;;; Time-stamp: " "
3854
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
29 ;;; The time stamp is written between the brackets or quotes, resulting in
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
30 ;;; Time-stamp: <93/06/18 10:26:51 gildea>
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
31 ;;; Here is an example which puts the file name and time stamp in the binary:
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
32 ;;; static char *time_stamp = "sdmain.c Time-stamp: <>";
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
33
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
34 ;;; To activate automatic time stamping, add this code to your .emacs file:
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
35 ;;;
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
36 ;;; (if (not (memq 'time-stamp write-file-hooks))
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
37 ;;; (setq write-file-hooks
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
38 ;;; (cons 'time-stamp write-file-hooks)))
5072
16da133809dd Comment changes.
Richard M. Stallman <rms@gnu.org>
parents: 4327
diff changeset
39 ;;;
16da133809dd Comment changes.
Richard M. Stallman <rms@gnu.org>
parents: 4327
diff changeset
40 ;;; In Emacs 18 you will also need
16da133809dd Comment changes.
Richard M. Stallman <rms@gnu.org>
parents: 4327
diff changeset
41 ;;; (autoload 'time-stamp "time-stamp" "Update the time stamp in a buffer." t)
3854
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
42
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
43 ;;; Change Log:
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
44
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
45 ;;; Originally based on the 19 Dec 88 version of
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
46 ;;; date.el by John Sturdy <mcvax!harlqn.co.uk!jcgs@uunet.uu.net>
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
47
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
48 ;;; Code:
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
49
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
50 (defvar time-stamp-active t
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
51 "*Non-nil to enable time-stamping of files. See the function time-stamp.")
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
52
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
53 (defvar time-stamp-format
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
54 '(time-stamp-yy/mm/dd time-stamp-hh:mm:ss user-login-name)
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
55 "*A list of functions to call to generate the time stamp string.
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
56 Each element of the list is called as a function and the results are
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
57 concatenated together separated by spaces. Elements may also be strings,
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
58 which are included verbatim. Spaces are not inserted around literal strings.")
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
59
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
60 ;;; Do not change time-stamp-line-limit, time-stamp-start, or
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
61 ;;; time-stamp-end in your .emacs or you will be incompatible
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
62 ;;; with other people's files! If you must change them,
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
63 ;;; do so only in the local variables section of the file itself.
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
64
5632
63d80d94e0d7 Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 5287
diff changeset
65 (defvar time-stamp-line-limit 8 ;Do not change!
3854
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
66 "Number of lines at the beginning of a file that are searched.
5632
63d80d94e0d7 Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 5287
diff changeset
67 The patterns `time-stamp-start' and `time-stamp-end' must be found on one
63d80d94e0d7 Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 5287
diff changeset
68 of the first `time-stamp-line-limit' lines of the file for the file to
63d80d94e0d7 Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 5287
diff changeset
69 be time-stamped by \\[time-stamp].
63d80d94e0d7 Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 5287
diff changeset
70
63d80d94e0d7 Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 5287
diff changeset
71 Do not change `time-stamp-line-limit', `time-stamp-start', or
63d80d94e0d7 Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 5287
diff changeset
72 `time-stamp-end' for yourself or you will be incompatible
63d80d94e0d7 Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 5287
diff changeset
73 with other people's files! If you must change them for some application,
63d80d94e0d7 Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 5287
diff changeset
74 do so in the local variables section of the time-stamped file itself.")
63d80d94e0d7 Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 5287
diff changeset
75
3854
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
76
5971
f97f4938fffa (time-stamp-start): Allow more white space
Richard M. Stallman <rms@gnu.org>
parents: 5632
diff changeset
77 (defvar time-stamp-start "Time-stamp:[ \t]+\\\\?[\"<]+" ;Do not change!
3854
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
78 "Regexp after which the time stamp is written by \\[time-stamp].
5632
63d80d94e0d7 Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 5287
diff changeset
79 See also the variables `time-stamp-end' and `time-stamp-line-limit'.
3854
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
80
5632
63d80d94e0d7 Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 5287
diff changeset
81 Do not change `time-stamp-line-limit', `time-stamp-start', or
63d80d94e0d7 Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 5287
diff changeset
82 `time-stamp-end' for yourself or you will be incompatible
3854
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
83 with other people's files! If you must change them for some application,
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
84 do so in the local variables section of the time-stamped file itself.")
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
85
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
86
5632
63d80d94e0d7 Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 5287
diff changeset
87 (defvar time-stamp-end "\\\\?[\">]" ;Do not change!
3854
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
88 "Regexp marking the text after the time stamp.
5632
63d80d94e0d7 Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 5287
diff changeset
89 \\[time-stamp] deletes the text between the first match of `time-stamp-start'
63d80d94e0d7 Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 5287
diff changeset
90 and the following match of `time-stamp-end' on the same line,
63d80d94e0d7 Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 5287
diff changeset
91 then writes the time stamp specified by `time-stamp-format' between them.
63d80d94e0d7 Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 5287
diff changeset
92
63d80d94e0d7 Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 5287
diff changeset
93 Do not change `time-stamp-line-limit', `time-stamp-start', or
63d80d94e0d7 Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 5287
diff changeset
94 `time-stamp-end' for yourself or you will be incompatible
63d80d94e0d7 Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 5287
diff changeset
95 with other people's files! If you must change them for some application,
63d80d94e0d7 Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 5287
diff changeset
96 do so in the local variables section of the time-stamped file itself.")
63d80d94e0d7 Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 5287
diff changeset
97
3854
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
98
4327
771786f5d8c2 (time-stamp): Add autoload cookie.
Richard M. Stallman <rms@gnu.org>
parents: 4325
diff changeset
99 ;;;###autoload
3854
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
100 (defun time-stamp ()
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
101 "Update the time stamp string in the buffer.
5632
63d80d94e0d7 Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 5287
diff changeset
102 If you put a time stamp template anywhere in the first 8 lines of a file,
63d80d94e0d7 Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 5287
diff changeset
103 it can be updated every time you save the file. See the top of
63d80d94e0d7 Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 5287
diff changeset
104 `time-stamp.el' for a sample. The template looks like one of the following:
63d80d94e0d7 Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 5287
diff changeset
105 Time-stamp: <>
63d80d94e0d7 Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 5287
diff changeset
106 Time-stamp: \" \"
63d80d94e0d7 Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 5287
diff changeset
107 The time stamp is written between the brackets or quotes, resulting in
63d80d94e0d7 Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 5287
diff changeset
108 Time-stamp: <93/06/18 10:26:51 gildea>
3854
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
109 Only does its thing if the variable time-stamp-active is non-nil.
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
110 Typically used on write-file-hooks for automatic time-stamping.
5632
63d80d94e0d7 Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 5287
diff changeset
111 The format of the time stamp is determined by the variable time-stamp-format.
63d80d94e0d7 Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 5287
diff changeset
112 The variables time-stamp-line-limit, time-stamp-start, and time-stamp-end
63d80d94e0d7 Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 5287
diff changeset
113 control finding the template."
3854
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
114 (interactive)
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
115 (if time-stamp-active
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
116 (let ((case-fold-search nil))
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
117 (if (and (stringp time-stamp-start)
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
118 (stringp time-stamp-end))
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
119 (save-excursion
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
120 (goto-char (point-min))
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
121 (if (re-search-forward time-stamp-start
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
122 (save-excursion
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
123 (forward-line time-stamp-line-limit)
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
124 (point))
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
125 t)
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
126 (let ((start (point)))
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
127 (if (re-search-forward time-stamp-end
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
128 (save-excursion (end-of-line) (point))
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
129 t)
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
130 (let ((end (match-beginning 0)))
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
131 (delete-region start end)
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
132 (goto-char start)
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
133 (insert (time-stamp-string))
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
134 (setq end (point))
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
135 ;; remove any tabs used to format the time stamp
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
136 (goto-char start)
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
137 (if (search-forward "\t" end t)
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
138 (untabify start end)))))))
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
139 ;; don't signal an error in a write-file-hook
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
140 (message "time-stamp-start or time-stamp-end is not a string"))))
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
141 ;; be sure to return nil so can be used on write-file-hooks
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
142 nil)
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
143
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
144 (defun time-stamp-string ()
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
145 "Generate the new string to be inserted by \\[time-stamp]."
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
146 (time-stamp-fconcat time-stamp-format " "))
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
147
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
148 (defun time-stamp-fconcat (list sep)
5632
63d80d94e0d7 Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 5287
diff changeset
149 "Similar to (mapconcat 'funcall LIST SEP) but LIST allows literals.
3854
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
150 If an element of LIST is a symbol, it is funcalled to get the string to use;
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
151 the separator SEP is used between two strings obtained by funcalling a
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
152 symbol. Otherwise the element itself is inserted; no separator is used
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
153 around literals."
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
154 (let ((return-string "")
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
155 (insert-sep-p nil))
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
156 (while list
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
157 (cond ((symbolp (car list))
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
158 (if insert-sep-p
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
159 (setq return-string (concat return-string sep)))
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
160 (setq return-string (concat return-string (funcall (car list))))
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
161 (setq insert-sep-p t))
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
162 (t
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
163 (setq return-string (concat return-string (car list)))
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
164 (setq insert-sep-p nil)))
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
165 (setq list (cdr list)))
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
166 return-string))
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
167
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
168
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
169 (defconst time-stamp-month-numbers
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
170 '(("Jan" . 1) ("Feb" . 2) ("Mar" . 3) ("Apr" . 4) ("May" . 5) ("Jun" . 6)
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
171 ("Jul" . 7) ("Aug" . 8) ("Sep" . 9) ("Oct" . 10) ("Nov" . 11) ("Dec" . 12))
5632
63d80d94e0d7 Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 5287
diff changeset
172 "Alist of months and their number.")
3854
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
173
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
174 (defconst time-stamp-month-full-names
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
175 ["(zero)" "January" "February" "March" "April" "May" "June"
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
176 "July" "August" "September" "October" "November" "December"])
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
177
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
178 (defvar time-stamp-mail-host nil
5632
63d80d94e0d7 Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 5287
diff changeset
179 "*Name of the host where the user receives mail.
63d80d94e0d7 Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 5287
diff changeset
180 See the function `time-stamp-mail-host-name'.")
3854
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
181
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
182 ;;; Some useful functions to use in time-stamp-format
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
183
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
184 ;;; Could generate most of a message-id with
5632
63d80d94e0d7 Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 5287
diff changeset
185 ;;; '(time-stamp-yymmdd "" time-stamp-hhmm "@" time-stamp-mail-host-name)
3854
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
186
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
187 (defun time-stamp-mail-host-name ()
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
188 "Return the name of the host where the user receives mail.
5632
63d80d94e0d7 Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 5287
diff changeset
189 This is the value of `time-stamp-mail-host' if bound and a string,
63d80d94e0d7 Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 5287
diff changeset
190 otherwise the value of the function system-name.
63d80d94e0d7 Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 5287
diff changeset
191 This function may be usefully referenced by `time-stamp-format'."
3854
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
192 (or (and (boundp 'time-stamp-mail-host)
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
193 (stringp time-stamp-mail-host)
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
194 time-stamp-mail-host)
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
195 (system-name)))
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
196
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
197 ;;; pretty form, suitable for a title page
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
198
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
199 (defun time-stamp-month-dd-yyyy ()
5632
63d80d94e0d7 Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 5287
diff changeset
200 "Return the current date as a string in \"Month DD, YYYY\" form."
3854
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
201 (let ((date (current-time-string)))
5287
6811f9d90b62 (time-stamp-month-dd-yyyy): no leading zero on day.
Richard M. Stallman <rms@gnu.org>
parents: 5072
diff changeset
202 (format "%s %d, %s"
3854
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
203 (aref time-stamp-month-full-names
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
204 (cdr (assoc (substring date 4 7) time-stamp-month-numbers)))
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
205 (string-to-int (substring date 8 10))
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
206 (substring date -4))))
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
207
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
208 ;;; same as __DATE__ in ANSI C
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
209
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
210 (defun time-stamp-mon-dd-yyyy ()
5632
63d80d94e0d7 Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 5287
diff changeset
211 "Return the current date as a string in \"Mon DD YYYY\" form.
63d80d94e0d7 Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 5287
diff changeset
212 The first character of DD is space if the value is less than 10."
3854
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
213 (let ((date (current-time-string)))
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
214 (format "%s %2d %s"
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
215 (substring date 4 7)
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
216 (string-to-int (substring date 8 10))
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
217 (substring date -4))))
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
218
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
219 ;;; RFC 822 date
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
220
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
221 (defun time-stamp-dd-mon-yy ()
5632
63d80d94e0d7 Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 5287
diff changeset
222 "Return the current date as a string in \"DD Mon YY\" form."
3854
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
223 (let ((date (current-time-string)))
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
224 (format "%02d %s %s"
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
225 (string-to-int (substring date 8 10))
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
226 (substring date 4 7)
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
227 (substring date -2))))
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
228
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
229 ;;; RCS 3 date
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
230
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
231 (defun time-stamp-yy/mm/dd ()
5632
63d80d94e0d7 Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 5287
diff changeset
232 "Return the current date as a string in \"YY/MM/DD\" form."
3854
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
233 (let ((date (current-time-string)))
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
234 (format "%s/%02d/%02d"
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
235 (substring date -2)
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
236 (cdr (assoc (substring date 4 7) time-stamp-month-numbers))
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
237 (string-to-int (substring date 8 10)))))
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
238
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
239 ;;; RCS 5 date
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
240
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
241 (defun time-stamp-yyyy/mm/dd ()
5632
63d80d94e0d7 Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 5287
diff changeset
242 "Return the current date as a string in \"YYYY/MM/DD\" form."
3854
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
243 (let ((date (current-time-string)))
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
244 (format "%s/%02d/%02d"
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
245 (substring date -4)
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
246 (cdr (assoc (substring date 4 7) time-stamp-month-numbers))
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
247 (string-to-int (substring date 8 10)))))
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
248
5632
63d80d94e0d7 Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 5287
diff changeset
249 ;;; ISO 8601 date
63d80d94e0d7 Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 5287
diff changeset
250
63d80d94e0d7 Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 5287
diff changeset
251 (defun time-stamp-yyyy-mm-dd ()
63d80d94e0d7 Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 5287
diff changeset
252 "Return the current date as a string in \"YYYY-MM-DD\" form."
63d80d94e0d7 Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 5287
diff changeset
253 (let ((date (current-time-string)))
63d80d94e0d7 Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 5287
diff changeset
254 (format "%s-%02d-%02d"
63d80d94e0d7 Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 5287
diff changeset
255 (substring date -4)
63d80d94e0d7 Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 5287
diff changeset
256 (cdr (assoc (substring date 4 7) time-stamp-month-numbers))
63d80d94e0d7 Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 5287
diff changeset
257 (string-to-int (substring date 8 10)))))
63d80d94e0d7 Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 5287
diff changeset
258
3854
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
259 (defun time-stamp-yymmdd ()
5632
63d80d94e0d7 Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 5287
diff changeset
260 "Return the current date as a string in \"YYMMDD\" form."
3854
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
261 (let ((date (current-time-string)))
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
262 (format "%s%02d%02d"
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
263 (substring date -2)
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
264 (cdr (assoc (substring date 4 7) time-stamp-month-numbers))
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
265 (string-to-int (substring date 8 10)))))
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
266
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
267 (defun time-stamp-hh:mm:ss ()
5632
63d80d94e0d7 Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 5287
diff changeset
268 "Return the current time as a string in \"HH:MM:SS\" form."
3854
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
269 (substring (current-time-string) 11 19))
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
270
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
271 (defun time-stamp-hhmm ()
5632
63d80d94e0d7 Better, more user-oriented doc strings.
Richard M. Stallman <rms@gnu.org>
parents: 5287
diff changeset
272 "Return the current time as a string in \"HHMM\" form."
3854
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
273 (let ((date (current-time-string)))
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
274 (concat (substring date 11 13)
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
275 (substring date 14 16))))
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
276
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
277 (provide 'time-stamp)
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
278
ae1022bb1578 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
279 ;;; time-stamp.el ends here
5971
f97f4938fffa (time-stamp-start): Allow more white space
Richard M. Stallman <rms@gnu.org>
parents: 5632
diff changeset
280