;;; -*- Mode: Lisp; Package: editor -*- ;;; AkaiKKR-mode.l ;;; Version 0.0.2 ;;; Last modified 2013/02/02 ;; ;; インストール方法 ;; 1. AkaiKKR-mode.lを$XYZZY/site-lisp/にコピーします。 ;; 2. キーワードファイル AkaiKKR を$XYZZY/etc/にコピーします。 ;; 3. .xyzzy または siteinit.l に下記を追記します。 ;; (require "AkaiKKR-mode") ;; 4. 拡張子に応じて自動的にAkaiKKR-modeをロードしたければ下記も追記します。 ;; ;; 拡張子".in"のファイルを開いたときにAkaiKKR-modeをロード ;; (pushnew '("\\.in$" . AkaiKKR-mode) *auto-mode-alist* :test 'equal) ;; 5. 上記の設定を反映させるために、 xyzzy を再起動します。 ;; siteinit.l に記述した場合は xyzzy を再ダンプ後再起動します。 ;; ※ NetInstallerには対応していません。 ;; 拡張Lispインストールの一般論は ;; XyzzyWiki の clickable-uri のインストール方法 ;; http://xyzzy.s53.xrea.com/wiki/index.php?QuickTour%2Fext%2Fclickable-uri ;; あたりが参考になると思います。 ;; ;; 使い方 ;; インストール方法の4.の設定をしてあれば、ファイルを開くだけでロードされます。 ;; 手動でのロード方法は ;; M-x AkaiKKR-mode ;; ;; 更新履歴 ;; 2013/02/02 下記関数追加(Version 0.0.2) ;; Bloch spectrum function から gnuplotでE-k曲線を描くための下準備関数 ;; 2013/01/07 初版(Version 0.0.1) ;; ;;;カスタマイズしないらへん。 (provide "AkaiKKR-mode") ; フック (defvar *AkaiKKR-mode-hook* nil) ; キーマップ (defvar *AkaiKKR-mode-map* nil) (unless *AkaiKKR-mode-map* (setq *AkaiKKR-mode-map* (make-sparse-keymap))) ; キーワード (defvar *AkaiKKR-keyword-hash-table* nil) (defvar *AkaiKKR-keyword-file* "AkaiKKR") ; シンタックステーブル (defvar *AkaiKKR-mode-syntax-table* nil) (unless *AkaiKKR-mode-syntax-table* (setq *AkaiKKR-mode-syntax-table* (make-syntax-table)) (set-syntax-comment-column *AkaiKKR-mode-syntax-table* 0) (set-syntax-option *AkaiKKR-mode-syntax-table* *syntax-option-column-comment-char*) (set-syntax-start-column-comment *AkaiKKR-mode-syntax-table* #\#) (set-syntax-start-column-comment *AkaiKKR-mode-syntax-table* #\C) (set-syntax-start-column-comment *AkaiKKR-mode-syntax-table* #\c) (set-syntax-end-comment *AkaiKKR-mode-syntax-table* #\LFD)) ;;; -*- 関数本体 -*- (defun AkaiKKR-mode () (interactive) (kill-all-local-variables) (setq buffer-mode 'AkaiKKR-mode) (setq mode-name "AkaiKKR-mode") (use-keymap *AkaiKKR-mode-map*) (use-syntax-table *AkaiKKR-mode-syntax-table*) ; キーワードのロード (and *AkaiKKR-keyword-file* (null *AkaiKKR-keyword-hash-table*) (setq *AkaiKKR-keyword-hash-table* (load-keyword-file *AkaiKKR-keyword-file* t))) (when *AkaiKKR-keyword-hash-table* (make-local-variable 'keyword-hash-table) (setq keyword-hash-table *AkaiKKR-keyword-hash-table*)) ; フックの実行 (run-hooks '*AkaiKKR-mode-hook*)) ;;; Bloch spectrum function から gnuplotでE-k曲線を描くための下準備関数 (defun AkaiKKR-spc2ek () (interactive) (long-operation (let ((d 0) (x0 0) (y0 0) (z0 0) (x1 0) (y1 0) (z1 0)) (while (not (eobp)) (narrow-to-region (progn (goto-bol) (point)) (progn (goto-eol) (point))) (goto-bol) ;; 数値データ列のとき (if (re-search-forward "^ " t) (progn (insert (format nil "~E" d)) (widen)) ;; 波数ベクトルを探す (if (re-search-forward "# +k= +\\([0-9].[0-9]+\\) +\\([0-9].[0-9]+\\) +\\([0-9].[0-9]+\\)" t) (progn (setf x1 x0) (setf y1 y0) (setf z1 z0) (setf x0 (read-from-string (match-string 1))) (setf y0 (read-from-string (match-string 2))) (setf z0 (read-from-string (match-string 3))) (setf d (+ d (sqrt (+ (* (- x1 x0) (- x1 x0)) (* (- y1 y0) (- y1 y0)) (* (- z1 z0) (- z1 z0)))))) (widen)) ;; 最初のスピン状態 (if (re-search-forward "A(E,k) for spin =" t) (progn (widen) (re-search-forward "# +k= +\\([0-9].[0-9]+\\) +\\([0-9].[0-9]+\\) +\\([0-9].[0-9]+\\)" t) (setf x0 (read-from-string (match-string 1))) (setf y0 (read-from-string (match-string 2))) (setf z0 (read-from-string (match-string 3))) (setf d 0)) (widen)))) (forward-line) (goto-eol))))) ;; **************************************************************************** ;; ;; Copyright (c) 2013, Hitoshi Gomi ;; All rights reserved. ;; ;; Redistribution and use in source and binary forms, with or without ;; modification, are permitted provided that the following conditions are met: ;; ;; 1.Redistributions of source code must retain the above copyright notice, ;; this list of conditions and the following disclaimer. ;; 2.Redistributions in binary form must reproduce the above copyright notice, ;; this list of conditions and the following disclaimer in the documentation ;; and/or other materials provided with the distribution. ;; 3.The names of the author may not be used to endorse or promote products ;; derived from this software without specific prior written permission. ;; ;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" ;; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE ;; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ;; ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE ;; LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR ;; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF ;; SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS ;; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN ;; CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ;; ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE ;; POSSIBILITY OF SUCH DAMAGE. ;; ;; ****************************************************************************