Skip to content

Instantly share code, notes, and snippets.

@ataka
Last active August 29, 2015 14:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ataka/58f740fda2b610fca82e to your computer and use it in GitHub Desktop.
Save ataka/58f740fda2b610fca82e to your computer and use it in GitHub Desktop.
convert-fudeo-2-hagaki-design

筆王からはがきデザインキットへ連絡帳をインポートする

対象とするはがきアプリのバージョンは以下の通りです:

  • 筆王 2003
  • はがきデザインキット 2015

はがきデザインキットのインポート

はがきデザインキット 2015 がサポートするインポート項目は次の通りです。

  • 氏名(姓)
  • 氏名(名)
  • フリガナ(姓)
  • フリガナ(名)
  • リスト表示用氏名
  • リスト表示用フリガナ
  • 郵便番号(自宅欄)
  • 自宅住所(都道府県)
  • 自宅住所(市区町村)
  • 自宅住所(番地等)
  • 自宅住所(建物名)
  • 会社名(会社欄)
  • 部署名1(会社欄)
  • 役職(会社欄)
  • 郵便番号(会社欄)
  • 会社住所(都道府県)
  • 会社住所(市区町村)
  • 会社住所(番地等)
  • 会社住所(建物名)
  • 敬称
  • 連名1(姓:自宅欄)
  • 連名1(名:自宅欄)
  • 連名1(姓名:自宅欄)
  • 連名1(敬称:自宅欄)
  • 連名2(姓:自宅欄)
  • 連名2(名:自宅欄)
  • 連名2(姓名:自宅欄)
  • 連名2(敬称:自宅欄)
  • 連名3(姓:自宅欄)
  • 連名3(名:自宅欄)
  • 連名3(姓名:自宅欄)
  • 連名3(敬称:自宅欄)
  • 連名4(姓:会社欄)
  • 連名4(名:会社欄)
  • 連名4(姓名:会社欄)
  • 連名4(敬称:会社欄)
  • 連名5(姓:会社欄)
  • 連名5(名:会社欄)
  • 連名5(姓名:会社欄)
  • 連名5(敬称:会社欄)
  • 連名6(姓:会社欄)
  • 連名6(名:会社欄)
  • 連名6(姓名:会社欄)
  • 連名6(敬称:会社欄)
  • カテゴリ
  • 送受履歴
;;; fudeo2hagaki-design.el --- Convert AddressBook from Fudeo to Hagaki Design
;; -*- Mode: Emacs-Lisp -*-
;; Copyright (C) 2014 Masayuki Ataka <masayuki.ataka@gmail.com>
;; Author: Masayuki Ataka <masayuki.ataka@gmail.com>
;; Keywords: tools, convenience
;; This file is not part of GNU Emacs.
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, you can either send email to this
;; program's maintainer or write to: The Free Software Foundation,
;; Inc.; 59 Temple Place, Suite 330; Boston, MA 02111-1307, USA.
;;; Code:
(defconst fudeo2hagaki-design-prefecture-names-list
'("北海道" "青森県" "岩手県" "宮城県" "秋田県" "山形県" "福島県" "茨城県" "栃木県" "群馬県" "埼玉県" "千葉県" "東京都" "神奈川県" "新潟県" "富山県" "石川県" "福井県" "山梨県" "長野県" "岐阜県" "静岡県" "愛知県" "三重県" "滋賀県" "京都府" "大阪府" "兵庫県" "奈良県" "和歌山県" "鳥取県" "島根県" "岡山県" "広島県" "山口県" "徳島県" "香川県" "愛媛県" "高知県" "福岡県" "佐賀県" "長崎県" "熊本県" "大分県" "宮崎県" "鹿児島県" "沖縄県")
"List of Japanese prefecture names")
(defconst fudeo2hagaki-design-zenkaku-space " "
"Zenkaku Space")
(defun fudeo2hagaki-design-convert-addressbook (beg end)
"Convert CSV AddressBook from Fudeo to Hagaki Design in region
Fudeo should export in following format:
1: Name
2: Kana
3: Zip Number
4: Address 1
5: Address 2
6: Address 3
7: Company
8: Department
9: Title
10: Joint Signature 1
11: Joint Signature 2
12: Joint Signature 3"
(interactive "r")
(save-excursion
(save-restriction
(narrow-to-region beg end)
(japanese-zenkaku-region beg end t)
(fudeo2hagaki-design-convert-name)
(fudeo2hagaki-design-convert-furigana)
(fudeo2hagaki-design-split-prefecture))))
(defun fudeo2hagaki-design-convert-name ()
(save-excursion
(goto-char (point-min))
(while (not (= (progn (end-of-line) (point)) (point-max)))
(forward-line 0)
(let ((beg (point))
(bound (search-forward "," nil t)))
(goto-char beg)
(fudeo2hagaki-design-convert-space-zenkaku-to-hankaku bound)
(fudeo2hagaki-design-replace-space-with-comma bound))
(forward-line 1))))
(defun fudeo2hagaki-design-convert-furigana ()
(save-excursion
(goto-char (point-min))
(while (not (= (progn (end-of-line) (point)) (point-max)))
(forward-line 0)
(search-forward "," nil t 2)
(let ((beg (point))
(bound (search-forward "," nil t)))
(goto-char beg)
(fudeo2hagaki-design-convert-space-zenkaku-to-hankaku bound)
(fudeo2hagaki-design-replace-space-with-comma bound))
(forward-line 1))))
(defsubst fudeo2hagaki-design-convert-space-zenkaku-to-hankaku (bound)
(save-excursion
(when (search-forward fudeo2hagaki-design-zenkaku-space bound t)
(replace-match " "))))
(defsubst fudeo2hagaki-design-replace-space-with-comma (bound)
(when (re-search-forward " +" bound t)
(replace-match "\",\"")))
(defun fudeo2hagaki-design-split-prefecture ()
(save-excursion
(let ((prefecture-regexp (regexp-opt fudeo2hagaki-design-prefecture-names-list)))
(goto-char (point-min))
(while (not (= (progn (end-of-line) (point)) (point-max)))
(forward-line 0)
(search-forward "," nil t 5)
(let ((beg (point))
(bound (search-forward "," nil t)))
(goto-char beg)
(re-search-forward prefecture-regexp bound t)
(insert "\",\""))
(forward-line 1)))))
(provide 'fudeo2hagaki-design.el)
;;; fudeo2hagaki-design.el ends here
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment