Mercurial > hgrepos > hgweb.cgi > yatex
annotate yatex23.el @ 364:d69fd7b1ac4d dev yatex-1.78
yatex-1.78
author | HIROSE Yuuji <yuuji@gentei.org> |
---|---|
date | Fri, 26 Dec 2014 01:02:52 +0900 |
parents | 41a05a44826a |
children | 77a2fd4fd634 |
rev | line source |
---|---|
330 | 1 ;;; yatex23.el --- YaTeX facilities for Emacs 23 or later -*- coding: sjis -*- |
2 ;;; (c)2014 by HIROSE Yuuji.[yuuji@yatex.org] | |
361
41a05a44826a
[pdftex] option for pdflatex
HIROSE Yuuji <yuuji@gentei.org>
parents:
358
diff
changeset
|
3 ;;; Last modified Tue Dec 23 12:44:35 2014 on firestorm |
364 | 4 ;;; $Id: yatex23.el,v 1.78 2014/12/25 15:11:02 yuuji Rel $ |
330 | 5 |
6 ;;; Code: | |
343
43fb2bf403e4
Set undo-boundary for quick modification by user.
HIROSE Yuuji <yuuji@gentei.org>
parents:
331
diff
changeset
|
7 (defvar YaTeX-dnd-auto-figure "figure" |
43fb2bf403e4
Set undo-boundary for quick modification by user.
HIROSE Yuuji <yuuji@gentei.org>
parents:
331
diff
changeset
|
8 "*If set, include dropped \\includegraphcs{} into that environment. |
43fb2bf403e4
Set undo-boundary for quick modification by user.
HIROSE Yuuji <yuuji@gentei.org>
parents:
331
diff
changeset
|
9 The value should be string. Set this `nil' to disable enclosing.") |
361
41a05a44826a
[pdftex] option for pdflatex
HIROSE Yuuji <yuuji@gentei.org>
parents:
358
diff
changeset
|
10 (defvar YaTeX-dnd-auto-figure-package |
41a05a44826a
[pdftex] option for pdflatex
HIROSE Yuuji <yuuji@gentei.org>
parents:
358
diff
changeset
|
11 (cons "graphicx" |
41a05a44826a
[pdftex] option for pdflatex
HIROSE Yuuji <yuuji@gentei.org>
parents:
358
diff
changeset
|
12 (cond ((string-match "pdflatex" tex-command) "pdftex") |
41a05a44826a
[pdftex] option for pdflatex
HIROSE Yuuji <yuuji@gentei.org>
parents:
358
diff
changeset
|
13 (t "dvipdfmx"))) |
358
2c2b70f41fb3
New variable YaTeX-dnd-auto-figure-package for full-auto usepackage
HIROSE Yuuji <yuuji@gentei.org>
parents:
357
diff
changeset
|
14 "*Default LaTeX package and its option for \\includegraphics") |
2c2b70f41fb3
New variable YaTeX-dnd-auto-figure-package for full-auto usepackage
HIROSE Yuuji <yuuji@gentei.org>
parents:
357
diff
changeset
|
15 |
330 | 16 (defun YaTeX-dnd-handler (uri action) |
17 "DnD handler for yatex-mode | |
18 Convert local image URI to \\includegraphcis{} and | |
19 .tex file names to \\include{}." | |
343
43fb2bf403e4
Set undo-boundary for quick modification by user.
HIROSE Yuuji <yuuji@gentei.org>
parents:
331
diff
changeset
|
20 (let*((file (dnd-get-local-file-name uri)) |
43fb2bf403e4
Set undo-boundary for quick modification by user.
HIROSE Yuuji <yuuji@gentei.org>
parents:
331
diff
changeset
|
21 (path (save-excursion |
43fb2bf403e4
Set undo-boundary for quick modification by user.
HIROSE Yuuji <yuuji@gentei.org>
parents:
331
diff
changeset
|
22 (YaTeX-visit-main t) |
43fb2bf403e4
Set undo-boundary for quick modification by user.
HIROSE Yuuji <yuuji@gentei.org>
parents:
331
diff
changeset
|
23 (file-relative-name file))) |
43fb2bf403e4
Set undo-boundary for quick modification by user.
HIROSE Yuuji <yuuji@gentei.org>
parents:
331
diff
changeset
|
24 (insert-file-directory nil) |
43fb2bf403e4
Set undo-boundary for quick modification by user.
HIROSE Yuuji <yuuji@gentei.org>
parents:
331
diff
changeset
|
25 (case-fold-search t) |
43fb2bf403e4
Set undo-boundary for quick modification by user.
HIROSE Yuuji <yuuji@gentei.org>
parents:
331
diff
changeset
|
26 (b nil) p1 p2 (cc (current-column)) envstart) |
43fb2bf403e4
Set undo-boundary for quick modification by user.
HIROSE Yuuji <yuuji@gentei.org>
parents:
331
diff
changeset
|
27 (cond |
43fb2bf403e4
Set undo-boundary for quick modification by user.
HIROSE Yuuji <yuuji@gentei.org>
parents:
331
diff
changeset
|
28 ((memq action '(copy link move private)) |
330 | 29 (cond |
343
43fb2bf403e4
Set undo-boundary for quick modification by user.
HIROSE Yuuji <yuuji@gentei.org>
parents:
331
diff
changeset
|
30 ((string-match "\\.\\(jpe?g\\|png\\|gif\\|bmp\\|tiff?\\|e?ps\\|pdf\\)$" path) |
43fb2bf403e4
Set undo-boundary for quick modification by user.
HIROSE Yuuji <yuuji@gentei.org>
parents:
331
diff
changeset
|
31 (if (and (stringp YaTeX-dnd-auto-figure) |
43fb2bf403e4
Set undo-boundary for quick modification by user.
HIROSE Yuuji <yuuji@gentei.org>
parents:
331
diff
changeset
|
32 (not (YaTeX-in-environment-p YaTeX-dnd-auto-figure)) |
43fb2bf403e4
Set undo-boundary for quick modification by user.
HIROSE Yuuji <yuuji@gentei.org>
parents:
331
diff
changeset
|
33 (not (string-match "figure" |
43fb2bf403e4
Set undo-boundary for quick modification by user.
HIROSE Yuuji <yuuji@gentei.org>
parents:
331
diff
changeset
|
34 (or (YaTeX-inner-environment t) "body"))) |
43fb2bf403e4
Set undo-boundary for quick modification by user.
HIROSE Yuuji <yuuji@gentei.org>
parents:
331
diff
changeset
|
35 YaTeX-dnd-auto-figure) |
43fb2bf403e4
Set undo-boundary for quick modification by user.
HIROSE Yuuji <yuuji@gentei.org>
parents:
331
diff
changeset
|
36 (setq b (format "\\begin{%s}[htbp] %%\\centering\n" |
43fb2bf403e4
Set undo-boundary for quick modification by user.
HIROSE Yuuji <yuuji@gentei.org>
parents:
331
diff
changeset
|
37 YaTeX-dnd-auto-figure))) |
43fb2bf403e4
Set undo-boundary for quick modification by user.
HIROSE Yuuji <yuuji@gentei.org>
parents:
331
diff
changeset
|
38 (unwind-protect |
43fb2bf403e4
Set undo-boundary for quick modification by user.
HIROSE Yuuji <yuuji@gentei.org>
parents:
331
diff
changeset
|
39 (progn |
43fb2bf403e4
Set undo-boundary for quick modification by user.
HIROSE Yuuji <yuuji@gentei.org>
parents:
331
diff
changeset
|
40 (setq envstart (point-marker)) |
43fb2bf403e4
Set undo-boundary for quick modification by user.
HIROSE Yuuji <yuuji@gentei.org>
parents:
331
diff
changeset
|
41 (insert "\\includegraphics") |
43fb2bf403e4
Set undo-boundary for quick modification by user.
HIROSE Yuuji <yuuji@gentei.org>
parents:
331
diff
changeset
|
42 (insert "{" (YaTeX::includegraphics 1 path t) "}") |
43fb2bf403e4
Set undo-boundary for quick modification by user.
HIROSE Yuuji <yuuji@gentei.org>
parents:
331
diff
changeset
|
43 (save-excursion |
357
4ea63809a0ca
Insert `\includegraphics[dvipdfmx]{graphics}' without query
HIROSE Yuuji <yuuji@gentei.org>
parents:
348
diff
changeset
|
44 (YaTeX-package-auto-usepackage |
358
2c2b70f41fb3
New variable YaTeX-dnd-auto-figure-package for full-auto usepackage
HIROSE Yuuji <yuuji@gentei.org>
parents:
357
diff
changeset
|
45 "includegraphics" 'section |
2c2b70f41fb3
New variable YaTeX-dnd-auto-figure-package for full-auto usepackage
HIROSE Yuuji <yuuji@gentei.org>
parents:
357
diff
changeset
|
46 (car YaTeX-dnd-auto-figure-package) |
2c2b70f41fb3
New variable YaTeX-dnd-auto-figure-package for full-auto usepackage
HIROSE Yuuji <yuuji@gentei.org>
parents:
357
diff
changeset
|
47 (cdr YaTeX-dnd-auto-figure-package))) |
343
43fb2bf403e4
Set undo-boundary for quick modification by user.
HIROSE Yuuji <yuuji@gentei.org>
parents:
331
diff
changeset
|
48 (cond |
43fb2bf403e4
Set undo-boundary for quick modification by user.
HIROSE Yuuji <yuuji@gentei.org>
parents:
331
diff
changeset
|
49 (b |
43fb2bf403e4
Set undo-boundary for quick modification by user.
HIROSE Yuuji <yuuji@gentei.org>
parents:
331
diff
changeset
|
50 (undo-boundary) |
43fb2bf403e4
Set undo-boundary for quick modification by user.
HIROSE Yuuji <yuuji@gentei.org>
parents:
331
diff
changeset
|
51 (save-excursion |
43fb2bf403e4
Set undo-boundary for quick modification by user.
HIROSE Yuuji <yuuji@gentei.org>
parents:
331
diff
changeset
|
52 (goto-char envstart) |
43fb2bf403e4
Set undo-boundary for quick modification by user.
HIROSE Yuuji <yuuji@gentei.org>
parents:
331
diff
changeset
|
53 (insert b)) |
43fb2bf403e4
Set undo-boundary for quick modification by user.
HIROSE Yuuji <yuuji@gentei.org>
parents:
331
diff
changeset
|
54 (YaTeX-indent-line) |
43fb2bf403e4
Set undo-boundary for quick modification by user.
HIROSE Yuuji <yuuji@gentei.org>
parents:
331
diff
changeset
|
55 (insert "\n") |
43fb2bf403e4
Set undo-boundary for quick modification by user.
HIROSE Yuuji <yuuji@gentei.org>
parents:
331
diff
changeset
|
56 (indent-to (1+ cc)) |
43fb2bf403e4
Set undo-boundary for quick modification by user.
HIROSE Yuuji <yuuji@gentei.org>
parents:
331
diff
changeset
|
57 (setq p1 (point)) |
43fb2bf403e4
Set undo-boundary for quick modification by user.
HIROSE Yuuji <yuuji@gentei.org>
parents:
331
diff
changeset
|
58 (insert "\\caption{") |
43fb2bf403e4
Set undo-boundary for quick modification by user.
HIROSE Yuuji <yuuji@gentei.org>
parents:
331
diff
changeset
|
59 (setq p2 (point)) |
43fb2bf403e4
Set undo-boundary for quick modification by user.
HIROSE Yuuji <yuuji@gentei.org>
parents:
331
diff
changeset
|
60 (insert (format "}\\label{%s}\n" path)) |
43fb2bf403e4
Set undo-boundary for quick modification by user.
HIROSE Yuuji <yuuji@gentei.org>
parents:
331
diff
changeset
|
61 (indent-to cc) |
43fb2bf403e4
Set undo-boundary for quick modification by user.
HIROSE Yuuji <yuuji@gentei.org>
parents:
331
diff
changeset
|
62 (insert (format "\\end{%s}\n" YaTeX-dnd-auto-figure)) |
43fb2bf403e4
Set undo-boundary for quick modification by user.
HIROSE Yuuji <yuuji@gentei.org>
parents:
331
diff
changeset
|
63 (goto-char p2) |
43fb2bf403e4
Set undo-boundary for quick modification by user.
HIROSE Yuuji <yuuji@gentei.org>
parents:
331
diff
changeset
|
64 (undo-boundary) |
43fb2bf403e4
Set undo-boundary for quick modification by user.
HIROSE Yuuji <yuuji@gentei.org>
parents:
331
diff
changeset
|
65 (insert (file-name-nondirectory path)) |
43fb2bf403e4
Set undo-boundary for quick modification by user.
HIROSE Yuuji <yuuji@gentei.org>
parents:
331
diff
changeset
|
66 (undo-boundary) |
43fb2bf403e4
Set undo-boundary for quick modification by user.
HIROSE Yuuji <yuuji@gentei.org>
parents:
331
diff
changeset
|
67 (goto-char p1) |
43fb2bf403e4
Set undo-boundary for quick modification by user.
HIROSE Yuuji <yuuji@gentei.org>
parents:
331
diff
changeset
|
68 (insert "%") |
43fb2bf403e4
Set undo-boundary for quick modification by user.
HIROSE Yuuji <yuuji@gentei.org>
parents:
331
diff
changeset
|
69 (end-of-line) |
43fb2bf403e4
Set undo-boundary for quick modification by user.
HIROSE Yuuji <yuuji@gentei.org>
parents:
331
diff
changeset
|
70 (or (get 'YaTeX-dnd-auto-figure 'guide) |
43fb2bf403e4
Set undo-boundary for quick modification by user.
HIROSE Yuuji <yuuji@gentei.org>
parents:
331
diff
changeset
|
71 (progn |
43fb2bf403e4
Set undo-boundary for quick modification by user.
HIROSE Yuuji <yuuji@gentei.org>
parents:
331
diff
changeset
|
72 (newline 1) |
43fb2bf403e4
Set undo-boundary for quick modification by user.
HIROSE Yuuji <yuuji@gentei.org>
parents:
331
diff
changeset
|
73 (indent-to (1+ cc)) |
43fb2bf403e4
Set undo-boundary for quick modification by user.
HIROSE Yuuji <yuuji@gentei.org>
parents:
331
diff
changeset
|
74 (insert (format |
43fb2bf403e4
Set undo-boundary for quick modification by user.
HIROSE Yuuji <yuuji@gentei.org>
parents:
331
diff
changeset
|
75 (if YaTeX-japan |
43fb2bf403e4
Set undo-boundary for quick modification by user.
HIROSE Yuuji <yuuji@gentei.org>
parents:
331
diff
changeset
|
76 "%% Undo(%s)するとcaptionが活きます。2度押しで空欄 3度押しで無環境" |
43fb2bf403e4
Set undo-boundary for quick modification by user.
HIROSE Yuuji <yuuji@gentei.org>
parents:
331
diff
changeset
|
77 "%% TYPE undo(%s) to ACTIVATE caption. Twice to clear caption. 3 to no-env") |
43fb2bf403e4
Set undo-boundary for quick modification by user.
HIROSE Yuuji <yuuji@gentei.org>
parents:
331
diff
changeset
|
78 (key-description |
43fb2bf403e4
Set undo-boundary for quick modification by user.
HIROSE Yuuji <yuuji@gentei.org>
parents:
331
diff
changeset
|
79 (car (where-is-internal 'undo))))) |
43fb2bf403e4
Set undo-boundary for quick modification by user.
HIROSE Yuuji <yuuji@gentei.org>
parents:
331
diff
changeset
|
80 (put 'YaTeX-dnd-auto-figure 'guide t))))) |
348 | 81 (YaTeX-help "includegraphics")) |
343
43fb2bf403e4
Set undo-boundary for quick modification by user.
HIROSE Yuuji <yuuji@gentei.org>
parents:
331
diff
changeset
|
82 (set-marker envstart nil) ;;sure to reset marker |
43fb2bf403e4
Set undo-boundary for quick modification by user.
HIROSE Yuuji <yuuji@gentei.org>
parents:
331
diff
changeset
|
83 action)) |
344
bfd7a5998555
Give argument for \include without `.tex' extension.
HIROSE Yuuji <yuuji@gentei.org>
parents:
343
diff
changeset
|
84 ((string-match "\\(.*\\)\\.tex$" path) |
348 | 85 (insert "\\include{" (match-string 1 path) "}")) |
86 ((string-match "\\(.*\\)\\.bib$" path) | |
87 (insert "\\bibliography{" (match-string 1 path) "}")) | |
88 ((string-match "\\.ind$" path) | |
89 (insert "\\input{" path "}")))) | |
343
43fb2bf403e4
Set undo-boundary for quick modification by user.
HIROSE Yuuji <yuuji@gentei.org>
parents:
331
diff
changeset
|
90 (t (message "%s" action))))) |
330 | 91 |
92 (provide 'yatex23) | |
93 | |
94 ; Local variables: | |
95 ; fill-prefix: ";;; " | |
96 ; paragraph-start: "^$\\|\\|;;;$" | |
97 ; paragraph-separate: "^$\\|\\|;;;$" | |
98 ; coding: sjis | |
99 ; End: |