■掲示板に戻る■ 全部 1- 101- 201- 301- 401- 501- 601- 701- 801- 901- 最新50

レス数が950を超えています。1000を超えると表示できなくなるよ。

2ch専用ブラウザ「Navi2ch」

930 :名無しさん@お腹いっぱい。 :01/12/25 04:51
navi2chでのbase64サポート関数。~/.navi2ch/init.elに入れとくと便利。
将来的にはnavi2ch-util.elにつっこんでほしい。

FSF emacs 20、21で動作確認。xemacsは使ってないので誰か確認お願い。

(defun navi2ch-base64-write-region (start end filename)
"STARTとENDの間のリージョンをbase64デコードし、FILENAMEに書き出す"
(interactive "r\nFDecode and write region to file: ")
(let ((str (buffer-substring start end)))
(save-excursion
(with-temp-buffer
(let ((buffer-file-coding-system 'binary)
(file-coding-system 'binary)
(coding-system-for-write 'binary))
(insert str)
(base64-decode-region (point-min) (point-max))
(if (or (not (file-exists-p filename))
(y-or-n-p (format "File `%s' exists; overwrite? "
filename)))
(write-region (point-min) (point-max) filename)))))))

(defun navi2ch-base64-insert-file (filename)
"FILENAMEをbase64エンコードし、現在のポイントに挿入する"
(interactive "fEncode and insert file: ")
(let ((str nil))
(save-excursion
(with-temp-buffer
(let ((buffer-file-coding-system 'binary)
(file-coding-system 'binary))
(insert-file-contents-literally filename)
(base64-encode-region (point-min) (point-max) nil)
(setq str (buffer-string)))))
(insert str)))


新着レスの表示

掲示板に戻る 全部 前100 次100 最新50
名前: E-mail (省略可) :

read.cgi ver5.26+ (01/10/21-)