eichin@ATHENA.MIT.EDU ("Mark W. Eichin") (04/09/91)
>> Novice question: >> What's the difference between call-process and shell-command? What's >> the most efficient way to call 'date' to insert a formatted date/time >> stamp into a text file. >> Regards, >> Ken It's a good thing you enclosed your second question - the answer you probably want is "don't call date". Enclosed find stardate.el, a little tool I use to insert a datestamp in files I'm editting (usually comments in code). The "icky" version referred to used call-process of "date"; this one uses "(current-time-string)" which returns a string which is the vlaue of the library "ctime" function (so "man ctime" to see what the string will look like on your system, or just ESC ESC (current-time-string) RET to see directly what it is. Needless to say, (current-time-string) is *MUCH* faster. _Mark_ <eichin@athena.mit.edu> MIT Student Information Processing Board ;;; stardate.el ;;; insert something like [eichin:19880309.0843EST] into a file, as a ;;; nerdly sort of timestamp. ;;; [eichin:19880309.0843EST] ;;; There MUST be some way of speeding this up... ;;; sigh. there is. look at the rcslogs for the old icky version. ;;; [eichin:19880309.0936EST] (defvar stardate_el-RCS-id) (setq stardate_el-RCS-id "$Header: stardate.el,v 1.2 88/03/09 09:44:01 eichin Exp $") (defconst month-day-alist '(("Jan"."01") ("Feb"."02") ("Mar"."03") ("Apr"."04") ("May"."05") ("Jun"."06") ("Jul"."07") ("Aug"."08") ("Sep"."09") ("Oct"."10") ("Nov"."11") ("Dec"."12")) "assoc list of months/numeric string numbers. See calendar.el.") (defvar stardate-timezone "EST") (setq date (current-time-string)) (defun insert-stardate () "Put stardate at point." (interactive) (let ((date (current-time-string))) (insert "[" (getenv "USER") ":" (substring date -4 nil) ; yyyy (cdr (assoc (substring date 4 7) month-day-alist)) ; MM (let ((d (substring date 8 9))) (if (equal d " ") "0" d)) (substring date 9 10) ; d "." (substring date 11 13) ; hh (substring date 14 16) ; mm stardate-timezone "]")))