◎以下のプログラムは、下記URLに公開されているソースを改変したものです。  下記頁の作者に感謝します。  http://members.tripod.co.jp/kwatch/mule/tips.html ------------------------cut here------------------------- ;; F5キーに割り当てる (define-key global-map [f5] 'my-insert-date) ; ;;; ;;; 日付入力関数 ;;; (defun my-insert-date (arg) "'8/29(Wed)'のような形式で日付を挿入する。 引数 N を渡すと、N日前の日付まで挿入する。" (interactive "p") (if (not arg) (setq arg 1)) (let* ((time (current-time-string)) (weekday (substring time 0 3)) (monthname (substring time 4 7)) (index (string-match monthname "JanFebMarAprMayJunJulAugSepOctNovDec")) (month (+ 1 (/ index 3))) (year (string-to-number (substring time 22 24))) (day (string-to-number (substring time 8 10))) ) (my-insert-date-body arg month day weekday year) )) (defun my-insert-date-body (arg month day weekday year) ;;来年、去年、今年を書式付きで定義 (setq next-year (format "%02d" (+ year 1)) last-year (format "%02d" (- year 1)) this-year (format "%02d" year)) ;; 日付を挿入する (insert ;; *** この行を変えれば、書式が変えられます! ******* (concat "

- 20" this-year "年" (int-to-string month) "月" (int-to-string day) "日" " (" weekday ")+

\n\n\n") ) ;; arg > 1 なら、前日の日付も挿入する (if (> arg 1) (progn ;; 前日の日にちを求める (setq day (- day 1)) (if (= day 0) (progn (setq month (- month 1)) ;; 前の月 (if (= month 0) (setq month 12)) (setq day ;; 日にち (nth month '(0 31 28 31 30 31 30 31 31 30 31 30 31))) )) ;; 前日の曜日を求める (let* ( ;; "Sat" から始まって "Sat" で終わっているのがミソ (weekdays "SatSunMonTueWedThuFriSat") ;; 検索するのは先頭からではなく3文字目から (index1 (string-match weekday weekdays 3)) ;; 前日の曜日 (index2 (- index1 3)) ) (setq weekday (substring weekdays index2 (+ 3 index2))) ) ; let end ;; 前日の日付を挿入する (my-insert-date-body (- arg 1) month day weekday year) )) ) ; defun end ;;; ;;; end of file ;;;