Difference between revisions of "Configure .emacs file"

From Notes_Wiki
m
m
Line 15: Line 15:
(global-visual-line-mode 1)
(global-visual-line-mode 1)


;;Wrap lines at 60 columns
;;Wrap lines at 70 columns
(set-fill-column 60)
(set-fill-column 70)


;;Wrap lines at 60 columns and enable auto-fill-mode automatically
;;Wrap lines at 70 columns and enable auto-fill-mode automatically
(setq-default fill-column 60)
(setq-default fill-column 70)
(add-hook 'text-mode-hook 'turn-on-auto-fill)
(add-hook 'text-mode-hook 'turn-on-auto-fill)



Revision as of 04:26, 4 June 2014

<yambe:breadcrumb>Emacs</yambe:breadcrumb>

Configure .emacs file

Use following as .emacs configuration. If there are already few lines in .emacs file then these lines can be appended / prepended to existing file:

(setq load-path (cons "~/.emacs.d" load-path))

;;Preventing emacs from creating backup files
(setq make-backup-files nil)

;;Preventing emacs from creating auto-save files
(setq auto-save-default nil)

;;Use visual-line-mode for word wrap
(global-visual-line-mode 1)

;;Wrap lines at 70 columns
(set-fill-column 70)

;;Wrap lines at 70 columns and enable auto-fill-mode automatically
(setq-default fill-column 70)
(add-hook 'text-mode-hook 'turn-on-auto-fill)

;;Set default font-size to 160 (16pt)
(set-face-attribute 'default nil :height 160) 


;;Setting up Emacs for use with Erlang
;;Update the below mentioned paths appropriately based on installation
(add-to-list 'load-path "/usr/local/lib/erlang/lib/tools-2.6.7/emacs/")
(require 'erlang-start)

(add-to-list 'auto-mode-alist '("\\.erl?$" . erlang-mode))
(add-to-list 'auto-mode-alist '("\\.hrl?$" . erlang-mode))
(add-to-list 'auto-mode-alist '("\\.escript?$" . erlang-mode))

(setq erlang-root-dir "/usr/local/lib/erlang")
(add-to-list 'exec-path "/usr/local/lib/erlang/bin")
(setq erlang-man-root-dir "/usr/local/lib/erlang/man")


;;Disable splash screen at start-up
(setq inhibit-splash-screen t)

;;Make emacs copy-paste M-w, C-y work with system copy-paste
(setq x-select-enable-clipboard t)

;;To maximize emacs window at start-up
(defun toggle-fullscreen ()
  (interactive)
  (x-send-client-message nil 0 nil "_NET_WM_STATE" 32
                 '(2 "_NET_WM_STATE_MAXIMIZED_VERT" 0))
  (x-send-client-message nil 0 nil "_NET_WM_STATE" 32
                 '(2 "_NET_WM_STATE_MAXIMIZED_HORZ" 0))
)
(toggle-fullscreen)


;; PDFs visited in Org-mode are opened in Evince and not in the default choice
(add-hook 'org-mode-hook
      '(lambda ()
         (delete '("\\.pdf\\'" . default) org-file-apps)
         (add-to-list 'org-file-apps '("\\.pdf\\'" . "evince %s"))))


;; Set email address 
(setq user-mail-address "saurabh@sbarjatiya.com")


;;For setting tab to 4 spaces for .py programs
(add-hook 'python-mode-hook
      (lambda ()
        (setq indent-tabs-mode 'nil)
        (setq tab-width 4)
        (setq python-indent 4)))


;;To set proper command for exporting latex to pdf from org-mode
(setq org-latex-to-pdf-process (quote ("pdflatex %f" "bibtex %b" "pdflatex %f")))
(setq org-latex-pdf-process (quote ("pdflatex %f" "bibtex %b" "pdflatex %f")))


If you have installed ELPA (Emacs Lisp Package Archive) then it might have added few lines of its own.


Configure .emacs for Erlang if erlang is installed via yum

If Erlang is installed via yum or package manager instead of source then the erlang-mode files will get installed at different location. Hence to configure .emacs for erlang-mode in such cases use:

;;Setting up Emacs for use with Erlang
;;Update the below mentioned paths appropriately based on installation
(add-to-list 'load-path "/usr/lib64/erlang/lib/tools-2.6.8/emacs/")
(require 'erlang-start)

(add-to-list 'auto-mode-alist '("\\.erl?$" . erlang-mode))
(add-to-list 'auto-mode-alist '("\\.hrl?$" . erlang-mode))

(setq erlang-root-dir "/usr/lib64/erlang")
(add-to-list 'exec-path "/usr/lib64/erlang/bin")
(setq erlang-man-root-dir "/usr/lib64/erlang/man")


<yambe:breadcrumb>Emacs</yambe:breadcrumb>