Force DocView mode to show updated file without confirmation? - emacs

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.

Related

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

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.

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

emacs color-theme by buffer

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.

Suggestion for \cite in Emacs with AUCTeX

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.

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.