home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / languages / elisp / modes / multi-forms-mode / utilities / insert-date.el next >
Encoding:
Text File  |  1992-03-20  |  2.9 KB  |  94 lines

  1. ;;;; -*- Mode: Emacs-Lisp -*- 
  2. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  3. ;;;; 
  4. ;;;; File            : insert-date.el
  5. ;;;; Author          : Frank Ritter
  6. ;;;; Created On      : Sun Oct  6 23:43:48 1991
  7. ;;;; Last Modified By: Frank Ritter
  8. ;;;; Last Modified On: Fri Mar 20 19:04:15 1992
  9. ;;;; Update Count    : 6
  10. ;;;; 
  11. ;;;; PURPOSE
  12. ;;;;     Provides functions to insert the date and time into buffers.
  13. ;;;; Original code by Erik Altmann.
  14. ;;;;
  15. ;;;; TABLE OF CONTENTS
  16. ;;;;     i.    Variables and inits.
  17. ;;;;    I.    Insert-date-string
  18. ;;;; 
  19. ;;;; Copyright 1991, Frank Ritter.
  20. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  21. ;;;; Status          : Unknown, Use with caution!
  22. ;;;; HISTORY
  23. ;;;; 
  24. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  25.  
  26. (provide 'insert-date)
  27.  
  28.  
  29. ;;;
  30. ;;;     i.    Variables and inits.
  31. ;;;
  32.  
  33. (defvar insert-date-with-month-namep nil
  34.   "*Print out the month in insert-date-string as letters, and in
  35. 30-Oct-91 order, rather than as 10-30-91.")
  36.  
  37. ;; 3-6-91 -  tested only for march:
  38. (defconst *date-table*
  39.     '(("Jan" 1) ("Feb" 2) ("Mar" 3) ("Apr" 4)
  40.       ("May" 5) ("Jun" 6) ("Jul" 7) ("Aug" 8)
  41.       ("Sep" 9) ("Oct" 10) ("Nov" 11) ("Dec" 12))
  42.   "Maps into numbers the month strings returned by current-time-string.")
  43.  
  44.  
  45. ;;;
  46. ;;;    I.    Erik's insert-date-string & insert-time-string
  47. ;;;
  48. ;;; Code from Erik Altmann on a quick hack to insert date and time on 
  49. ;;; headerless files.  Not really necc. for soar-mode, but what the heck.
  50.  
  51. ;; 3-6-91 -
  52. ;; (current-time-string)
  53. ;; -> "Wed Mar  6 10:31:12 1991"
  54. ;;     012345678901234567890123
  55.  
  56. (defun insert-time-string ()
  57.   "Inserts an Al-like time-stamp after point."
  58.   (interactive)
  59.   (insert-before-markers
  60.    (format "%s%s" (substring (current-time-string) 11 13)
  61.        (substring (current-time-string) 14 16))))
  62.  
  63. (defun insert-current-time-string ()
  64.   "Inserts a full time-stamp after point."
  65.   (interactive)
  66.   (insert-before-markers
  67.    (format "%s%s" (current-time-string))) )
  68.  
  69. (defun insert-date-string (arg)
  70.   "Inserts the current date after point, in m-d-y format.  With prefix
  71. argument, inserts the weekday first."
  72.   (interactive "P")
  73.   (let ((time-string (current-time-string)))
  74.     (if arg
  75.         ;; insert day before date:
  76.         (insert-before-markers
  77.         (format "%s " (downcase (substring time-string 0 3)))))
  78.     ;; insert date:
  79.     (insert-before-markers
  80.      (if insert-date-with-month-namep
  81.      (format "%s-%s-%s -"
  82.          (if (string-equal " " (substring time-string 8 9))
  83.              (substring time-string 9 10)
  84.            (substring time-string 8 10))
  85.          (substring time-string 4 7)
  86.          (substring time-string  -2 nil))
  87.      (format "%s-%s-%s - "
  88.          (car (cdr (assoc (substring time-string 4 7) *date-table*)))
  89.          (if (string-equal " " (substring time-string 8 9))
  90.              (substring time-string 9 10)
  91.            (substring time-string 8 10))
  92.          (substring time-string  -2 nil))))))
  93.  
  94.