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