yatex

view yatex23.el @ 330:9cef5d10a0f1

First Drag-n-Drop support
author HIROSE Yuuji <yuuji@gentei.org>
date Tue, 16 Dec 2014 11:12:38 +0900
parents
children d9c547265e6e
line source
1 ;;; yatex23.el --- YaTeX facilities for Emacs 23 or later -*- coding: sjis -*-
2 ;;; (c)2014 by HIROSE Yuuji.[yuuji@yatex.org]
3 ;;; Last modified Tue Dec 16 11:08:10 2014 on firestorm
4 ;;; $Id:$
6 ;;; Code:
7 (defun YaTeX-dnd-handler (uri action)
8 "DnD handler for yatex-mode
9 Convert local image URI to \\includegraphcis{} and
10 .tex file names to \\include{}."
11 (save-excursion
12 (YaTeX-visit-main t)
13 (let*((file (dnd-get-local-file-name uri))
14 (path (file-relative-name file))
15 (insert-file-directory nil)
16 (case-fold-search t))
17 (cond
18 ((memq action '(copy link move private))
19 (cond
20 ((string-match "\\.\\(jpe?g\\|png\\|gif\\|bmp\\|tiff?\\|e?ps\\|pdf\\)$" path)
21 (insert "\\includegraphics"
22 "{" (YaTeX::includegraphics 1 path t) "}")
23 (YaTeX-package-auto-usepackage "includegraphics" 'section))
24 ((string-match "\\.tex$" path)
25 (insert "\\include{" path "}"))
26 ))
27 (t (message "%s" action))))))
29 (provide 'yatex23)
31 ; Local variables:
32 ; fill-prefix: ";;; "
33 ; paragraph-start: "^$\\| \\|;;;$"
34 ; paragraph-separate: "^$\\| \\|;;;$"
35 ; coding: sjis
36 ; End: