Next: Forcing Time Stamps for One File, Up: Updating Time Stamps Automatically [Contents][Index]
20.3.6.1 Customizing the Time StampTo customize the time stamp in a particular file, set the variable time-stamp-pattern
in that file’s local variables list (see Specifying File Variables). You can change what pattern time-stamp
will match against to identify a template and where in the file to look for the pattern using time-stamp-pattern
; for details, see the variable’s built-in documentation (with C-h v, see Help by Command or Variable Name).
As a simple example, if this line occurs near the top of a file:
publishing_year_and_city = "Published nnnn in Boston, Mass.";
then the following comment at the end of the same file tells time-stamp
how to identify and update that custom template:
// Local variables: // time-stamp-pattern: "Published %Y in Boston" // End:
This pattern says that the text before the start of the time stamp is “Published ”, and the text after the end is “ in Boston”. If time-stamp
finds both in one of the first eight lines, what is between will be replaced by the current year, as requested by the %Y
format.
After any change to file-local variables, type M-x normal-mode to re-read them.
Here is another example, with the time stamp inserted into the last paragraph of an HTML document. Since this template is at the end of the document, not in the first eight lines, time-stamp-pattern
starts with -10/
to tell time-stamp
to look at the last 10 lines. The %%
asks for the default format (specified by time-stamp-format
).
… <p>Last modified: </p> </body> </html> <!-- Local variables: time-stamp-pattern: "-10/Last modified: %%</p>$" End: -->
By default the time stamp is formatted according to your locale setting (see Environment Variables) and time zone (see Time of Day in The Emacs Lisp Reference Manual). Set time-stamp-time-zone
to override the time zone used. See the built-in documentation for the variable time-stamp-format
for specifics on formatting and other variables that affect it.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4