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
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))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Related
I'm looking to build a capture template that, when run, prompts the user for more information to determine the path of the target file.
I have a few pieces already.
A function which asks the user for data and returns a string:
(defun my/get-121-orgfile ()
"Ask the user for the name of the participant so that we can build"
(interactive)
(read-string "Participant Name: ")
)
An org-capture-template which will run the prompt successfully when emacs loads:
(setq org-capture-templates
`(
("m1" "1-1 meetings")
("m1b" "prep for a 1-1 meeting" entry
(file ,(concat "~/org/meetings/1-2-1/" (my/get-121-orgfile) ".org"))
(file "~/org/templates/meeting-121-prep.org")
:clock-in t)
))
I took the back quote and comma pattern from this SO answer, but I haven't been able to figure out how to scope this behaviour to when I select the template: I want the prompt to pop up each time I hit <org-capture>m1b.
The backquote-comma pattern will not help here: it will call the function at the time that org-capture-template is set. What you are trying to do is to call the function when the capture is executed.
The only way I know to do that would to use the (function foo) target mechanism of org-capture-templates. The doc string says:
(function function-finding-location)
Most general way: write your own function which both visits
the file and moves point to the right location
So you would not be able to use the (file ...) target as you do above. Instead you have to write a function that gets all the information you want and then visit the target file at the target location and add the filled-out template.
This is not a complete answer but it was too long for a comment, but maybe it helps to point you in the right direction.
I use DocView Mode to display .pdf compilations via "latex-preview-pane-mode." Recently, Emacs will ask me "file ____.pdf changed on disk. Reread from disk? (yes or no)".
Typing "yes" each time disrupts my workflow. I have tried setting auto-revert-mode for the DocView buffer, but this did not help. Is there any way to fix this, or any idea why it changed suddenly (no changes to my .emacs.d in the recent past).
To achieve what Tristan suggests, first I tried M-x customize-variable RET revert-without-query, but couldn't get very far, so I wrote this in my init.el file:
(setq revert-without-query '(".pdf"))
and I'm happily udating my pdf files from org-mode without getting queried every time. (I use pdf-tools).
Source: fourth answer to a similar question in stackoverflow
(defun revert-buffer-no-confirm ()
"Revert buffer without confirmation."
(interactive)
(revert-buffer :ignore-auto :noconfirm))
Source: http://www.emacswiki.org/emacs-en/download/misc-cmds.el
Maybe this function could help you out
Take a look at the variable revert-without-query. From the Emacs Lisp documentation:
This variable holds a list of files that should be reverted without
query. The value is a list of regular expressions. If the visited
file name matches one of these regular expressions, and the file
has changed on disk but the buffer is not modified, then
‘revert-buffer’ reverts the file without asking the user for
confirmation.
Adding .+\.pdf to the list should make buffers visiting pdf files revert when you change the file on disk.
When I modify a buffer, Emacs automatically creates a temporary symlink in the same directory as the file being edited (e.g. foo.c):
.#foo.c -> user#host.12345:1296583136
where '12345' is Emacs' PID (I don't know what the last number means).
Why does Emacs create these links, and how do I prevent it from doing that?
Note that I have turned off auto save mode (M-x auto-save-mode) and disabled backup files (M-x set-variable -> make-backup-files -> nil). When I save a modified buffer, or undo the changes to it, the symlink disappears.
In particular, I'm trying to prevent Emacs from creating these links because they cause the directory timestamp to be modified, which causes our build system to rebuild an entire module instead of compiling and linking for one changed file :/
Thanks for any input!
Update: In order to prevent Emacs from creating interlocking files permanently, you can change src/filelock.c and build a custom binary:
void
lock_file (fn)
Lisp_Object fn;
{
return;
// Unused code below...
}
Update 2: Arne's answer is correct. It's now possible to disable lock files in the latest Emacs (24.3.1), by adding this to your .emacs file:
(setq create-lockfiles nil)
Update: Emacs 24.3 has been released with full support for this new setting!
In the current trunk of emacs, you can simply customize the variable create-lockfiles:
C-h v create-lockfiles
Documentation:
Non-nil means use lockfiles to avoid editing collisions.
In your init file, you can set
(setq create-lockfiles nil)
Get it via
bzr branch bzr://bzr.savannah.gnu.org/emacs/trunk emacs-trunk
make
src/emacs
(I found out about this, because I decided to get active and just add an option like that myself… :) )
The symbolic link is emacs' file interlocking system: the symbolic link indicates that an instance of emacs is editing this file. If another instance tries to edit the same file, emacs will issue a warning. See http://www.gnu.org/software/emacs/manual/html_node/emacs/Interlocking.html
This has nothing to do with auto-save.
I cannot find how to modify or disable file locking from within emacs.
So, way back in January, I went here:
http://emacsformacosx.com/
I downloaded Emacs and have been using it on my Mac and I like it. I've started trying to get into Elisp programming. To learn more, I'd like to look up some functions. So for instance I do:
C-h f
and then type "scroll-down"
This gives me the following text:
>scroll-down is an interactive built-in function in `window.c'.
>
>It is bound to <kp-prior>, <prior>, C-1, C-x C-1, M-v.
>
>(scroll-down &optional ARG)
>
>Scroll text of selected window down ARG lines.
>If ARG is omitted or nil, scroll down by a near full screen.
>A near full screen is `next-screen-context-lines' less than a full screen.
>Negative ARG means scroll upward.
>If ARG is the atom `-', scroll upward by nearly full screen.
>When calling from a program, supply as argument a number, nil, or `-'.
And the text "window.c" is a link. So I click on the link and I get:
find-function-C-source: The C source file window.c is not available
I'm getting this error a lot while doing a lot of different things. Where do I find the right path, and how do I tell Emacs what that path is?
I did just recently install some ELPA packages, so maybe one of them is causing some chaos?
The variable source-directory will point to the location where the C sources are. If you have a separately downloaded copy, you'll have to point this variable to that directory.
Most packagers don't include the sources, or split them off into a separate package. Install the sources (and maybe tweak an init script to tell Emacs where you put them, if it's not the default location. The pertinent variable is find-function-C-source-directory).
If you didn't manually build Emacs from the source code and patch the C source code, value of source-directory or find-function-C-source-directory would be wrong.
You can manually download Emacs source code, unpack it somewhere and set above two variables accordingly like following
(setq source-directory "/path/to/your-emacs-repo")
;; OR
(setq find-function-C-source-directory "/path/to/your-emacs-repo/src")
GNU Emacs source code and development is hosted on savannah.gnu.org. You can find all the tags here and download the one that matches your M-x emacs-version.
I'm in love with emacs. I don't believe there is anything one can't do with enough effort!
I have just fine working scripts/extensions installed that could be relevant to get my point:
org-mode (with a CAPTURE-TEMPLATE named "Journal")
color-theme (emacswiki)
theme-changer (github)
color-theme-buffer-local (github)
emacs-version: "GNU Emacs 23.3.1 (i686-pc-linux-gnu, GTK+ Version 2.24.10) of 2012-03-25 on roseapple, modified by Debian"
Whats already working fine
When I'm starting a journal-entry trough my defined shortcut, what happens is the following:
emacs opens a new buffer("CAPTURE-journal.org") in a new window
I edit it
with another keystroke the entry gets refiled to my defined journal.org file
the buffer and the window are then closed automatically
I continue working on the file I worked before
What I want it to do additionally:
the "CAPTURE-journal.org"-buffer in the new window should have a unique color-theme, lets say color-theme-retro-orange
My .emacs with the code snippet I believe should be relevant.
I have no idea how to tackle this task. Where does one begin editing? Are even all tools needed for this listed above?
Seen from scratch: you need a list with color-themes
(setq my-themes (list "color-theme-retro-orange" "second-theme" "third...))
than you need a pointer, storing position used last.
See Emacs Lisp Intro chapter of kill-ring-save
When finished, bind that function at a suitable place, where-from your buffer is opened, resp. load it with the stuff mentioned by OP.
Or create a minor-mode, which will all new buffers provide with this.