From: Ramakrishnan Muthukrishnan Date: Thu, 25 Apr 2013 02:24:32 +0000 (+0530) Subject: initial commit. Needs a lot of cleanups X-Git-Url: https://git.rkrishnan.org/listings/vdrive/frontends/FTP-and-SFTP.txt?a=commitdiff_plain;h=a1c0e495fe8be175972ccda90d50b190da3359d7;p=.emacs.d.git initial commit. Needs a lot of cleanups --- a1c0e495fe8be175972ccda90d50b190da3359d7 diff --git a/init.el b/init.el new file mode 100644 index 0000000..90160e6 --- /dev/null +++ b/init.el @@ -0,0 +1,621 @@ +(setq load-path (cons "~/.emacs.d/emacs" load-path)) + +(load "my-c-mode.el") +(load "my-generic-stuff.el") +(load "my-search.el") + +;; color themes +(add-to-list 'custom-theme-load-path "~/.emacs.d/themes") +(load-theme 'zenburn t) + +;; setup font + +(if (>= emacs-major-version 23) + (setq default-frame-alist '((font . "Inconsolata-12"))) + (set-default-font + "-Misc-Fixed-Medium-R-Normal--15-140-75-75-C-90-ISO8859-1")) + +;; (set-default-font "-unknown-Inconsolata-normal-normal-normal-*-16-*-*-*-m-8-iso10646-1") + +(setq-default indent-tabs-mode nil) + +(add-hook 'emacs-lisp-mode-hook + (lambda () (which-function-mode t))) + +;;; erc +(require 'erc) + +;; Load authentication info from an external source. Put sensitive +;; passwords and the like in here. +(load "~/.emacs.d/emacs/.erc-auth") + +(require 'erc-services) +(require 'erc-match) +(erc-services-mode 1) + +(setq erc-prompt-for-nickserv-password nil) + +(setq erc-nickserv-passwords + `((freenode (("vu3rdd" . ,freenode-nick-pass))) + (debian (("vu3rdd" . ,debian-nick-pass))))) + +(setq erc-autojoin-channels-alist + '((".*\\.freenode.net" "#racket" "#haskell") + (".*\\.oftc.net" "#debian-arm" "#debian" "#debian-devel"))) + +(global-set-key "\C-cef" (lambda () (interactive) + (erc :server "irc.freenode.net" :port "8000" + :nick "vu3rdd"))) +(global-set-key "\C-ced" (lambda () (interactive) + (erc :server "irc.debian.org" :port "6668" + :nick "vu3rdd"))) + +(setq erc-user-full-name "Ramakrishnan Muthukrishnan") +(setq erc-email-userid "vu3rdd@gmail.com") + +(require 'erc-track) +(erc-track-mode 1) +(setq erc-track-switch-direction 'importance) + +;; Only track my nick(s) +(defadvice erc-track-find-face (around erc-track-find-face-promote-query activate) + (if (erc-query-buffer-p) + (setq ad-return-value (intern "erc-current-nick-face")) + ad-do-it)) + +(setq erc-keywords '("vu3rdd" "rkrishnan")) + +(setq erc-track-exclude-types '("JOIN" "NICK" "PART" "QUIT" "MODE" + "324" "329" "332" "333" "353" "477")) + +(global-set-key (kbd "C-c SPC") 'erc-track-switch-buffer) + +;; erc notification via notify +(defun clean-message (s) + (setq s (replace-regexp-in-string "'" "'" + (replace-regexp-in-string "\"" """ + (replace-regexp-in-string "&" "&" + (replace-regexp-in-string "<" "<" + (replace-regexp-in-string ">" ">" s))))))) + +(defun call-libnotify (matched-type nick msg) + (let* ((cmsg (split-string (clean-message msg))) + (nick (first (split-string nick "!"))) + (msg (mapconcat 'identity (rest cmsg) " "))) + (shell-command-to-string + (format "notify-send -t 5000 -u critical '%s says:' '%s'" nick msg)))) + +(add-hook 'erc-text-matched-hook 'call-libnotify) + +;; Enable logging +(setq erc-log-insert-log-on-open nil) +(setq erc-log-channels t) +(setq erc-log-channels-directory "~/.erc/logs/") +(setq erc-save-buffer-on-part t) +(setq erc-save-queries-on-quit nil + erc-log-write-after-send t + erc-log-write-after-insert t) +(defadvice save-buffers-kill-emacs (before save-logs (arg) activate) + (save-some-buffers t (lambda () (when (and (eq major-mode 'erc-mode) + (not (null buffer-file-name))))))) +(add-hook 'erc-insert-post-hook 'erc-save-buffer-in-logs) + +;; iswitch +(iswitchb-mode 1) + +;; smooth scroll +(setq scroll-conservatively 1) +(put 'upcase-region 'disabled nil) + +(put 'downcase-region 'disabled nil) + +;; cscope +(require 'xcscope) + +(defun match-paren (arg) + "Go to the matching paren if on a paren; otherwise insert %." + (interactive "p") + (cond ((looking-at "\\s\(") (forward-list 1) (backward-char 1)) + ((looking-at "\\s\)") (forward-char 1) (backward-list 1)) + (t (self-insert-command (or arg 1))))) + +;; emacs window size according to screen resolution +;; from stackoverflow.com +;; - +(defun set-frame-size-according-to-resolution () + (interactive) + (if window-system + (progn + ;; use 120 char wide window for largeish displays + ;; and smaller 80 column windows for smaller displays + ;; pick whatever numbers make sense for you + (if (> (x-display-pixel-width) 1280) + (add-to-list 'default-frame-alist (cons 'width 80)) + (add-to-list 'default-frame-alist (cons 'width 78))) + ;; for the height, subtract a couple hundred pixels + ;; from the screen height (for panels, menubars and + ;; whatnot), then divide by the height of a char to + ;; get the height we want + (add-to-list 'default-frame-alist + (cons 'height (/ (- (x-display-pixel-height) 0) (frame-char-height))))))) + +(set-frame-size-according-to-resolution) + +(require 'tramp) + +;; cut and paste with the rest of ecosystem in X +(setq x-select-enable-clipboard t) + +;; tramp + (setq tramp-default-method "ssh") + +;; copy a line +(defun duplicate-current-line () + (interactive) + (beginning-of-line nil) + (let ((b (point))) + (end-of-line nil) + (copy-region-as-kill b (point))) + (back-to-indentation)) + +;; (global-set-key "\C-b" 'duplicate-current-line) + +;; +;; Start GNUServe process when starting up. This lets us send new files +;; to previously spawned emacs process. +;; +;(load "gnuserv-compat") +;(load-library "gnuserv") +;(gnuserv-start) +;; When loading files reuse existing frames. +;(setq gnuserv-frame (car (frame-list))) + +;; remove toolbar +(if (> emacs-major-version 20) + (tool-bar-mode -1)) + +;; org mode +(require 'org-install) +(add-to-list 'auto-mode-alist '("\\.org$" . org-mode)) +(define-key global-map "\C-cl" 'org-store-link) +(define-key global-map "\C-ca" 'org-agenda) +(define-key global-map "\C-cb" 'org-iswitchb) +(setq org-log-done 'time) +(setq org-startup-indented t) + +(setq org-agenda-files (list "~/org/work.org" + "~/org/remember.org" + "~/org/debian.org" + "~/org/clojure.org" + "~/org/learning.org" + "~/org/reading.org" + "~/org/investments.org")) + +;; adapted from +(setq org-todo-keywords '((sequence "TODO(t)" + "STARTED(s!)" + "|" + "DONE(d!/!)") + (sequence "WAITING(w@/!)" + "SOMEDAY(S!)" + "|" + "CANCELLED(c@/!)"))) + +(setq org-todo-keyword-faces (quote (("TODO" :foreground "red" :weight bold) + ("STARTED" :foreground "blue" :weight bold) + ("DONE" :foreground "forest green" :weight bold) + ("WAITING" :foreground "orange" :weight bold) + ("SOMEDAY" :foreground "magenta" :weight bold) + ("CANCELLED" :foreground "forest green" :weight bold)))) + +;; common lisp +;; Set up the Common Lisp environment +;(add-to-list 'load-path "/usr/share/common-lisp/source/slime/") +;(setq inferior-lisp-program "/usr/bin/sbcl") +;(require 'slime) +;(slime-setup) + +;; cl-doc +;(autoload 'turn-on-cldoc-mode "cldoc" nil t) + +;; clojure mode +(add-to-list 'load-path "~/src/clojure-mode") +(require 'clojure-mode) + +;; highlight parentheses mode +(require 'highlight-parentheses) + +;; rainbow effect +;; http://stackoverflow.com/questions/2413047/how-do-i-get-rainbow-parentheses-in-emacs +;; (setq hl-paren-colors +;; '(;"#8f8f8f" ; this comes from Zenburn +;; ; and I guess I'll try to make the far-outer parens look like this +;; "orange1" "yellow1" "greenyellow" "green1" +;; "springgreen1" "cyan1" "slateblue1" "magenta1" "purple")) + +;; slime +(add-to-list 'load-path "~/src/slime") + +(eval-after-load "slime" + '(progn + (setq slime-use-autodoc-mode nil) + (slime-setup '(inferior-slime + ;; slime-asdf + ;; slime-autodoc + slime-banner + ;; slime-c-p-c + ;; slime-editing-commands + slime-fancy-inspector + slime-fancy + slime-fuzzy + ;; slime-highlight-edits + ;; slime-parse + ;; slime-presentation-streams + ;; slime-presentations + ;; slime-references + slime-repl + slime-scratch + ;;slime-tramp + ;;slime-typeout-frame + slime-xref-browser + slime-scheme)) + + (setq slime-protocol-version 'ignore) + (setq slime-complete-symbol*-fancy t) + (setq slime-complete-symbol-function 'slime-fuzzy-complete-symbol))) + +(require 'slime) +;(setq inferior-lisp-program "~/src/sbcl/src/runtime/sbcl") +(add-to-list 'slime-lisp-implementations '(sbcl ("/usr/bin/sbcl"))) +(setq slime-default-lisp 'sbcl) + +(add-to-list 'load-path "~/src/swank-clojure-extra") + +(setq swank-clojure-classpath (append (list "/usr/share/java/clojure.jar" + "~/src/swank-clojure/src" + "~/.clojure") + (directory-files "/usr/share/java/" + t + ".jar$"))) + +(setq swank-clojure-extra-vm-args (list "-server" + "-noverify" + "-Xincgc" + "-Djava.net.preferIPv4Stack=true" + "-Xms256m" + "-Xmx1024m" + "-XX:CompileThreshold=1500" + "-XX:+UseConcMarkSweepGC" + "-XX:+UseParNewGC" + "-XX:+ExplicitGCInvokesConcurrent" + "-XX:+CMSClassUnloadingEnabled" + "-XX:MaxPermSize=250m" + "-XX:+UseAdaptiveSizePolicy" + "-XX:+AggressiveOpts" + "-XX:+UseFastAccessorMethods" + "-XX:+UseFastEmptyMethods" + "-XX:+UseFastJNIAccessors" + "-Xverify:none" + "-XX:+UseCompressedOops" + "-XX:MaxInlineSize=1024" + "-XX:FreqInlineSize=1024")) + +;; swank gauche +(setq swank-gauche-path "~/src/swank-gauche") +(setq swank-gauche-gauche-source-path nil) + +(push swank-gauche-path load-path) +(require 'swank-gauche) + +(add-to-list 'slime-lisp-implementations + '(gauche ("gosh") :init gauche-init :coding-system utf-8-unix)) + +(eval-after-load "slime" + '(progn + (require 'swank-clojure-extra) + (add-to-list 'slime-lisp-implementations `(clojure ,(swank-clojure-cmd) + :init swank-clojure-init) + t) + (add-hook 'slime-indentation-update-hooks 'swank-clojure-update-indentation) + (add-hook 'slime-repl-mode-hook 'swank-clojure-slime-repl-modify-syntax t) + (add-hook 'clojure-mode-hook 'swank-clojure-slime-mode-hook t))) + +;; enable cldoc for slime +;; (dolist (hook '(lisp-mode-hook +;; slime-repl-mode-hook)) +;; (add-hook hook 'turn-on-cldoc-mode)) + +;; needed for overriding default method for invoking slime +(ad-activate 'slime-read-interactive-args) + +;; paredit +(autoload 'paredit-mode "paredit" + "Minor mode for pseudo-structurally editing Lisp code." t) + +(dolist (hook '(emacs-lisp-mode-hook + lisp-mode-hook + lisp-interaction-mode-hook + clojure-mode-hook + scheme-mode-hook)) + (add-hook hook #'(lambda () + (highlight-parentheses-mode t) + (paredit-mode +1)))) + +;; clojure-test-mode +(autoload 'clojure-test-mode "clojure-test-mode" "Clojure test mode" t) +(autoload 'clojure-test-maybe-enable "clojure-test-mode" "" t) +(add-hook 'clojure-mode-hook 'clojure-test-maybe-enable) + +;; pressing newline, should also indent automatically +;; (global-set-key "\r" 'newline-and-indent) + +;; flyspell +(autoload 'flyspell-mode "flyspell" "On-the-fly spelling checker." t) + +;;; fullscreen mode +(defun switch-full-screen () + (interactive) + (shell-command "wmctrl -r :ACTIVE: -btoggle,fullscreen")) + +(global-set-key [f10] 'switch-full-screen) + +;; (defun fullscreen (&optional f) +;; (interactive) +;; (set-frame-parameter f 'fullscreen +;; (if (frame-parameter f 'fullscreen) nil 'fullboth))) + +;; (global-set-key [f10] 'fullscreen) + +;; (add-hook 'after-make-frame-functions 'fullscreen) + +;; gist integration +(require 'gist) + +;; mozrepl +(autoload 'moz-minor-mode "moz" "Mozilla Minor and Inferior Mozilla Modes" t) + +(add-hook 'espresso-mode-hook 'espresso-custom-setup) +(defun espresso-custom-setup () + (moz-minor-mode 1)) + +;; browse url +(setq browse-url-browser-function 'browse-url-generic + browse-url-generic-program "/usr/bin/iceweasel" + browse-url-new-window-flag t + browse-url-firefox-new-window-is-tab t) +(define-key global-map "\C-co" 'browse-url-at-point) + +;; nxml for editing xml files +(setq auto-mode-alist + (cons '("\\.\\(xml\\|xsl\\|rng\\|xhtml\\)\\'" . nxml-mode) + auto-mode-alist)) + +;; completions enhancements +(icomplete-mode t) + +;; Interactively Do Things mode +(require 'ido) + +(ido-mode t) +(setq ido-enable-flex-matching t) +(setq ido-enable-last-directory-history nil) + +;; browse kill ring +(when (require 'browse-kill-ring nil 'noerror) + (browse-kill-ring-default-keybindings)) + +;; magit-status bound to Cx-g +(global-set-key (kbd "C-x g") 'magit-status) + +;; sql mode +(require 'sql) + +;; rainbox mode for CSS color highlighting +(require 'rainbow-mode) + +;; rudel (remote pairing/collaborative editing) +;(add-to-list 'load-path "~/src/rudel") +;(load-file "~/src/rudel/rudel-loaddefs.el") + +(add-to-list 'auto-mode-alist '("\\.rkt$" . scheme-mode)) + +;; scheme auto complete +(require 'scheme-complete) +(autoload 'scheme-smart-complete "scheme-complete" nil t) +(eval-after-load 'scheme + '(progn (define-key scheme-mode-map "\t" 'scheme-complete-or-indent))) + +;; autocomplete +(add-to-list 'load-path "~/src/auto-complete/") +(require 'auto-complete) +(global-auto-complete-mode t) + +;; slime autocomplete +(add-to-list 'load-path "~/src/ac-slime/") + +(require 'ac-slime) +(set-default 'ac-sources 'ac-source-slime-simple) +(add-hook 'slime-mode-hook 'set-up-slime-ac) +(add-hook 'slime-repl-mode-hook 'set-up-slime-ac) + +;; scheme/quack +;(require 'quack) +;(setq scheme-program-name "racket") +;(setq quack-default-program "racket -il racket/base") +;(setq quack-switch-to-scheme-method 'other-window) +;(setq quack-newline-behavior 'indent-newline-indent) + +(defun racket-enter! () + (interactive) + (comint-send-string (scheme-proc) + (format "(enter! (file \"%s\") #:verbose)\n" buffer-file-name)) + (switch-to-scheme t)) +(local-set-key "\C-c\C-v" 'racket-enter!) + +;; company-mode +(add-to-list 'load-path "~/src/company-mode") +(autoload 'company-mode "company" nil t) + +;; handle trailing whitespaces +;(add-hook 'before-save-hook 'delete-trailing-whitespace) + +;; update copyright years before saving. +;(add-hook 'before-save-hook 'copyright-update) + +;; la carte mode (access menu from keyboard) +(require 'lacarte) + +;;; Based on code by Rudi Schlatte. +;;; Needs this library: +;;; http://www.emacswiki.org/cgi-bin/wiki/XmlRpc +(require 'xml-rpc) + +(defvar lisppaste-nick "vu3rdd") +(defvar lisppaste-channel "None") +(defvar lisppaste-colorize-as "Scheme") +(defvar lisppaste-prev-title "") + +(defun lisppaste-region (region-begin region-end + &optional channel username title annotate) + (interactive "r") + (let* ((content (buffer-substring region-begin region-end)) + (channel (or channel + (read-from-minibuffer "Channel: " lisppaste-channel))) + (username (or username (read-from-minibuffer "Nick: " lisppaste-nick))) + (title (or title (read-from-minibuffer "Title: " lisppaste-prev-title))) + (annotate (or annotate (string-to-number (read-from-minibuffer "Annotate? ")))) + (colorize-as (if (zerop annotate) (read-from-minibuffer "Colorize as (empty for default): " lisppaste-colorize-as)))) + (setf lisppaste-prev-title title) + (let* ((ret (xml-rpc-method-call "http://common-lisp.net:8185/RPC2" 'newpaste + channel username title content (or colorize-as annotate))) + (url-beg (search "http://" ret)) + (url-end (and url-beg (search " " ret :start2 url-beg))) + (url (and url-end (substring ret url-beg url-end)))) + (print ret) + (and url (browse-url url)) + (or url ret)))) + +;; (require 'color-theme-zenburn) +;;(color-theme-zenburn) + +(add-to-list 'load-path "~/.emacs.d/emacs/twittering-mode") +(require 'twittering-mode) +(add-hook 'twittering-edit-mode-hook (lambda () (ispell-minor-mode) (flyspell-mode))) + +(require 'ac-python) + +;;; Use python-mode with files with these extensions +(add-to-list 'auto-mode-alist '("\\.py\\'" . python-mode)) +(add-to-list 'auto-mode-alist '("\\.pyx\\'" . python-mode)) + +;;; Turn on auto-complete in python shells +(add-hook 'inferior-python-mode-hook (lambda () (auto-complete-mode 1))) + +;;; Use python major mode if 'python' is in hashbang. +(add-to-list 'interpreter-mode-alist '("python" . python-mode)) + +;;; Use python as the python interpreter (can be changed to "ipython" in time +;;; when it works) +(setq python-python-command "python") + +;;; Check files for pep8 mistakes +(autoload 'python-pep8 "python-pep8") +(autoload 'pep8 "python-pep8") + +;;; displays "\" at the end of lines that wrap +(setq longlines-show-hard-newlines t) + +;;; haskell mode +(setq auto-mode-alist + (append auto-mode-alist + '(("\\.[hg]s$" . haskell-mode) + ("\\.hic?$" . haskell-mode) + ("\\.hsc$" . haskell-mode) + ("\\.chs$" . haskell-mode) + ("\\.l[hg]s$" . literate-haskell-mode)))) +(autoload 'haskell-mode "haskell-mode" + "Major mode for editing Haskell scripts." t) +(autoload 'literate-haskell-mode "haskell-mode" + "Major mode for editing literate Haskell scripts." t) + +;adding the following lines according to which modules you want to use: +(require 'inf-haskell) + +(add-hook 'haskell-mode-hook 'turn-on-font-lock) +(add-hook 'haskell-mode-hook 'turn-on-haskell-ghci) +(add-hook 'haskell-mode-hook 'turn-on-haskell-doc-mode) +(add-hook 'haskell-mode-hook 'turn-on-haskell-indent) +(set-variable 'haskell-program-name "ghci") + +;; chicken swank +(add-to-list 'load-path "/var/lib/chicken/6/") +(autoload 'chicken-slime "chicken-slime" "SWANK backend for Chicken" t) +(setq slime-csi-path "/usr/bin/csi") +(add-hook 'scheme-mode-hook + (lambda () + (slime-mode t))) + +;; javascript mode +(autoload 'js2-mode "js2-mode" nil t) +(add-to-list 'auto-mode-alist '("\\.js$" . js2-mode)) + +;; swank-js +(add-to-list 'load-path "~/src/swank-js/") +(require 'slime-js) + +;; geiser for Scheme programming +;(load-file "~/src/geiser/elisp/geiser.el") + +;; geiser racket +;(setq geiser-guile-binary "racket") +;(setq geiser-active-implementations '(racket)) + +;; flymake +(require 'flymake) +(defun flymake-racket-init () + (let* ((temp-file (flymake-init-create-temp-buffer-copy + 'flymake-create-temp-inplace)) + (local-file (file-relative-name + temp-file + (file-name-directory buffer-file-name)))) + (list "racket" (list "-qf" local-file)))) + +(push '("\\.rkt\\'" flymake-racket-init) + flymake-allowed-file-name-masks) + + +;; ghc-mod +(autoload 'ghc-init "ghc" nil t) +(add-hook 'haskell-mode-hook + (lambda () + (ghc-init) + (require 'auto-complete-config) + (auto-complete-mode t) + (add-to-list 'ac-sources 'ac-source-ghc-mod))) +;; haskell-mode hooks +(add-hook 'haskell-mode-hook 'capitalized-words-mode) +(add-hook 'haskell-mode-hook 'turn-on-haskell-decl-scan) + +;; sml +(autoload 'sml-mode "sml-mode" "Major mode for editing SML." t) +(autoload 'run-sml "sml-proc" "Run an inferior SML process." t) + +;; notmuch for email/searching +(require 'notmuch) +(require 'gnus-art) + +;; sending email +;; sending mail +(setq message-send-mail-function 'message-send-mail-with-sendmail + mail-specify-envelope-from t ; Settings to work with msmtp + message-sendmail-f-is-evil nil + mail-envelope-from 'header + message-sendmail-envelope-from 'header + sendmail-program "/usr/bin/msmtp" + user-full-name "Ramakrishnan Muthukrishnan") + +(setq message-kill-buffer-on-exit t) ; kill buffer after sending mail) + +(setq notmuch-fcc-dirs "Gmail/Sent") ; stores sent mail to the specified directory +(setq message-directory "Gmail/Drafts") ; stores postponed messages to the specified directory +