I have enabled electric pair mode according to instructions on this page: http://ergoemacs.org/emacs/emacs_insert_brackets_by_pair.html , i.e. adding these lines to ~/.emacs:
;; autocomplete paired brackets
(electric-pair-mode 1)
But this doesn't take any effect, I still have to M-x electric-pair-mode
to activate it. Why is this happening?
Emacs version is 24.3, on Mac OSX.
Here is my entire ~/.emacs
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; set up package-archives
(require 'package)
(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.
'(package-archives (quote (("gnu" . "http://elpa.gnu.org/packages/") ("marmalade" . "http://marmalade-repo.org/packages/") ("melpa" . "http://melpa.milkbox.net/packages/"))))
'(py-shell-name "python3")
'(py-split-windows-on-execute-function (quote split-window-horizontally))
'(scroll-bar-mode nil)
'(send-mail-function (quote mailclient-send-it))
'(tool-bar-mode nil)
'(truncate-lines 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.
'(default ((t (:family "DejaVu Sans Mono for Powerline" :foundry "unknown" :slant normal :weight normal :height 120 :width normal))))
'(cursor ((t (:background "light gray" :foreground "pale green")))))
(package-initialize)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;; ESS settings ;;;;;;;;;;;;;;;;;;;;;;;;;
;;ESS
(require 'ess-site)
(ess-toggle-underscore nil)
(setq ess-history-file nil)
(setq ess-help-kill-bogus-buffers t)
(setq
ac-auto-show-menu 0
ac-candidate-limit nil
ac-delay 0.1
ac-disable-faces (quote (font-lock-comment-face font-lock-doc-face))
ac-ignore-case 'smart
ac-menu-height 10
ac-quick-help-delay 111.5
ac-quick-help-prefer-pos-tip t
ac-use-quick-help nil
)
(add-hook 'ess-mode-hook
(lambda ()
(ess-set-style 'C++ 'quiet)
(add-hook 'local-write-file-hooks
(lambda ()
(ess-nuke-trailing-whitespace)))))
(setq ess-nuke-trailing-whitespace-p 'ask)
;; or even
;; (setq ess-nuke-trailing-whitespace-p t)
;; do not ask for working dir
(setq ess-ask-for-ess-directory nil)
;; always split side by side
(defun forbid-vertical-split ()
"Only permit horizontal window splits."
(setq-local split-height-threshold nil)
(setq-local split-width-threshold 0))
(add-hook 'ess-mode-hook
'forbid-vertical-split)
;; Let the ESS R console automatically scroll!
(setq comint-scroll-to-bottom-on-input t)
(setq comint-scroll-to-bottom-on-output t)
(setq comint-move-point-for-output t)
(define-key comint-mode-map [C-up] 'comint-previous-matching-input-from-input)
(define-key comint-mode-map [C-down] 'comint-next-matching-input-from-input)
; (define-key ess-mode-map (kbd "C-c d") 'comment-region)
; (define-key ess-mode-map (kbd "C-c u") 'uncomment-region)
;; (define-key ess-mode-map (kbd "C-S-e") 'comment-region)
;; (define-key ess-mode-map (kbd "C-S-d") 'uncomment-region)
;; ESS Mode (.R file)
(define-key ess-mode-map "\C-l" 'ess-eval-line-and-step)
(define-key ess-mode-map "\C-p" 'ess-eval-function-or-paragraph-and-step)
(define-key ess-mode-map "\C-r" 'ess-eval-region)
;; use this one if each help window goes to a new frame
(setq ess-help-own-frame t)
;; use this one if you want all help windows into one frame!
(setq ess-help-own-frame 'one)
;;;;;;;;;;;; ESS settings ;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;; Perl settings ;;;;;;;;;;;;;;;;;;;;;;;
(add-hook 'perl-mode-hook
(lambda () (setq perl-indent-level 4)))
;;;;;;;;;;;; Perl settings ;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;; evil copied to osx ;;;;;;;;;;;;;;;;;;;;;;;;;
;; evil and its plugins (ports from vim, or not?)
(require 'evil)
(evil-mode 1)
;; evil nerd commenter
(evilnc-default-hotkeys)
;;;;;;;;;;;; evil copied to osx ;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;; settings copied to osx ;;;;;;;;;;;;;;;;;;;;;;;;;
;; shift width set to 4
(setq c-basic-offset 4)
(setq-default tab-width 4)
;; autocomplete globally
(require 'auto-complete)
(defun auto-complete-mode-maybe ()
"I do not want MAYBE, I want real autocomplete!"
(auto-complete-mode 1))
(global-auto-complete-mode t)
;; only show one window when start up
(add-hook 'emacs-startup-hook 'delete-other-windows)
;; no backup ~n~ nonsense please
(setq make-backup-files nil)
(setq auto-save-default nil)
;; no startup logo and message
(setq inhibit-startup-echo-area-message t)
(setq inhibit-startup-message t)
;; solarized theme
(load-theme 'solarized-dark t)
;;;;;;;;;;;; settings copied to osx ;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;; python stuff copied to osx ;;;;;;;;;;;;;;;;;;;;;;;;;
;; Standard Jedi.el setting
(add-hook 'python-mode-hook 'jedi:setup)
(setq jedi:setup-keys t)
(setq jedi:complete-on-dot t)
(require 'python-mode)
(add-to-list 'auto-mode-alist '("\.py\'" . python-mode))
;; send line to python console
(require 'python-mode)
(defun py-execute-line-down ()
"execute python line and move cursor down"
(interactive)
(py-execute-line)
(forward-line 1))
(define-key python-mode-map (kbd "C-c j") 'py-execute-line-down)
;;;;;;;;;;;; python stuff copied to osx ;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;; buffer/win management stuff ;;;;;;;;;;;;;;;;;;;;;;;;;
;; easy buffer switch
(require 'ido)
(ido-mode 'buffers) ;; only use this line to turn off ido for file names!
(setq ido-ignore-buffers '("^ " "*Completions*" "*Shell Command Output*"
"*Messages*" "Async Shell Command"))
; use meta + arrow keys to switch between visible windows
;; handy in split views
(require 'windmove)
(windmove-default-keybindings 'meta)
;; automatically save buffers associated with files on buffer switch
;; and on windows switch
(defadvice switch-to-buffer (before save-buffer-now activate)
(when buffer-file-name (save-buffer)))
(defadvice other-window (before other-window-now activate)
(when buffer-file-name (save-buffer)))
(defadvice windmove-up (before other-window-now activate)
(when buffer-file-name (save-buffer)))
(defadvice windmove-down (before other-window-now activate)
(when buffer-file-name (save-buffer)))
(defadvice windmove-left (before other-window-now activate)
(when buffer-file-name (save-buffer)))
(defadvice windmove-right (before other-window-now activate)
(when buffer-file-name (save-buffer)))
;;;;;;;;;;;; buffer/win management stuff ;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;; misc ;;;;;;;;;;;;;;;;;;;;;;;
;; enable clipboard
(setq x-select-enable-clipboard t)
;; disable parentheses highlighting
(setq blink-matching-paren nil)
;; autocomplete paired brackets
(electric-pair-mode 1)
(global-set-key [C-tab] 'other-window)
;; tramp mode for editing through ssh
(setq tramp-default-method "ssh")
;;;;;;;;;;;; misc ;;;;;;;;;;;;;;;;;;;;;;;
;; probably a good idea to keep this at the very end!!
(server-start)
(setq server-socket-dir "~/.emacs.d/server")
My crystal ball tells me there's an error in your ~/.emacs file which prevents Emacs from reading/processing it to the end. Try
emacs --debug-init
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With