yatex

changeset 392:c44910b36b95 dev

Switch to region-mode if completion called with active region.
author HIROSE Yuuji <yuuji@gentei.org>
date Thu, 15 Jan 2015 23:21:24 +0900
parents e834bbfce2ab
children 318841b09570
files docs/yatexe.tex docs/yatexj.tex yahtml.el yatex.el yatex.new yatexlib.el
diffstat 6 files changed, 215 insertions(+), 154 deletions(-) [+]
line diff
     1.1 --- a/docs/yatexe.tex	Thu Jan 15 23:20:31 2015 +0900
     1.2 +++ b/docs/yatexe.tex	Thu Jan 15 23:21:24 2015 +0900
     1.3 @@ -8,7 +8,7 @@
     1.4  
     1.5  @iftex
     1.6  @c @syncodeindex fn cp
     1.7 -@c Last modified Sun Jan  4 18:17:02 2015 on firestorm
     1.8 +@c Last modified Thu Jan 15 13:28:10 2015 on firestorm
     1.9  @syncodeindex vr cp
    1.10  @end iftex
    1.11  
    1.12 @@ -77,7 +77,7 @@
    1.13          @code{\section} etc. 
    1.14          (@kbd{C-c b}, @kbd{C-c s}, @kbd{C-c l}, @kbd{C-c m})
    1.15  @item Enclosing text into La@TeX{} environments or commands
    1.16 -      (@kbd{C-u} @var{AboveKeyStrokes})
    1.17 +      (@var{AboveKeyStrokes} after region setting)
    1.18  @item Displaying the structure of text at entering sectioning commands
    1.19  @item Lump shifting of sectioning commands (@ref{view-sectioning})
    1.20  @item Learning unknown/new La@TeX{} commands for the next completion
    1.21 @@ -146,12 +146,12 @@
    1.22  
    1.23  @table @kbd
    1.24  @item [prefix] t j
    1.25 -        @dots{} invoke latex
    1.26 +        @dots{} invoke typesetter
    1.27  @item [prefix] t r
    1.28 -        @dots{} invoke latex on region
    1.29 +        @dots{} invoke typesetter on region
    1.30  @item [prefix] t e
    1.31 -        @dots{} invoke latex on current environment or whole
    1.32 -         portion of current formulas in math-mode.
    1.33 +        @dots{} `on-the-fly preview' on current environment or whole
    1.34 +         portion of current formulas in math-mode
    1.35  @item [prefix] t d
    1.36  	@dots{} invoke dvipdfmx after successful typesetting
    1.37  @item [prefix] t k
    1.38 @@ -215,9 +215,16 @@
    1.39  edit splitting files.
    1.40  
    1.41    The @kbd{[prefix] te} key automatically marks current inner environment
    1.42 -or inner math mode and then call typeset-region with marked region.  This
    1.43 +or inner math mode or paragraph, and then call typeset-region with marked
    1.44 +region.  This
    1.45  is convenient to quick view of current tabular environment or current
    1.46 -editing formulas.  Keeping previewer window for @file{texput.dvi} is handy
    1.47 +editing formulas.  If running Emacs has the ability of displaying images,
    1.48 +typeset image will be shown in the next window.  Further more,
    1.49 +if you modify the content within that environment, YaTeX performs
    1.50 +`on-the-fly' preview that automatically update preview image as you typed.
    1.51 +
    1.52 +If your Emacs does not supply on-the-fly preview,
    1.53 +keeping previewer window for @file{texput.dvi} is handy
    1.54  for debugging.  Since @kbd{[prefix] te} selects the inner-most environment
    1.55  as region, it is not suitable for partial typesetting of doubly or more
    1.56  composed environment.  If you want to do partial typesetting for a nested
    1.57 @@ -369,7 +376,7 @@
    1.58  @code{%#BEGIN} alone at the middle of very long text.  Do not forget to
    1.59  erase @code{%#BEGIN} @code{%#END} pair.
    1.60  
    1.61 -@node Lpr format, Controlling which command to invoke, Static region for typesetting, %#notation
    1.62 +@node Lpr format,  , Static region for typesetting, %#notation
    1.63  @comment  node-name,  next,  previous,  up
    1.64  @section Lpr format
    1.65  @cindex lpr format
    1.66 @@ -464,15 +471,16 @@
    1.67  kinds of completion type, begin-type, section-type, large-type, etc...
    1.68  
    1.69  @menu
    1.70 -* Begin-type completion::       
    1.71 -* Section-type completion::     
    1.72 -* Large-type completion::       
    1.73 -* Maketitle-type completion::   
    1.74 -* Arbitrary completion::        
    1.75 -* End completion::              
    1.76 -* Accent completion::           
    1.77 -* Image completion::            
    1.78 -* Greek letters completion::    
    1.79 +* Begin-type completion::
    1.80 +* Section-type completion::
    1.81 +* Large-type completion::
    1.82 +* Maketitle-type completion::
    1.83 +* Arbitrary completion::
    1.84 +* End completion::
    1.85 +* Accent completion::
    1.86 +* Image completion::
    1.87 +* Greek letters completion::
    1.88 +* Inserting parentheses::
    1.89  @end menu
    1.90  
    1.91  @node Begin-type completion, Section-type completion, Completion, Completion
    1.92 @@ -559,26 +567,15 @@
    1.93  automatically inserted such as @code{\item} for @code{itemize}
    1.94  environment.  If you don't want the entry, it can be removed by undoing.
    1.95  
    1.96 -  If you want to  enclose some paragraphs  which have already been
    1.97 -written, invoke the  begin-type completion with changing  the case
    1.98 -of @kbd{b} of key sequence upper(or invoke it with  universal argument
    1.99 -by @kbd{C-u} prefix).
   1.100 +  If you want to enclose some paragraphs which have already been written
   1.101 +into environment, invoke the begin-type completion right after region marking.
   1.102  @cindex enclose region into environment
   1.103  
   1.104 -  The following example encloses a region with `description'
   1.105 -environment.
   1.106 -
   1.107 -@table @kbd
   1.108 -@item [prefix] B D
   1.109 -@itemx (or ESC 1 [prefix] b D)
   1.110 -@itemx (or  C-u  [prefix] b D)
   1.111 -
   1.112 -        @dots{} begin-type completion for region
   1.113 -@end table
   1.114 -
   1.115 -  This enclosing holds good for the completing input by @kbd{[prefix] b
   1.116 -SPC}.  @kbd{[prefix] B SPC} enclose a region with the environment selected
   1.117 -by completing-read.
   1.118 +If you set @code{transient-mark-mode} to @code{nil} in your
   1.119 +@file{~/.emacs},  typing @kbd{C-space} (@code{set-mark-command}) twice
   1.120 +turns @code{transient-mark-mode} on temporarily.  Then, type call
   1.121 +begin-type completion to enclose text into a environment.
   1.122 +
   1.123  
   1.124  @node Section-type completion, Large-type completion, Begin-type completion, Completion
   1.125  @comment  node-name,  next,  previous,  up
   1.126 @@ -755,9 +752,8 @@
   1.127  TeX commands to change fonts or sizes, @code{it}, @code{huge} and so on,
   1.128  in the completion table.
   1.129  
   1.130 -  Region-based completion is also invoked by changing the letter after
   1.131 -prefix key stroke as @kbd{[prefix] L}.  It encloses the region by braces
   1.132 -with large-type command.
   1.133 +  Region-based completion is also invoked by calling completion
   1.134 +after region activated.
   1.135  
   1.136  @node Maketitle-type completion, Arbitrary completion, Large-type completion, Completion
   1.137  @comment  node-name,  next,  previous,  up
   1.138 @@ -912,7 +908,7 @@
   1.139  Emacs-Lisp variable @code{YaTeX-math-sign-alist-private}.  See also
   1.140  @file{yatexmth.el} for the information of the structure of this variable.
   1.141  
   1.142 -@node Greek letters completion,  , Image completion, Completion
   1.143 +@node Greek letters completion, Inserting parentheses, Image completion, Completion
   1.144  @comment  node-name,  next,  previous,  up
   1.145  @section Greek letters completion
   1.146  @cindex Greek letters completion
   1.147 @@ -930,6 +926,15 @@
   1.148  @kbd{;} or @kbd{:} after universal-argument(@kbd{C-u}) which forces
   1.149  @kbd{;} and @kbd{:} to work as math-prefix.
   1.150  
   1.151 +@node Inserting parentheses,  , Greek letters completion, Completion
   1.152 +@section Inserting parentheses
   1.153 +
   1.154 +  Typing opening parenthesis, one of @code{(}, @code{@{ and @code{[}},
   1.155 +automatically inserts the closing one.  If a opening bracket is typed
   1.156 +after @code{\}, @code{\]} is automatically inserted with computed
   1.157 +indentation.  If you stop automatic insertion, type @kbd{C-q} before
   1.158 +opening parenthesis.
   1.159 +
   1.160  @node Local dictionaries, Commenting out, Completion, Top
   1.161  @comment  node-name,  next,  previous,  up
   1.162  @chapter Local dictionaries
   1.163 @@ -1700,6 +1705,16 @@
   1.164  @code{Nil} disables on-the-fly preview.
   1.165  @end defvar
   1.166  
   1.167 +@defvar YaTeX-on-the-fly-math-preview-engine
   1.168 +Function symbol to use on-the-fly preview of MATH environment
   1.169 +started by @kbd{[prefix] t e} (@code{'YaTeX-typeset-environment-by-lmp}
   1.170 +which calls latex-math-preview-expression function if latex-math-preview
   1.171 +is available, otherwise @code{'YaTeX-typeset-environment-by-builtin} which
   1.172 +alls built-in function).
   1.173 +
   1.174 +@code{Nil} disables on-the-fly preview.
   1.175 +@end defvar
   1.176 +
   1.177  @defvar YaTeX-cmd-gimp
   1.178  Command name of GIMP (code{"gimp"})
   1.179  @end defvar
     2.1 --- a/docs/yatexj.tex	Thu Jan 15 23:20:31 2015 +0900
     2.2 +++ b/docs/yatexj.tex	Thu Jan 15 23:21:24 2015 +0900
     2.3 @@ -13,7 +13,7 @@
     2.4  @c ノードいじったら C-l C-u C-n 全部のノード更新 C-l C-u C-e
     2.5  @c メニュー増やしたら C-l C-u C-m 全部のメニュー更新 C-l C-u C-a
     2.6  @c フォーマットするときは C-l C-e C-b
     2.7 -@c Last modified Sun Jan  4 18:15:05 2015 on firestorm
     2.8 +@c Last modified Thu Jan 15 12:42:54 2015 on firestorm
     2.9  @syncodeindex vr cp
    2.10  @end iftex
    2.11  
    2.12 @@ -124,7 +124,7 @@
    2.13  コマンドの補完入力
    2.14  (@kbd{C-c b}, @kbd{C-c s}, @kbd{C-c l}, @kbd{C-c m})
    2.15  @item 既に入力したテキストを環境やコマンド引数の中に取り込む括り補完
    2.16 -(@kbd{C-u} +通常補完キー)
    2.17 +(リジョン指定後に通常補完キー)
    2.18  @item セクション区切り入力時の文書構造アウトライン表示
    2.19  @item セクションコマンドの一括シフト (@ref{view-sectioning})
    2.20  @item 補完辞書の学習
    2.21 @@ -228,8 +228,9 @@
    2.22  @item [prefix] t r
    2.23          @dots{} タイプセッタ起動(領域指定)
    2.24  @item [prefix] t e
    2.25 -        @dots{} タイプセッタ起動
    2.26 -        (ポイント位置の環境または数式モードのみ対象)
    2.27 +        @dots{} 部分タイプセット&プレヴュー
    2.28 +        (ポイント位置の段落、環境または数式モードのみをタイプセットして
    2.29 +        隣のバッファに組版結果の画像を出す)
    2.30  @item [prefix] t k
    2.31          @dots{} 動作中のタイプセッタの停止
    2.32  @item [prefix] t b
    2.33 @@ -296,11 +297,20 @@
    2.34  @subsection 環境タイプセット
    2.35  
    2.36    @kbd{[prefix] te} を押すと、ポイント位置の最も内側の環境、または数式モー
    2.37 -ド内の場合はその数式モード全体が自動的に領域選択されて、領域タイプセットを
    2.38 -呼び出します。tabular環境や数式モードで複雑なものを作っている場合は確かめた
    2.39 -い部分だけを確認できるので便利です。これも @file{texput.tex} に該当部分を
    2.40 -書き出します。プレヴューアで @file{texput.dvi} を開いたままにしておけば
    2.41 -修正と確認が素早くできるでしょう。
    2.42 +ド内の場合はその数式モード全体、あるいは環境がなければその段落が自動的に
    2.43 +領域選択されて、領域タイプセットを呼び出します。
    2.44 +tabular環境や数式モードで複雑なものを作っている場合は確かめたい部分だけを
    2.45 +確認できるので便利です。Emacsが画像表示可能な場合は、
    2.46 +部分タイプセットの結果を画像化して隣のウィンドウに表示します。また、
    2.47 +特定の環境で呼び出した場合は、環境内の文字を書き換える度に自動的に
    2.48 +プレビュー画像を更新します(on-the-flyプレヴュー)。
    2.49 +自動表示されない場合はプレヴューアで @file{texput.dvi}
    2.50 +を開いたままにしておけば修正と確認が素早くできるでしょう。
    2.51 +
    2.52 +  画像プレヴューの場合の大きさ(解像度)はデフォルトで200dpi(数式は300dpi)です。
    2.53 +dpiを変えたい場合はLaTeXソースのどこかに
    2.54 +@code{%#PREVIEWDPI 150}
    2.55 +のようにdpi値を書いてください。
    2.56  
    2.57  @node Calling previewer, Print out, Calling typesetter, Invocation
    2.58  @comment  node-name,  next,  previous,  up
    2.59 @@ -570,15 +580,16 @@
    2.60  ができます。
    2.61  
    2.62  @menu
    2.63 -* begin型補完::                 
    2.64 -* section型補完::               
    2.65 -* large型補完::                 
    2.66 -* maketitle型補完::             
    2.67 +* begin型補完::
    2.68 +* section型補完::
    2.69 +* large型補完::
    2.70 +* maketitle型補完::
    2.71  * Arbitrary completion::        随時補完
    2.72 -* end補完::                     
    2.73 +* end補完::
    2.74  * Accent mark completion::      アクセント記号補完
    2.75  * Image completion::            数式記号イメージ補完
    2.76  * Greek letter completion::     ギリシャ文字補完
    2.77 +* Inserting parens::
    2.78  @end menu
    2.79  
    2.80  @node begin型補完, section型補完, Completion, Completion
    2.81 @@ -678,17 +689,19 @@
    2.82  @cindex 閉じ込める[としこめる]
    2.83  
    2.84    例えばあるパラグラフを description 環境の中に入れたいときは、
    2.85 -そのパラグラフをマークしてから、
    2.86 -
    2.87 -@table @kbd
    2.88 -@item [prefix] B D
    2.89 -@itemx (または ESC 1 [prefix] b D)
    2.90 -@itemx (または  C-u  [prefix] b D など)
    2.91 -@end table
    2.92 -
    2.93 -とタイプしてください。これは、@kbd{[prefix] b SPC}の補完入力にもあてはまり、
    2.94 -@kbd{b} を大文字に変えて、@kbd{[prefix] B SPC} とタイプすれば、あらかじめ
    2.95 -マークしておいたリジョンを、begin と end の環境で括ります。
    2.96 +そのパラグラフをマークしてから、補完機能を呼び出してください(description
    2.97 +環境の場合は @kbd{[prefix] b D})。
    2.98 +
    2.99 +選択された領域を括ります。ただしこれは @code{transient-mark-mode} が t
   2.100 +(Emacsの標準)になっている場合のみで、普段
   2.101 +@code{transient-mark-mode} を @code{nil} にしている場合は、
   2.102 +補完キー前に @code{universal-argument} 指定(@kbd{C-u})
   2.103 +をタイプしてから @kbd{[prefix] b D} など、補完キーを
   2.104 +タイプすれば括り補完になります。
   2.105 +なおEmacs22以降であれば @code{transient-mark-mode} 無効時も
   2.106 +@code{set-mark-command} (@kbd{C-space})の連打で一時的に
   2.107 +@code{transient-mark-mode} が有効になります。
   2.108 +
   2.109  
   2.110  @node section型補完, large型補完, begin型補完, Completion
   2.111  @comment  node-name,  next,  previous,  up
   2.112 @@ -801,8 +814,11 @@
   2.113  @subsection 既に書いたテキストを括る
   2.114  @cindex 括る[くくる]
   2.115  
   2.116 -  また、起動コマンドの@kbd{s}を大文字に変えて起動すると、あらかじめ書
   2.117 -いた文章を section 型コマンドの第一引数として括ります。
   2.118 +  また、section型補完機能の呼び出し時に領域選択状態にしておくと
   2.119 +領域内のテキストを section 型コマンドの第一引数として括ります。
   2.120 +これも普段 @code{transient-mark-mode} を @code{nil} にしている場合は
   2.121 +@kbd{C-u} のあとに補完キーをタイプすれば強制的に括り補完になります。
   2.122 +
   2.123  
   2.124  @node Recursive completion, view-sectioning, Enclose section-type command, section型補完
   2.125  @comment  node-name,  next,  previous,  up
   2.126 @@ -911,8 +927,7 @@
   2.127  
   2.128    また、begin型補完の時と同様、先に書いてしまった一連の文章の文字のサイズ
   2.129  を変えたいと思う時がありますが、そのような時は、サイズや大きさを変えたい文
   2.130 -字の範囲をマークしてから、呼び出しキーを @kbd{[prefix] L} と、大文字の L 
   2.131 -に変えて呼び出せば、そのリジョン全体が、ブレースで囲まれます。
   2.132 +字の範囲をマークしてからlarge型補完を呼んでください。
   2.133  
   2.134  @node maketitle型補完, Arbitrary completion, large型補完, Completion
   2.135  @comment  node-name,  next,  previous,  up
   2.136 @@ -1082,7 +1097,7 @@
   2.137  照してください。
   2.138  @cindex YaTeX-math-sign-alist-private
   2.139  
   2.140 -@node Greek letter completion,  , Image completion, Completion
   2.141 +@node Greek letter completion, Inserting parens, Image completion, Completion
   2.142  @comment  node-name,  next,  previous,  up
   2.143  @section ギリシャ文字補完
   2.144  @cindex ギリシャ文字補完[きりしやもしほかん]
   2.145 @@ -1100,6 +1115,18 @@
   2.146  とにより、強制的にイメージ補完に入ることができます。また、この時にどのよう
   2.147  な状態で数式環境内判定に失敗したかをご連絡下さい。
   2.148  
   2.149 +@node Inserting parens,  , Greek letter completion, Completion
   2.150 +@section 括弧入力補助
   2.151 +@cindex 括弧入力補助[かつこにゆうりよくほしよ]
   2.152 +
   2.153 +  3種類ある括弧 () {} [] の開き括弧を入れたときに閉じ括弧を自動的に入れます。
   2.154 +@code{\} の直後にの @code{[} を入れると行を分けてインデントを揃え、
   2.155 +数式入力に備えます。その他 La@TeX{} のマクロに応じて括弧の釣合の取れた
   2.156 +状態に導きます。開き括弧そのものを1つだけ入れたいときは @kbd{C-q} で
   2.157 +クォート入力するか、@kbd{[prefix] w m} で修正モードをOFFにしてください。
   2.158 +
   2.159 +  領域選択してから開き括弧を入れるとその領域をその種類の括弧で括ります。
   2.160 +
   2.161  @node Local dictionary, Commenting out, Completion, Top
   2.162  @comment  node-name,  next,  previous,  up
   2.163  @chapter ローカル辞書
   2.164 @@ -1898,11 +1925,18 @@
   2.165  @end defvar
   2.166  
   2.167  @defvar YaTeX-on-the-fly-preview-interval
   2.168 -@kbd{[prefix] t e}で環境即時プレヴューをする場合の変換処理までの
   2.169 +@kbd{[prefix] t e}で環境即時previewをする場合の変換処理までの
   2.170  無操作時間(秒) (0.9)
   2.171  @code{nil} の場合は即時プレヴューをしない。
   2.172  @end defvar
   2.173  
   2.174 +@defvar YaTeX-on-the-fly-math-preview-engine
   2.175 +@kbd{[prefix] t e}で数式環境を即時previewする時に用いるエンジン
   2.176 +(latex-math-previewが利用可能なときは latex-math-preview-expression を呼ぶ
   2.177 +@code{'YaTeX-typeset-environment-by-lmp}
   2.178 +そうでないときは内蔵関数を呼ぶ @code{'YaTeX-typeset-environment-by-builtin})
   2.179 +@end defvar
   2.180 +
   2.181  @defvar YaTeX-cmd-gimp
   2.182  GIMPを起動するコマンド (code{"gimp"})
   2.183  @end defvar
     3.1 --- a/yahtml.el	Thu Jan 15 23:20:31 2015 +0900
     3.2 +++ b/yahtml.el	Thu Jan 15 23:21:24 2015 +0900
     3.3 @@ -1,6 +1,6 @@
     3.4  ;;; yahtml.el --- Yet Another HTML mode -*- coding: sjis -*-
     3.5  ;;; (c) 1994-2013 by HIROSE Yuuji [yuuji(@)yatex.org]
     3.6 -;;; Last modified Mon Dec 22 22:17:24 2014 on firestorm
     3.7 +;;; Last modified Thu Jan 15 11:34:59 2015 on firestorm
     3.8  ;;; $Id$
     3.9  
    3.10  (defconst yahtml-revision-number "1.77"
    3.11 @@ -830,7 +830,8 @@
    3.12  (defun yahtml-insert-begend (&optional region env)
    3.13    "Insert <cmd> ... </cmd>."
    3.14    (interactive "P")
    3.15 -  (setq yahtml-current-completion-type 'multiline)
    3.16 +  (setq yahtml-current-completion-type 'multiline
    3.17 +	region (or region (YaTeX-region-active-p)))
    3.18    (let*((completion-ignore-case t)
    3.19  	(cmd
    3.20  	 (or env
    3.21 @@ -1646,7 +1647,8 @@
    3.22  (defun yahtml-insert-tag (region-mode &optional tag)
    3.23    "Insert <TAG> </TAG> and put cursor inside of them."
    3.24    (interactive "P")
    3.25 -  (setq yahtml-current-completion-type 'inline)
    3.26 +  (setq yahtml-current-completion-type 'inline
    3.27 +	region-mode (or region-mode (YaTeX-region-active-p)))
    3.28    (or tag
    3.29        (let ((completion-ignore-case t))
    3.30  	(setq tag
    3.31 @@ -2493,13 +2495,6 @@
    3.32  		    (match-beginning 0))))
    3.33  	(fset 'move-to-column yahtml-saved-move-to-column)))))
    3.34  
    3.35 -;(defun yahtml-indent-new-commnet-line ()
    3.36 -;  (unwind-protect
    3.37 -;      (progn
    3.38 -;	(fset 'move-to-column 'yahtml-move-to-column)
    3.39 -;	(apply 'YaTeX-saved-indent-new-comment-line (if soft (list soft))))
    3.40 -;    (fset 'move-to-column yahtml-saved-move-to-column)))
    3.41 -
    3.42  ;;;
    3.43  ;;; ---------- move forward/backward field ----------
    3.44  ;;;
     4.1 --- a/yatex.el	Thu Jan 15 23:20:31 2015 +0900
     4.2 +++ b/yatex.el	Thu Jan 15 23:21:24 2015 +0900
     4.3 @@ -1,6 +1,6 @@
     4.4  ;;; yatex.el --- Yet Another tex-mode for emacs //野鳥// -*- coding: sjis -*-
     4.5  ;;; (c)1991-2015 by HIROSE Yuuji.[yuuji@yatex.org]
     4.6 -;;; Last modified Thu Jan 15 10:42:01 2015 on firestorm
     4.7 +;;; Last modified Thu Jan 15 23:15:51 2015 on firestorm
     4.8  ;;; $Id$
     4.9  ;;; The latest version of this software is always available at;
    4.10  ;;; http://www.yatex.org/
    4.11 @@ -8,7 +8,7 @@
    4.12  ;;; Code:
    4.13  (require 'comment)
    4.14  (require 'yatexlib)
    4.15 -(defconst YaTeX-revision-number "1.78.5"
    4.16 +(defconst YaTeX-revision-number "1.78.6"
    4.17    "Revision number of running yatex.el")
    4.18  
    4.19  ;---------- Local variables ----------
    4.20 @@ -864,16 +864,18 @@
    4.21  you can put REGION into that environment between \\begin and \\end."
    4.22    (interactive "P")
    4.23    (let*
    4.24 -      ((mode (if arg " region" ""))
    4.25 +      ((region-p (or arg (YaTeX-region-active-p)))
    4.26 +       (mode (if region-p " region" ""))
    4.27         (env
    4.28 -	(YaTeX-read-environment
    4.29 -	 (format "Begin environment%s(default %s): " mode YaTeX-env-name))))
    4.30 +	(save-excursion		;for Emacs24 work-around to avoid point warp 
    4.31 +	  (YaTeX-read-environment
    4.32 +	   (format "Begin environment%s(default %s): " mode YaTeX-env-name)))))
    4.33      (if (string= env "")
    4.34  	(setq env YaTeX-env-name))
    4.35      (setq YaTeX-env-name env)
    4.36      (YaTeX-update-table
    4.37       (list YaTeX-env-name) 'env-table 'user-env-table 'tmp-env-table)
    4.38 -    (YaTeX-insert-begin-end YaTeX-env-name arg)))
    4.39 +    (YaTeX-insert-begin-end YaTeX-env-name region-p)))
    4.40  
    4.41  (defun YaTeX-make-begin-end-region ()
    4.42    "Call YaTeX-make-begin-end with ARG to specify region mode."
    4.43 @@ -928,7 +930,8 @@
    4.44  Optional 4th arg CMD is LaTeX command name, for non-interactive use."
    4.45    (interactive "P")
    4.46    (setq YaTeX-current-completion-type 'section)
    4.47 -  (if (equal arg '(4)) (setq beg (region-beginning) end (region-end)))
    4.48 +  (if (or (equal arg '(4)) (YaTeX-region-active-p))
    4.49 +      (setq beg (region-beginning) end (region-end)))
    4.50    (unwind-protect
    4.51        (let*
    4.52  	  ((source-window (selected-window))
    4.53 @@ -1028,7 +1031,9 @@
    4.54  \(key binding for universal-argument is \\[universal-argument]\)"
    4.55    (interactive "P")
    4.56    (YaTeX-sync-local-table 'tmp-fontsize-table)
    4.57 -  (let* ((mode (if arg "region" ""))
    4.58 +  (let* ((region-p (if (or arg (YaTeX-region-active-p))
    4.59 +		       (cons (region-beginning) (region-end))))
    4.60 +	 (mode (if region-p "region" ""))
    4.61  	 (fontsize
    4.62  	  (or fontsize
    4.63  	      (YaTeX-read-fontsize
    4.64 @@ -1050,12 +1055,14 @@
    4.65  	 (setq fontsize
    4.66  	       (cdr (assoc YaTeX-fontsize-name LaTeX2e-fontstyle-alist)))
    4.67  	 (setq YaTeX-fontsize-name fontsize))
    4.68 -    (if arg
    4.69 -	(save-excursion
    4.70 -	  (if (> (point) (mark)) (exchange-point-and-mark))
    4.71 +    (if region-p
    4.72 +	(let ((b (car region-p))
    4.73 +	      (e (set-marker (make-marker) (cdr region-p))))
    4.74 +	  (goto-char b)
    4.75  	  (insert "{\\" YaTeX-fontsize-name " ")
    4.76 -	  (exchange-point-and-mark)
    4.77 -	  (insert "}"))
    4.78 + 	  (goto-char e)
    4.79 +	  (insert "}")
    4.80 +	  (set-marker e nil))
    4.81        (insert (concat "{\\" YaTeX-fontsize-name " }"))
    4.82        (forward-char -1)
    4.83        (if YaTeX-current-position-register
    4.84 @@ -1267,7 +1274,7 @@
    4.85  			  (get 'YaTeX-insert-braces 'begend-guide)))))))))
    4.86  	env macro not-literal b e)
    4.87      (cond
    4.88 -     ((and (fboundp 'region-active-p) (region-active-p))
    4.89 +     ((YaTeX-region-active-p)
    4.90        (YaTeX-insert-braces-region (region-beginning) (region-end)))
    4.91       ((YaTeX-jmode) (YaTeX-self-insert arg))
    4.92       ((not (YaTeX-closable-p)) (YaTeX-self-insert arg))
    4.93 @@ -1388,6 +1395,8 @@
    4.94    (interactive "p")
    4.95    (let ((col (1- (current-column))))
    4.96      (cond
    4.97 +     ((YaTeX-region-active-p)
    4.98 +      (YaTeX-insert-brackets-region (region-beginning) (region-end)))
    4.99       ((YaTeX-jmode) (YaTeX-self-insert arg))
   4.100       ((not (YaTeX-closable-p))
   4.101        (YaTeX-self-insert arg))
   4.102 @@ -1434,6 +1443,8 @@
   4.103    "Insert parenthesis pair."
   4.104    (interactive "p")
   4.105    (cond
   4.106 +   ((YaTeX-region-active-p)
   4.107 +    (YaTeX-insert-parens-region (region-beginning) (region-end)))
   4.108     ((YaTeX-jmode) (YaTeX-self-insert arg))
   4.109     ((not (YaTeX-closable-p)) (YaTeX-self-insert arg))
   4.110     ((save-excursion
   4.111 @@ -2668,64 +2679,6 @@
   4.112  		      YaTeX-verbatim-environments))))))
   4.113        (store-match-data md))))
   4.114  
   4.115 -(defun YaTeX-in-environment-p (env)
   4.116 -  "Return if current LaTeX environment is ENV.
   4.117 -ENV is given in the form of environment's name or its list."
   4.118 -  (let ((md (match-data)) (nest 0) p envrx)
   4.119 -    (cond
   4.120 -     ((atom env)
   4.121 -      (setq envrx
   4.122 -	    (concat "\\("
   4.123 -		    (regexp-quote
   4.124 -		     (YaTeX-replace-format-args
   4.125 -		      YaTeX-struct-begin env "" ""))
   4.126 -		    "\\>\\)\\|\\("
   4.127 -		    (regexp-quote
   4.128 -		     (YaTeX-replace-format-args
   4.129 -		      YaTeX-struct-end env "" ""))
   4.130 -		    "\\)"))
   4.131 -      (save-excursion
   4.132 -	(setq p (catch 'open
   4.133 -		  (while (YaTeX-re-search-active-backward
   4.134 -			  envrx YaTeX-comment-prefix nil t)
   4.135 -		    (if (match-beginning 2)
   4.136 -			(setq nest (1+ nest))
   4.137 -		      (setq nest (1- nest)))
   4.138 -		    (if (< nest 0)
   4.139 -			(throw 'open (cons env (match-beginning 0)))))))))
   4.140 -     ((listp env)
   4.141 -      (setq p
   4.142 -	    (or (YaTeX-in-environment-p (car env))
   4.143 -		(and (cdr env) (YaTeX-in-environment-p (cdr env)))))))
   4.144 -    (store-match-data md)
   4.145 -    p;(or p (YaTeX-in-verb-p (match-beginning 0)))
   4.146 -    ))
   4.147 -
   4.148 -(defun YaTeX-quick-in-environment-p (env)
   4.149 -  "Check quickly but unsure if current environment is ENV.
   4.150 -ENV is given in the form of environment's name or its list.
   4.151 -This function returns correct result only if ENV is NOT nested."
   4.152 -  (save-excursion
   4.153 -    (let ((md (match-data)) m0 (p (point)) rc clfound)
   4.154 -      (cond
   4.155 -       ((listp env)
   4.156 -	(or (YaTeX-quick-in-environment-p (car env))
   4.157 -	    (and (cdr env) (YaTeX-quick-in-environment-p (cdr env)))))
   4.158 -       (t
   4.159 -	(unwind-protect
   4.160 -	    (if (prog1
   4.161 -		    (YaTeX-search-active-backward
   4.162 -		     (YaTeX-replace-format-args YaTeX-struct-begin env "" "")
   4.163 -		     YaTeX-comment-prefix nil t)
   4.164 -		  (setq m0 (match-beginning 0)))
   4.165 -		(if (YaTeX-search-active-forward
   4.166 -		     (YaTeX-replace-format-args
   4.167 -		      YaTeX-struct-end env)
   4.168 -		     YaTeX-comment-prefix p t nil)
   4.169 -		    nil			;if \end{env} found, return nil
   4.170 -		  (cons env m0)))	;else, return meaningful values
   4.171 -	  (store-match-data md)))))))
   4.172 -
   4.173  ;; Filling \item
   4.174  (defun YaTeX-remove-trailing-comment (start end)
   4.175    "Remove trailing comment from START to end."
     5.1 --- a/yatex.new	Thu Jan 15 23:20:31 2015 +0900
     5.2 +++ b/yatex.new	Thu Jan 15 23:21:24 2015 +0900
     5.3 @@ -4,6 +4,9 @@
     5.4  1.79	=== yatex ===
     5.5  	数式環境など特定環境内の [prefix] t e で On-the-fly preview 発動。
     5.6  	YaTeX-help-file のデフォルト位置を site-lisp/yatex/help/ に変更。
     5.7 +	領域活性時に呼び出す補完は領域括りになるようにした。
     5.8 +	=== yahtml ===
     5.9 +	領域活性時に呼び出す補完は領域括りになるようにした。
    5.10  	...
    5.11  
    5.12  
     6.1 --- a/yatexlib.el	Thu Jan 15 23:20:31 2015 +0900
     6.2 +++ b/yatexlib.el	Thu Jan 15 23:21:24 2015 +0900
     6.3 @@ -1,7 +1,7 @@
     6.4  ;;; yatexlib.el --- YaTeX and yahtml common libraries
     6.5  ;;; 
     6.6  ;;; (c)1994-2013 by HIROSE Yuuji.[yuuji@yatex.org]
     6.7 -;;; Last modified Sun Jan  4 21:04:29 2015 on firestorm
     6.8 +;;; Last modified Thu Jan 15 11:22:54 2015 on firestorm
     6.9  ;;; $Id$
    6.10  
    6.11  ;;; Code:
    6.12 @@ -974,6 +974,64 @@
    6.13  	   (progn (skip-chars-forward open) (1+ (point)))
    6.14  	   (progn (skip-chars-forward close) (point)))))))
    6.15  
    6.16 +(defun YaTeX-in-environment-p (env)
    6.17 +  "Return if current LaTeX environment is ENV.
    6.18 +ENV is given in the form of environment's name or its list."
    6.19 +  (let ((md (match-data)) (nest 0) p envrx)
    6.20 +    (cond
    6.21 +     ((atom env)
    6.22 +      (setq envrx
    6.23 +	    (concat "\\("
    6.24 +		    (regexp-quote
    6.25 +		     (YaTeX-replace-format-args
    6.26 +		      YaTeX-struct-begin env "" ""))
    6.27 +		    "\\>\\)\\|\\("
    6.28 +		    (regexp-quote
    6.29 +		     (YaTeX-replace-format-args
    6.30 +		      YaTeX-struct-end env "" ""))
    6.31 +		    "\\)"))
    6.32 +      (save-excursion
    6.33 +	(setq p (catch 'open
    6.34 +		  (while (YaTeX-re-search-active-backward
    6.35 +			  envrx YaTeX-comment-prefix nil t)
    6.36 +		    (if (match-beginning 2)
    6.37 +			(setq nest (1+ nest))
    6.38 +		      (setq nest (1- nest)))
    6.39 +		    (if (< nest 0)
    6.40 +			(throw 'open (cons env (match-beginning 0)))))))))
    6.41 +     ((listp env)
    6.42 +      (setq p
    6.43 +	    (or (YaTeX-in-environment-p (car env))
    6.44 +		(and (cdr env) (YaTeX-in-environment-p (cdr env)))))))
    6.45 +    (store-match-data md)
    6.46 +    p;(or p (YaTeX-in-verb-p (match-beginning 0)))
    6.47 +    ))
    6.48 +
    6.49 +(defun YaTeX-quick-in-environment-p (env)
    6.50 +  "Check quickly but unsure if current environment is ENV.
    6.51 +ENV is given in the form of environment's name or its list.
    6.52 +This function returns correct result only if ENV is NOT nested."
    6.53 +  (save-excursion
    6.54 +    (let ((md (match-data)) m0 (p (point)) rc clfound)
    6.55 +      (cond
    6.56 +       ((listp env)
    6.57 +	(or (YaTeX-quick-in-environment-p (car env))
    6.58 +	    (and (cdr env) (YaTeX-quick-in-environment-p (cdr env)))))
    6.59 +       (t
    6.60 +	(unwind-protect
    6.61 +	    (if (prog1
    6.62 +		    (YaTeX-search-active-backward
    6.63 +		     (YaTeX-replace-format-args YaTeX-struct-begin env "" "")
    6.64 +		     YaTeX-comment-prefix nil t)
    6.65 +		  (setq m0 (match-beginning 0)))
    6.66 +		(if (YaTeX-search-active-forward
    6.67 +		     (YaTeX-replace-format-args
    6.68 +		      YaTeX-struct-end env)
    6.69 +		     YaTeX-comment-prefix p t nil)
    6.70 +		    nil			;if \end{env} found, return nil
    6.71 +		  (cons env m0)))	;else, return meaningful values
    6.72 +	  (store-match-data md)))))))
    6.73 +
    6.74  (defun YaTeX-goto-corresponding-environment (&optional allow-mismatch noerr)
    6.75    "Go to corresponding begin/end enclosure.
    6.76  Optional argument ALLOW-MISMATCH allows mismatch open/clese.  Use this
    6.77 @@ -1299,6 +1357,9 @@
    6.78  	  'buffer-substring-no-properties
    6.79  	'buffer-substring))
    6.80  
    6.81 +(defun YaTeX-region-active-p ()
    6.82 +  (and (fboundp 'region-active-p) (region-active-p)))
    6.83 +
    6.84  ;;;
    6.85  ;; hilit19 vs. font-lock
    6.86  ;;;