; ; html-nikki-helper.el by Jun Obama ; Special thanks to TAMURA Kent ; ; INSTALL: ; 1.Put this file to a directory in load-path. ; 2.Add following line to your ~/.emacs: ; (require 'html-nikki-helper) ; ;---------- ; ; Setting for html-helper-mode: ; add following line to your ~/.emacs: ; ; (add-hook 'html-helper-mode-hook ; '(lambda () ; (progn ; (require 'html-nikki-helper) ; (define-key html-helper-mode-map "\C-cd" 'html-nikki-insert-date) ; (define-key html-helper-mode-map "\C-u\C-cd" 'html-nikki-insert-date-offset) ; (define-key html-helper-mode-map "\C-ce" 'html-nikki-insert-paragraph-title))) t) ; ;---------- ; ; Setting for XEmacs 20.4 sgml-mode: ; add following line to your ~/.emacs: ; ; (add-hook 'sgml-mode-hook ; '(lambda () ; (progn ; (require 'html-nikki-helper) ; (define-key sgml-mode-map "\C-cd" 'html-nikki-insert-date) ; (define-key sgml-mode-map "\C-ce" 'html-nikki-insert-paragraph-title))) t) ; ; (provide 'html-nikki-helper) ; ; set default value ; (defvar baseurl "http://www.ceres.dti.ne.jp/~george/") ; ; 日付タグ挿入 ; ;現在の日付を数値化したもの(たとえば19980327)をnameタグとして日付区切り ;タグを現在のバッファに挿入する。 ; (defun html-nikki-insert-date (&optional OFFSET-DAY) (interactive) (let (datestr tagstr str offsetsec specified-time) (setq offsetsec (* 3600 24 (or OFFSET-DAY 0) )) (setq specified-time (html-nikki-add-time (current-time) (list 0 offsetsec))) (setq datestr (strftime "%y.%m.%d (%a)" specified-time)) (setq tagstr (strftime "%y%m%d" specified-time)) (insert "
" "\n" "

■ 宇宙歴 " datestr "

" "\n" "" "\n"))) ; ; 日付タグ挿入 ; ; 現在の日付から前後にn日を問い合わせて ; 日付タグを現在のバッファに挿入する。 ; (defun html-nikki-insert-date-offset-interactive () (list (string-to-int (read-string "input date offset : " "" )))) ; (defun html-nikki-insert-date-offset (offsetday) (interactive (html-nikki-insert-date-offset-interactive)) (message "day of offset is %d" offsetday) (html-nikki-insert-date offsetday)) ; ; 段落タグ挿入 ; ;backward方向に日付タグ(のように、nameタグの内容が8 ;桁の数字になっているもの)があれば、それを利用して1998032701というname ;タグを作成。 ; ;backward方向に段落タグ(のように、nameタグの内容が ;10桁の数字になっているもの)があれば、最後の2桁の数字を+1して、 ;1998032702というnameタグを作成。 ; (defun html-nikki-insert-paragraph-title () (interactive) (let (tagstr ptagstr sp ep tmp dif) (setq tagstr (strftime "%y%m%d")) (setq ptagstr "01") (save-excursion (cond ((search-backward-regexp "<[aA] [nN][aA][mM][eE]=\"[^<>\"]*" 0 t) (setq sp (+ (match-beginning 0) 9)) (setq ep (+ (match-beginning 0) 9 8)) (setq tagstr (buffer-substring sp ep)) (setq dif (- (match-end 0) (match-beginning 0))) (cond ((equal dif 19) (setq sp (- (match-end 0) 2)) (setq ep (match-end 0)) (setq ptagstr (format "%02d" (+ 1 (string-to-int (buffer-substring sp ep)))))))))) (insert "

" " " "" " " "

\n" "

\n" "\n" "

\n") (search-backward " ") )) ; ; 単純な段落タグ

挿入 ; (defun html-nikki-insert-paragraph () (interactive) (let () (insert "

\n" "\n" "

\n") (forward-line -2) )) ; ; minimum subset of strftime :-) ; (defun strftime (&optional fmt SPECIFIED-TIME) (let (str week month-name month day time year timelist ret) (setq str (current-time-string SPECIFIED-TIME)) (setq timelist (html-table-region-split-string-to-list str)) (setq week (car timelist)) (setq timelist (cdr timelist)) (setq month-name (car timelist)) (setq month (month-name-to-number-string month-name)) (setq timelist (cdr timelist)) (setq day (format "%02d" (string-to-int (car timelist)))) (setq timelist (cdr timelist)) (setq time (car timelist)) (setq timelist (cdr timelist)) (setq year (car timelist)) (cond ((equal fmt "%y.%m.%d") (setq ret (concat year "." month "." day))) ((equal fmt "%y%m%d") (setq ret (concat year month day))) ((equal fmt "%y.%m.%d (%a)") (setq ret (concat year "." month "." day " (" week ")"))) ((t) (setq ret (concat year month day)))) ret)) ; ; convert month short name to number string ; by KENT TAMURA Kent ; (defconst html-nikki-helper-month-number-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"))) (defun month-name-to-number-string (mon) (cdr (assoc mon html-nikki-helper-month-number-alist))) ; ; add time ; 時間の差分計算を行う ; ( MSB-side-16bit LSB-side-16bit . micro-second ) ; 形式の時間(秒)を足し算して結果を返す ; 例:(html-nikki-add-time (list 1 1) (list 0 0)) ; (defun html-nikki-add-time (x y) (let (xh xl) (setq xh (+ (car x) (car y))) (setq xl (+ (cadr x) (cadr y))) (while (< xl 0) (setq xh (- xh 1)) (setq xl (+ xl 65536))) (while (< 65536 xl) (setq xh (+ xh 1)) (setq xl (- xl 65536))) (list xh xl 0) )) ; ; FreeBSD-users-jp ML へのリンクを挿入するためのコード ; (defvar mailing-list-name "freebsd-users-jp") (defvar mailing-list-number 1) (defun html-nikki-insert-mailing-list-link-interactive (prompt-ml-name default-ml-name prompt-ml-number default-ml-number) (list (read-string prompt-ml-name default-ml-name) (string-to-int(read-string prompt-ml-number (format "%d" default-ml-number))))) (defun html-nikki-insert-mailing-list-link (ml-name ml-num) "insert hyper link to freebsd-users-jp mailing list web site." (interactive (html-nikki-insert-mailing-list-link-interactive "Mailing list name : " mailing-list-name "Mailing list number : " mailing-list-number)) (setq mailing-list-name ml-name) (setq mailing-list-number ml-num) (insert (format " %s [%d] " mailing-list-name mailing-list-number mailing-list-name mailing-list-number))) ; ; end of file ;