auctex
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[AUCTeX] Fwd: Re: just wondering ...


From: Dr. Ing. Dieter Jurzitza
Subject: [AUCTeX] Fwd: Re: just wondering ...
Date: Sat, 1 Nov 2014 16:06:11 +0100
User-agent: KMail/1.13.6 (Linux/3.11.10-21-desktop; KDE/4.11.5; x86_64; ; )

Sorry, just discovered that I had forgotten to forward to the list ... only 
have been sending to David Kastrup

Dear listmembers,
so, below please find the patch I am using right now. It leads beyond my lisp 
- capabilities to judge the "crudeness" of this, I can only say one thing: it 
is woking on openSUSE linux - I haven't tested anything else.

Thank you for looking into this, take care





Dieter Jurzitza


--- tex.el.original     2014-10-31 19:33:28.492129180 +0100
+++ tex.el      2014-10-31 19:37:20.036344699 +0100
@@ -54,6 +54,11 @@
   "Various AUCTeX settings."
   :group 'AUCTeX)
 
+(defgroup AUCTeX-dnd nil
+  "A (La)TeX drag-and-drop mode."
+  :tag "AUCTeX"
+  :group 'AUCTeX)
+  
 ;;; Site Customization
 ;;
 ;; The following variables are likely to need to be changed for your
@@ -6103,6 +6108,48 @@
        (fax-sort-aliasesfile)
        (save-buffer))
 
+(defcustom AUCTeX-dnd-format "\\includegraphics[scale=1.0,angle=0]{%s}"
+  "What to insert, when a file is dropped on Emacs window. %s is
+replaced by the actual file name. If the filename is located
+under the directory of .tex document, only the part of the name
+relative to that directory in used."
+  :type 'string
+  :group 'AUCTeX)
+
+
+(defun AUCTeX-dnd-includegraphics (uri action)
+  "Insert the text defined by `AUCTeX-dnd-format' when a file is
+dropped on Emacs window."
+  (let ((file (dnd-get-local-file-name uri t)))
+    (when (and file (file-regular-p file))
+      (let* ((curdir (file-name-directory buffer-file-name))
+             (path (if (string-match curdir file)
+                       (replace-match "" t t file)
+                     file)))
+        (insert (format AUCTeX-dnd-format path))))))
+
+(defcustom AUCTeX-dnd-protocol-alist
+  '(("^file:///" . AUCTeX-dnd-includegraphics)
+    ("^file://"  . dnd-open-file)
+    ("^file:"    . AUCTeX-dnd-includegraphics))
+  "The functions to call when a drop in `mml-mode' is made.
+See `dnd-protocol-alist' for more information.  When nil, behave
+as in other buffers."
+  :type '(choice (repeat (cons (regexp) (function)))
+                 (const :tag "Behave as in other buffers" nil))
+  :version "22.1" ;; Gnus 5.10.9
+  :group 'AUCTeX)
+
+
+(define-minor-mode AUCTeX-dnd-mode
+  "Minor mode to inser some text (\includegraphics by default)
+when a file is dopped on Emacs window."
+  :lighter " DND"
+  (when (boundp 'dnd-protocol-alist)
+    (if AUCTeX-dnd-mode
+        (set (make-local-variable 'dnd-protocol-alist)
+             (append AUCTeX-dnd-protocol-alist dnd-protocol-alist))
+      (kill-local-variable 'dnd-protocol-alist))))
 ;; local additions done
 
 ;; Some versions of ispell 3 use this.


-- 
-----------------------------------------------------------

                               |
                                \
                 /\_/\           |
                | ~x~ |/-----\   /
                 \   /-       \_/
  ^^__   _        /  _  ____   /
 <°°__ \- \_/     |  |/    |  |
  ||  ||         _| _|    _| _|

if you really want to see the pictures above - use some font
with constant spacing like courier! :-)
-----------------------------------------------------------

-----------------------------------------
-- 
-----------------------------------------------------------

                               |
                                \
                 /\_/\           |
                | ~x~ |/-----\   /
                 \   /-       \_/
  ^^__   _        /  _  ____   /
 <°°__ \- \_/     |  |/    |  |
  ||  ||         _| _|    _| _|

if you really want to see the pictures above - use some font
with constant spacing like courier! :-)
-----------------------------------------------------------



reply via email to

[Prev in Thread] Current Thread [Next in Thread]