I would like to add a hook, so that each time I open a new file, projectile is enabled. However, I don't know where to add it so that emacs will read it. Any hints?
This must surely be in Prelude's documentation? If not, I suggest you write to the author to suggest that it be added.
I note the following in its init.el file:
(defvar prelude-personal-dir (concat prelude-dir "personal/")
"Users of Emacs Prelude are encouraged to keep their personal configuration
changes in this directory. All Emacs Lisp files there are loaded automatically
by Prelude.")
Therefore you should create a personal sub-directory if it doesn't already exist, and create any *.el filename you like in that directory, for your own customisations.
Related
I am trying to use emacs as an editor with other applications which allow people to open text in an editor (Sublime in this case), save it, and see it updated in the application. For example, in Houdini, a 3D software, I can type code in an external editor (in this case, Sublime), modify, save... and see it update in the application (Houdini). When I use emacs, it doesn't work. As an example, here I am adding a line of text using Sublime in Houdini:
Once I save and close, the text is updated in Houdini, and I can continue working:
Try as I might, I can't get this to work in emacs. I am sure the file has the same name, and when I save, it confirms the right file path.
What am I missing? I have run into the same problem with an application called Joplin: Sublime works, emacs does not.
A wild guess: Emacs has different behaviour when saving files than Sublime, and Houdini gets confused by that.
When you save a file in Emacs, Emacs creates a backup of the previous contents of the file, suffixing the file name with a tilde. By default it does this by renaming the existing file to the backup name, and then writing the contents to the real filename, thereby creating a new file.
(You can observe this by running ls -i before and after: the backup file will have the inode number that the main file had previously. Note that Emacs doesn't make backups after the first save during the same editor session, so you might need to restart Emacs or kill the buffer with C-x k to see this.)
I suspect that Houdini keeps the file open while Emacs is editing it, and so when you save the file from Emacs, the file that Houdini has open is actually the backup file.
You can configure Emacs to make backups by copying instead of renaming by setting the variable backup-by-copying to t. Add this to your ~/.emacs file (creating it if it doesn't exist):
(setq backup-by-copying t)
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.
How can I view source code for a builtin Emacs package?
For instance given lisp code (require 'color), I would be interested in which functions are provided by that package. I googled emacs "color.el" and found the source code. But I wonder if this file can be viewed directly from within Emacs itself? By the way, find . -name 'color*' gives
./share/emacs/24.3/lisp/color.el.gz
./share/emacs/24.3/lisp/color.elc
You can get to the source code in a single command with M-x find-library.
You can either open the file directly in Emacs. I think .gz files are by default decompressed. Usually, I pick out one function from the package I'm interested in (e.g. org-mode), look up the documentation for that using C-hf org-mode RET and then click on the file name in the documentation buffer. It will take you the source file.
So ./share/emacs/24.3/lisp/color.el.gz is the gzipped source code, and you can open that in emacs by first doing M-x auto-compression-mode, and then visiting that file.
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.
I would like to know how can I get the suggestion when I do a \cite in Emacs-AUCTeX. The minibuffer tells me when I do C-c [ that:
No valid bibliography in this document, and no default available
So how can I set this default? I have a separated file with my bibtex references that is called by a master document, and I want the suggestion for any of the other files included.
Have you tried: Ref -> Parse Dokument -> Entire Document? That solved the problem for me.
The variable reftex-default-bibliography is what defines the default bibliography to use. I don't do much with mult-file documents, do you have reftex-plug-into-AUCTeX turned on?
Yes, modifying this variable is a solution (I don't know if it is the "best solution"). I go to the ref menu -> Customize -> Browse Reftex Group -> Reftex Citacion Support -> Reftex Default Bibliography and then I add the path to the bib file (without the .bib extension) and it works!! These options create this in the init file:
(custom-set-variables
'(reftex-default-bibliography (quote ("D:/mybibdirectory/mybibfile"))))
(custom-set-faces
)
Well, perhaps that it works now that suggestions are going to appear in every document that I write. It would be good have a solution only for this document.
Reading the help file of reftex (reftex->finding files) also mentions make the next modifications in order to get the suggestions:
(setq reftex-bibpath-environment-variables
'("D:/mybibdirectory/"))
You may also try the solution mentioned in Re: auctex - no valid bibliography?. It worked for me.
(It might help to check whether you have kpsewhich installed, before attempting to use this fix. The following command should output its path if you do have it installed:
$ which kpsewhich
)
When in the buffer of your non-master file, try to query for the name of a master file (again) with C-c _ (Control C + underscore) as explained in auctex manual
This will add the local variable TeX-master to the end of your file. Save your file, restart emacs and load your file again. Hopefully, you can now get references from the bibliography stated in your master file by calling C-c [ in the subfile.
Mysteriously, when I do this manually without letting auctex query for it, it does not work. I cannot see how the end result is different in the auto directory either. But somehow letting auctex query for the value made it work for me.