From 0acb70b9354d379615ebad38c3a143103733808b Mon Sep 17 00:00:00 2001 From: j8takagi Date: Wed, 20 Feb 2013 23:27:34 +0900 Subject: [PATCH] =?utf8?q?=E3=82=B3=E3=83=A1=E3=83=B3=E3=83=88=E3=81=AE?= =?utf8?q?=E4=BF=AE=E6=AD=A3=E3=80=81=E3=83=97=E3=83=AD=E3=82=B0=E3=83=A9?= =?utf8?q?=E3=83=A0=E3=81=AE=E6=8E=A8=E6=95=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- exopen-mode.el | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/exopen-mode.el b/exopen-mode.el index 46aa2f1..3b74f8b 100644 --- a/exopen-mode.el +++ b/exopen-mode.el @@ -3,7 +3,7 @@ ;; Copyright (C) 2013 j8takagi ;; Author: j8takagi -;; Keywords: Emacs 外部プログラム +;; Keywords: Emacs external program 外部プログラム ;; This file is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by @@ -22,7 +22,7 @@ ;;; Commentary: -;; Emacsからの外部プログラム呼び出しを支援するマイナーモードです。 +;; Emacsからの外部プログラム呼び出しを支援するマイナーモード。 ;; ■動作環境 ;; Linux、Mac OS X、WindowsのいずれかのWindowシステム上 @@ -37,18 +37,23 @@ ;; Windowシステム上でEmacsが動作している場合、exopen-mode は自動的に有効になります。 ;; ;; ■使い方 - +;; exopen-modeが有効な場合、次の関数を使うことができます。 +;; +;; exopen-file (file) 外部ファイルを呼び出す +;; 標準で、C-x C-M-fにバインド ;; ■hook ;; マイナーモードの定義 - (easy-mmode-define-minor-mode exopen-mode - "minor mode for opening fle in external program." - ;; 初期値 -(display-graphic-p) - ;; モード行の表示 - "" - ;; マイナーモード用キーマップの初期値 - '(("\C-x\C-\M-f" . exopen-find-file))) +(define-minor-mode exopen-mode +"Toggle exopen-mode. +With a prefix argument ARG, enable Auto Composition mode if ARG +is positive, and disable it otherwise. If called from Lisp, +enable the mode if ARG is omitted or nil. + +open file in external program." +(display-graphic-p) ; Windowシステムかどうかの判定 +nil ; モード行に何も表示しない +'(("\C-x\C-\M-f" . exopen-find-file))) ; キーバインド ;; exopen-std-cmd: OSやWindowで設定された関連付けをもとに ;; ファイルを開くプログラムコマンド @@ -71,10 +76,12 @@ (let ((process-connection-type nil) (cmd)) (if exopen-suffix-cmd (setq cmd (cdr(assoc (file-name-extension file 1) exopen-suffix-cmd)))) - (if (null cmd) + (unless cmd (setq cmd exopen-std-cmd)) (start-process "exopen" nil cmd file) - (message (concat "exopen: " cmd " " file " at " (format-time-string "%Y/%m/%d %H:%M:%S" (current-time)))))) + (message + (concat "exopen: " cmd " " file " at " + (format-time-string "%Y/%m/%d %H:%M:%S" (current-time)))))) ;;; バッファで開いているファイルを外部プログラムでオープン (defun exopen-buffer-file () @@ -88,7 +95,7 @@ (defun exopen-buffer-file-suffix (suffix) "open buffer file of other extension in external program" (let (afile) - (if (not buffer-file-name) + (unless buffer-file-name (error "This buffer is not visiting a file")) (setq afile (concat (file-name-sans-extension (buffer-file-name)) suffix)) (if (file-exists-p afile) @@ -119,7 +126,7 @@ "open buffer file or find-file in external program" (interactive "P") (let ((afile)) - (if (null find-or-buffer) + (unless find-or-buffer (progn (setq afile (expand-file-name (read-file-name "Find external open file: " buffer-file-name))) -- 2.18.0