[Mew-Win32 00256] Re: mew-caesar.el

Hideyuki SHIRAI Shirai at example.com
1998年 2月 19日 (木) 13:13:46 JST


白井@mew-caesar.elの作者です。

# mew-win32 MLの方はだぶります。m(__)m
# 内容は同じものです。

From: Kazu Yamamoto (山本和彦) <Kazu at example.com> さん曰く
Subject: Re: mew-caesar.el (Re: mew-win32.el: browse-url-or-mew)
Message-ID: <19980218235703W.kazu at example.com>
Date: Wed, 18 Feb 1998 23:57:18 +0900

Kazu> From: "YAMAGUCHI, Shuhei" <yamagus at example.com>
Kazu> Subject: [Mew-dist 03831] mew-caesar.el (Re: mew-win32.el: browse-url-or-mew)
Kazu> Date: Wed, 18 Feb 1998 23:35:24 +0900
Kazu> 
Kazu> > やっぱり、[Mew-dist 03692]のmew-caesar.elがcontribに入るとうれしいです。
Kazu> > Win32環境だけでなく、Emacs-20.2 on FreeBSD-2.2.5でも動作するのは確認し
Kazu> > ています。
Kazu> > ダメでしょうか? > かずさん
Kazu> 
Kazu> こういう他人の迷惑を考えないもの(相手が読めない書式のこと、
Kazu> mew-caesar.el のことではない)は、基本的にサポートする気はありません。
Kazu> しかし、mew-caesar.el を contrib に入れるのは OK です。

というわけなので(このメールを読んだときは驚きましたが…)
新しい、mew-caesar.elをお届けします。

変更点は、
1. attachで"R"を押したとき、defineされているキーを忘れないように
オープニング画面(?)を出した。

2. バイトコンパイル出来るようにした。
 tmとSEMIと両方ロード出来る人はいないでしょう(?)からエラーが出ま
すが、実害は無いようです。

SUN-OS 5.4上のemacs19.28.1+tm、emacs20.2+SEMI、
Win95上のMule forWin32(1.22)+tmで動作確認をしました。

attachの"f"にあたるモノも実装しようかと思ったのですが、止めまし
た。青春はUターン禁止です。また、意味の無い多用も止めましょう。

### しかし、かずさんのコメントを読んだときは、冷汗たら〜〜りでし
### た。^^;;;

P.S.
attachの"F"や"f"でバッファをエディットした後、"\C-c\C-s"かなにか
のキーで save&kill-buffer(当然、y-or-nして)すると便利かなぁと思
うのですが、いかがなものでしょう?
必要性があるかどうか自信がありません。

