annotate yatex23.el @ 613:38b311149463 draft dev tip

Key definition fixed
author HIROSE Yuuji <yuuji@gentei.org>
date Mon, 06 May 2024 17:11:31 +0900
parents c0827f80b18e
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
330
9cef5d10a0f1 First Drag-n-Drop support
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
1 ;;; yatex23.el --- YaTeX facilities for Emacs 23 or later -*- coding: sjis -*-
443
7a9d30752353 Release preparation
HIROSE Yuuji <yuuji@gentei.org>
parents: 433
diff changeset
2 ;;; (c)2014-2017 by HIROSE Yuuji.[yuuji@yatex.org]
497
c0827f80b18e Merged with old orphaned branch for clarity
HIROSE Yuuji <yuuji@gentei.org>
parents: 481
diff changeset
3 ;;; Last modified Sun Sep 17 10:23:02 2017 on firestorm
366
HIROSE Yuuji <yuuji@gentei.org>
parents: 364
diff changeset
4 ;;; $Id$
330
9cef5d10a0f1 First Drag-n-Drop support
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
5
433
5b49aea3810d Loading error avoided(yatex19)
HIROSE Yuuji <yuuji@gentei.org>
parents: 402
diff changeset
6 (require 'yatex19)
330
9cef5d10a0f1 First Drag-n-Drop support
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
7 ;;; Code:
343
43fb2bf403e4 Set undo-boundary for quick modification by user.
HIROSE Yuuji <yuuji@gentei.org>
parents: 331
diff changeset
8 (defvar YaTeX-dnd-auto-figure "figure"
43fb2bf403e4 Set undo-boundary for quick modification by user.
HIROSE Yuuji <yuuji@gentei.org>
parents: 331
diff changeset
9 "*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
10 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
11 (defvar YaTeX-dnd-auto-figure-package
41a05a44826a [pdftex] option for pdflatex
HIROSE Yuuji <yuuji@gentei.org>
parents: 358
diff changeset
12 (cons "graphicx"
41a05a44826a [pdftex] option for pdflatex
HIROSE Yuuji <yuuji@gentei.org>
parents: 358
diff changeset
13 (cond ((string-match "pdflatex" tex-command) "pdftex")
41a05a44826a [pdftex] option for pdflatex
HIROSE Yuuji <yuuji@gentei.org>
parents: 358
diff changeset
14 (t "dvipdfmx")))
358
2c2b70f41fb3 New variable YaTeX-dnd-auto-figure-package for full-auto usepackage
HIROSE Yuuji <yuuji@gentei.org>
parents: 357
diff changeset
15 "*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
16
330
9cef5d10a0f1 First Drag-n-Drop support
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
17 (defun YaTeX-dnd-handler (uri action)
9cef5d10a0f1 First Drag-n-Drop support
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
18 "DnD handler for yatex-mode
9cef5d10a0f1 First Drag-n-Drop support
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
19 Convert local image URI to \\includegraphcis{} and
9cef5d10a0f1 First Drag-n-Drop support
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
20 .tex file names to \\include{}."
402
27d24ac018c1 Explicitly feed second arg `t' to dnd-get-local-file-name.
HIROSE Yuuji <yuuji@gentei.org>
parents: 384
diff changeset
21 (let*((file (dnd-get-local-file-name uri t))
343
43fb2bf403e4 Set undo-boundary for quick modification by user.
HIROSE Yuuji <yuuji@gentei.org>
parents: 331
diff changeset
22 (path (save-excursion
43fb2bf403e4 Set undo-boundary for quick modification by user.
HIROSE Yuuji <yuuji@gentei.org>
parents: 331
diff changeset
23 (YaTeX-visit-main t)
43fb2bf403e4 Set undo-boundary for quick modification by user.
HIROSE Yuuji <yuuji@gentei.org>
parents: 331
diff changeset
24 (file-relative-name file)))
43fb2bf403e4 Set undo-boundary for quick modification by user.
HIROSE Yuuji <yuuji@gentei.org>
parents: 331
diff changeset
25 (insert-file-directory nil)
43fb2bf403e4 Set undo-boundary for quick modification by user.
HIROSE Yuuji <yuuji@gentei.org>
parents: 331
diff changeset
26 (case-fold-search t)
43fb2bf403e4 Set undo-boundary for quick modification by user.
HIROSE Yuuji <yuuji@gentei.org>
parents: 331
diff changeset
27 (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
28 (cond
43fb2bf403e4 Set undo-boundary for quick modification by user.
HIROSE Yuuji <yuuji@gentei.org>
parents: 331
diff changeset
29 ((memq action '(copy link move private))
330
9cef5d10a0f1 First Drag-n-Drop support
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
30 (cond
343
43fb2bf403e4 Set undo-boundary for quick modification by user.
HIROSE Yuuji <yuuji@gentei.org>
parents: 331
diff changeset
31 ((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
32 (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
33 (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
34 (not (string-match "figure"
43fb2bf403e4 Set undo-boundary for quick modification by user.
HIROSE Yuuji <yuuji@gentei.org>
parents: 331
diff changeset
35 (or (YaTeX-inner-environment t) "body")))
43fb2bf403e4 Set undo-boundary for quick modification by user.
HIROSE Yuuji <yuuji@gentei.org>
parents: 331
diff changeset
36 YaTeX-dnd-auto-figure)
43fb2bf403e4 Set undo-boundary for quick modification by user.
HIROSE Yuuji <yuuji@gentei.org>
parents: 331
diff changeset
37 (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
38 YaTeX-dnd-auto-figure)))
43fb2bf403e4 Set undo-boundary for quick modification by user.
HIROSE Yuuji <yuuji@gentei.org>
parents: 331
diff changeset
39 (unwind-protect
43fb2bf403e4 Set undo-boundary for quick modification by user.
HIROSE Yuuji <yuuji@gentei.org>
parents: 331
diff changeset
40 (progn
43fb2bf403e4 Set undo-boundary for quick modification by user.
HIROSE Yuuji <yuuji@gentei.org>
parents: 331
diff changeset
41 (setq envstart (point-marker))
43fb2bf403e4 Set undo-boundary for quick modification by user.
HIROSE Yuuji <yuuji@gentei.org>
parents: 331
diff changeset
42 (insert "\\includegraphics")
43fb2bf403e4 Set undo-boundary for quick modification by user.
HIROSE Yuuji <yuuji@gentei.org>
parents: 331
diff changeset
43 (insert "{" (YaTeX::includegraphics 1 path t) "}")
43fb2bf403e4 Set undo-boundary for quick modification by user.
HIROSE Yuuji <yuuji@gentei.org>
parents: 331
diff changeset
44 (save-excursion
357
4ea63809a0ca Insert `\includegraphics[dvipdfmx]{graphics}' without query
HIROSE Yuuji <yuuji@gentei.org>
parents: 348
diff changeset
45 (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
46 "includegraphics" 'section
2c2b70f41fb3 New variable YaTeX-dnd-auto-figure-package for full-auto usepackage
HIROSE Yuuji <yuuji@gentei.org>
parents: 357
diff changeset
47 (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
48 (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
49 (cond
43fb2bf403e4 Set undo-boundary for quick modification by user.
HIROSE Yuuji <yuuji@gentei.org>
parents: 331
diff changeset
50 (b
43fb2bf403e4 Set undo-boundary for quick modification by user.
HIROSE Yuuji <yuuji@gentei.org>
parents: 331
diff changeset
51 (undo-boundary)
43fb2bf403e4 Set undo-boundary for quick modification by user.
HIROSE Yuuji <yuuji@gentei.org>
parents: 331
diff changeset
52 (save-excursion
43fb2bf403e4 Set undo-boundary for quick modification by user.
HIROSE Yuuji <yuuji@gentei.org>
parents: 331
diff changeset
53 (goto-char envstart)
43fb2bf403e4 Set undo-boundary for quick modification by user.
HIROSE Yuuji <yuuji@gentei.org>
parents: 331
diff changeset
54 (insert b))
43fb2bf403e4 Set undo-boundary for quick modification by user.
HIROSE Yuuji <yuuji@gentei.org>
parents: 331
diff changeset
55 (YaTeX-indent-line)
43fb2bf403e4 Set undo-boundary for quick modification by user.
HIROSE Yuuji <yuuji@gentei.org>
parents: 331
diff changeset
56 (insert "\n")
43fb2bf403e4 Set undo-boundary for quick modification by user.
HIROSE Yuuji <yuuji@gentei.org>
parents: 331
diff changeset
57 (indent-to (1+ cc))
43fb2bf403e4 Set undo-boundary for quick modification by user.
HIROSE Yuuji <yuuji@gentei.org>
parents: 331
diff changeset
58 (setq p1 (point))
43fb2bf403e4 Set undo-boundary for quick modification by user.
HIROSE Yuuji <yuuji@gentei.org>
parents: 331
diff changeset
59 (insert "\\caption{")
43fb2bf403e4 Set undo-boundary for quick modification by user.
HIROSE Yuuji <yuuji@gentei.org>
parents: 331
diff changeset
60 (setq p2 (point))
43fb2bf403e4 Set undo-boundary for quick modification by user.
HIROSE Yuuji <yuuji@gentei.org>
parents: 331
diff changeset
61 (insert (format "}\\label{%s}\n" path))
43fb2bf403e4 Set undo-boundary for quick modification by user.
HIROSE Yuuji <yuuji@gentei.org>
parents: 331
diff changeset
62 (indent-to cc)
43fb2bf403e4 Set undo-boundary for quick modification by user.
HIROSE Yuuji <yuuji@gentei.org>
parents: 331
diff changeset
63 (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
64 (goto-char p2)
43fb2bf403e4 Set undo-boundary for quick modification by user.
HIROSE Yuuji <yuuji@gentei.org>
parents: 331
diff changeset
65 (undo-boundary)
43fb2bf403e4 Set undo-boundary for quick modification by user.
HIROSE Yuuji <yuuji@gentei.org>
parents: 331
diff changeset
66 (insert (file-name-nondirectory path))
43fb2bf403e4 Set undo-boundary for quick modification by user.
HIROSE Yuuji <yuuji@gentei.org>
parents: 331
diff changeset
67 (undo-boundary)
43fb2bf403e4 Set undo-boundary for quick modification by user.
HIROSE Yuuji <yuuji@gentei.org>
parents: 331
diff changeset
68 (goto-char p1)
43fb2bf403e4 Set undo-boundary for quick modification by user.
HIROSE Yuuji <yuuji@gentei.org>
parents: 331
diff changeset
69 (insert "%")
43fb2bf403e4 Set undo-boundary for quick modification by user.
HIROSE Yuuji <yuuji@gentei.org>
parents: 331
diff changeset
70 (end-of-line)
43fb2bf403e4 Set undo-boundary for quick modification by user.
HIROSE Yuuji <yuuji@gentei.org>
parents: 331
diff changeset
71 (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
72 (progn
43fb2bf403e4 Set undo-boundary for quick modification by user.
HIROSE Yuuji <yuuji@gentei.org>
parents: 331
diff changeset
73 (newline 1)
43fb2bf403e4 Set undo-boundary for quick modification by user.
HIROSE Yuuji <yuuji@gentei.org>
parents: 331
diff changeset
74 (indent-to (1+ cc))
43fb2bf403e4 Set undo-boundary for quick modification by user.
HIROSE Yuuji <yuuji@gentei.org>
parents: 331
diff changeset
75 (insert (format
43fb2bf403e4 Set undo-boundary for quick modification by user.
HIROSE Yuuji <yuuji@gentei.org>
parents: 331
diff changeset
76 (if YaTeX-japan
43fb2bf403e4 Set undo-boundary for quick modification by user.
HIROSE Yuuji <yuuji@gentei.org>
parents: 331
diff changeset
77 "%% Undo(%s)するとcaptionが活きます。2度押しで空欄 3度押しで無環境"
43fb2bf403e4 Set undo-boundary for quick modification by user.
HIROSE Yuuji <yuuji@gentei.org>
parents: 331
diff changeset
78 "%% 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
79 (key-description
43fb2bf403e4 Set undo-boundary for quick modification by user.
HIROSE Yuuji <yuuji@gentei.org>
parents: 331
diff changeset
80 (car (where-is-internal 'undo)))))
43fb2bf403e4 Set undo-boundary for quick modification by user.
HIROSE Yuuji <yuuji@gentei.org>
parents: 331
diff changeset
81 (put 'YaTeX-dnd-auto-figure 'guide t)))))
348
3478a327ae41 DnD *.ind and *.big file
HIROSE Yuuji <yuuji@gentei.org>
parents: 344
diff changeset
82 (YaTeX-help "includegraphics"))
343
43fb2bf403e4 Set undo-boundary for quick modification by user.
HIROSE Yuuji <yuuji@gentei.org>
parents: 331
diff changeset
83 (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
84 action))
344
bfd7a5998555 Give argument for \include without `.tex' extension.
HIROSE Yuuji <yuuji@gentei.org>
parents: 343
diff changeset
85 ((string-match "\\(.*\\)\\.tex$" path)
348
3478a327ae41 DnD *.ind and *.big file
HIROSE Yuuji <yuuji@gentei.org>
parents: 344
diff changeset
86 (insert "\\include{" (match-string 1 path) "}"))
3478a327ae41 DnD *.ind and *.big file
HIROSE Yuuji <yuuji@gentei.org>
parents: 344
diff changeset
87 ((string-match "\\(.*\\)\\.bib$" path)
3478a327ae41 DnD *.ind and *.big file
HIROSE Yuuji <yuuji@gentei.org>
parents: 344
diff changeset
88 (insert "\\bibliography{" (match-string 1 path) "}"))
3478a327ae41 DnD *.ind and *.big file
HIROSE Yuuji <yuuji@gentei.org>
parents: 344
diff changeset
89 ((string-match "\\.ind$" path)
3478a327ae41 DnD *.ind and *.big file
HIROSE Yuuji <yuuji@gentei.org>
parents: 344
diff changeset
90 (insert "\\input{" path "}"))))
343
43fb2bf403e4 Set undo-boundary for quick modification by user.
HIROSE Yuuji <yuuji@gentei.org>
parents: 331
diff changeset
91 (t (message "%s" action)))))
330
9cef5d10a0f1 First Drag-n-Drop support
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
92
377
81413ee9c32d Use overlay to distinguish border of on-the-fly preview area.
HIROSE Yuuji <yuuji@gentei.org>
parents: 376
diff changeset
93 (defvar YaTeX-on-the-fly-bg-face '("#f0f0c0" . "#706868")
376
1bbd0c2b340f When on-the-fly preview activated, overlay indicate its busy state.
HIROSE Yuuji <yuuji@gentei.org>
parents: 366
diff changeset
94 "Background color of on-the-fly preview image activated environment.")
1bbd0c2b340f When on-the-fly preview activated, overlay indicate its busy state.
HIROSE Yuuji <yuuji@gentei.org>
parents: 366
diff changeset
95 (defvar YaTeX-on-the-fly-overlay nil
1bbd0c2b340f When on-the-fly preview activated, overlay indicate its busy state.
HIROSE Yuuji <yuuji@gentei.org>
parents: 366
diff changeset
96 "Overlay of on-the-fly preview image")
1bbd0c2b340f When on-the-fly preview activated, overlay indicate its busy state.
HIROSE Yuuji <yuuji@gentei.org>
parents: 366
diff changeset
97 (defface YaTeX-on-the-fly-activated-face
1bbd0c2b340f When on-the-fly preview activated, overlay indicate its busy state.
HIROSE Yuuji <yuuji@gentei.org>
parents: 366
diff changeset
98 (list
381
fc1ad3b337a9 Platform dependent default parameters adjusted
HIROSE Yuuji <yuuji@gentei.org>
parents: 377
diff changeset
99 (list (list '(class color) '(min-colors 65536))
376
1bbd0c2b340f When on-the-fly preview activated, overlay indicate its busy state.
HIROSE Yuuji <yuuji@gentei.org>
parents: 366
diff changeset
100 (list ':background
1bbd0c2b340f When on-the-fly preview activated, overlay indicate its busy state.
HIROSE Yuuji <yuuji@gentei.org>
parents: 366
diff changeset
101 (if (eq YaTeX-background-mode 'light)
1bbd0c2b340f When on-the-fly preview activated, overlay indicate its busy state.
HIROSE Yuuji <yuuji@gentei.org>
parents: 366
diff changeset
102 (car YaTeX-on-the-fly-bg-face)
1bbd0c2b340f When on-the-fly preview activated, overlay indicate its busy state.
HIROSE Yuuji <yuuji@gentei.org>
parents: 366
diff changeset
103 (cdr YaTeX-on-the-fly-bg-face))))
1bbd0c2b340f When on-the-fly preview activated, overlay indicate its busy state.
HIROSE Yuuji <yuuji@gentei.org>
parents: 366
diff changeset
104 (list t (list ':bold t)))
1bbd0c2b340f When on-the-fly preview activated, overlay indicate its busy state.
HIROSE Yuuji <yuuji@gentei.org>
parents: 366
diff changeset
105 "Face of on-the-fly preview image mode")
1bbd0c2b340f When on-the-fly preview activated, overlay indicate its busy state.
HIROSE Yuuji <yuuji@gentei.org>
parents: 366
diff changeset
106
330
9cef5d10a0f1 First Drag-n-Drop support
HIROSE Yuuji <yuuji@gentei.org>
parents:
diff changeset
107 (provide 'yatex23)

yatex.org