[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[mhc:02096] Re: Location: guess 時の全角半角変換



野口です。

白井さんありがとうございます。

From: Hideyuki SHIRAI (白井秀行) <shirai@xxxxxxxxxxxxx>
Subject: [mhc:02095] Re: Location: guess 時の全角半角変換
Date: Fri, 15 Apr 2005 17:49:37 +0900 (JST)

> よって、get-char-code-property() が返す値を変えれば良いのですが、
> それには、通常 put-char-code-property() を以下のように使います。
> 
> (put-char-code-property ?〜 'ascii nil)
> で、
> (get-char-code-property ?〜 'ascii) => nil
> となり、
> (japanese-hankaku "コミュニティホ〜ル" t) => "コミュニティホ〜ル"
> と変換されるようになります。

以下のようにしてみました。
とりあえず思い通りの動作をしています(どこかに副作用があるかもしれ
ませんが...)

(defcustom mhc-location-string-conversion 'no-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))
    (put-char-code-property ?ー 'ascii nil)
    (setq org-hankaku (cons (list "〜" (get-char-code-property ?〜 'ascii)) org-hankaku))
    (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 'no-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))
    (put-char-code-property ?ー 'ascii nil)
    (setq org-hankaku (cons (list "〜" (get-char-code-property ?〜 'ascii)) org-hankaku))
    (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>