Org-mode capture and Evil - go into insert mode automatically - emacs

I'm using org-mode capture to create small notes and todos. I'm also using evil-mode.
What I'd love to do is to automatically go into insert-mode when I go into a capture. I've tried adding a hook to org-capture-mode-hook and running (evil-insert) in the hook, but that doesn't work. Is there anything else I can try?
Thanks!
Simon

(add-hook 'org-capture-mode-hook 'evil-insert-state)

You can try
(evil-set-initial-state 'org-capture-mode 'insert)

Related

Removing DocView Welcome Page on Emacs

Emacs 23 can view PDF files inside the editor which is great. However it also shows a welcome page, for every PDF page, like this:
How can I remove this welcome page? I understand Emacs is doing some processing for the PDF page, and it probably does not want the user to try to open the file over and over again while it is doing that, but I'd prefer and hourglass instead of a whole page.
I tried setting doc-view-conversion-refresh-interval to nil BTW, it didnt work.
I am on GNU Emacs 23.2.1 (i686-pc-linux-gnu, GTK+ Version 2.24.4).
Thanks,
WRT your answer, it sounds like you either edited the original file, or made a replacement copy of that entire library.
The first way will be lost when you update Emacs. The second way means you won't get any improvements to that library when you update Emacs. Neither is a very good option.
Instead you can tell Emacs that if and when it loads the original library, it should re-define that one function at that time.
This minimises the potential problems associated with upgrades, and does not require you to load the library unconditionally in your .emacs (which would increase your start-up time unnecessarily for sessions where you didn't load any PDFs).
(eval-after-load 'doc-view
'(defun doc-view-buffer-message ()
;; your definition here
))
I think you need to press C-c C-c
I found doc-view.el source for Emacs 23, and I removed the message from doc-view-buffer-message function. So now when PDF is loaded an empty page is shown which is less confusing, welcome page made it look like the PDF was loaded.
After the changes I did byte-compile-file on the el file, and at the end of my .emacs I load this overriding the original doc-view.

Is there an Emacs hook that runs after every buffer is created?

I'm looking to run some code every time Emacs creates a buffer. Is there a hook for this? Something with a name like after-make-buffer-functions?
Edit: If anyone wants to know what I wanted this for, you can read the relevant portion of my Emacs config here: https://github.com/DarwinAwardWinner/dotemacs/blob/master/site-lisp/settings/tempbuf-settings.el
Basically, I want tempbuf-mode to be enabled in all buffers with certain major modes. So Lindydancer's answer is actually more appropriate than what I was originally looking for.
I know that I could already enable tempbuf-mode in specific modes by adding the tempbuf mode hook to all of those major mode hooks, but I wanted to make it editable through M-x customize, and this was the easiest way.
Unfortunately, no. Emacs use the low-level function ´get-buffer-create´ to create buffers, and it does not provide any hook mechanism.
You could use advice to pick-up all calls to this function, even though I would not recommend this method as it is quite intrusive. (Update: The advice hook will only see calls from elisp, not calls from the Emacs C core parts.)
There are some alternatives which you could use, depending on what you are implementing:
change-major-mode-hook -- called before a major mode change.
after-change-major-mode-hook -- called when the major mode is beginning to change.
You can use buffer-list-update-hook
buffer-list-update-hook
This is a normal hook run whenever the buffer list changes
You can define a function to do whatever you want.
(defun awesome-foo ()
;; do awesome things
)
Hook that function to buffer list hook
(add-hook 'buffer-list-update-hook 'awesome-foo)

Enabling viper-mode and vimpulse in compilation-mode

viper.el is hardcoded to disable viper in compilation-mode. How can I fix this without modifying the original file?
If you really want to do this, you should be able to customize the variable viper-emacs-state-mode-list and remove compilation-mode.
Have you tried running "M-x viper-mode"? That's what I do when I end up in a buffer in which it has been disabled, or at least not enabled.

How can I make emacs stop loading viper-mode?

I'm developing a mode for Emacs, and everytime I switch to its buffer, viper gets turned on. I've modified viper-mode to trace where viper-mode is being called, and surprisingly set-viper-state-in-major-mode is called by running the viper-post-command-hooks, set to nil. Any idea of what is going on?
Thanks!
EDIT: For the benefit of all beings, here is what I found out: as instructed by Trey, I started emacs with -Q and manually loaded both viper and my package. As I could reproduce the bug, the problem was on one of these packages. After line-by-line filtering, I discovered that the innoquous-looking (kill-all-local-variables) was causing the problem.
There's something in initialization that's causing it.
First try starting without your .emacs emacs -q. If the problem persists, then the trigger is in the site-start.el. So, talk to whomever installed Emacs and get them to remove the customizations there. You can also always use the -Q startup option to avoid loading the site-start.el.
If the problem isn't in site-start.el, and you don't think it's in your .emacs, it might be in a custom default.el file, which you can prevent from being loaded by adding:
(setq inhibit-default-init t)
to your .emacs.
If you still have a problem, then I'm 99% sure it's in your .emacs.
To be 100% sure, try emacs -Q, which runs Emacs with no customizations. If the problem persists, download and install your own Emacs b/c you surely can't trust the installation you're using.
So, now if you're convinced it's in your .emacs, start cutting out parts of your .emacs, or introduce an error in your .emacs with (error "frog"), and progressively rule out which portions of your .emacs are causing the problem.
g'luck
The function kill-all-local-variables will run all functions added to change-major-mode-hook, this is a common way for global minor modes to initialize themselves. For example, global font lock and global cwarn mode use this.
I haven't used viper myself, but chances are that it use this mechanism. Of course, you still would have had to enable it in your init file, somehow, so if you simply would stop doing this, it would solve your problem as well.
Try commenting out any references to viper mode in your .emacs. I don't get sent into viper mode, unless I start playing around with viper mode before I eval your new mode.
Maybe there's more being done with this statement than you think:
(use-local-map ecoli-map)
Try to change some of your binds in your map. eg. j to C-j and k to C-k.
Maybe emacs is getting confused?
Try removing your ~/.viper config file, and also check your .custom.el for settings that might kick viper into action in your major mode (or globally).

docview in emacs: refreshing dvi content automatically

Is there a way Emacs can automatically refresh the buffer showing the dvi right after my LaTeX compilation?
Thank you.
The global auto revert is not always desirable, in fact I only use it for for the DocView to see the new output of pdflatex.
The following will allow auto revert for the DocView major mode
(add-hook 'doc-view-mode-hook 'auto-revert-mode)
Use interactive function:
auto-revert-mode
to enable reloading when the file changes.