-------------- next part --------------
;; -*- emacs-lisp -*-
;; mew-caesar.el --- Caesar encode/decode assistant package for Mew.
;;
;;                         "Hideyuki SHIRAI" <Shirai at example.com>
;;                                            Created: <02/07/1998>
;;                                Revised: Time-stamp: <02/18/1998 20:59:09>
;;
;; To use mew-caesar.el, install (tm|SEMI) package
;;  and put the following codes in your .emacs.
;;
;; (add-hook 'mew-init-hook
;;  	  (lambda ()
;;  	    (require 'mew-caesar)))
;;
;; (setq mew-caesar-use-tm t|nil)
;; ;;   caesar package select   t => tm:caesar-region
;; ;;                         nil => mule-caesar-region
;;

(eval-when-compile
  (require 'mew))

(defconst mew-caesar-version "mew-caesar.el 0.12")

(defvar mew-caesar-use-tm nil
  "nil require \"SEMI\", t require \"tm\".")

(defvar mew-caesar-prog-xrot '(mew-caesar-mime-text/x-rot () nil))
(defconst mew-caesar-ct-rot13 "Text/X-Rot13-47-48")
(defconst mew-caesar-rot13-suffix ".rot")

(define-key mew-summary-mode-map "\C-cr" 'mew-caesar-summary-insert-xrot)
(define-key mew-virtual-mode-map "\C-cr" 'mew-caesar-summary-insert-xrot)
(define-key mew-draft-attach-map "R" 'mew-caesar-attach-find-new-xrot)

(setq mew-mime-content-type-text-list
      (append
       '("Text/X-Rot13-47-48")
       mew-mime-content-type-text-list))

(setq mew-mime-content-type-list
      (append
       '("Text/X-Rot13-47-48")
       mew-mime-content-type-list))

(setq mew-mime-content-type
      (append
       '(("text/x-rot13-47-48" "\\.rot$" nil mew-caesar-prog-xrot mew-icon-text)
	 ("text/x-rot13.*" "\\.rot$" nil mew-caesar-prog-xrot mew-icon-text))
       mew-mime-content-type))

(defun mew-caesar-mime-text/x-rot (begin end &optional params)
  (if (> end begin)
      (save-excursion
	(set-buffer (mew-buffer-message))
	(let ((buffer-read-only nil))
	  (insert " #     #         ######  ####### #######    #     #####\n"
		  "  #   #          #     # #     #    #      ##    #     #\n"
		  "   # #           #     # #     #    #     # #          #\n"
		  "    #     #####  ######  #     #    #       #     #####\n"
		  "   # #           #   #   #     #    #       #          #\n"
		  "  #   #          #    #  #     #    #       #    #     #\n"
		  " #     #         #     # #######    #     #####   #####\n"
		  "\n")
	  (insert "To save this part, type "
		  (substitute-command-keys
		   "\\<mew-summary-mode-map>\\[mew-summary-save].")
		  "\nTo display this part in Message mode, type "
		  (substitute-command-keys
		   "\\<mew-summary-mode-map>\\[mew-caesar-summary-insert-xrot]."))
	  (insert "\n\n-------------------- Original \"X-ROT13\" follows --------------------\n")
	  (insert-buffer-substring (mew-current-get 'cache) begin end)
	  ))))

(defun mew-caesar-summary-insert-xrot ()
  (interactive)
  (let* ((ofld-msg (mew-current-get 'message))
	 (msg (mew-summary-message-number))
	 (part (mew-summary-part-number))
	 (buf (buffer-name)))
    (if (or msg (not part))
	(let ((mew-analysis nil))
	  (mew-summary-display))
      (unwind-protect
	  (progn
	    (mew-summary-toggle-disp-msg 'on)
	    (mew-window-configure buf 'message)
	    (set-buffer (mew-buffer-message))
	    (let* ((buffer-read-only nil)
		   (syntax (mew-cache-decode-syntax (mew-cache-hit ofld-msg)))
		   (stx (mew-syntax-get-entry-strnum syntax part))
		   (begin (mew-syntax-get-begin stx))
		   (end (mew-syntax-get-end stx)))
	      (erase-buffer)
	      (insert-buffer-substring (mew-current-get 'cache) begin end)
	      (goto-char (point-min))
	      (mew-caesar-whole-buffer)))
	(pop-to-buffer buf)))
    ))

(defun mew-caesar-attach-find-new-xrot ()
  "Open a new Caesar encoding file into a buffer on \".\" in attachments."
  (interactive)
  (if (not (mew-attach-not-line012-1))
      (message "Can't find a new file here.")
    (let* ((nums (mew-attach-nums))
	   (subdir (mew-attach-expand-path mew-encode-syntax nums))
	   (mimedir (mew-expand-folder (mew-draft-to-mime (buffer-name))))
	   file filepath)
      ;; mimedir / {subdir/} dir
      (if (not (equal subdir ""))
	  (setq mimedir (expand-file-name subdir mimedir)))
      ;; mimedir / file
      (setq filepath (mew-random-filename mimedir mew-caesar-rot13-suffix))
      (if (null filepath)
	  (message "Could not make a text file, sorry.")
	(setq file (file-name-nondirectory filepath))
	(setq mew-encode-syntax
	      (mew-syntax-insert-entry
	       mew-encode-syntax
	       nums
	       (mew-encode-syntax-single file (list mew-caesar-ct-rot13))))
	(mew-encode-syntax-print mew-encode-syntax)
	;;
	(find-file filepath)
	;; buffer switched
	(setq mode-name "X-Rot13")
	(setq mode-line-buffer-identification mew-mode-line-id)
	(local-set-key "\C-c\C-q" 'mew-kill-buffer)
	(local-set-key "\C-cr" 'mew-caesar-whole-buffer)
	(local-set-key "\C-c\C-s" 'mew-caesar-save-exit)
	(insert " #     #         ######  ####### #######    #     #####\n"
		"  #   #          #     # #     #    #      ##    #     #\n"
		"   # #           #     # #     #    #     # #          #\n"
		"    #     #####  ######  #     #    #       #     #####\n"
		"   # #           #   #   #     #    #       #          #\n"
		"  #   #          #    #  #     #    #       #    #     #\n"
		" #     #         #     # #######    #     #####   #####\n")
	(insert "\n define-key \"\\C-cr\"    -> mew-caesar-whole-buffer.")
	(insert "\n define-key \"\\C-c\\C-s\" -> mew-caesar-save-exit.")
	(insert "\n\n Press any key to start editting.")
	(read-char-exclusive)
	(delete-region (point-min) (point-max))
	))))

(defun mew-caesar-save-exit ()
  "Caesar encoding/decoding at whole buffer, save and exit."
  (interactive)
  (mew-caesar-whole-buffer)
  (if (y-or-n-p (format "Save & Exit ?"))
      (progn
	(save-buffer)
	(kill-buffer (current-buffer)))
    (mew-caesar-whole-buffer)))

(defun mew-caesar-whole-buffer ()
  "Caesar encoding/decoding at whole buffer."
  (interactive)
  (let ()
      (save-excursion
	(if mew-caesar-use-tm
	    (progn
	      (require 'tm-def)
	      (mark-whole-buffer)
	      (tm:caesar-region))
	  (progn
	    (require 'mule-caesar)
	    (mule-caesar-region (point-min) (point-max)))))))

(provide 'mew-caesar)
;;
-------------- next part --------------

-- 
+--------- 白井秀行 (Hideyuki SHIRAI) --------------+
 Organization: 松下電送(株) 技術研究所 第3研究室
       mailto: Shirai at example.com


Mew-win32 メーリングリストの案内