Difference between revisions of "Configure .emacs file"

From Notes_Wiki
m
m
 
(12 intermediate revisions by the same user not shown)
Line 1: Line 1:
=Configure .emacs file=
[[Main Page|Home]] > [[CentOS]] > [[CentOS 6.x]] > [[Text editors]] > [[Emacs]] > [[Configure .emacs file]]


Use following as <tt>.emacs</tt> configuration. If there are already few lines in .emacs file then these lines can be appended / prepended to existing file:
Use following as <tt>.emacs</tt> configuration. If there are already few lines in .emacs file then these lines can be appended / prepended to existing file:
<pre>
<pre>
(setq load-path (cons "~/.emacs.d" load-path))
;; .emacs - Assumes emacs 24.4.1+, org 8.2.10-34+
;; Considerable information learned from http://www.aaronbedra.com/emacs.d/
 
;; Set full username and email address
(setq user-full-name "Saurabh Barjatiya")
(setq user-mail-address "saurabh [at] sbarjatiya.com")  ;***Replace with correct email ID***
 
;Modify path as neeed
;(setenv "PATH" (concat "/usr/local/bin:/opt/local/bin:/usr/bin:/bin" (getenv "PATH")))
 
;Package common lisp is required to add more functionality to emacs lisp to
;allow easier configuration of emacs.  Without this loop used further in this file is not available.
(require 'cl)
 
;; Initialize built-in package manager
(load "package")
(package-initialize)
(add-to-list 'package-archives
            '("marmalade" . "http://marmalade-repo.org/packages/"))
(add-to-list 'package-archives
            '("melpa" . "http://melpa.milkbox.net/packages/") t)
 
(setq package-archive-enable-alist '(("melpa" deft magit)))
 
;; define list of default packages to install
(defvar saurabh/packages '(ac-slime
                          auto-complete
                          autopair
                          clojure-mode
                          coffee-mode
                          csharp-mode
                          deft
                          erlang
                          feature-mode
                          flycheck
                          gist
                          go-mode
                          graphviz-dot-mode
                          haml-mode
                          haskell-mode
                          htmlize
                          magit
                          markdown-mode
                          marmalade
                          nodejs-repl
                          o-blog
                          org
                          paredit
                          php-mode
                          puppet-mode
                          restclient
                          rvm
                          scala-mode
                          smex
                          sml-mode
                          solarized-theme
                          web-mode
                          writegood-mode
                          yaml-mode)
  "Default packages")
 
;;Install default packages
(defun saurabh/packages-installed-p ()
  (loop for pkg in saurabh/packages
        when (not (package-installed-p pkg)) do (return nil)
        finally (return t)))
 
(unless (saurabh/packages-installed-p)
  (message "%s" "Refreshing package database...")
  (package-refresh-contents)
  (dolist (pkg saurabh/packages)
    (when (not (package-installed-p pkg))
      (package-install pkg))))
 
 
 
;; default to better frame titles
(setq frame-title-format
      (concat  "%b - emacs@" (system-name)))
 
;; default to unified diffs
(setq diff-switches "-u")


;;Preventing emacs from creating backup files
;;Preventing emacs from creating backup files
Line 14: Line 95:
(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)


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




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


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


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




Line 53: Line 136:
)
)
(toggle-fullscreen)
(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"))))
;;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")))
;;Add INPROGRESS along with TODO, DONE.  Also enable flyspell-mode and writegood-mode
;;while org-mode is active
(setq org-log-done t
      org-todo-keywords '((sequence "TODO" "INPROGRESS" "DONE"))
      org-todo-keyword-faces '(("INPROGRESS" . (:foreground "blue" :weight bold))))
(add-hook 'org-mode-hook
          (lambda ()
            (flyspell-mode)))
(add-hook 'org-mode-hook
          (lambda ()
            (writegood-mode)))


</pre>
</pre>
Line 59: Line 175:




If you have installed ELPA (Emacs Lisp Package Archive) then it might have added few lines of its own.
[[Main Page|Home]] > [[CentOS]] > [[CentOS 6.x]] > [[Text editors]] > [[Emacs]] > [[Configure .emacs file]]

Latest revision as of 15:53, 24 August 2022

Home > CentOS > CentOS 6.x > Text editors > Emacs > 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:

;; .emacs - Assumes emacs 24.4.1+, org 8.2.10-34+
;; Considerable information learned from http://www.aaronbedra.com/emacs.d/

;; Set full username and email address
(setq user-full-name "Saurabh Barjatiya")
(setq user-mail-address "saurabh [at] sbarjatiya.com")   ;***Replace with correct email ID***

;Modify path as neeed
;(setenv "PATH" (concat "/usr/local/bin:/opt/local/bin:/usr/bin:/bin" (getenv "PATH")))

;Package common lisp is required to add more functionality to emacs lisp to
;allow easier configuration of emacs.  Without this loop used further in this file is not available.
(require 'cl)

;; Initialize built-in package manager
(load "package")
(package-initialize)
(add-to-list 'package-archives
             '("marmalade" . "http://marmalade-repo.org/packages/"))
(add-to-list 'package-archives
             '("melpa" . "http://melpa.milkbox.net/packages/") t)

(setq package-archive-enable-alist '(("melpa" deft magit)))

;; define list of default packages to install
(defvar saurabh/packages '(ac-slime
                          auto-complete
                          autopair
                          clojure-mode
                          coffee-mode
                          csharp-mode
                          deft
                          erlang
                          feature-mode
                          flycheck
                          gist
                          go-mode
                          graphviz-dot-mode
                          haml-mode
                          haskell-mode
                          htmlize
                          magit
                          markdown-mode
                          marmalade
                          nodejs-repl
                          o-blog
                          org
                          paredit
                          php-mode
                          puppet-mode
                          restclient
                          rvm
                          scala-mode
                          smex
                          sml-mode
                          solarized-theme
                          web-mode
                          writegood-mode
                          yaml-mode)
  "Default packages")

;;Install default packages
(defun saurabh/packages-installed-p ()
  (loop for pkg in saurabh/packages
        when (not (package-installed-p pkg)) do (return nil)
        finally (return t)))

(unless (saurabh/packages-installed-p)
  (message "%s" "Refreshing package database...")
  (package-refresh-contents)
  (dolist (pkg saurabh/packages)
    (when (not (package-installed-p pkg))
      (package-install pkg))))



;; default to better frame titles
(setq frame-title-format
      (concat  "%b - emacs@" (system-name)))

;; default to unified diffs
(setq diff-switches "-u")

;;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 120 (12pt)
(set-face-attribute 'default nil :height 120) 


;;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.6.5/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))
(add-to-list 'auto-mode-alist '("\\.yaws?$" . 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")


;;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"))))


;;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")))

;;Add INPROGRESS along with TODO, DONE.  Also enable flyspell-mode and writegood-mode
;;while org-mode is active
(setq org-log-done t
      org-todo-keywords '((sequence "TODO" "INPROGRESS" "DONE"))
      org-todo-keyword-faces '(("INPROGRESS" . (:foreground "blue" :weight bold))))
(add-hook 'org-mode-hook
          (lambda ()
            (flyspell-mode)))
(add-hook 'org-mode-hook
          (lambda ()
            (writegood-mode)))




Home > CentOS > CentOS 6.x > Text editors > Emacs > Configure .emacs file