My emacs is running on Window 7 and I have just installed yasnippet via M-x package-list
and added few lines to my .emacs file because I read around the web that it needs to be initialized.
I tried writing a simple yasnippet for LaTeX, calling it "fraction", triggered by typing fr
+ TAB and saved it in ~\.emacs.d\elpa\yasnippet-0.8.0\snippets\latex-mode
. This is the code.
# -*- mode: snippet -*-
# name: fraction
# key: fr
# --
\dfrac{$1}{$0}
Since yasnippet was adding a newline everytime I triggered this snippet I modified the .emacs file. This is how it looks now:
;; yasnippet
(add-to-list 'load-path "~/.emacs.d/elpa/yasnippet-0.8.0")
(require 'yasnippet)
(setq yas-snippet-dirs '("~/.emacs.d/elpa/yasnippet-0.8.0/snippets"))
(setq-default mode-require-final-newline nil)
(yas-global-mode 1)
Now however, everytime I type 'fr' it sure gives me \dfrac{}{}
but as soon as I write inside the first pair of curly braces, the same value appears in the second pair of braces (denominator) and pressing TAB pushes the cursor out of the last '}'. What am I missing here? How can I fix this problem?
My entire .emacs file is below. I'm probably doing something wrong, please help me correct it.
;;; Schlosser's .emacs
(server-start)
(add-hook 'LaTeX-mode-hook 'turn-on-reftex)
(setq reftex-plug-into-AUCTeX t)
;(setq-default ispell-program-name "aspell")
;;; Brent.Longborough's .emacs
(setq inhibit-splash-screen t); Disable splash screen
(setq visible-bell t); Flashes on error
(show-paren-mode 1); Matches parentheses and such in every mode
;;; AUCTeX
;; Customary Customization, p. 1 and 16 in the manual, and http://www.emacswiki.org/emacs/AUCTeX#toc2
(setq TeX-parse-self t); Enable parse on load.
(setq TeX-auto-save t); Enable parse on save.
(setq-default TeX-master nil)
(setq TeX-PDF-mode t); PDF mode (rather than DVI-mode)
;activate Flyspell, for all modes(?), not just TeX; from alienexp.blogspot.com
(add-to-list 'exec-path "C:/Program Files/Aspell/bin/")
(setq ispell-program-name "aspell")
(setq ispell-dictionary "english") ;to change do M-x ispell-change-dictionary RET
(add-hook 'TeX-mode-hook 'flyspell-mode); Enable Flyspell mode for TeX modes such as AUCTeX. Highlights all misspelled words.
(add-hook 'emacs-lisp-mode-hook 'flyspell-prog-mode); Enable Flyspell program mode for emacs lisp mode, which highlights all misspelled words in comments and strings.
;(setq ispell-dictionary "english"); Default dictionary. To change do M-x ispell-change-dictionary RET.
(add-hook 'TeX-mode-hook
(lambda () (TeX-fold-mode 1))); Automatically activate TeX-fold-mode.
(setq LaTeX-babel-hyphen nil); Disable language-specific hyphen insertion.
;; " expands into csquotes macros (for this to work babel must be loaded after csquotes).
(setq LaTeX-csquotes-close-quote "}"
LaTeX-csquotes-open-quote "\\enquote{")
;from StackExchange question "AUCTeX preview font size too small"
(set-default 'preview-scale-function 1.1)
;; LaTeX-math-mode http://www.gnu.org/s/auctex/manual/auctex/Mathematics.html
(add-hook 'TeX-mode-hook 'LaTeX-math-mode)
(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.
'(org-format-latex-options
(quote
(:foreground default :background default :scale 1.0 :html-foreground "Black" :html-background "Transparent" :html-scale 1.0 :matchers
("begin" "$1" "$" "$$" "\\(" "\\["))))
'(org-startup-with-latex-preview t)
'(preview-default-document-pt 12)
'(show-paren-mode t)
'(transient-mark-mode (quote (only . t))))
(custom-set-faces
;; custom-set-faces 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.
)
;;; a key for tilde symbol
(global-set-key [f2] "~")
;;; visual line word wrapping
(global-visual-line-mode t)
;; yasnippet
(add-to-list 'load-path "~/.emacs.d/elpa/yasnippet-0.8.0")
(require 'yasnippet)
(setq yas-snippet-dirs '("~/.emacs.d/elpa/yasnippet-0.8.0/snippets"))
(setq-default mode-require-final-newline nil)
(yas-global-mode 1)