comparison yatexprc.el @ 69:807c1e7e68b7

yahtml-escape-chars-region Translate <>"& to entity reference. And inverse translation to above. yahtml-translate-hyphens-when-comment-region yahtml-prefer-upcase-attributes Inquire .htaccess file to determine the file-coding-system. Completions for StyleSheet. ---yahtml--- Auto insert of \), \|, \] after corresponding \(, \| \]. [prefix] c for \right\left parens.
author yuuji
date Thu, 15 Jul 1999 04:58:26 +0000
parents 0eb6997bee16
children 44e3a5e1e883
comparison
equal deleted inserted replaced
68:0eb6997bee16 69:807c1e7e68b7
1 ;;; -*- Emacs-Lisp -*- 1 ;;; -*- Emacs-Lisp -*-
2 ;;; YaTeX process handler. 2 ;;; YaTeX process handler.
3 ;;; yatexprc.el 3 ;;; yatexprc.el
4 ;;; (c )1993-1997 by HIROSE Yuuji.[yuuji@ae.keio.ac.jp] 4 ;;; (c )1993-1999 by HIROSE Yuuji.[yuuji@gentei.org]
5 ;;; Last modified Mon Mar 9 11:44:29 1998 on crx 5 ;;; Last modified Tue Jul 13 13:47:46 1999 on firestorm
6 ;;; $Id$ 6 ;;; $Id$
7 7
8 ;(require 'yatex) 8 ;(require 'yatex)
9 (require 'yatexlib) 9 (require 'yatexlib)
10 10
11 (defvar YaTeX-typeset-process nil 11 (defvar YaTeX-typeset-process nil
12 "Process identifier for jlatex" 12 "Process identifier for jlatex")
13 ) 13
14 (defvar YaTeX-typeset-buffer "*YaTeX-typesetting*" 14 (defvar YaTeX-typeset-buffer "*YaTeX-typesetting*"
15 "Process buffer for jlatex") 15 "Process buffer for jlatex")
16 16
17 (defvar YaTeX-typeset-buffer-syntax nil 17 (defvar YaTeX-typeset-buffer-syntax nil
18 "*Syntax table for typesetting buffer") 18 "*Syntax table for typesetting buffer")
42 (setq YaTeX-typeset-buffer-syntax 42 (setq YaTeX-typeset-buffer-syntax
43 (make-syntax-table (standard-syntax-table))) 43 (make-syntax-table (standard-syntax-table)))
44 (modify-syntax-entry ?\{ "w" YaTeX-typeset-buffer-syntax) 44 (modify-syntax-entry ?\{ "w" YaTeX-typeset-buffer-syntax)
45 (modify-syntax-entry ?\} "w" YaTeX-typeset-buffer-syntax) 45 (modify-syntax-entry ?\} "w" YaTeX-typeset-buffer-syntax)
46 (modify-syntax-entry ?\[ "w" YaTeX-typeset-buffer-syntax) 46 (modify-syntax-entry ?\[ "w" YaTeX-typeset-buffer-syntax)
47 (modify-syntax-entry ?\] "w" YaTeX-typeset-buffer-syntax) 47 (modify-syntax-entry ?\] "w" YaTeX-typeset-buffer-syntax))
48 )
49 48
50 (defun YaTeX-typeset (command buffer &optional prcname modename) 49 (defun YaTeX-typeset (command buffer &optional prcname modename)
51 "Execute jlatex (or other) to LaTeX typeset." 50 "Execute jlatex (or other) to LaTeX typeset."
52 (interactive) 51 (interactive)
53 (save-excursion 52 (save-excursion
54 (let ((p (point)) (window (selected-window)) execdir (cb (current-buffer)) 53 (let ((p (point)) (window (selected-window)) execdir (cb (current-buffer))
55 (map YaTeX-typesetting-mode-map) 54 (map YaTeX-typesetting-mode-map)
56 (outcode 55 (outcode
57 (cond ((eq major-mode 'yatex-mode) YaTeX-coding-system) 56 (cond ((eq major-mode 'yatex-mode) YaTeX-coding-system)
58 ((eq major-mode 'yahtml-mode) yahtml-coding-system)))) 57 ((eq major-mode 'yahtml-mode) yahtml-kanji-code))))
59 (if (and YaTeX-typeset-process 58 (if (and YaTeX-typeset-process
60 (eq (process-status YaTeX-typeset-process) 'run)) 59 (eq (process-status YaTeX-typeset-process) 'run))
61 ;; if tex command is halting. 60 ;; if tex command is halting.
62 (YaTeX-kill-typeset-process YaTeX-typeset-process)) 61 (YaTeX-kill-typeset-process YaTeX-typeset-process))
63 (YaTeX-put-nonstopmode) 62 (YaTeX-put-nonstopmode)
116 (select-window (get-buffer-window buffer)) 115 (select-window (get-buffer-window buffer))
117 (goto-char (point-max)) 116 (goto-char (point-max))
118 (recenter -1)) 117 (recenter -1))
119 (select-window window) 118 (select-window window)
120 (switch-to-buffer cb) 119 (switch-to-buffer cb)
121 (YaTeX-remove-nonstopmode))) 120 (YaTeX-remove-nonstopmode))))
122 )
123 121
124 (defun YaTeX-typeset-sentinel (proc mes) 122 (defun YaTeX-typeset-sentinel (proc mes)
125 (cond ((null (buffer-name (process-buffer proc))) 123 (cond ((null (buffer-name (process-buffer proc)))
126 ;; buffer killed 124 ;; buffer killed
127 (set-process-buffer proc nil)) 125 (set-process-buffer proc nil))
158 (setq YaTeX-typeset-process nil) 156 (setq YaTeX-typeset-process nil)
159 ;; Force mode line redisplay soon 157 ;; Force mode line redisplay soon
160 (set-buffer-modified-p (buffer-modified-p)) 158 (set-buffer-modified-p (buffer-modified-p))
161 ) 159 )
162 (select-window owin) 160 (select-window owin)
163 (set-buffer obuf)))) 161 (set-buffer obuf)))))
164 )
165 162
166 (defvar YaTeX-texput-file "texput.tex" 163 (defvar YaTeX-texput-file "texput.tex"
167 "*File name for temporary file of typeset-region." 164 "*File name for temporary file of typeset-region.")
168 )
169 165
170 (defun YaTeX-typeset-region () 166 (defun YaTeX-typeset-region ()
171 "Paste the region to the file `texput.tex' and execute typesetter. 167 "Paste the region to the file `texput.tex' and execute typesetter.
172 The region is specified by the rule: 168 The region is specified by the rule:
173 (1)If keyword `%#BEGIN' is found in the upper direction from (point). 169 (1)If keyword `%#BEGIN' is found in the upper direction from (point).
245 (set-buffer main) ;return to parent file or itself. 241 (set-buffer main) ;return to parent file or itself.
246 (YaTeX-typeset cmd YaTeX-typeset-buffer) 242 (YaTeX-typeset cmd YaTeX-typeset-buffer)
247 (switch-to-buffer buffer) ;for Emacs-19 243 (switch-to-buffer buffer) ;for Emacs-19
248 (put 'dvi2-command 'region t) 244 (put 'dvi2-command 'region t)
249 (put 'dvi2-command 'file buffer) 245 (put 'dvi2-command 'file buffer)
250 (put 'dvi2-command 'offset lineinfo) 246 (put 'dvi2-command 'offset lineinfo))))
251 ))
252 )
253 247
254 (defun YaTeX-typeset-buffer () 248 (defun YaTeX-typeset-buffer ()
255 "Typeset whole buffer. 249 "Typeset whole buffer.
256 If %#! usage says other buffer is main text, 250 If %#! usage says other buffer is main text,
257 visit main buffer to confirm if its includeonly list contains current 251 visit main buffer to confirm if its includeonly list contains current
301 (t nil)) 295 (t nil))
302 (basic-save-buffer)))) 296 (basic-save-buffer))))
303 (exchange-point-and-mark))) 297 (exchange-point-and-mark)))
304 (switch-to-buffer cb)) ;for 19 298 (switch-to-buffer cb)) ;for 19
305 (YaTeX-typeset cmd YaTeX-typeset-buffer) 299 (YaTeX-typeset cmd YaTeX-typeset-buffer)
306 (put 'dvi2-command 'region nil)) 300 (put 'dvi2-command 'region nil)))
307 )
308 301
309 (defvar YaTeX-call-command-history nil 302 (defvar YaTeX-call-command-history nil
310 "Holds history list of YaTeX-call-command-on-file.") 303 "Holds history list of YaTeX-call-command-on-file.")
311 (put 'YaTeX-call-command-history 'no-default t) 304 (put 'YaTeX-call-command-history 'no-default t)
312 (defun YaTeX-call-command-on-file (base-cmd buffer) 305 (defun YaTeX-call-command-on-file (base-cmd buffer)
314 (YaTeX-typeset 307 (YaTeX-typeset
315 (read-string-with-history 308 (read-string-with-history
316 "Call command: " 309 "Call command: "
317 (concat base-cmd " " (YaTeX-get-preview-file-name)) 310 (concat base-cmd " " (YaTeX-get-preview-file-name))
318 'YaTeX-call-command-history) 311 'YaTeX-call-command-history)
319 buffer) 312 buffer))
320 )
321 313
322 (defun YaTeX-bibtex-buffer (cmd) 314 (defun YaTeX-bibtex-buffer (cmd)
323 "Pass the bibliography data of editing file to bibtex." 315 "Pass the bibliography data of editing file to bibtex."
324 (interactive) 316 (interactive)
325 (YaTeX-save-buffers) 317 (YaTeX-save-buffers)
326 (YaTeX-call-command-on-file cmd "*YaTeX-bibtex*" ) 318 (YaTeX-call-command-on-file cmd "*YaTeX-bibtex*" ))
327 )
328 319
329 (defun YaTeX-kill-typeset-process (proc) 320 (defun YaTeX-kill-typeset-process (proc)
330 "Kill process PROC after sending signal to PROC. 321 "Kill process PROC after sending signal to PROC.
331 PROC should be process identifier." 322 PROC should be process identifier."
332 (cond 323 (cond
345 (process-send-string proc "x\n") 336 (process-send-string proc "x\n")
346 (while (= mp (point-max)) (sit-for 1)))))) 337 (while (= mp (point-max)) (sit-for 1))))))
347 (if (eq (process-status proc) 'run) 338 (if (eq (process-status proc) 'run)
348 (progn 339 (progn
349 (interrupt-process proc) 340 (interrupt-process proc)
350 (delete-process proc))))) 341 (delete-process proc))))))
351 )
352 342
353 (defun YaTeX-system (command buffer) 343 (defun YaTeX-system (command buffer)
354 "Execute some command on buffer. Not a official function." 344 "Execute some command on buffer. Not a official function."
355 (save-excursion 345 (save-excursion
356 (YaTeX-showup-buffer 346 (YaTeX-showup-buffer
369 (y-or-n-p (format "Process %s is running. Continue?" buffer)))) 359 (y-or-n-p (format "Process %s is running. Continue?" buffer))))
370 nil 360 nil
371 (set-process-buffer 361 (set-process-buffer
372 (start-process 362 (start-process
373 "system" buffer shell-file-name YaTeX-shell-command-option command) 363 "system" buffer shell-file-name YaTeX-shell-command-option command)
374 (get-buffer buffer))))) 364 (get-buffer buffer))))))
375 )
376 365
377 (defvar YaTeX-preview-command-history nil 366 (defvar YaTeX-preview-command-history nil
378 "Holds minibuffer history of preview command.") 367 "Holds minibuffer history of preview command.")
379 (put 'YaTeX-preview-command-history 'no-default t) 368 (put 'YaTeX-preview-command-history 'no-default t)
380 (defvar YaTeX-preview-file-history nil 369 (defvar YaTeX-preview-file-history nil
411 (call-process shell-file-name "con" "*dvi-preview*" nil 400 (call-process shell-file-name "con" "*dvi-preview*" nil
412 YaTeX-shell-command-option 401 YaTeX-shell-command-option
413 (concat preview-command " " preview-file)) 402 (concat preview-command " " preview-file))
414 (send-string-to-terminal "\e[>5l") ;show cursor 403 (send-string-to-terminal "\e[>5l") ;show cursor
415 (redraw-display)) 404 (redraw-display))
405 ((and (string-match "dviout" preview-command) ;maybe on `kon'
406 (stringp (getenv "TERM"))
407 (string-match "^kon" (getenv "TERM")))
408 (call-process shell-file-name "con" "*dvi-preview*" nil
409 YaTeX-shell-command-option
410 (concat preview-command " " preview-file)))
416 (t ;if UNIX 411 (t ;if UNIX
417 (set-process-buffer 412 (set-process-buffer
418 (start-process "preview" "*dvi-preview*" shell-file-name 413 (start-process "preview" "*dvi-preview*" shell-file-name
419 YaTeX-shell-command-option 414 YaTeX-shell-command-option
420 (concat preview-command " " preview-file)) 415 (concat preview-command " " preview-file))
421 (get-buffer pbuffer)) 416 (get-buffer pbuffer))
422 (message 417 (message
423 (concat "Starting " preview-command 418 (concat "Starting " preview-command
424 " to preview " preview-file)))))) 419 " to preview " preview-file)))))))
425 )
426 420
427 (defvar YaTeX-xdvi-remote-program "xdvi") 421 (defvar YaTeX-xdvi-remote-program "xdvi")
428 (defun YaTeX-xdvi-remote-search (&optional region-mode) 422 (defun YaTeX-xdvi-remote-search (&optional region-mode)
429 "Search string at the point on xdvi -remote window. 423 "Search string at the point on xdvi -remote window.
430 Non-nil for optional argument REGION-MODE specifies the search string 424 Non-nil for optional argument REGION-MODE specifies the search string
445 (setq proc 439 (setq proc
446 (start-process 440 (start-process
447 "xdvi" pb YaTeX-xdvi-remote-program 441 "xdvi" pb YaTeX-xdvi-remote-program
448 "-remote" (format "SloppySearch(%s) " str) 442 "-remote" (format "SloppySearch(%s) " str)
449 (concat (YaTeX-get-preview-file-name) ".dvi"))) 443 (concat (YaTeX-get-preview-file-name) ".dvi")))
450 (message "Searching `%s'...Done" str))) 444 (message "Searching `%s'...Done" str))))
451 )
452 445
453 (defun YaTeX-set-virtual-error-position (file-sym line-sym) 446 (defun YaTeX-set-virtual-error-position (file-sym line-sym)
454 "Replace the value of FILE-SYM, LINE-SYM by virtual error position." 447 "Replace the value of FILE-SYM, LINE-SYM by virtual error position."
455 (cond 448 (cond
456 ((and (get 'dvi2-command 'region) 449 ((and (get 'dvi2-command 'region)
506 (select-window typeset-win) 499 (select-window typeset-win)
507 (skip-chars-backward "0-9") 500 (skip-chars-backward "0-9")
508 (recenter (/ (window-height) 2)) 501 (recenter (/ (window-height) 2))
509 (sit-for 1) 502 (sit-for 1)
510 (goto-char (match-beginning 0)) 503 (goto-char (match-beginning 0))
511 (select-window error-win)) 504 (select-window error-win)))
512 )
513 505
514 (defun YaTeX-jump-error-line () 506 (defun YaTeX-jump-error-line ()
515 "Jump to corresponding line on latex command's error message." 507 "Jump to corresponding line on latex command's error message."
516 (interactive) 508 (interactive)
517 (let (error-line error-file error-buf) 509 (let (error-line error-file error-buf)
529 (YaTeX-set-virtual-error-position 'error-file 'error-line) 521 (YaTeX-set-virtual-error-position 'error-file 'error-line)
530 (setq error-buf (YaTeX-switch-to-buffer error-file t))) 522 (setq error-buf (YaTeX-switch-to-buffer error-file t)))
531 (if (null error-buf) 523 (if (null error-buf)
532 (error "`%s' is not found in this directory." error-file)) 524 (error "`%s' is not found in this directory." error-file))
533 (YaTeX-showup-buffer error-buf nil t) 525 (YaTeX-showup-buffer error-buf nil t)
534 (goto-line error-line)) 526 (goto-line error-line)))
535 )
536 527
537 (defun YaTeX-send-string () 528 (defun YaTeX-send-string ()
538 "Send string to current typeset process." 529 "Send string to current typeset process."
539 (interactive) 530 (interactive)
540 (if (and (eq (process-status YaTeX-typeset-process) 'run) 531 (if (and (eq (process-status YaTeX-typeset-process) 'run)
548 YaTeX-typeset-process (concat (buffer-substring b e) "\n")) 539 YaTeX-typeset-process (concat (buffer-substring b e) "\n"))
549 (goto-char e) 540 (goto-char e)
550 (insert "\n") 541 (insert "\n")
551 (set-marker (process-mark YaTeX-typeset-process) (point)) 542 (set-marker (process-mark YaTeX-typeset-process) (point))
552 (insert " ")) 543 (insert " "))
553 (ding)) 544 (ding)))
554 )
555 545
556 (defun YaTeX-view-error () 546 (defun YaTeX-view-error ()
557 (interactive) 547 (interactive)
558 (if (null (get-buffer YaTeX-typeset-buffer)) 548 (if (null (get-buffer YaTeX-typeset-buffer))
559 (message "No typeset buffer found.") 549 (message "No typeset buffer found.")
562 ;; Next 3 lines are obsolete because YaTeX-typesetting-buffer is 552 ;; Next 3 lines are obsolete because YaTeX-typesetting-buffer is
563 ;; automatically scrolled up at typesetting. 553 ;; automatically scrolled up at typesetting.
564 ;;(goto-char (point-max)) 554 ;;(goto-char (point-max))
565 ;;(forward-line -1) 555 ;;(forward-line -1)
566 ;;(recenter -1) 556 ;;(recenter -1)
567 (select-window win))) 557 (select-window win))))
568 )
569 558
570 (defun YaTeX-get-error-file (default) 559 (defun YaTeX-get-error-file (default)
571 "Get current processing file from typesetting log." 560 "Get current processing file from typesetting log."
572 (save-excursion 561 (save-excursion
573 (let(s) 562 (let(s)
587 (setq s 576 (setq s
588 (buffer-substring 577 (buffer-substring
589 (progn (forward-char 1) (point)) 578 (progn (forward-char 1) (point))
590 (progn (skip-chars-forward "^ \n" (point-end-of-line)) 579 (progn (skip-chars-forward "^ \n" (point-end-of-line))
591 (point)))) 580 (point))))
592 (if (string= "" s) default s))) 581 (if (string= "" s) default s))))
593 )
594 582
595 (defun YaTeX-put-nonstopmode () 583 (defun YaTeX-put-nonstopmode ()
596 (if (and (eq major-mode 'yatex-mode) YaTeX-need-nonstop) 584 (if (and (eq major-mode 'yatex-mode) YaTeX-need-nonstop)
597 (if (re-search-backward "\\\\nonstopmode{}" (point-min) t) 585 (if (re-search-backward "\\\\nonstopmode{}" (point-min) t)
598 nil ;if already written in text then do nothing 586 nil ;if already written in text then do nothing
599 (save-excursion 587 (save-excursion
600 (YaTeX-visit-main t) 588 (YaTeX-visit-main t)
601 (goto-char (point-min)) 589 (goto-char (point-min))
602 (insert "\\nonstopmode{}%_YaTeX_%\n") 590 (insert "\\nonstopmode{}%_YaTeX_%\n")
603 (if (buffer-file-name) (basic-save-buffer)))) 591 (if (buffer-file-name) (basic-save-buffer))))))
604 )
605 )
606 592
607 (defun YaTeX-remove-nonstopmode () 593 (defun YaTeX-remove-nonstopmode ()
608 (if (and (eq major-mode 'yatex-mode) YaTeX-need-nonstop) ;for speed 594 (if (and (eq major-mode 'yatex-mode) YaTeX-need-nonstop) ;for speed
609 (save-excursion 595 (save-excursion
610 (YaTeX-visit-main t) 596 (YaTeX-visit-main t)
611 (goto-char (point-min)) 597 (goto-char (point-min))
612 (forward-line 1) 598 (forward-line 1)
613 (narrow-to-region (point-min) (point)) 599 (narrow-to-region (point-min) (point))
614 (goto-char (point-min)) 600 (goto-char (point-min))
615 (delete-matching-lines "^\\\\nonstopmode\\{\\}%_YaTeX_%$") 601 (delete-matching-lines "^\\\\nonstopmode\\{\\}%_YaTeX_%$")
616 (widen))) 602 (widen))))
617 )
618 603
619 (defun YaTeX-get-preview-file-name () 604 (defun YaTeX-get-preview-file-name ()
620 "Get file name to preview by inquiring YaTeX-get-latex-command" 605 "Get file name to preview by inquiring YaTeX-get-latex-command"
621 (let* ((latex-cmd (YaTeX-get-latex-command t)) 606 (let* ((latex-cmd (YaTeX-get-latex-command t))
622 (rin (rindex latex-cmd ? )) 607 (rin (rindex latex-cmd ? ))
625 (if (string= fname "") 610 (if (string= fname "")
626 (setq fname (substring (file-name-nondirectory 611 (setq fname (substring (file-name-nondirectory
627 (buffer-file-name)) 612 (buffer-file-name))
628 0 -4)) 613 0 -4))
629 (setq period (rindex fname ?.)) 614 (setq period (rindex fname ?.))
630 (setq fname (substring fname 0 (if (eq -1 period) nil period))) 615 (setq fname (substring fname 0 (if (eq -1 period) nil period))))))
631 ))
632 )
633 616
634 (defun YaTeX-get-latex-command (&optional switch) 617 (defun YaTeX-get-latex-command (&optional switch)
635 "Specify the latex-command name and its argument. 618 "Specify the latex-command name and its argument.
636 If there is a line which begins with string: \"%#!\", the following 619 If there is a line which begins with string: \"%#!\", the following
637 strings are assumed to be the latex-command and arguments. The 620 strings are assumed to be the latex-command and arguments. The
657 (magic 640 (magic
658 (cond 641 (cond
659 (switch (if (string-match "\\s " magic) magic 642 (switch (if (string-match "\\s " magic) magic
660 (concat magic " " parent))) 643 (concat magic " " parent)))
661 (t (concat (substring magic 0 (string-match "\\s " magic)) " ")))) 644 (t (concat (substring magic 0 (string-match "\\s " magic)) " "))))
662 (t (concat tex-command " " (if switch parent))))) 645 (t (concat tex-command " " (if switch parent))))))
663 )
664 646
665 (defvar YaTeX-lpr-command-history nil 647 (defvar YaTeX-lpr-command-history nil
666 "Holds command line history of YaTeX-lpr.") 648 "Holds command line history of YaTeX-lpr.")
667 (put 'YaTeX-lpr-command-history 'no-default t) 649 (put 'YaTeX-lpr-command-history 'no-default t)
668 (defun YaTeX-lpr (arg) 650 (defun YaTeX-lpr (arg)
718 (t 700 (t
719 (set-process-buffer 701 (set-process-buffer
720 (start-process "print" "*dvi-printing*" shell-file-name 702 (start-process "print" "*dvi-printing*" shell-file-name
721 YaTeX-shell-command-option cmd) 703 YaTeX-shell-command-option cmd)
722 (get-buffer lbuffer)) 704 (get-buffer lbuffer))
723 (message "Starting printing command: %s..." cmd))) 705 (message "Starting printing command: %s..." cmd))))))
724 ))
725 )
726 706
727 (defun YaTeX-main-file-p () 707 (defun YaTeX-main-file-p ()
728 "Return if current buffer is main LaTeX source." 708 "Return if current buffer is main LaTeX source."
729 (cond 709 (cond
730 (YaTeX-parent-file 710 (YaTeX-parent-file
734 (t 714 (t
735 (save-excursion 715 (save-excursion
736 (let ((latex-main-id 716 (let ((latex-main-id
737 (concat "^\\s *" YaTeX-ec-regexp "document\\(style\\|class\\)"))) 717 (concat "^\\s *" YaTeX-ec-regexp "document\\(style\\|class\\)")))
738 (or (re-search-backward latex-main-id nil t) 718 (or (re-search-backward latex-main-id nil t)
739 (re-search-forward latex-main-id nil t)))))) 719 (re-search-forward latex-main-id nil t)))))))
740 )
741 720
742 (defun YaTeX-visit-main (&optional setbuf) 721 (defun YaTeX-visit-main (&optional setbuf)
743 "Switch buffer to main LaTeX source. 722 "Switch buffer to main LaTeX source.
744 Use set-buffer instead of switch-to-buffer if the optional second argument 723 Use set-buffer instead of switch-to-buffer if the optional second argument
745 SETBUF is t(Use it only from Emacs-Lisp program)." 724 SETBUF is t(Use it only from Emacs-Lisp program)."
765 (YaTeX-switch-to-buffer main-file setbuf)) 744 (YaTeX-switch-to-buffer main-file setbuf))
766 (t (setq main-file (read-file-name "Enter your main text: " nil nil 1)) 745 (t (setq main-file (read-file-name "Enter your main text: " nil nil 1))
767 (setq YaTeX-parent-file main-file) 746 (setq YaTeX-parent-file main-file)
768 (YaTeX-switch-to-buffer main-file setbuf)) 747 (YaTeX-switch-to-buffer main-file setbuf))
769 ))) 748 )))
770 nil 749 nil)
771 )
772
773 750
774 (defun YaTeX-guess-parent (command-line) 751 (defun YaTeX-guess-parent (command-line)
775 (setq command-line 752 (setq command-line
776 (if (string-match ".*\\s " command-line) 753 (if (string-match ".*\\s " command-line)
777 (substring command-line (match-end 0)) 754 (substring command-line (match-end 0))
778 (file-name-nondirectory (buffer-file-name))) 755 (file-name-nondirectory (buffer-file-name)))
779 command-line 756 command-line
780 (concat (if (string-match "\\(.*\\)\\." command-line) 757 (concat (if (string-match "\\(.*\\)\\." command-line)
781 (substring command-line (match-beginning 1) (match-end 1)) 758 (substring command-line (match-beginning 1) (match-end 1))
782 command-line) 759 command-line)
783 ".tex")) 760 ".tex")))
784 )
785 761
786 (defun YaTeX-visit-main-other-window () 762 (defun YaTeX-visit-main-other-window ()
787 "Switch to buffer main LaTeX source in other window." 763 "Switch to buffer main LaTeX source in other window."
788 (interactive) 764 (interactive)
789 (if (YaTeX-main-file-p) (message "I think this is main LaTeX source.") 765 (if (YaTeX-main-file-p) (message "I think this is main LaTeX source.")
790 (YaTeX-switch-to-buffer-other-window 766 (YaTeX-switch-to-buffer-other-window
791 (concat (YaTeX-get-preview-file-name) ".tex"))) 767 (concat (YaTeX-get-preview-file-name) ".tex"))))
792 )
793 768
794 (defun YaTeX-get-builtin (key) 769 (defun YaTeX-get-builtin (key)
795 "Read source built-in command of %# usage." 770 "Read source built-in command of %# usage."
796 (save-excursion 771 (save-excursion
797 (goto-char (point-min)) 772 (goto-char (point-min))
799 (concat "^" (regexp-quote (concat "%#" key))) nil t) 774 (concat "^" (regexp-quote (concat "%#" key))) nil t)
800 (not (eolp))) 775 (not (eolp)))
801 (buffer-substring 776 (buffer-substring
802 (progn (skip-chars-forward " " (point-end-of-line))(point)) 777 (progn (skip-chars-forward " " (point-end-of-line))(point))
803 (point-end-of-line)) 778 (point-end-of-line))
804 nil)) 779 nil)))
805 )
806 780
807 (defun YaTeX-save-buffers () 781 (defun YaTeX-save-buffers ()
808 "Save buffers whose major-mode is equal to current major-mode." 782 "Save buffers whose major-mode is equal to current major-mode."
809 (basic-save-buffer) 783 (basic-save-buffer)
810 (let ((cmm major-mode)) 784 (let ((cmm major-mode))
814 (if (and (buffer-file-name buf) 788 (if (and (buffer-file-name buf)
815 (eq major-mode cmm) 789 (eq major-mode cmm)
816 (buffer-modified-p buf) 790 (buffer-modified-p buf)
817 (y-or-n-p (format "Save %s" (buffer-name buf)))) 791 (y-or-n-p (format "Save %s" (buffer-name buf))))
818 (save-buffer buf))) 792 (save-buffer buf)))
819 (buffer-list)))) 793 (buffer-list)))))
820 )
821 794
822 (provide 'yatexprc) 795 (provide 'yatexprc)

yatex.org