yatex

view yatex23.el @ 563:bf4bdd7c4aae

YaTeX-default-documentclass set to jsarticle
author HIROSE Yuuji <yuuji@gentei.org>
date Wed, 16 Jan 2019 08:24:17 +0900
parents 723f136edde5
children
line source
1 ;;; yatex23.el --- YaTeX facilities for Emacs 23 or later -*- coding: sjis -*-
2 ;;; (c)2014-2017 by HIROSE Yuuji.[yuuji@yatex.org]
3 ;;; Last modified Sun Sep 17 10:23:02 2017 on firestorm
4 ;;; $Id$
6 (require 'yatex19)
7 ;;; Code:
8 (defvar YaTeX-dnd-auto-figure "figure"
9 "*If set, include dropped \\includegraphcs{} into that environment.
10 The value should be string. Set this `nil' to disable enclosing.")
11 (defvar YaTeX-dnd-auto-figure-package
12 (cons "graphicx"
13 (cond ((string-match "pdflatex" tex-command) "pdftex")
14 (t "dvipdfmx")))
15 "*Default LaTeX package and its option for \\includegraphics")
17 (defun YaTeX-dnd-handler (uri action)
18 "DnD handler for yatex-mode
19 Convert local image URI to \\includegraphcis{} and
20 .tex file names to \\include{}."
21 (let*((file (dnd-get-local-file-name uri t))
22 (path (save-excursion
23 (YaTeX-visit-main t)
24 (file-relative-name file)))
25 (insert-file-directory nil)
26 (case-fold-search t)
27 (b nil) p1 p2 (cc (current-column)) envstart)
28 (cond
29 ((memq action '(copy link move private))
30 (cond
31 ((string-match "\\.\\(jpe?g\\|png\\|gif\\|bmp\\|tiff?\\|e?ps\\|pdf\\)$" path)
32 (if (and (stringp YaTeX-dnd-auto-figure)
33 (not (YaTeX-in-environment-p YaTeX-dnd-auto-figure))
34 (not (string-match "figure"
35 (or (YaTeX-inner-environment t) "body")))
36 YaTeX-dnd-auto-figure)
37 (setq b (format "\\begin{%s}[htbp] %%\\centering\n"
38 YaTeX-dnd-auto-figure)))
39 (unwind-protect
40 (progn
41 (setq envstart (point-marker))
42 (insert "\\includegraphics")
43 (insert "{" (YaTeX::includegraphics 1 path t) "}")
44 (save-excursion
45 (YaTeX-package-auto-usepackage
46 "includegraphics" 'section
47 (car YaTeX-dnd-auto-figure-package)
48 (cdr YaTeX-dnd-auto-figure-package)))
49 (cond
50 (b
51 (undo-boundary)
52 (save-excursion
53 (goto-char envstart)
54 (insert b))
55 (YaTeX-indent-line)
56 (insert "\n")
57 (indent-to (1+ cc))
58 (setq p1 (point))
59 (insert "\\caption{")
60 (setq p2 (point))
61 (insert (format "}\\label{%s}\n" path))
62 (indent-to cc)
63 (insert (format "\\end{%s}\n" YaTeX-dnd-auto-figure))
64 (goto-char p2)
65 (undo-boundary)
66 (insert (file-name-nondirectory path))
67 (undo-boundary)
68 (goto-char p1)
69 (insert "%")
70 (end-of-line)
71 (or (get 'YaTeX-dnd-auto-figure 'guide)
72 (progn
73 (newline 1)
74 (indent-to (1+ cc))
75 (insert (format
76 (if YaTeX-japan
77 "%% Undo(%s)するとcaptionが活きます。2度押しで空欄 3度押しで無環境"
78 "%% TYPE undo(%s) to ACTIVATE caption. Twice to clear caption. 3 to no-env")
79 (key-description
80 (car (where-is-internal 'undo)))))
81 (put 'YaTeX-dnd-auto-figure 'guide t)))))
82 (YaTeX-help "includegraphics"))
83 (set-marker envstart nil) ;;sure to reset marker
84 action))
85 ((string-match "\\(.*\\)\\.tex$" path)
86 (insert "\\include{" (match-string 1 path) "}"))
87 ((string-match "\\(.*\\)\\.bib$" path)
88 (insert "\\bibliography{" (match-string 1 path) "}"))
89 ((string-match "\\.ind$" path)
90 (insert "\\input{" path "}"))))
91 (t (message "%s" action)))))
93 (defvar YaTeX-on-the-fly-bg-face '("#f0f0c0" . "#706868")
94 "Background color of on-the-fly preview image activated environment.")
95 (defvar YaTeX-on-the-fly-overlay nil
96 "Overlay of on-the-fly preview image")
97 (defface YaTeX-on-the-fly-activated-face
98 (list
99 (list (list '(class color) '(min-colors 65536))
100 (list ':background
101 (if (eq YaTeX-background-mode 'light)
102 (car YaTeX-on-the-fly-bg-face)
103 (cdr YaTeX-on-the-fly-bg-face))))
104 (list t (list ':bold t)))
105 "Face of on-the-fly preview image mode")
107 (provide 'yatex23)