Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Loading drawing program through emacs

I'm looking for a way to integrate a drawing program with emacs. I often write lecture notes in LaTeX using emacs. The problem is that when the presenter draws a diagram I start to scramble to draw out the diagram, save it, and type the location into my TeX file in a reasonable time.

Is it possible to set up emacs such that when I press a key combination a drawing program will load (e.g. pinta) and once I draw the diagram, the file will automatically save in the folder of the emacs file and the name of the file will be inserted into emacs through

\includegraphics{File_Name}

If this feature is too difficult to implement please let me know as well (I'm also more than happy to try to out variations of this idea).

EDIT in response to comments: My operating system is Ubuntu 14.04 and the absolute path my drawing program is /usr/bin/pinta

like image 687
JeffDror Avatar asked Feb 07 '26 10:02

JeffDror


1 Answers

Initial Draft -- Not Fully Tested -- Prototype (June 22, 2014):  The following is a first rough draft / not fully tested protype of the concept function idea outlined in the comment beneath the question by the original poster. Because @lawlist does not have an Ubantu OS set-up, or pinta installed, the last part of the function is untested -- i.e., (start-process "open-in-pinta" nil "/usr/bin/pinta" my-new-filename). If there are additional command-line arguments needed for that start-process statement to work on Ubantu, please let me know. The variable form-graphic-file needs to have the absolute path to an already existing blank file created with the pinta program -- that file should be saved in a forms directory somewhere chosen by the user. The function copy-graphic is a modification of the function dired-do-create-files.

TODO:

  • Verify functionality of the start-process statement.

  • Convert variable form-file-graphic from a list to a string format and revise copy-graphic function accordingly.

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; \includegraphics{File_Name}

(defvar form-file-graphic "~/forms/my-empty-image.ora"
  "Absolute path to existing blank graphic file previously created with `pinta'.")

(defun copy-graphic (target)
  "This function is a modification of `dired-do-create-files'."
  (interactive
   (list (expand-file-name (read-file-name "Copy to: " nil "diagram.ora"))))
  (copy-file form-file-graphic target)
  (insert "\\includegraphics{" (file-relative-name target) "}\n")
  (start-process "open-in-pinta" nil "/usr/bin/pinta" target))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
like image 127
lawlist Avatar answered Feb 09 '26 05:02

lawlist



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!