Is it possible to prevent emacs from creating " .#files " [duplicate] - emacs

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.

Related

Force DocView mode to show updated file without confirmation?

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.

Shift selection in Emacs 24 does not highlight text

I must be stupid, but I just switched to Emacs 24, and holding Shift while moving the point no longer highlights text. Mouse selection works as before. What am I missing? Did I turn it off by chance? Or has Shift selection been deemed unergonomical so we have some other, better keyboard-based selection at hand?
Shift selection is enabled by default in Emacs 24.
You can always run emacs -Q to disable your init file and any other default libraries, in order to determine what Emacs' default behaviour is.
You can also run emacs -q which will disable only your init file (other system-wide init files can be loaded).
If the feature works without your init file and does not work with it, you can then start to narrow down what part of your init file is at fault (often by commenting out functionality until the feature starts working as expected -- note Drew's comment).
In this case I suggest that you firstly verify (using C-hv) that the shift-select-mode variable is non-nil (when running with your normal configuration), as a nil value means that shift selection is disabled.
I also found it useful to look at load-path variable, C-h v load-path, which directed me to the culprits, old elpa packages.

Bookmark+ using a temporary file, despite having asked for a specific file

After typing C-x r l I get a buffer called *Bookmark List*
In this buffer I see:
Bookmark file:
/tmp/bmkp-temp/19236bkt
If I open help (i.e. press h), I see:
Bookmark file: /tmp/bmkp-temp-19236bkt
Sorted:
Filtering: none
Marked: 0
Omitted: 0
Autosave bookmarks: no
Autosave list display: yes
This is even though I have the following in my .emacs file:
(setq bookmark-file "~/.emacs.d/bookmarks")
(setq bookmark-default-file "~/.emacs.d/bookmarks")
(setq bmkp-default-bookmark-file "~/.emacs.d/bookmarks")
(setq bmkp-last-as-first-bookmark-file nil)
Why is it using a different bookmark file from the one I specified?
I also noticed that when I load Emacs the following happens:
Emptying bookmark file `/tmp/bmkp-temp-23808OMn'...
Saving file /tmp/bmkp-temp-23808OMn...
Wrote /tmp/bmkp-temp-23808OMn
Emptying bookmark file `/tmp/bmkp-temp-23808OMn'...done
...
Helm completion enabled
Emptying bookmark file `/tmp/bmkp-temp-23808bWt'...
Saving file /tmp/bmkp-temp-23808bWt...
Wrote /tmp/bmkp-temp-23808bWt
Emptying bookmark file `/tmp/bmkp-temp-23808bWt'...done
...
Emacs goes on a spree deleting temporary bookmark files. ?
Perhaps you were trying to use "bookmark-file bookmarks"? Or anyways, accidently hit C-x p x?
These are claimed to correspond, at EmacsWiki: Bookmark Plus / Bookmark-File Bookmarks, where they say, "bmkp-set-bookmark-file-bookmark, bound to C-x p x". For my Emacs, this is not true.
By typing C-x p C-h, I can check key-bindings that start with C-x p. I find
C-x p x is bound to bmkp-toggle-autotemp-on-set, and
C-x p y is bound to bmkp-set-bookmark-file-bookmark.
Then, the link should say C-x p y instead.
It looks like something, somewhere (e.g. check your .emacs file) has turned on bmkp-temporary-bookmarking-mode. When that mode is on, any bookmarks you create are for the current session only -- they are not saved to your bookmark file.
And that means that your bookmark-file location settings are ignored. (Note, BTW, that bmkp-default-bookmark-file is a function, not a variable -- it is not something that you set. And you don't need all of those bookmark-file settings; some are redundant: old names from old versions of Emacs bookmarking.)
I don't know why you are getting multiple temporary bookmark-file creations and saves. You didn't provide a complete recipe. You should get only one such. This is all I see in *Messages* in this regard, for instance:
Emptying bookmark file `c:/DOCUME~1/me/LOCALS~1/Temp/bmkp-temp-5348su1'...
Saving file c:/Documents and Settings/me/Local Settings/Temp/bmkp-temp-5348su1...
Wrote c:/Documents and Settings/me/Local Settings/Temp/bmkp-temp-5348su1
Emptying bookmark file `c:/DOCUME~1/me/LOCALS~1/Temp/bmkp-temp-5348su1'...done
It also appears that you have a lot of stuff going on (Helm etc.). When trying to understand or debug a problem, it helps to narrow things down as much as possible. Who can tell what other interactions might be involved here?
All of that said, my advice would be to not start out using the temporary bookmarking mode. I would not suggest you use that until you are quite familiar with Bookmark+. You can use temporary bookmarks without using this mode.
Here is the doc about using temporary bookmarks:
http://www.emacswiki.org/cgi-bin/wiki/BookmarkPlus#toc55
Finally, as Stefan suggested, please follow up by email. It's a lot easier for debugging/discussing things in detail.
Thx -- Drew
Update 2019-04-21:
I think what might have happened is that you quit Emacs with bmkp-temporary-bookmarking-mode enabled. Although Bookmark+ (correctly) does not save the file of temporary bookmarks it was not preventing the recording of bmkp-last-as-first-bookmark-file from being updated to point to the temporary file. In your next Emacs session that temporary file (if it still existed) was loaded because of bmkp-last-as-first-bookmark-file.
That should be OK now. Enabling bmkp-temporary-bookmarking-mode now resets bmkp-last-as-first-bookmark-file to nil, so if you quit with the temp mode still enabled, then when you load your bookmark file in a new session the file that is read is the value of bookmark-default-file. (The value of bookmark-default-file is never changed, except by your
customizations.)
It's quite an old question, but since I had just the same problem and the other answers didn't help me I'll post my solution:
I'm using desktop files from desktop.el and the temporary mode was set there in the desktop file! Removing that setting from all my desktop files fixed the problem.
This might be handy:
find ~ -name .emacs.desktop -print0 | xargs -0 grep -l bmkp-temporary-bookmarking-mode

What should I use as a config/settings file with emacs prelude?

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.

emacs: force ido-mode to forget history

I wonder if I can keep ido from not remembering my history and only show completions for files that are in the current directory when I am searching for a file. I understand that this history feature is useful at times, but I often end up editing the incorrect file because I think I am editing file called 'abc.txt' in the current directory but in fact I am editing the file by the same name in another one that I previously visited (often happens when there is not an 'abc.txt' in the current directory, as I mistakenly assume). From reading the ido.el file I thought to set in my .emacs file (also evaluated these expressions in running emacs instance):
(custom-set-variables
'(ido-enable-last-directory-history nil)
'(ido-record-commands nil)
)
and deleted a file called .ido.last in ~/, but still it remembers some previous files I've visited before making these changes. How can I purge my previous history, and I am not entirely sure what the difference between the two variables above are but seems to have done the trick to keep ido from remembering files I visit in the future?
Thanks for your help!
Deleting ~/.ido.last and setting the variables as above appears to keep ido from searching files visited in the past.
Edit: Actually, the full customization for this task would be
(custom-set-variables
'(ido-enable-last-directory-history nil)
'(ido-record-commands nil)
'(ido-max-work-directory-list 0)
'(ido-max-work-file-list 0))
This happens to me all the time. Given I am in directory /path/to/dir and I try to edit abc.txt, (ido-find-file) will "helpfully" pop me over to /somewhere/else/abc.txt if /path/to/dir/abc.txt doesn't exist and /somewhere/else/abc.txt does.
In this situtation, CTRL-F in the minibuffer when in the middle of an (ido-find-file) reverts to the usual behavior of (find-file), so I can force Emacs to edit /path/to/dir/abc.txt, dammit.
Setting ido-auto-merge-work-directories-length to -1 disables automatic directory switching.