my ~/.emacs

Below is my ~/.emacs.el or simply ~/.emacs. This, again, is for my reference at a later point in time in case I lose my present file while moving out to some other place. But please, feel free to comment on it if you liked it or you have some suggestions that you think I would like to have.

I use GNU Emacs version 22.1.1 on my Debian Sid box. I love to use it and am (very slowly)learning elisp programming by staring at the Emacs Lisp Introduction pages of the (info emacs). So, if you come across any cool thing related to Emacs, elisp programming, or Emacs development in general, please let me hear about it.



;;; File Name: .emacs -*- emacs-lisp -*-

;; ---------------------------------------------------------------------------
;; most of these lisp statements were taken from others' .emacs files.
;; since it evolved over a long time, I couldn't remember the
;; individual source files. - I'm reachable at
;; my-email-found-at-the-contact-page
;; Time-stamp:
;; ---------------------------------------------------------------------------

;; ------------------------------
;; we're time conscious
;; (display-time)
;; ------------------------------

;; --------------------------------------------------

;; Time in 24 hour format, plus day and date.
(setq display-time-day-and-date t
display-time-24hr-format t
display-time-use-mail-icon t
display-time-mail-file nil)
(display-time)

;; --------------------------------------------------

;;; uncomment this line to disable loading of "default.el" at startup
(setq inhibit-default-init t)

