[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[mhc:02098] Re: Location: guess 時の全角半角変換
野口です。
白井さん、ありとうございます。
# 興味の無い方、度々申し訳ありません。
From: Hideyuki SHIRAI (白井秀行) <shirai@xxxxxxxxxxxxx>
Subject: [mhc:02097] Re: Location: guess 時の全角半角変換
Date: Fri, 15 Apr 2005 20:00:47 +0900 (JST)
> ばぁぁと見ただけですが、こういうときは、unwind-protect() を使わ
> ないと危なそうですね。C-g はいつでも打てますから。
なるほど。
以下のような感じでしょうか。
(defcustom mhc-location-string-conversion 'dont-care
"Location character conversion. (Zenkaku or Hankaku)"
:group 'mhc
:type '(choice (const :tag "Dont Care" dont-care)
(const :tag "Hankaku" hankaku)
(const :tag "Zenkaku" zenkaku)))
(defun mhc-minibuf/location-to-string (location-cons)
(let ((loc (car location-cons))
(loc2 (cdr location-cons))
(org-hankaku ()))
(setq org-hankaku
(cons (list "ー" (get-char-code-property ?ー 'ascii)) org-hankaku))
(setq org-hankaku
(cons (list "〜" (get-char-code-property ?〜 'ascii)) org-hankaku))
(unwind-protect
(progn
(put-char-code-property ?ー 'ascii nil)
(put-char-code-property ?〜 'ascii nil)
(cond
((eq mhc-location-string-conversion 'hankaku)
(setq loc (japanese-hankaku loc 'ascii))
(if loc2
(setq loc2 (japanese-hankaku loc2 'ascii))))
((eq mhc-location-string-conversion 'zenkaku)
(setq loc (japanese-zenkaku loc))
(if loc2
(setq loc2 (japanese-zenkaku loc2))))
(t
)))
(put-char-code-property ?ー 'ascii (nth 1 (assoc "ー" org-hankaku)))
(put-char-code-property ?〜 'ascii (nth 1 (assoc "〜" org-hankaku))))
(if loc2
(concat
(format "%s" loc) "-" (format "%s" loc2))
(format "%s" loc))))
(defcustom mhc-subject-string-conversion 'dont-care
"Subject character conversion. (Zenkaku or Hankaku)"
:group 'mhc
:type '(choice (const :tag "Dont Care" dont-care)
(const :tag "Hankaku" hankaku)
(const :tag "Zenkaku" zenkaku)))
(defun mhc-input-subject (&optional prompt default)
(interactive)
(let ((org-hankaku ()) tmp-subj)
(setq org-hankaku
(cons (list "ー" (get-char-code-property ?ー 'ascii)) org-hankaku))
(setq org-hankaku
(cons (list "〜" (get-char-code-property ?〜 'ascii)) org-hankaku))
(unwind-protect
(progn
(put-char-code-property ?ー 'ascii nil)
(put-char-code-property ?〜 'ascii nil)
(if default
(cond
((eq mhc-subject-string-conversion 'hankaku)
(setq tmp-subj (japanese-hankaku default t)))
((eq mhc-subject-string-conversion 'zenkaku)
(setq tmp-subj (japanese-zenkaku default)))
(t
(setq tmp-subj default)))
(setq tmp-subj "")))
(put-char-code-property ?ー 'ascii (nth 1 (assoc "ー" org-hankaku)))
(put-char-code-property ?〜 'ascii (nth 1 (assoc "〜" org-hankaku))))
(read-from-minibuffer (or prompt "Subject: ")
tmp-subj
nil nil 'mhc-subject-hist)
))
--
NOGUCHI Yusuke <nogunogu@xxxxxxxxxxxxxxxxx>