I want to get the search at point functionality ("*" and "#") in emacs.
So I want to use "*" and "#" from the emacs evil-mode, as this is one of the suggestions. However, I don't want anything else from the evil-mode, just those two functions!
This is my .emacs file:
(package-initialize)
(evil-mode 1) ;; enable evil-mode
(global-set-key (kbd "C-*") 'evil-search-symbol-forward)
(global-set-key (kbd "C-#") 'evil-search-symbol-backward)
Now the keybindings work, but I loaded the whole evil-mode, so it messes up my standard emacs keybindings like "C-y" for yank.
If I don't load the evil-mode in the .emacs file, I get the error:
Symbol's function definition is void: evil-search-symbol-forward
#event_jr's answer mentions highlight-symbols, which is probably a much more lightweight way to do what you want.
However, if you really want to use the evil version, you can (require 'evil) in your .emacs file without turning it on (ie, leave off the (evil-mode 1) statement).
Meanwhile, the functions you want are actually named evil-search-word-forward and evil-search-word-backward, not the ...-symbol-... version you saw on the wiki page (which is probably outdated).
You should use highlight-symbols for symbol jumping and highlighting.
I have an org-mode file for todos, and I have renamed the todo bullets to "Att göra" (TODO in swedish). However org-mode (in Windows, see exact version below) think it is "Att göra" (pressing M-S-RET). I can see åäö correct, but "Att göra" is not intepreted as a TODO item. I can also see in the configuration files that it is spelled "Att göra", still org-mode think it is "Att göra".
I have tried to save the configuration files and my org-mode file in UTF-8 (C-x RET f utf-8 RET). I have the following in my Emacs configuration:
;; Prefer utf-8
(prefer-coding-system 'utf-8)
(setq coding-system-for-read 'utf-8)
(setq coding-system-for-write 'utf-8)
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(inhibit-startup-screen t)
'(keyboard-coding-system (quote utf-8))
'(selection-coding-system (quote utf-8)))
This happens only in Emacs for Windows (I think this is the version number):
GNU Emacs 24.3.1 (i386-mingw-nt6.1.7601) of 2013-03-17 on MARVIN
It works in Mac, Cygwin (however I have trouble with M-S-RET as the terminal doesn't transfer that sequence right, despite that I have disabled the Alt-Enter shortcut to go fullscreen), Linux etc. It is only in Emacs Windows standalone client.
If you have any idea why this is, I would be very greateful for your suggestions.
I want to leave this question answered.
Brady told med to add
(modify-coding-system-alist 'file "" 'utf-8-unix)
to my Emacs file and it works! No idea what it really does.
I am now engaged with emacs prelude and find everything nice. But
A lot of flycheck warnings are displayed while editing el file
and syntax coloring is overrided
Warnings like "the first line shoud be of form package --- summary"
How to turn off those warnings?
These are Checkdoc warnings. To disable these, add emacs-lisp-checkdoc to the option flycheck-disabled-checkers, either with the following code in your init file
(with-eval-after-load 'flycheck
(setq-default flycheck-disabled-checkers '(emacs-lisp-checkdoc)))
or via the customize interface with M-x customize-variable RET flycheck-disabled-checkers.
If you wish to disable a particular Flycheck just for this one file, you can also use a file-local variable definition.
You can do this interactively while in the file's buffer by typing
M-x add-file-local-variable flycheck-disabled-checkers RET
(emacs-lisp-checkdoc)
which will add a local variables section to the end of the file.
;; Local Variables:
;; flycheck-disabled-checkers: (emacs-lisp-checkdoc)
;; End:
This is like customizing flycheck-disabled-checkers but only for the file.
This can also be customized on the level of the directory. http://www.gnu.org/software/emacs/manual/html_mono/emacs.html#Directory-Variables
Specifically this problem arises when working in LaTeX (auctex) for me, but I think it must have a general emacs solution.
To every doc.tex file, I have an associated and oft-edited doc.sty file in the same folder.
Is there a way that whenever I open the doc.tex file I can have emacs open the doc.sty file in that folder? I'm not proficient at all in elisp, so something very simple---it doesn't need to be robust code: it can work on the assumption that both files are named doc.* and that both exist.
Take a look at the commentary for:
M-x find-library RET find-file RET
It's not precisely what you asked for, but it is a built-in solution for opening related files. Just bind a key to ff-find-other-file (or ff-find-related-file if you prefer that alias), and you can switch back and forth between the two files easily.
In particular, see:
C-hv ff-other-file-alist RET
C-hv ff-search-directories RET
So something like this:
(add-hook 'latex-mode-hook 'my-latex-mode-hook)
(defun my-latex-mode-hook ()
"My LaTeX customisations."
(setq ff-search-directories '(".")
ff-other-file-alist '(("\\.tex$" (".sty"))
("\\.sty$" (".tex"))))
(local-set-key (kbd "C-c f") 'ff-find-other-file))
How can I get Emacs to reload all my definitions that I have updated in .emacs without restarting Emacs?
You can use the command load-file (M-x load-file, and then press Return twice to accept the default filename, which is the current file being edited).
You can also just move the point to the end of any sexp and press C-x, C-e to execute just that sexp. Usually it's not necessary to reload the whole file if you're just changing a line or two.
There is the very convenient
M-x eval-buffer
It immediately evaluates all code in the buffer. It's the quickest method if your .emacs file is idempotent.
You can usually just re-evaluate the changed region. Mark the region of ~/.emacs that you've changed, and then use M-x eval-region RET. This is often safer than re-evaluating the entire file since it's easy to write a .emacs file that doesn't work quite right after being loaded twice.
If you've got your .emacs file open in the currently active buffer:
M-x eval-buffer
Solution
M-: (load user-init-file)
Notes
you type it in Eval: prompt (including the parentheses)
user-init-file is a variable holding the ~/.emacs value (pointing to the configuration file path) by default
(load) is shorter, older, and non-interactive version of (load-file); it is not an Emacs command (to be typed in M-x), but a mere Elisp function
Conclusion
M-: > M-x
M-x load-file
~/.emacs
Others already answered your question as stated, but I find that I usually want to execute the lines that I just wrote.
For that, Ctrl + Alt + X in the Elisp part works just fine.
The following should do it...
M-x load-file
I suggest that you don't do this, initially. Instead, start a new Emacs session and test whatever changes you made to see if they work correctly. The reason to do it this way is to avoid leaving you in a state where you have an inoperable .emacs file, which fails to load or fails to load cleanly. If you do all of your editing in the original session, and all of your testing in a new session, you'll always have something reliable to comment out offending code.
When you are finally happy with your changes, then go ahead and use one of the other answers to reload. My personal preference is to eval just the section you've added/changed, and to do that just highlight the region of added/changed code and call M-x eval-region. Doing that minimizes the code that's evaluated, minimizing any unintentional side-effects, as luapyad points out.
Keyboard shortcut:
(defun reload-init-file ()
(interactive)
(load-file user-init-file))
(global-set-key (kbd "C-c C-l") 'reload-init-file) ; Reload .emacs file
C-x C-e ;; current line
M-x eval-region ;; region
M-x eval-buffer ;; whole buffer
M-x load-file ~/.emacs.d/init.el
Define it in your init file and call by M-x reload-user-init-file
(defun reload-user-init-file()
(interactive)
(load-file user-init-file))
I'm currently on Ubuntu 15.04 (Vivid Vervet); I like to define a key for this.
[M-insert] translates to Alt + Ins on my keyboard.
Put this in your .emacs file:
(global-set-key [M-insert] '(lambda() (interactive) (load-file "~/.emacs")))
Besides commands like M-x eval-buffer or M-x load-file, you can restart a fresh Emacs instance from the command line:
emacs -q --load "init.el"
Usage example: Company backends in GNU Emacs
Here is a quick and easy way to quick test your config. You can also use C-x C-e at the end of specific lisp to execute certain function individually.
C-x C-e runs the command eval-last-sexp (found in global-map), which
is an interactive compiled Lisp function.
It is bound to C-x C-e.
(eval-last-sexp EVAL-LAST-SEXP-ARG-INTERNAL)
Evaluate sexp before point; print value in the echo area.
Interactively, with prefix argument, print output into current buffer.
Normally, this function truncates long output according to the value
of the variables ‘eval-expression-print-length’ and
‘eval-expression-print-level’. With a prefix argument of zero,
however, there is no such truncation. Such a prefix argument also
causes integers to be printed in several additional formats (octal,
hexadecimal, and character).
If ‘eval-expression-debug-on-error’ is non-nil, which is the default,
this command arranges for all errors to enter the debugger.
Although M-x eval-buffer will work, you may run into problems with toggles and other similar things. A better approach might be to "mark" or highlight what’s new in your .emacs file (or even scratch buffer if you're just messing around) and then M-x eval-region.
You can set a key binding for Emacs like this:
;; Reload Emacs configuration
(defun reload-init-file ()
(interactive)
(load-file "~/.emacs"))
(global-set-key (kbd "C-c r") 'reload-init-file)
If you happen to have a shell opened inside Emacs, you can also do:
. ~/.emacs
It may save a few key strokes.