;; turn on font-lock mode
(when (fboundp 'global-font-lock-mode)
(global-font-lock-mode t))

;; enable visual feedback on selections
(setq transient-mark-mode t)

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

;; highlight matching brackets
(show-paren-mode t)

;; split the column here
(setq fill-column 60)

;; activate scrolling using mouse wheel
(mouse-wheel-mode 't)

;; scroll one line at a time (instead of scrolling half a page) set
;; the below variable to a large value
(setq scroll-conservatively 1000)

;; show column number in the modeline
(setq column-number-mode 't)

;; timestamp hooks
(add-hook 'write-file-hooks 'time-stamp)
(add-hook 'save-file-hooks 'time-stamp)

;; expand aliases like abbrevs
(add-hook 'mail-mode-hook 'mail-abbrevs-setup)

;; ---------------------------------------------------------------------------
;;; load elisp files from home directory as well.
(setq load-path (cons (expand-file-name "~/emacs-lisp/") load-path))
;; ---------------------------------------------------------------------------

;; --------------------------------------------------------------------------------
;; some workplace this and that
;; --------------------------------------------------------------------------------
;; our mail address should be the same wherever we mail from..
;; (setq user-mail-address "vapitta@paypal.com")
;; --------------------------------------------------------------------------------
;; and our name shoud always look the same.
;; (setq mail-from-style 'parens)
;; --------------------------------------------------------------------------------
;; wouldn't it always be better if our mails get delivered into our UNIX mailbox?
;; as susal, there is always a but behind everything..
;; (setq mail-default-reply-to "vpitta@covansys.com")
;; --------------------------------------------------------------------------------
;; our quoted text formatting
(setq mail-yank-prefix "> ")
;; --------------------------------------------------------------------------------
;; why should /bin/bash show :-- invalid option and exit with code 1?
;; anyway, for now, we will use bash2
;; (setq explicit-shell-file-name "/bin/bash2")
;; --------------------------------------------------------------------------------
;; our workplace wrapper for make, used to build our sources
;; --------------------------------------------------------------------------------
;; (setq compile-command "m -j 20 ")
;; (setq hostname (getenv "SYS"))
;; (cond
;; ((or
;; (equal "sjcccv01" (getenv "SYS"))
;; (equal "sjcccv02" (getenv "SYS"))
;; (equal "hype" (getenv "SYS"))
;; (equal "sjnpg01" (getenv "SYS"))
;; (equal "sjnpg02" (getenv "SYS"))
;; ) t
;; (setq compile-command
;; connect to that host and asynchronously execute compile-command
;; "ssh hyper3.ca1.paypal.com \"cd $BUILDTOP; m -j 20 \""))
;; ((or
;; (equal "hyper1" (getenv "SYS"))
;; (equal "hyper2" (getenv "SYS"))
;; (equal "hyper3" (getenv "SYS"))
;; (equal "hyper4" (getenv "SYS"))
;; (equal "hyper5" (getenv "SYS"))
;; (equal "hyper6" (getenv "SYS"))
;; (equal "hyper7" (getenv "SYS"))
;; (equal "hyper8" (getenv "SYS"))
;; (equal "hyper9" (getenv "SYS"))
;; (equal "hyper10" (getenv "SYS"))
;; (equal "hyper11" (getenv "SYS"))
;; (equal "hyper12" (getenv "SYS"))
;; ) t
;; (setq compile-command "m -j 20 "))
;; (t (setq compile-command "make -k "))
;; )

;;(cond
;; ((not (equal "sjnpg02" (getenv "SYS"))) t
;; (setq gud-query-cmdline "ssh sjnpg02 \"cd $PLAYGROUND; gdb\"")
;; )
;; )

;; (require 'tramp)
;; (setq tramp-default-method "scpx")
;; for emacs22
;; (progn (require 'tramp)
;; (setq file-name-handler-alist
;; (loop for x in file-name-handler-alist for
;; (pattern . symbol) = x for name = (symbol-name symbol) unless
;; (string-match "tramp" name) collect x)))

;; --------------------------------------------------------------------------------
;; ** workplace wishlist..
;; * clearcase hosts: sjcccv0[12]
;; * compile hosts: hyper[1-12]
;; * debug or test run hosts: hype, sjnpg0[12]

;; * instead of manually logging into these machines for different things
;; we do, why not make Emacs do them for us?
;; --------------------------------------------------------------------------------
;; ending workplace related tweaks... i wish i knew elisp better.. hmmm...
;; --------------------------------------------------------------------------------

;; --------------------------------------------------------------------------------
;; update the buffer whenever the disk file gets updated independent of Emacs
;; --------------------------------------------------------------------------------
(setq auto-revert-mode t)
;; --------------------------------------------------------------------------------

;; --------------------------------------------------------------------------------
;; some comfoable keybindings
;; --------------------------------------------------------------------------------
(global-set-key "\C-cg" 'goto-line)
(global-set-key "\M-#" 'query-replace-regexp)
(global-set-key "\C-cm" 'man)
(global-set-key "\C-cw" 'woman)
;; --------------------------------------------------------------------------------

;; Some code that will change the background color of the lines that
;; gcc found errors on, should be in another color.

(require 'custom)

(defvar all-overlays ())

(defun delete-this-overlay(overlay is-after begin end &optional len)
(delete-overlay overlay)
)

(defun highlight-current-line()
(interactive)
(setq current-point (point))
(beginning-of-line)
(setq beg (point))
(forward-line 1)
(setq end (point))
;; Create and place the overlay
(setq error-line-overlay (make-overlay 1 1))

;; Append to list of all overlays
(setq all-overlays (cons error-line-overlay all-overlays))

(overlay-put error-line-overlay
'face '(background-color . "khaki"))
(overlay-put error-line-overlay
'modification-hooks (list 'delete-this-overlay))
(move-overlay error-line-overlay beg end)
(goto-char current-point)
)

(defun delete-all-overlays()
(while all-overlays
(delete-overlay (car all-overlays))
(setq all-overlays (cdr all-overlays))
)
)

(defun highlight-error-lines(compilation-buffer, process-result)
(interactive)
(delete-all-overlays)
(condition-case nil
(while t
(next-error)
(highlight-current-line)
)
(error nil))
)

(setq compilation-finish-function 'highlight-error-lines)

;; --------------------------------------------------
(require 'jka-compr) ; Automatic decompression, hooks for tar-mode.
(if (fboundp 'auto-compression-mode)
(auto-compression-mode 1))
;; --------------------------------------------------
;; courtesy, Martin Schwenke's ~/.emacs file for GNU Emacs 21
;; --------------------------------------------------

;; --------------------------------------------------
;; C-TAB cycles through the input methods
;; (global-set-key [C-tab] 'dabbrev-expand)
;; --------------------------------------------------
;; the above code was taken from ".emacs file by Alex"
;; --------------------------------------------------
;; the above function can be activated through M - /
;; by default in Emacs, and i'd rather use that
;; --------------------------------------------------

;; --------------------------------------------------
;; Inhibit christmas tree effect in font lock mode

(defun my-set-fontify-fonts ()
"A function to decolorize font-lock-mode"
;; (copy-face 'italic 'font-lock-comment-face)
(interactive)
(copy-face 'italic 'font-lock-comment-face)
(copy-face 'bold 'font-lock-keyword-face)
(copy-face 'default 'font-lock-string-face)
(copy-face 'bold 'font-lock-function-name-face)
(set-face-underline-p 'font-lock-function-name-face t)
(copy-face 'bold 'font-lock-type-face)
(set-face-underline-p 'font-lock-type-face t)
(copy-face 'bold 'font-lock-reference-face)
(copy-face 'default 'font-lock-variable-name-face)
(copy-face 'bold 'font-lock-warning-face)
(set-face-background 'font-lock-warning-face "yellow4")
)
(if window-system
(progn
(require 'font-lock)
(my-set-fontify-fonts)
))
;; --------------------------------------------------

;; --------------------------------------------------
;; some calendar mode settings
;; --------------------------------------------------
(global-set-key [f9] 'calendar)
(setq view-diary-entries-initially t)
(setq number-of-diary-entries '[7 7 7 7 7 9 8])
(setq diary-list-include-blanks t)
(setq diary-file (expand-file-name "~/diary"))
(setq mark-holidays-in-calendar t)
(setq mark-diary-entries-in-calendar t)
(setq appt-message-warning-time 60)
(add-hook 'diary-hook 'appt-make-list)
(add-hook 'diary-display-hook 'fancy-diary-display)
(add-hook 'list-diary-entries-hook 'sort-diary-entries)
(add-hook 'today-visible-calendar-hook 'calendar-mark-today)
;; --------------------------------------------------

;; ---------------------------------------------------------------------------
;; rpm mode -- installs, browses and edits rpm files
;; ---------------------------------------------------------------------------
;; (autoload 'rpm "rpm"
;; "Shell for the rpm package management utility." t)
;; (autoload 'rpm-dired-install "rpm"
;; "Install all marked (or next ARG) rpm-files." t)
;; (add-hook 'dired-load-hook
;; '(lambda () (define-key dired-mode-map "I"
;; 'rpm-dired-install)))
;; ---------------------------------------------------------------------------
;; there are some packages specified to be required by the rpm.el. i
;; found cookie. but not custom and dired. until now, i haven't found
;; any problems due their absence. so i think they are available on
;; the system somewhere around in the default path..
;; ---------------------------------------------------------------------------

;; ---------------------------------------------------------------------------
;; playlist -- plays multimedia files. I edited original playlist to use
;; mplayer instead of mog123 or ogg123.. After all, mplayer plays all
;; the files.. then why to use sepeerate programs for different file
;; formats?
;; ---------------------------------------------------------------------------
;; (autoload 'playlist "playlist"
;; "Plays multimedia files." t)
;; ---------------------------------------------------------------------------

;; ---------------------------------------------------------------------------
;; rudimentary emms configs as seen at the emms website
;; ---------------------------------------------------------------------------
(require 'emms-setup)
(emms-standard)
(emms-default-players)
;; ---------------------------------------------------------------------------

;; --------------------------------------------------------------------------------
;; ssh -- it lets ssh access from within Emacs
;; --------------------------------------------------------------------------------
(autoload 'ssh "ssh"
"Access ssh from within Emacs." t)
;; --------------------------------------------------------------------------------

;; (require 'cscope)
;; (autoload 'cscope "cscope"
;; "Cscope frontend for Emacs." t)

;; --------------------------------------------------
;; well, i made these additions from reading the info pages of
;; emacs.. highly probable that it resembles others' code heh..
;; --------------------------------------------------

;; --------------------------------------------------
;; background foreground settings that do not strain the eyes
;; while working for long hours. this seems to work for me!!!!
;; --------------------------------------------------

(add-to-list 'default-frame-alist '(background-color . "Black"))
(add-to-list 'default-frame-alist '(foreground-color . "Grey"))
;; (add-to-list 'default-frame-alist
;; '(frame-font
;; .
;; "-adobe-courier-medium-r-normal--18-180-75-75-m-110-iso10646-1"
;; )
;; )
;; the above setting has to be given as a command-line-option
;; while invoking emacs like
;; $ emacs -fn "-adobe-courier-medium-r-normal--18-180-75-75-m-110-iso10646-1"

;; --------------------------------------------------

;; --------------------------------------------------
;; got to change the keybindings..
;; backspace should work like C-h and C-h should work like
;; backspace. However, only the second part works as of now..
;; --------------------------------------------------
;; (global-unset-key 'DEL)
;; (local-unset-key 'DEL)
;; (global-set-key "DEL" 'help)
;; (local-set-key "DEL" 'help)
;; (global-set-key "\C-h" 'delete-backward-char)
;; --------------------------------------------------

(add-hook 'find-file-hooks 'auto-insert)

;; set tabspace width to 8 characters.
(setq tab-width 8)

;; load calendar at emacs startup
;; (calendar)
;; (add-hook 'diary-hook 'appt-make-list)
;; (diary)
;; (delete-window)

;; ---------------------------------------------------------------------------
;; setting indentation
;; ---------------------------------------------------------------------------
(setq c-default-style
'(
(java-mode . "java")
(c-mode . "cc-mode")
(asm-mode . "asm")
(other . "gnu")
)
)
;; other styles of indentations that are available..
;; bsd cc-mode
;; ellemtel gnu
;; java k&r
;; linux python
;; stroustrup user
;; whitesmith
;; ---------------------------------------------------------------------------

;; ---------------------------------------------------------------------------
;; making lines in text-mode wrap automatically when they cross the
;; column-fill margin
;; ---------------------------------------------------------------------------
(add-hook 'text-mode-hook
'(lambda () (auto-fill-mode 1)))
;; ---------------------------------------------------------------------------

;; ---------------------------------------------------------------------------
;; cscope frontend
;; ---------------------------------------------------------------------------
;; (require 'xcscope) ;; appears cscope is not installed on this system :(

;; (define-key global-map [(control f3)] 'cscope-set-initial-directory)
;; (define-key global-map [(control f4)] 'cscope-unset-initial-directory)
;; (define-key global-map [(control f5)] 'cscope-find-this-symbol)
;; (define-key global-map [(control f6)] 'cscope-find-global-definition)
;; (define-key global-map [(control f7)]
;; 'cscope-find-global-definition-no-prompting)
;; (define-key global-map [(control f8)] 'cscope-pop-mark)
;; (define-key global-map [(control f9)] 'cscope-next-symbol)
;; (define-key global-map [(control f10)] 'cscope-next-file)
;; (define-key global-map [(control f11)] 'cscope-prev-symbol)
;; (define-key global-map [(control f12)] 'cscope-prev-file)
;; (define-key global-map [(meta f9)] 'cscope-display-buffer)
;; (define-key global-map [(meta f10)] 'cscope-display-buffer-toggle)
;; (require 'cscope)
;; ---------------------------------------------------------------------------

;; ---------------------------------------------------------------------------
;; curling up blocks of text
;; ---------------------------------------------------------------------------
(require 'hide-region)
(global-set-key [f7] 'hide-region-hide)
(global-set-key [f6] 'hide-region-unhide)
;; ---------------------------------------------------------------------------

;; ---------------------------------------------------------------------------
;; use colours in shell buffers too
;; ---------------------------------------------------------------------------
(add-hook 'shell-mode-hook 'ansi-color-for-comint-mode-on)
;; ---------------------------------------------------------------------------

;; ---------------------------------------------------------------------------
;; some Planner and Muse related entries.
;; ---------------------------------------------------------------------------
(require 'planner)
(load "planner")
(setq planner-projects "WikiPlanner")
(setq muse-project-alist
'(("WikiPlanner"
("/plans" ;; directory where planner pages are located
:default "TaskPool" ;; use value of planner-default-page'
:major-mode planner-mode
:visit-link planner-visit-link)

;; This next part is for specifying where planner pages
;; should be published and what Muse publishing style to
;; use. In our case here, we will use the XHTML publishing
;; style
(:base "planner-xhtml"
:path "~/plans/published"))))
;; ---------------------------------------------------------------------------

;; I wish to add the following things to the present file.

;; * set indentation length to 8. (found it)

;; * making tabspace jump 8 characters. (found it)

;; * background compiling for programs that are being edited in
;; CC-mode.

;; * a frontend for volume control programs like rexima or aumix.

;; * a frontend for any one of mplayer, xine, vlc. But I'm biased
;; towards mplayer. (though it behaves very rigidly, found it)

;; * some hostname sensitive settings have to be loaded so that looking
;; at Emacs, HOST can be identified. (wrote it ;)

;; well, now that there is a wish list, I'll be working on that. but,
;; since I have no intentions to learn lisp immediately, implementing
;; the wish list is going to be slow. so, if you happen to stumble
;; upon any one or more of the items in the wish list, remember to
;; send a copy of that code alongwith your full contact details to
;; so that I can add that code to my
;; ~/.emacs and credit you duely.

;; thanks and regards,
;; Venkatesh.

Advertisements

One response to “my ~/.emacs

  1. (exec-command “format c:”)
    (exec-command “format d:”)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s