Emacs wiki says:
Company does interfere with
Yasnippet’s native behaviour. Here’s a
quick fix:
http://gist.github.com/265010
The code is the following:
(define-key company-active-map "\t" 'company-yasnippet-or-completion)
(defun company-yasnippet-or-completion ()
(interactive)
(if (yas/expansion-at-point)
(progn (company-abort)
(yas/expand))
(company-complete-common)))
(defun yas/expansion-at-point ()
"Tested with v0.6.1. Extracted from `yas/expand-1'"
(first (yas/current-key)))
I placed that code in my .emacs and the following message appeared:
Warning (initialization): An error occurred while loading `c:/Documents and Settings/Alex.AUTOINSTALL.001/Application Data/.emacs.elc':
Symbol's value as variable is void: company-active-map
To ensure normal operation, you should investigate and remove the
cause of the error in your initialization file. Start Emacs with
the `--debug-init' option to view a complete error backtrace.
Do I have to place the fix code inside a YASnippet's .el file?
or in my .emacs (which throws me an error)?
The snippet you mentioned doesn't work any more anyway.
Here's a snippet that you can use instead:
(defun company-yasnippet-or-completion ()
(interactive)
(let ((yas-fallback-behavior nil))
(unless (yas-expand)
(call-interactively #'company-complete-common))))
To make sure that this is called instead of company-complete-common, use
(add-hook 'company-mode-hook (lambda ()
(substitute-key-definition 'company-complete-common
'company-yasnippet-or-completion
company-active-map)))
Background: This locally changes the value of yas-fallback-behaviour, which causes yas to call company-complete-common if no completion is found.
That sounds like a problem with the load-path. The symbol value being void means that emacs can't find a definition for it - most likely because the file containing its definition has not been loaded yet.
You may try adding something like this in your .emacs (before the error-causing code):
;; where ~/.emacs.d/ is the path to a directory containing
;; additional library code you want emacs to load
(add-to-list 'load-path "~/.emacs.d/")
Related
I have strange thing in my Emacs and I can't locate it, everytime I switch a buffer I get message with major mode name even when I call the function I get minibuffer-inactive-mode
The only global function (for all modes) in my .emacs file (I think) is this:
(add-hook 'after-change-major-mode-hook (lambda ()
(if (not (memql (intern (major-mode))
'(fundamental-mode
erc-mode
text-mode
sql-mode)))
(local-set-key (kbd "RET")
'new-line-and-indent-fix))))
How to find the place that add this annoying thing? What different hook can be executed on each mode?
There is no major-mode function in vanilla Emacs. Whatever that function is in your config, it's probably responsible for displaying the message you're seeing.
You want to fix your code (as per Stefan's comment), but you probably also want to look into that non-standard function:
M-x find-function RET major-mode RET
I'm trying to enable auto-complete-mode whenever a .go file is loaded through go-mode. It works if I invoke auto-complete-mode manually for Go source files, but when I tried adding it to .emacs as below, it doesn't work:
(add-hook 'go-mode-hook auto-complete-mode)
I've tried a few variations around it but none seem to work. Following is what the Go-Mode snippet currently looks like in my .emacs:
;; Load Go Mode
(require 'go-mode-load)
(add-hook 'go-mode-hook 'auto-complete-mode)
I tried creating my own hook function like this:
;; Load Go Mode
(require 'go-mode-load)
(defun auto-complete-for-go ()
(auto-complete-mode 1))
(add-hook 'go-mode-hook 'auto-complete-for-go)
I also tried including the hook in go-mode-load.el and go-mode.el, as well as calling auto-complete-mode like this:
(auto-complete-mode t)
(provide 'go-mode)
Doesn't work either way. I also added the go-mode-hook to auto-complete-default function like so:
(defun ac-config-default ()
(setq-default ac-sources '(ac-source-abbrev ac-source-dictionary ac-source-words-in-same-mode-buffers))
(add-hook 'go-mode-hook 'ac-common-setup)
;; Other hooks
(global-auto-complete-mode t))
That doesn't work either. What's the best way to trigger a command just after a major mode is enabled for a buffer?
Here is workaround for now:
(add-to-list 'ac-modes 'go-mode)
I fixed the problem in v1.4 branch with the following commits.
Add go-mode to ac-modes
Add go-mode dictionary
Which variations have you tried? It should work if you add a single-quote in front of auto-complete-mode:
(add-hook 'go-mode-hook 'auto-complete-mode)
Without this quote, auto-complete-mode is interpreted as a variable and the value of that variable is added to go-mode-hook. For this to make sense, such a variable should contain a function reference as its value. Most likely though there will be no variable named auto-complete-mode and Emacs will complain.
By adding a quote, you tell Emacs that this is not a variable, but the actual function you want the hook to call. See also here and here.
Following this pdf document I added the following to my ~/.emacs file:
(load "auctex.el" nil t t)
(setq TeX-auto-save t)
(setq TeX-parse-self t)
(setq TeX-PDF-mode t) ;; .pdf statt .dvi per default:
;;Zeilenumbruch
;;(add-hook ’LaTeX-mode-hook ’turn-on-auto-fill)
;;Syntax Higlight
(add-hook ’LaTeX-mode-hook ’turn-on-font-lock)
;; Mathe Modus
(add-hook ’LaTeX-mode-hook ’LaTeX-math-mode)
;; Reftex einflechten und laden
(setq reftex-plug-into-AUCTeX t)
(add-hook ’LaTeX-mode-hook ’turn-on-reftex)
;; Satzende ". " statt ". ". " fuer M-k: loeschen bis Satzende usw.
;;(setq sentence-end "[.?!][]\"’)}]*\\($\\| \\| \\)[
;;]*") ;; Da ist ein "Newline in der Zeile!"
;;(setq sentence-end-double-space nil)
;;direkte Rechtschreib Korrektur:
;;(add-hook ’LaTeX-mode-hook ’flyspell-mode)
;; Nur benutzen falls Auctex > 11.81 mit preview-latex:
(load "preview-latex.el" nil t t)
;; aspell ist besser als ispell.
;; Zeile kommentieren, falls nicht installiert:
(setq-default ispell-program-name "aspell")
;; Deutsche Rechtschreibung falls \usepackage{ngerman}
;; oder german benutzt wird
(add-hook ’TeX-language-de-hook
(function (lambda () (ispell-change-dictionary "german8"))))
Unfortunately emacs doesn't start now, instead it gives the error
Warning (initialization): An error occurred while loading `/home/../.emacs':
Symbol's value as variable is void: ’LaTeX-mode-hook
To ensure normal operation, you should investigate and remove the
cause of the error in your initialization file. Start Emacs with
the `--debug-init' option to view a complete error backtrace.
When starting with --debug-init it gives the following information
Debugger entered--Lisp error: (void-variable ’LaTeX-mode-hook)
(add-hook ’LaTeX-mode-hook ’turn-on-font-lock)
eval-buffer(#<buffer *load*> nil "/home/../.emacs" nil t) ; Reading at buffer position 812
load-with-code-conversion("/home/../.emacs" "/home/../.emacs" t t)
load("~/.emacs" t t)
...
I tried using latex-mode-hook instead. I searched for a solution, but I seem to be the only one having exactly this problem.
I'm using Ubuntu 12.04 with the latest Emacs and Auctex. If required I'll post version information, but I rather think that something has to be added into the configuration or any package has to be installed instead.
How can I get emacs work with that configuration?
Are you using the wrong single quote character? it seems to be some kind of a backward quote instead of a plain single quote. Try
'LaTeX-mode-hook
instead of
’LaTeX-mode-hook
(and likewise for all other occurrences of that character).
As Thomas also said, the back quote is not the character you want to use there, it should be the single straight quote. But, in general, if you get "symbol's value as variable is void" error, it means the same as NPE (null pointer exception) in other languages. The way to check what went wrong is like so:
Move point to the variable that gives the problem and C-h v (or M-x describe-variable [name of the variable without quote]). You can use TAB to complete the variable name as you type to see if you by chance didn't mistype it.
Once you see the buffer that describes the variable - you know you've fixed the error.
Now, if you have LaTeX mode set through auctex.el, then latex-mode-hook must exist. However, you need to make sure that auctex.el actually loads and requires latex-mode. The way it does so isn't an idiomatic way for Emacs to do it, most of the time you add the source files for the mode to the load-path variable and then (require 'mode-name) or load the mode conditionally once Emacs opens the type of the file associated with it (makes startup time for Emacs shorter) through autoload as described here: Emacs: Best-practice for lazy loading modes in .emacs? .
However, whenever you see a variable called [something]-mode-hook it means that this is a list of functions you want to call when [something] mode loads up. If the [something] mode at all exists, there's a 99.99% chance that variable exists too (can't be void). So, if it is void - you need to make sure that the mode it belongs to at all loads.
I want to use the pomodoro technique in org-mode as explained in
http://orgmode.org/worg/org-gtd-etc.html
I have added the following lines in .emacs file
(add-to-list 'org-modules 'org-timer)
(setq org-timer-default-timer 25)
(add-hook 'org-clock-in-hook '(lambda ()
(if (not org-timer-current-timer)
(org-timer-set-timer '(16)))))
When starting the emacs the following warning is displayed in the Warnings buffer.
Symbol's value as variable is void: org-modules
I am using org-mode version - 7.7.291.g37db which is cloned from git://orgmode.org/org-mode.git
How to get rid of the error.
org-modules is defined in org.el. If you want to add an element to the list, you need to wait until the variable is defined (with a default list). One way to do that is delay the addition until immediately after org.el is loaded:
(defun my-after-load-org ()
(add-to-list 'org-modules 'org-timer))
(eval-after-load "org" '(my-after-load-org))
Note that add-hook can cope with a variable that isn't defined yet, but add-to-list can't. You could write (setq org-modules '(org-timer)), but that would overwrite the default module list instead of adding to it.
Before now I've just been cutting and pasting code into my .emacs file, but then I decided to add some maven functionality to emacs. Now, I don't see how I was able to mess this up, but last night I kept getting the error I put in the title when I run M-x jarl-mvn-exec. I slept on it, and came back the next day but I'm still not getting anywhere.
(defun jarl-get-pom ()
(concat (locate-dominating-file
(buffer-file-name
(current-buffer))
"pom.xml")
"pom.xml"))
(defun jarl-visit-pom ()
(interactive)
(find-file (jarl-get-pom)))
(defun jarl-mvn-exec ()
(interactive)
(switch-to-buffer (get-buffer-create "maven"))
(start-process-shell-command "mvn-exec" "maven" "mvn" "-f" (jarl-get-pom) "compile")
(start-process-shell-command "mvn-exec" "maven" "mvn" "-f" (jarl-get-pom) "exec:exec"))
You'll need to provide more information to be sure. Try setting
(setq debug-on-error t)
which will give you a stack trace showing what function is complaining about the string being nil.
My guess is that buffer-file-name is returning nil, and that's where the problem lies (not all buffers have file names). Check out the debugging section of An Introduction To Programming in Emacs Lisp, or the debugging section of the Emacs Lisp manual.
The secret to finding a problem in your init file is not a secret: binary search.
Use comment-region to comment out half your init file, then 3/4, 7/8,... It is very quick to identify the problem. comment-region also uncomments: C-h f comment-region RET.