comparison yatex.el @ 517:668632d9392e dev

Initial implementation of SpecialFilterRegion
author HIROSE Yuuji <yuuji@gentei.org>
date Sat, 06 Jan 2018 23:54:17 +0900
parents 46f02e576ee1
children cef987df070f
comparison
equal deleted inserted replaced
516:603acc1caec7 517:668632d9392e
1 ;;; yatex.el --- Yet Another tex-mode for emacs //–ì’¹// -*- coding: sjis -*- 1 ;;; yatex.el --- Yet Another tex-mode for emacs //–ì’¹// -*- coding: sjis -*-
2 ;;; (c)1991-2018 by HIROSE Yuuji.[yuuji@yatex.org] 2 ;;; (c)1991-2018 by HIROSE Yuuji.[yuuji@yatex.org]
3 ;;; Last modified Wed Jan 3 23:56:34 2018 on firestorm 3 ;;; Last modified Sat Jan 6 22:52:02 2018 on firestorm
4 ;;; $Id$ 4 ;;; $Id$
5 ;;; The latest version of this software is always available at; 5 ;;; The latest version of this software is always available at;
6 ;;; https://www.yatex.org/ 6 ;;; https://www.yatex.org/
7 7
8 ;;; This program is distributed as a free software. You can 8 ;;; This program is distributed as a free software. You can
374 374
375 (defvar YaTeX-ams-env-table 375 (defvar YaTeX-ams-env-table
376 (append YaTeX-ams-math-begin-alist YaTeX-ams-math-gathering-alist) 376 (append YaTeX-ams-math-begin-alist YaTeX-ams-math-gathering-alist)
377 "*Standard AMS-LaTeX(2e) environment completion table.") 377 "*Standard AMS-LaTeX(2e) environment completion table.")
378 378
379 (defvar YaTeX-use-dot-env-extension t
380 "*Use YaTeX's dot-env filter special environment.")
381 (defvar YaTeX-filter-special-env-alist-default
382 '((".blockdiag"
383 "blockdiag -T %t -o %o -"
384 "blockdiag {
385 default_fontsize = 32;
386 A -> B;
387 }")
388 (".seqdiag" "seqdiag -T %t -o %o -"
389 "seqdiag {
390 client -> server [label = \"SYN\"];
391 client <- server [label = \"SYN/ACK\"];
392 client -> server [label = \"ACK\"];}")
393 (".actdiag" "actdiag -T %t -o %o -"
394 "actdiag {
395 sayHo -> ho -> hohoho
396 lane dj {
397 label = \"DJ\"
398 sayHo [label = \"Say Ho\"]; hohoho [label = \"Ho Ho Ho!\"]; }
399 lane mc { label = \"MC\"; ho [label = \"Hooooh!\"]}}")
400 (".nwdiag" "nwdiag -T %t -o %o -"
401 "nwdiag {
402 network ext {
403 address = \"10.1.2.0/24\"
404 router [address = \"10.1.2.1\"]
405 }
406 network int {
407 address = \"192.168.22.0/24\"
408 router [address = \"192.168.22.1\"]
409 websrv [address = \"192.168.22.80\"]
410 cli-1; cli-2
411 }
412 }")
413 (".rackdiag" "rackdiag -T %t -o %o -"
414 "rackdiag {
415 16U;
416 1: UPS [4U]; 5: Storage [3U]; 8: PC [2U]; 8: PC [2U];
417 }")
418 (".dot"
419 "dot -T %t -o %o"
420 "digraph {
421 graph [charset=\"utf-8\"]
422 }
423 bigraph {
424 graph [charset=\"utf-8\"]}"
425 )))
426
427 (defvar YaTeX-filter-special-env-alist-private nil)
428 (defvar YaTeX-filter-special-env-alist
429 (append YaTeX-filter-special-env-alist-private
430 YaTeX-filter-special-env-alist-default))
431
432
433
379 ; Set tex-environment possible completion 434 ; Set tex-environment possible completion
380 (defvar env-table 435 (defvar env-table
381 (append 436 (append
382 '(("quote") ("quotation") ("center") ("verse") ("document") 437 '(("quote") ("quotation") ("center") ("verse") ("document")
383 ("verbatim") ("itemize") ("enumerate") ("description") 438 ("verbatim") ("itemize") ("enumerate") ("description")
397 ("screen") ("boxnote") ("shadebox") ;; ("itembox") ;in ascmac 452 ("screen") ("boxnote") ("shadebox") ;; ("itembox") ;in ascmac
398 ("alltt") ;defined in alltt 453 ("alltt") ;defined in alltt
399 ("multicols") ;defined in multicol 454 ("multicols") ;defined in multicol
400 ("breakbox"))) ;defined in eclbkbox 455 ("breakbox"))) ;defined in eclbkbox
401 (if YaTeX-use-AMS-LaTeX YaTeX-ams-env-table) 456 (if YaTeX-use-AMS-LaTeX YaTeX-ams-env-table)
402 YaTeX-math-other-env-alist) 457 YaTeX-math-other-env-alist
458 (if YaTeX-use-dot-env-extension
459 '((".blockdiag") (".nwdiag") (".seqdiag") (".rackdiag") (".packetdiag")
460 (".dot"))
461 ))
403 "Default completion table for begin-type completion.") 462 "Default completion table for begin-type completion.")
404 463
405 (defvar user-env-table nil) 464 (defvar user-env-table nil)
406 (defvar tmp-env-table nil) 465 (defvar tmp-env-table nil)
407 466
918 (defun YaTeX-make-begin-end (arg) 977 (defun YaTeX-make-begin-end (arg)
919 "Make LaTeX environment command of \\begin{env.} ... \\end{env.} 978 "Make LaTeX environment command of \\begin{env.} ... \\end{env.}
920 by completing read. 979 by completing read.
921 If you invoke this command with universal argument, 980 If you invoke this command with universal argument,
922 \(key binding for universal-argument is \\[universal-argument]\) 981 \(key binding for universal-argument is \\[universal-argument]\)
923 you can put REGION into that environment between \\begin and \\end." 982 you can put REGION into that environment between \\begin and \\end.
983 If the environment name begins with `.'(dot),
984 that environment will be treated as `special environment', which
985 enables special feature such as text conversion."
924 (interactive "P") 986 (interactive "P")
925 (let* 987 (let*
926 ((region-p (or arg (YaTeX-region-active-p))) 988 ((region-p (or arg (YaTeX-region-active-p)))
927 (mode (if region-p " region" "")) 989 (mode (if region-p " region" ""))
928 (env 990 (env
929 (save-excursion ;for Emacs24 work-around to avoid point warp 991 (save-excursion ;for Emacs24 work-around to avoid point warp
930 (YaTeX-read-environment 992 (YaTeX-read-environment
931 (format "Begin environment%s(default %s): " mode YaTeX-env-name))))) 993 (format "Begin environment%s(default %s): " mode YaTeX-env-name))))
994 special)
932 (if (string= env "") 995 (if (string= env "")
933 (setq env YaTeX-env-name)) 996 (setq env YaTeX-env-name))
934 (setq YaTeX-env-name env) 997 (setq special (assoc env YaTeX-filter-special-env-alist)
998 YaTeX-env-name env)
935 (YaTeX-update-table 999 (YaTeX-update-table
936 (list YaTeX-env-name) 'env-table 'user-env-table 'tmp-env-table) 1000 (list YaTeX-env-name) 'env-table 'user-env-table 'tmp-env-table)
937 (YaTeX-insert-begin-end YaTeX-env-name region-p))) 1001 (if special
1002 (YaTeX-insert-filter-special YaTeX-env-name (cdr special) region-p)
1003 (YaTeX-insert-begin-end YaTeX-env-name region-p))))
938 1004
939 (defun YaTeX-make-begin-end-region () 1005 (defun YaTeX-make-begin-end-region ()
940 "Call YaTeX-make-begin-end with ARG to specify region mode." 1006 "Call YaTeX-make-begin-end with ARG to specify region mode."
941 (interactive) 1007 (interactive)
942 (YaTeX-make-begin-end t)) 1008 (YaTeX-make-begin-end t))
1259 (insert 1325 (insert
1260 (cond 1326 (cond
1261 ((YaTeX-literal-p) ?\") 1327 ((YaTeX-literal-p) ?\")
1262 ((= (preceding-char) ?\\ ) ?\") 1328 ((= (preceding-char) ?\\ ) ?\")
1263 ;((= (preceding-char) ?\( ) ?\") 1329 ;((= (preceding-char) ?\( ) ?\")
1330 ((save-excursion (beginning-of-line)
1331 (skip-chars-forward "\t ")
1332 (looking-at "%#"))
1333 ?\")
1334 ((let ((ovl (overlays-at (point))))
1335 (and ovl
1336 (catch 'found
1337 (while ovl
1338 (if (overlay-get (car ovl) 'filter-input) (throw 'found t))
1339 (setq ovl (cdr ovl))))))
1340 ?\")
1264 ((or (= (preceding-char) 32) 1341 ((or (= (preceding-char) 32)
1265 (= (preceding-char) 9) 1342 (= (preceding-char) 9)
1266 (= (preceding-char) ?\n) 1343 (= (preceding-char) ?\n)
1267 (bobp) 1344 (bobp)
1268 (string-match 1345 (string-match

yatex.org