diff --git a/docs/yatexe b/docs/yatexe index 570919b..8706f14 100644 --- a/docs/yatexe +++ b/docs/yatexe @@ -249,6 +249,7 @@ * Changing typesetter:: * Splitting input files:: * Static region for typesetting:: +* Special Filtering Region:: * Lpr format:: * Controlling which command to invoke:: * Editing %# notation:: @@ -337,6 +338,30 @@  +File: yatexe, Node: Special Filtering Region, Next: Lpr format, Prev: Static region for typesetting, Up: %#notation + +Special Filtering Region +======================== + A region like below will be passed to external filter command. + %#BEGIN FILTER{foo.pdf}{dot -T %t -o %o} + \if0 + ....blah blah blah... + ....blah blah blah... + ....blah blah blah... + \fi + %#END + +In this case, typing `[prefix] t e' send three `blah' lines +to "dot -T pdf -o foo.pdf" as standard-input. It is useful to +have source of text-origin graphic generated by such tools as +graphviz or blockdiag, in LaTeX source. This special form of region +can be inserted via feeding `.dot' into environment completion by +`[prefix] t b'. + + + + + File: yatexe, Node: Lpr format, Next: Controlling which command to invoke, Prev: Static region for typesetting, Up: %#notation Lpr format @@ -535,7 +560,7 @@  -File: yatexe, Node: Section-type completion, Prev: Begin-type completion, Up: Completion +File: yatexe, Node: Section-type completion, Next: Label Generation, Prev: Begin-type completion, Up: Completion Section-type completion ======================= @@ -2314,60 +2339,61 @@ Node: Calling previewer8016 Node: Printing out8377 Node: %#notation8669 -Node: Changing typesetter9040 -Node: Splitting input files9404 -Node: Static region for typesetting10833 -Node: Lpr format11962 -Node: Controlling which command to invoke13035 -Node: Editing %# notation13992 -Node: Completion14536 -Node: Begin-type completion15072 -Node: Section-type completion17926 -Node: view-sectioning20318 -Node: Label Generation21897 -Node: Large-type completion22797 -Node: Maketitle-type completion23443 -Node: Arbitrary completion23995 -Node: End completion24385 -Node: Accent completion24855 -Node: Image completion25472 -Node: Greek letters completion27727 -Node: Inserting parentheses28483 -Node: Local dictionaries28890 -Node: Commenting out29827 -Node: Cursor jump31286 -Node: Jump to corresponding object31577 -Node: Invoking image processor32977 -Node: Jump to main file34320 -Node: Jumping around the environment34686 -Node: Jumping to last completion position35104 -Node: Changing and Deleting35613 -Node: Changing LaTeX commands35994 -Node: Killing LaTeX commands37171 -Node: Filling38356 -Node: Updation of includeonly40211 -Node: What column41008 -Node: Intelligent newline42093 -Node: Usepackage checker43754 -Node: Online help44345 -Node: Browsing file hierarchy46020 -Node: Cooperation with other packages47757 -Node: Customizations48462 -Node: Lisp variables48758 -Node: All customizable variables49717 -Node: Sample definitions61682 -Node: Hook variables62195 -Node: Hook file62899 -Node: Add-in functions63238 -Node: How the add-in function works64076 -Node: Defining option-add-in66262 -Node: Defining argument-add-in66984 -Node: Defining enclosing-add-in67865 -Node: How the function is called68721 -Node: Useful functions for creating add-in69397 -Node: Contribution70807 -Node: Add-in generator71081 -Node: Etcetera76657 -Node: Copying77262 +Node: Changing typesetter9069 +Node: Splitting input files9433 +Node: Static region for typesetting10862 +Node: Special Filtering Region11991 +Node: Lpr format12723 +Node: Controlling which command to invoke13796 +Node: Editing %# notation14753 +Node: Completion15297 +Node: Begin-type completion15833 +Node: Section-type completion18687 +Node: view-sectioning21103 +Node: Label Generation22682 +Node: Large-type completion23582 +Node: Maketitle-type completion24228 +Node: Arbitrary completion24780 +Node: End completion25170 +Node: Accent completion25640 +Node: Image completion26257 +Node: Greek letters completion28512 +Node: Inserting parentheses29268 +Node: Local dictionaries29675 +Node: Commenting out30612 +Node: Cursor jump32071 +Node: Jump to corresponding object32362 +Node: Invoking image processor33762 +Node: Jump to main file35105 +Node: Jumping around the environment35471 +Node: Jumping to last completion position35889 +Node: Changing and Deleting36398 +Node: Changing LaTeX commands36779 +Node: Killing LaTeX commands37956 +Node: Filling39141 +Node: Updation of includeonly40996 +Node: What column41793 +Node: Intelligent newline42878 +Node: Usepackage checker44539 +Node: Online help45130 +Node: Browsing file hierarchy46805 +Node: Cooperation with other packages48542 +Node: Customizations49247 +Node: Lisp variables49543 +Node: All customizable variables50502 +Node: Sample definitions62467 +Node: Hook variables62980 +Node: Hook file63684 +Node: Add-in functions64023 +Node: How the add-in function works64861 +Node: Defining option-add-in67047 +Node: Defining argument-add-in67769 +Node: Defining enclosing-add-in68650 +Node: How the function is called69506 +Node: Useful functions for creating add-in70182 +Node: Contribution71592 +Node: Add-in generator71866 +Node: Etcetera77442 +Node: Copying78047  End tag table diff --git a/docs/yatexe.tex b/docs/yatexe.tex index cb6e48f..6ecf0ad 100644 --- a/docs/yatexe.tex +++ b/docs/yatexe.tex @@ -8,7 +8,7 @@ @iftex @c @syncodeindex fn cp -@c Last modified Sat Sep 9 23:41:37 2017 on firestorm +@c Last modified Sat Jan 6 23:42:24 2018 on firestorm @syncodeindex vr cp @end iftex @@ -265,6 +265,7 @@ * Changing typesetter:: * Splitting input files:: * Static region for typesetting:: +* Special Filtering Region:: * Lpr format:: * Controlling which command to invoke:: * Editing %# notation:: @@ -377,6 +378,28 @@ @code{%#BEGIN} alone at the middle of very long text. Do not forget to erase @code{%#BEGIN} @code{%#END} pair. +@node Special Filtering Region, Lpr format, Static region for typesetting, %#notation +@section Special Filtering Region + A region like below will be passed to external filter command. +@example +%#BEGIN FILTER{foo.pdf}{dot -T %t -o %o} +\if0 +....blah blah blah... +....blah blah blah... +....blah blah blah... +\fi +%#END +@end example + +In this case, typing @kbd{[prefix] t e} send three `blah' lines +to "dot -T pdf -o foo.pdf" as standard-input. It is useful to +have source of text-origin graphic generated by such tools as +graphviz or blockdiag, in La@TeX{} source. This special form of region +can be inserted via feeding @code{.dot} into environment completion by +@kbd{[prefix] t b}. + + + @node Lpr format, Controlling which command to invoke, Static region for typesetting, %#notation @comment node-name, next, previous, up @section Lpr format @@ -587,7 +610,7 @@ begin-type completion to enclose text into a environment. -@node Section-type completion, , Begin-type completion, Completion +@node Section-type completion, Label Generation, Begin-type completion, Completion @comment node-name, next, previous, up @section Section-type completion @cindex section-type completion diff --git a/docs/yatexj b/docs/yatexj index 85e6af0..2189b5f 100644 --- a/docs/yatexj +++ b/docs/yatexj Binary files differ diff --git a/docs/yatexj.tex b/docs/yatexj.tex index 2254ee8..4f96230 100644 --- a/docs/yatexj.tex +++ b/docs/yatexj.tex @@ -13,7 +13,7 @@ @c �m�[�h���������� C-l C-u C-n �S���̃m�[�h�X�V C-l C-u C-e @c ���j���[���₵���� C-l C-u C-m �S���̃��j���[�X�V C-l C-u C-a @c �t�H�[�}�b�g����Ƃ��� C-l C-e C-b -@c Last modified Sat Sep 9 23:43:04 2017 on firestorm +@c Last modified Sat Jan 6 23:49:50 2018 on firestorm @syncodeindex vr cp @end iftex @@ -35,7 +35,7 @@ * Main features:: ��ȋ@�\ * Installation:: �C���X�g�[�� * Invocation:: �v���Z�X�N�� -* %#notation :: %#�L�@ +* %#notation :: * Completion:: �⊮���� * Local dictionary:: ���[�J������ * Commenting out:: �R�����g�A�E�g @@ -357,9 +357,10 @@ * Changing typesetter:: �^�C�v�Z�b�g�p�R�}���h�̕ύX * Splitting input files:: ���̓t�@�C������ * Fix region for typesetting:: �̈�̌Œ� +* Special Filtering Region:: * lpr format:: �v�����g�A�E�g�R�}���h�p�t�H�[�}�b�g * Controlling which command to invoke:: ���̑��̋N���R�}���h���� -* Editing %# notation:: %#�L�@�̕ҏW +* Editing %# notation:: @end menu @node Changing typesetter, Splitting input files, %#notation , %#notation @@ -479,6 +480,31 @@ �̏����Y��ɂ͏\�������Ӊ������B @cindex �����t�@�C���̕ҏW[�Ȃ����ӂ�����̂ւ񂵂䂤] +@node Special Filtering Region, lpr format, Fix region for typesetting, %#notation +@section �����O���t�B���^ + +���Ƃ��΁A�e�L�X�g�t�@�C������摜�𐶐�����悤�ȃc�[���ɗ^����\�[�X�� +La@TeX{}�\�[�X���ɖ��ߍ��݁A���̕����������c�[���̕W�����͂ɓn�����Ƃ��ł� +�܂��B���̂��߂ɂ͈ȉ��̂悤�ȃ\�[�X�𕶏����ɏ����܂��B + +@example +%#BEGIN FILTER{foo.pdf}{blockdiag -T %t -o %o} +\if0 +--- +....blah blah blah... +....blah blah blah... +....blah blah blah... +--- +\fi +%#END +@end example + +���̗̈���� @kbd{[prefix] t e} ���^�C�v����ƁA���̗�ł����blah�̂���3�s�� +�O���R�}���h @code{"blockdiag -T pdf -o foo.pdf"} �̕W�����͂ɓn����A +���ʂƂ��� foo.pdf ����������܂��B���̓��ʂȃu���b�N�� +@kbd{[prefix] tb} �̊‹��⊮�ŁA@code{.blockdiag} �̂悤�ȃs���I�h�Ŏn�܂� +����‹�������͂��邱�ƂŎ����I�ɑ}������܂��B + @c @node Require, lpr format, Fix region for typesetting, %#notation @comment node-name, next, previous, up @@ -778,7 +804,7 @@ �������}������A���s�͂����J�[�\���͎����I�ɒ����ʂ̓����Ɉړ����܂��B @menu -* 2�ˆȏ�̈������Ƃ� section�^�R�}���h:: +* 2�ˆȏ�̈������Ƃ� section�^�R�}���h:: * Enclose section-type command:: ����⊮ * Recursive completion:: �ċA�⊮ * view-sectioning:: �Z�N�V������؂�̃A�E�g���C���\�� @@ -1261,11 +1287,11 @@ @menu -* �Ή��I�u�W�F�N�g�ւ̃W�����v:: -* ���G�`���c�[���N��:: -* ���C���t�@�C���ւ̃W�����v:: -* �‹���P�ʂƂ����W�����v:: -* �Ō�̕⊮�ʒu�ւ̃W�����v:: +* �Ή��I�u�W�F�N�g�ւ̃W�����v:: +* ���G�`���c�[���N��:: +* ���C���t�@�C���ւ̃W�����v:: +* �‹���P�ʂƂ����W�����v:: +* �Ō�̕⊮�ʒu�ւ̃W�����v:: @end menu @node �Ή��I�u�W�F�N�g�ւ̃W�����v, ���G�`���c�[���N��, Cursor jump, Cursor jump diff --git a/yatex.el b/yatex.el index 039d63d..9f2ec72 100644 --- a/yatex.el +++ b/yatex.el @@ -1,6 +1,6 @@ ;;; yatex.el --- Yet Another tex-mode for emacs //�쒹// -*- coding: sjis -*- ;;; (c)1991-2018 by HIROSE Yuuji.[yuuji@yatex.org] -;;; Last modified Wed Jan 3 23:56:34 2018 on firestorm +;;; Last modified Sat Jan 6 22:52:02 2018 on firestorm ;;; $Id$ ;;; The latest version of this software is always available at; ;;; https://www.yatex.org/ @@ -376,6 +376,61 @@ (append YaTeX-ams-math-begin-alist YaTeX-ams-math-gathering-alist) "*Standard AMS-LaTeX(2e) environment completion table.") +(defvar YaTeX-use-dot-env-extension t + "*Use YaTeX's dot-env filter special environment.") +(defvar YaTeX-filter-special-env-alist-default + '((".blockdiag" + "blockdiag -T %t -o %o -" + "blockdiag { + default_fontsize = 32; + A -> B; +}") + (".seqdiag" "seqdiag -T %t -o %o -" + "seqdiag { + client -> server [label = \"SYN\"]; + client <- server [label = \"SYN/ACK\"]; + client -> server [label = \"ACK\"];}") + (".actdiag" "actdiag -T %t -o %o -" + "actdiag { + sayHo -> ho -> hohoho + lane dj { + label = \"DJ\" + sayHo [label = \"Say Ho\"]; hohoho [label = \"Ho Ho Ho!\"]; } + lane mc { label = \"MC\"; ho [label = \"Hooooh!\"]}}") + (".nwdiag" "nwdiag -T %t -o %o -" + "nwdiag { + network ext { + address = \"10.1.2.0/24\" + router [address = \"10.1.2.1\"] + } + network int { + address = \"192.168.22.0/24\" + router [address = \"192.168.22.1\"] + websrv [address = \"192.168.22.80\"] + cli-1; cli-2 + } +}") + (".rackdiag" "rackdiag -T %t -o %o -" + "rackdiag { + 16U; + 1: UPS [4U]; 5: Storage [3U]; 8: PC [2U]; 8: PC [2U]; +}") + (".dot" + "dot -T %t -o %o" + "digraph { + graph [charset=\"utf-8\"] +} +bigraph { + graph [charset=\"utf-8\"]}" + ))) + +(defvar YaTeX-filter-special-env-alist-private nil) +(defvar YaTeX-filter-special-env-alist + (append YaTeX-filter-special-env-alist-private + YaTeX-filter-special-env-alist-default)) + + + ; Set tex-environment possible completion (defvar env-table (append @@ -399,7 +454,11 @@ ("multicols") ;defined in multicol ("breakbox"))) ;defined in eclbkbox (if YaTeX-use-AMS-LaTeX YaTeX-ams-env-table) - YaTeX-math-other-env-alist) + YaTeX-math-other-env-alist + (if YaTeX-use-dot-env-extension + '((".blockdiag") (".nwdiag") (".seqdiag") (".rackdiag") (".packetdiag") + (".dot")) + )) "Default completion table for begin-type completion.") (defvar user-env-table nil) @@ -920,7 +979,10 @@ by completing read. If you invoke this command with universal argument, \(key binding for universal-argument is \\[universal-argument]\) -you can put REGION into that environment between \\begin and \\end." +you can put REGION into that environment between \\begin and \\end. +If the environment name begins with `.'(dot), +that environment will be treated as `special environment', which +enables special feature such as text conversion." (interactive "P") (let* ((region-p (or arg (YaTeX-region-active-p))) @@ -928,13 +990,17 @@ (env (save-excursion ;for Emacs24 work-around to avoid point warp (YaTeX-read-environment - (format "Begin environment%s(default %s): " mode YaTeX-env-name))))) + (format "Begin environment%s(default %s): " mode YaTeX-env-name)))) + special) (if (string= env "") (setq env YaTeX-env-name)) - (setq YaTeX-env-name env) + (setq special (assoc env YaTeX-filter-special-env-alist) + YaTeX-env-name env) (YaTeX-update-table (list YaTeX-env-name) 'env-table 'user-env-table 'tmp-env-table) - (YaTeX-insert-begin-end YaTeX-env-name region-p))) + (if special + (YaTeX-insert-filter-special YaTeX-env-name (cdr special) region-p) + (YaTeX-insert-begin-end YaTeX-env-name region-p)))) (defun YaTeX-make-begin-end-region () "Call YaTeX-make-begin-end with ARG to specify region mode." @@ -1261,6 +1327,17 @@ ((YaTeX-literal-p) ?\") ((= (preceding-char) ?\\ ) ?\") ;((= (preceding-char) ?\( ) ?\") + ((save-excursion (beginning-of-line) + (skip-chars-forward "\t ") + (looking-at "%#")) + ?\") + ((let ((ovl (overlays-at (point)))) + (and ovl + (catch 'found + (while ovl + (if (overlay-get (car ovl) 'filter-input) (throw 'found t)) + (setq ovl (cdr ovl)))))) + ?\") ((or (= (preceding-char) 32) (= (preceding-char) 9) (= (preceding-char) ?\n) diff --git a/yatex.new b/yatex.new index f2e96fa..2605489 100644 --- a/yatex.new +++ b/yatex.new @@ -3,6 +3,7 @@ 1.81 == yatex == �^�C�v�Z�b�g�R�}���h��`���� %k �������R�[�h���ɕϊ�(-kanji=%k) + �h�b�g�‹��ŊO���t�B���^�������N������@�\��lj��B 1.80 string-to-int���O�Ɠ����� emacs-18 ���T�|�[�g�O�ɁB 2-Clause BSD�ł�OK�Ƃ������ɏ����Ă݂��B diff --git a/yatexprc.el b/yatexprc.el index d69d220..cb645af 100644 --- a/yatexprc.el +++ b/yatexprc.el @@ -1,7 +1,7 @@ ;;; yatexprc.el --- YaTeX process handler -*- coding: sjis -*- ;;; ;;; (c)1993-2018 by HIROSE Yuuji.[yuuji@yatex.org] -;;; Last modified Thu Jan 4 00:09:28 2018 on firestorm +;;; Last modified Fri Jan 5 22:48:43 2018 on firestorm ;;; $Id$ ;;; Code: @@ -353,7 +353,7 @@ reg-begin reg-end lineinfo) (setq ppcmd (if (stringp pp) (concat pp " " texputroot) pp)) (save-excursion - (if (search-backward "%#BEGIN" nil t) + (if (re-search-backward "%#BEGIN\\s *$" nil t) (progn (setq typeout "--- Region from BEGIN to " end "the end of the buffer ---" @@ -478,6 +478,36 @@ The value is generated from YaTeX-typeset-pdf2image-chain and YaTeX-typeset-dvi2image-chain.") +(defun YaTeX-popup-image (imagesrc buffer &optional func) + (let ((sw (selected-window)) image + (data-p (and (> (length imagesrc) 128) + (not (file-readable-p imagesrc))))) + (save-excursion + (cond + ((featurep 'image) window-system + (YaTeX-showup-buffer ;showup and select + (get-buffer-create buffer) + (or func 'YaTeX-showup-buffer-bottom-most) + t) + (remove-images (point-min) (point-max)) + (erase-buffer) + (insert-image + (setq image (create-image + (if data-p imagesrc (expand-file-name imagesrc)) + nil data-p))) + (YaTeX-preview-image-mode) + (let ((height (1+ (cdr (image-size image))))) + (enlarge-window + (- (ceiling (min height (/ (frame-height) 2))) + (window-height)))) + (select-window sw)) + (t ;; Without direct image, display image with image viewer + (YaTeX-system + (format "%s %s" YaTeX-cmd-view-images target) + "YaTeX-region-image" + 'noask))) + ))) + (defvar YaTeX-typeset-conv2image-process nil "Process of conv2image chain") (defun YaTeX-typeset-conv2image-chain () (let*((proc (or YaTeX-typeset-process YaTeX-typeset-conv2image-process)) @@ -531,39 +561,11 @@ 'YaTeX-typeset-conv2image-chain) (get 'YaTeX-typeset-process 'ppcmd)))) ;; After all chain executed, display image in current window - (cond - ((and (featurep 'image) window-system) - ;; If direct image displaying available in running Emacs, - ;; display target image into the next window in Emacs. - (select-window w) - ;(setq foo (selected-window)) - (YaTeX-showup-buffer - (get-buffer-create " *YaTeX-region-image*") - 'YaTeX-showup-buffer-bottom-most t) - (remove-images (point-min) (point-max)) - (erase-buffer) - (cd pwd) ;when reuse from other source - ;(put-image (create-image (expand-file-name target)) (point)) - (insert-image-file target) - (setq img (plist-get (text-properties-at (point)) 'intangible)) - (YaTeX-preview-image-mode) - (if img - (let ((height (1+ (cdr (image-size img))))) - (enlarge-window - (- (ceiling (min height (/ (frame-height) 2))) - (window-height))))) - ;; Remember elapsed time, which will be threshold in onthefly-preview - (put 'YaTeX-typeset-conv2image-chain 'elapse - (YaTeX-elapsed-time - (get 'YaTeX-typeset-conv2image-chain 'start) (current-time)))) - (t - ;; Without direct image, display image with image viewer - (YaTeX-system - (format "%s %s" YaTeX-cmd-view-images target) - "YaTeX-region-image" - 'noask) - ) - ))))) + (YaTeX-popup-image target " *YaTeX-popup-image*") + (put 'YaTeX-typeset-conv2image-chain 'elapse + (YaTeX-elapsed-time + (get 'YaTeX-typeset-conv2image-chain 'start) (current-time))) + )))) (defvar YaTeX-typeset-environment-timer nil) @@ -657,6 +659,14 @@ (if usetimer (YaTeX-typeset-environment-auto b e))) (YaTeX-typeset-region)))) +(defun YaTeX-filter-BEGEND () + (let ((begend-info (YaTeX-in-BEGEND-p))) + (if begend-info + (progn + (require 'yatexflt) + (YaTeX-filter-pass-to-filter begend-info) + )))) + (defun YaTeX-typeset-environment () "Typeset current environment or paragraph. If region activated, use it." @@ -664,7 +674,8 @@ (let ((md (match-data))) (unwind-protect (save-excursion - (YaTeX-typeset-environment-1)) + (or (YaTeX-filter-BEGEND) + (YaTeX-typeset-environment-1))) (store-match-data md))))