Skip to content
Switch branches/tags
Go to file
Cannot retrieve contributors at this time
1603 lines (1307 sloc) 52.3 KB
(message "***** .emacs loading *****")
(defvar emacs-root
(if (eq system-type 'windows-nt)
(add-to-list 'load-path (concat emacs-root "emacs-misc"))
;; ------------------------------------------------------------
;; Install missing packages
(setq package-list '(magit
(setq package-archives '(("elpa" . "")
("melpa" . "")))
;; fetch the list of packages available
(unless package-archive-contents
;; install the missing packages
(dolist (package package-list)
(unless (package-installed-p package)
(if (y-or-n-p (format "Package %s is missing. Install it? " package))
(package-install package))))
;; ------------------------------------------------------------
;; (require 'cl)
;(global-set-key "\C-x\C-m" 'execute-extended-command) ;use chord xm
;(define-key global-map [f8] 'kill-region) ;use chord fk
(global-set-key "\C-w" 'backward-kill-word)
(define-key global-map [f9]
(lambda ()
(switch-to-buffer "*scratch*")
(if (fboundp 'scroll-bar-mode) (scroll-bar-mode -1))
(if (fboundp 'tool-bar-mode) (tool-bar-mode -1))
(if (fboundp 'menu-bar-mode) (menu-bar-mode -1))
(global-set-key [f5] 'call-last-kbd-macro)
(global-set-key [f6] 'magit-status)
;; tab
(setq-default tab-width 4)
(setq-default indent-tabs-mode nil)
;; karl at wmt uses tabs
;; this will help avoid
(add-hook 'ruby-mode-hook
(lambda ()
(setq indent-tabs-mode t)
;; (setq ruby-indent-tabs-mode t)
(setq show-paren-mode t)
(setq show-paren-style 'parenthesis)
;; --- to learn from ---
;; this url seems to be a good resource
(setq inhibit-startup-message t)
(defun alt-colors-1 ()
(set-cursor-color "Orchid")
(set-mouse-color "Orchid")
(set-background-color "DarkSlateGray")
(set-foreground-color "Wheat")
(blink-cursor-mode 0)
(global-hl-line-mode 1)
;; lines
(setq scroll-step 1)
(line-number-mode 1)
(column-number-mode 1)
;; backup
(setq make-backup-files t)
(setq version-control t)
(setq backup-directory-alist (quote ((".*" . "~/.emacs_backups/"))))
;; auto-save files
(setq auto-save-default t)
(defvar autosave-dir (expand-file-name "~/.emacs_autosave/"))
(setq auto-save-file-name-transforms `((".*" ,autosave-dir t)))
;; ----------------------------------------
;; paren hilite
(show-paren-mode t)
;(setq show-paren-style 'expression)
(setq show-paren-style 'parenthesis)
;; 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.
'(magit web-mode-edit-element web-mode helm-open-github sql-indent markdown-mode use-package go-mode ace-window ag realgud yafolding alchemist projectile rjsx-mode haskell-mode ox-gfm restclient rainbow-blocks yaml-mode js2-mode virtualenvwrapper virtualenv py-autopep8 pp-c-l ledger-mode key-chord jinja2-mode inf-ruby highlight-indentation highlight-chars eproject coffee-mode bookmark+ ace-jump-mode))
'(tramp-syntax 'default nil (tramp)))
(defun alt-colors-2 ()
(set-background-color "DimGray")
(set-foreground-color "LightGray")
(set-cursor-color "DarkSlateBlue")
(set-border-color "DimGray")
(set-mouse-color "DarkSlateBlue")
(set-face-background 'default "DimGray")
(set-face-background 'region "DarkSlateGray")
(set-face-background 'highlight "DarkSlateBlue")
(set-face-background 'modeline "DarkSlateBlue") ;;; CornflowerBlue")
(set-face-foreground 'default "LightGray")
(set-face-foreground 'region "Ivory")
(set-face-foreground 'highlight "LightGray") ;;; DimGray")
(set-face-foreground 'modeline "LightGray")
(setq-default delete-old-versions 't)
(dired emacs-root)
(rename-buffer "dired1")
;(find-file (concat emacs-root ".emacs"))
(find-file (concat emacs-root "ppp/emacs-kiru/dot-emacs.el"))
;; ----------------------------------------
(add-hook 'isearch-mode-end-hook 'custom-goto-match-beginning)
(defun custom-goto-match-beginning ()
"Use with isearch hook to end search at first char of match."
(when isearch-forward (goto-char isearch-other-end)))
;; ----------------------------------------
(setq resize-minibuffer-mode t)
;; ----------------------------------------
(defadvice save-buffers-kill-emacs (around no-query-kill-emacs activate)
"Prevent annoying \"Active processes exist\" query when you quit Emacs."
(cl-flet ((process-list ())) ad-do-it))
(fset 'yes-or-no-p 'y-or-n-p)
;repl for elisp
;; ----------------------------------------
;; slime
;; installation:
;; apt-get install sbcl sbcl-doc sbcl-source slime
;; bookmark: [transcript of marco baringer's slime movie]
(if (eq system-type 'windows-nt)
;; (message "i am starting slime")
;; (setq inferior-lisp-program "C:/sbcl-1.0.19/sbcl.exe --core C:/sbcl-1.0.19/sbcl.core")
;; (add-to-list 'load-path "C:/slime")
;; (require 'slime)
;; (slime-setup)
;; (slime-setup '(slime-fancy slime-asdf))
;; (slime)
;; (setq slime-startup-animation nil)
;; [May 04, 2013 18:44] - disabling slime as "Polling /tmp/slime.5268" message persists in the minibuffer
;; (message "i am starting slime")
;; (setq inferior-lisp-program "/usr/bin/sbcl")
;; (add-to-list 'load-path "/usr/share/emacs/site-lisp/slime")
;; (require 'slime)
;; (slime-setup)
;; (slime-setup '(slime-fancy slime-asdf))
;; ;(slime-setup '(slime-fancy slime-asdf slime-js))
;; (slime)
;; ;
;; (setq slime-startup-animation nil)
;; color theme
;(require 'color-theme)
;; ; w3m
;; ;
;; ;
;; ; note : worked when i used the dev branch instead of the stable branch for w3m.el
;; (if (eq system-type 'windows-nt)
;; (message "i am skipping w3m")
;; (progn
;; (message "i am starting w3m")
;; ;(add-to-list 'load-path (concat emacs-root "emacs/emacs-w3m-1.4.4"))
;; (add-to-list 'load-path "/usr/share/emacs/site-lisp/w3m")
;; (require 'w3m-load)
;; (setq browse-url-browser-function 'w3m-browse-url)
;; (autoload 'w3m-browse-url "w3m" "Ask a WWW browser to show a URL." t)
;; (global-set-key "\C-xm" 'browse-url-at-point)))
;(define-key global-map [f11] 'hexl-find-file)
;(define-key global-map [f12] 'compare-windows)
(global-set-key [kp-subtract] "\C-a\C-k\C-d") ; numpad minus = nuke line
;; Apr 26, 2013 - commented out the following section as emacs said:
;; "Package pgg-gpg is obsolete!"
;; ; auto encryption - begin
;; ;
;; (defvar pgg-gpg-user-id "kirubakaran")
;; (autoload 'pgg-make-temp-file "pgg" "PGG")
;; (autoload 'pgg-gpg-decrypt-region "pgg-gpg" "PGG GnuPG")
;; (define-generic-mode 'gpg-file-mode
;; (list ?#)
;; nil nil
;; '(".gpg\\'" ".gpg-encrypted\\'")
;; (list (lambda ()
;; (add-hook 'before-save-hook
;; (lambda ()
;; (let ((pgg-output-buffer (current-buffer)))
;; (pgg-gpg-encrypt-region (point-min) (point-max)
;; (list pgg-gpg-user-id))))
;; nil t)
;; (add-hook 'after-save-hook
;; (lambda ()
;; (let ((pgg-output-buffer (current-buffer)))
;; (pgg-gpg-decrypt-region (point-min) (point-max)))
;; (set-buffer-modified-p nil)
;; (auto-save-mode nil))
;; nil t)
;; (let ((pgg-output-buffer (current-buffer)))
;; (pgg-gpg-decrypt-region (point-min) (point-max)))
;; (auto-save-mode nil)
;; (set-buffer-modified-p nil)))
;; "Mode for gpg encrypted files")
;; ; auto encryption - end
(require 'epa-file)
;; ----------------------------------------
;; set window title to contain the current buffer name
;; this is so that rescue-time can see what buffer I am in
;; I don't want everything I do in emacs to be classified as 'dev work'
;(defadvice switch-to-buffer (after name-the-frame (arg))
;; (set-frame-name (concat (buffer-name) " - emacs")))
;(ad-activate 'switch-to-buffer)
;; a method that wasn't sufficient:
;(global-set-key [f10]
;; '(lambda ()
;; (interactive)
;; (set-frame-name (concat "emacs : " (buffer-name)))))
;; a method that didn't work:
;(global-set-key "\C-xb"
;; '(lambda (buffer &optional norecord)
;; (interactive)
;; (set-frame-name (concat "emacs : " (buffer-name)))
;; (switch-to-buffer buffer norecord)))
;; references:
;; ----------------------------------------
;; cygwin
(if (eq system-type 'windows-nt)
(setenv "PATH" (concat (getenv "PATH") ";C:\\users\\kirath\\cygwin\\bin"))
(setq exec-path (cons "c:/users/kirath/cygwin/bin/" exec-path))
(require 'cygwin-mount)
;; Replace DOS shell with Cygwin Bash Shell
(add-hook 'comint-output-filter-functions
'shell-strip-ctrl-m nil t)
(add-hook 'comint-output-filter-functions
'comint-watch-for-password-prompt nil t)
(setq explicit-shell-file-name "bash.exe")
;; For subprocesses invoked via the shell
;; (e.g., "shell -c command")
(setq shell-file-name explicit-shell-file-name)))
;; ------------------------------------------------------------
;; python mode
;; (add-hook 'python-mode-hook
;; (lambda ()
;; (define-key python-mode-map "\"" 'electric-pair)
;; (define-key python-mode-map "\'" 'electric-pair)
;; (define-key python-mode-map "(" 'electric-pair)
;; (define-key python-mode-map "[" 'electric-pair)
;; (define-key python-mode-map "{" 'electric-pair)))
;; (defun electric-pair ()
;; "Insert character pair without sournding spaces"
;; (interactive)
;; (let (parens-require-spaces)
;; (insert-pair)))
;; ------------------------------------------------------------
;; ------------------------------------------------------------
;; open my files
;; (message "i am loading files from thumb drive")
;; (defun thumbdrive ()
;; (if (eq system-type 'windows-nt)
;; '"f:/"
;; '"/media/HANZO\ SWORD/"))
;; (defun open-file-if-exists (file1)
;; (when (file-readable-p file1)
;; (find-file file1)))
;; (defun oife (file1)
;; (open-file-if-exists (concat (thumbdrive) "Performance/" file1)))
;; (mapc 'oife
;; (list
;; "done.txt"
;; "goals.txt"
;; "ideas.txt"
;; "startup-log.txt"
;; ""
;; "todo.txt"))
;; ------------------------------------------------------------
(defun my-date ()
(defun my-date-str ()
(concat "[" (format-time-string "%b %d, %Y %H:%M") "] "))
(defun my-time ()
(defun my-time-str ()
(concat "[" (format-time-string "Time %H:%M") "] "))
(defun my-just-date ()
(format-time-string "%b %d")))
(defun iso-date-str ()
(format-time-string "%Y-%m-%dT%T")
(substring (format-time-string "%z") 0 3)
(substring (format-time-string "%z") 3))))
(defun isodt ()
(define-key global-map [f3] 'my-time)
(define-key global-map [S-f3] 'my-date)
(define-key global-map [C-f3] 'my-just-date)
;; ------------------------------------------------------------
;; ---
;; copy line without selection
(defun copy-line (&optional arg)
"Save current line into Kill-Ring without mark the line "
(interactive "P")
(let ((beg (line-beginning-position))
(end (line-end-position arg)))
(copy-region-as-kill beg end)))
(global-set-key (kbd "C-c l") 'copy-line)
;; ---
;; (defun totd ()
;; (interactive)
;; (random t) ;; seed with time-of-day
;; (with-output-to-temp-buffer "*Tip of the day*"
;; (let* ((commands (loop for s being the symbols
;; when (commandp s) collect s))
;; (command (nth (random (length commands)) commands)))
;; (princ
;; (concat "Your tip for the day is:\n"
;; "========================\n\n"
;; (describe-function command)
;; "\n\nInvoke with:\n\n"
;; (with-temp-buffer
;; (where-is command t)
;; (buffer-string)))))))
;; (totd)
;; ------------------------------------------------------------
(defun my-file-processing-fn (fpath)
"\nelisp file processing function. \nKill word that occurs after kite and hoo. \n~Kirubakaran\n"
(let (mybuffer)
(setq mybuffer (find-file fpath))
(search-forward "kite")
(search-forward "hoo")
(kill-word (point))
(kill-buffer mybuffer)))
;; ------------------------------------------------------------
;; ------------------------------------------------------------
;;(require 'ido)
;;(ido-mode t)
;;(setq ido-enable-flex-matching t)
;;(setq ido-create-new-buffer 'always)
;(require 'browse-kill-ring)
;(global-set-key [(control c)(k)] 'browse-kill-ring)
(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)))))
;commenting coz this only turned out to be a nuisance in my non-lisp coding
;(global-set-key "%" 'match-paren)
(require 'generic)
(require 'generic-x)
(if (not (eq system-type 'windows-nt))
(setq x-select-enable-clipboard 't))
(autoload 'gtypist-mode "gtypist-mode")
(setq auto-mode-alist
(cons '("\\.typ\\'" . gtypist-mode) auto-mode-alist))
;; ------------------------------------------------------------
(if (eq system-type 'windows-nt)
;; 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
(:stipple nil
:background "DarkSlateGray"
:foreground "Wheat"
:inverse-video nil
:box nil
:strike-through nil
:overline nil
:underline nil
:slant normal
:weight normal
:height 140
:width normal
:family "outline-consolas"))))))
;; (require 'python-mode)
;; ;(require 'ipython)
;; (setq py-shell-name "ipython")
;; (setq ipython-command "/usr/bin/ipython")
;; ;(setq py-python-command-args '("-pylab" "-colors" "LightBG"))
;; ;(setq-default py-python-command-args '("--colors=LightBG"))
;; (setq-default py-python-command-args '("--colors=Linux"))
;(add-to-list 'load-path (concat emacs-root "emacs/g-client"))
;(load-library "g")
;; makes line into
;; +------+
;; | line |
;; +------+
(global-set-key [f7] 'k_box)
(defun k_box ()
(setq cur_line (thing-at-point 'line))
;delete trailing newline
(if (string=
(substring cur_line -1)
(setq cur_line
(substring cur_line 0 (- (length cur_line) 1)))))
(setq ins_line (concat "| " cur_line " |\n"))
(setq border_line
(concat "+"
(make-string (- (length ins_line) 3) ?-)
;; escreen
;; 2014-07-04 not needed as i now use xmonad to manage
;; even emacs frames
;; (load "escreen")
;; (escreen-install)
;; (global-set-key (kbd "<s-prior>") 'escreen-goto-prev-screen)
;; (global-set-key (kbd "<s-next>") 'escreen-goto-next-screen)
(delete-selection-mode t)
;; CSS color values colored by themselves
(defvar hexcolour-keywords
(0 (put-text-property
(match-beginning 0)
(match-end 0)
'face (list :background
(match-string-no-properties 0)))))))
(defun hexcolour-add-to-font-lockfont-lock ()
(font-lock-add-keywords nil hexcolour-keywords))
(add-hook 'css-mode-hook 'hexcolour-add-to-font-lock)
;; end
(global-set-key "\C-x\C-b" 'ibuffer) ; was list-buffers ;use chord xb
;; make emacs fonts bigger
;; :height 100 ===> 10px
(set-face-attribute 'default nil :height 110)
;; Use a better font
(when (string= system-name "hulk")
(set-default-font "Inconsolata-16"))
;; Zap-back-to-char
;; kiru : doesn't seem to work
;; (global-set-key "\C-\M-z" #'(lambda (arg char) (interactive "p\ncZap to char: ") (zap-to-char (- arg) char)))
(setq eshell-save-history-on-exit t)
;; windmove
(windmove-default-keybindings 'control)
;; chrome <--> emacs
;(require 'edit-server)
;(require 'org-babel-init)
;full screen / maximize
(defun toggle-fullscreen ()
(x-send-client-message nil 0 nil "_NET_WM_STATE" 32
(x-send-client-message nil 0 nil "_NET_WM_STATE" 32
;(global-unset-key [left])
;(global-unset-key [right])
;(global-unset-key [up])
;(global-unset-key [down])
;(global-unset-key [prior])
;(global-unset-key [next])
(global-unset-key [home])
(global-unset-key [end])
;; ------------------------------------------------------------
;; key : a
(put 'dired-find-alternate-file 'disabled nil)
(defvar pp^L-^L-string-function
(lambda (win) (make-string (1- (window-width win)) ?_)))
(put 'set-goal-column 'disabled nil)
;; (add-to-list 'load-path (concat emacs-root "emacs/plugins/yasnippet-0.6.1c"))
;; (require 'yasnippet)
;; (yas/initialize)
;; (yas/load-directory (concat emacs-root "emacs/plugins/yasnippet-0.6.1c/snippets"))
;; (setq yas/prompt-functions
;; '(yas/ido-prompt yas/x-prompt))
;; ------------------------------------------------------------
;; when using ido, the confirmation is rather annoying...
(setq confirm-nonexistent-file-or-buffer nil)
;; increase minibuffer size when ido completion is active
;; (add-hook 'ido-minibuffer-setup-hook
;; (function
;; (lambda ()
;; (make-local-variable 'resize-minibuffer-window-max-height)
;; (setq resize-minibuffer-window-max-height 1))))
(global-set-key (kbd "M-g") 'goto-line)
;; ------------------------------------------------------------
;; wanderlust
(autoload 'wl "wl" "Wanderlust" t)
(autoload 'wl-other-frame "wl" "Wanderlust on new frame." t)
(autoload 'wl-draft "wl-draft" "Write draft with Wanderlust." t)
(setq elmo-imap4-default-server "")
(setq elmo-imap4-default-user "")
(setq elmo-imap4-default-authenticate-type 'clear)
(setq elmo-imap4-default-port '993)
(setq elmo-imap4-default-stream-type 'ssl)
(setq elmo-imap4-use-modified-utf7 t)
(setq wl-smtp-connection-type 'starttls)
(setq wl-smtp-posting-port 587)
(setq wl-smtp-authenticate-type "plain")
(setq wl-smtp-posting-user "kulalosai")
(setq wl-smtp-posting-server "")
(setq wl-local-domain "")
(setq wl-default-folder "%inbox")
(setq wl-default-spec "%")
(setq wl-draft-folder "%[Gmail]/Drafts") ; Gmail IMAP
(setq wl-trash-folder "%[Gmail]/Trash")
(setq wl-folder-check-async t)
(setq elmo-imap4-use-modified-utf7 t)
(autoload 'wl-user-agent-compose "wl-draft" nil t)
(if (boundp 'mail-user-agent)
(setq mail-user-agent 'wl-user-agent))
(if (fboundp 'define-mail-user-agent)
;; ------------------------------------------------------------
;; restore window configuration
(require 'winner)
(setq winner-dont-bind-my-keys t) ;; winner conflicts with org
(global-set-key (kbd "<s-left>") 'winner-undo)
(global-set-key (kbd "<XF86Forward>") 'winner-redo)
(global-set-key (kbd "<s-right>") 'winner-redo)
(global-set-key (kbd "<XF86Back>") 'winner-undo)
(winner-mode t)
(size-indication-mode t)
;; uniquify: unique buffer names
(require 'uniquify) ;; make buffer names more unique
uniquify-buffer-name-style 'post-forward
uniquify-separator ":"
uniquify-after-kill-buffer-p t
uniquify-ignore-buffers-re "^\\*")
;; - same guy as
(setq cua-enable-cua-keys nil) ;; only for rectangles
(cua-mode t)
(setq delete-by-moving-to-trash t) ; moves file to ~/.Trash on delete
(setq save-place-file "~/.emacs.d/saveplace") ;; keep my ~/ clean
(save-place-mode 1)
;;(autoload 'django-html-mode "django-html-mode")
;; (add-to-list 'auto-mode-alist '("\\.[sx]?html?\\'" . html-mode))
;; (add-to-list 'auto-mode-alist '("\\.[sx]?html?\\'" . jinja2-mode))
;; ; start emacs server
;; ;
;; (defvar server-buffer-clients)
;; ;(when (and (fboundp 'server-start) (string-equal (getenv "TERM") 'xterm))
;; (when (fboundp 'server-start)
;; (server-start)
;; (defun fp-kill-server-with-buffer-routine ()
;; (and server-buffer-clients (server-done)))
;; (add-hook 'kill-buffer-hook 'fp-kill-server-with-buffer-routine))
;; C-a once command beginning and twice to line beginning
(defun eshell-maybe-bol ()
(let ((p (point)))
(if (= p (point))
(add-hook 'eshell-mode-hook
'(lambda () (define-key eshell-mode-map "\C-a" 'eshell-maybe-bol)))
;; [Apr 09, 2013] I'm going to use
(autoload 'js2-mode "js2-mode" nil t)
(add-to-list 'auto-mode-alist '("\\.js\\'" . js2-mode))
;; fixing js2-mode indentation
;; bottom of :
;; thanks to :
(setq js-indent-level 2)
(setq js2-basic-offset 2)
(setq js2-cleanup-whitespace t)
(defun duplicate-line()
(move-beginning-of-line 1)
(open-line 1)
(next-line 1)
(global-set-key (kbd "C-S-f") 'duplicate-line)
(global-set-key (kbd "C-S-a") 'align-regexp)
(put 'narrow-to-region 'disabled nil)
(global-set-key "\C-ch" 'highlight-indentation)
;; temporarily disabling this [Jul 04, 2014 12:05]
;; (push "/home/kiru/emacs-misc/distel/elisp" load-path)
;; (require 'erlang-start)
;; (require 'distel)
;; (distel-setup)
;; 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.
;(load-file "/home/kiru/opt/dvc/++build/dvc-load.el")
(setq dired-listing-switches "-alk")
;(require 'dired+)
(global-set-key (kbd "M-/") 'hippie-expand)
(require 'bookmark+)
;; (require 'google)
;; (setq google-license-key "ABQIAAAAX24y9sOWkGb05hZfRXyLqhQMUf-zCmQEDwv1N16oyUFq57qOsBRRq3EREDeLpkl2ki4azX9DIGjX5g" ; optional
;; google-referer "") ; required!
;; (google-search-video "rickroll")
;; keychord
(require 'key-chord)
(key-chord-mode 1)
;(key-chord-define-global "xm" 'execute-extended-command)
;;(key-chord-define-global "xo" 'other-window)
(key-chord-define-global "xo" 'ace-window)
(key-chord-define-global "xb" 'ibuffer)
(key-chord-define-global "fk" 'kill-region)
(key-chord-define-global "zl" 'insert-console-log)
(key-chord-define-global "zk" 'insert-js-fn)
(key-chord-define-global "z'" 'insert-pdb-break)
;(key-chord-define-global "ms" 'magit-status)
;(key-chord-define-global "fs" 'save-buffer)
;(key-chord-define-global "fb" 'ido-switch-buffer)
(global-set-key "\C-cr" 'remember)
(defun insert-console-log ()
"Insert 'console.log' into buffer"
(insert "console.log();")
(defun insert-pdb-break ()
"Insert pdb breakpoint"
(insert "import pdb;pdb.set_trace()")
(defun insert-js-fn ()
"Insert js function into buffer"
(insert "function () {}")
(defun my-org-extract-link ()
"Extract the link location at point and put it on the killring."
(when (org-in-regexp org-bracket-link-regexp 1)
(setq link (org-link-unescape (org-match-string-no-properties 1)))
(message (concat "In kill ring : " link))
(kill-new link)))
(defun org_setup ()
(setq org-directory "/home/kiru/Documents/org")
(setq org-default-notes-file
(concat org-directory "/"))
(define-key global-map "\C-cc" 'org-capture)
(define-key global-map "\C-cl" 'org-store-link)
;; (add-hook 'org-mode-hook 'visual-line-mode)
(add-hook 'org-mode-hook 'auto-fill-mode)
(add-hook 'org-mode-hook
(lambda ()
(local-set-key "\C-ck" 'my-org-extract-link)))
(setq sentence-end-double-space nil) ; fixing fill
(key-chord-define org-mode-map "fl" 'collapse-to-title-wrap)
(setq org-clock-modeline-total 'current)
(python . t)
(ruby . t)
(sqlite . t)
(js . t)
(message "Emacs version 23/24 check")
(if (> emacs-major-version 23)
(message "in >23")
;; expand emacs package manager with community contributed packages
(require 'package)
;; Add the original Emacs Lisp Package Archive
(add-to-list 'package-archives
'("elpa" . ""))
(add-to-list 'package-archives
'("gnu" . ""))
;; Add the user-contributed repository
;; (add-to-list 'package-archives
;; '("marmalade" . ""))
;; using melpa instead of marmalade [May 28, 2014 10:02]
(add-to-list 'package-archives
'("melpa" . "") t)
(eval-after-load "org"
(message "in <=23")
(require 'org)
;; doesn't seem to be working
;; --------------------------
;; plan9 style eshell
(require 'eshell)
(require 'em-smart)
(setq eshell-where-to-jump 'begin)
(setq eshell-review-quick-commands nil)
(setq eshell-smart-space-goes-to-end t)
;; use dpkg -L ledger-el to see where it is installed
;; 2012-jun-18 - note: i couldn't find ledger.el in the system
;; 2012-jun-18 - so i copied it from github /usr/share/emacs/site-lisp/
(lambda ()
(local-set-key (kbd "C-c =") 'ledger-align-amounts)))
;temporarily commented out for better presentation
;; ;
;; (add-to-list 'load-path (concat emacs-root "emacs/color-theme-6.6.0"))
;; (require 'color-theme)
;; (eval-after-load "color-theme"
;; '(progn
;; (color-theme-initialize)
;; (color-theme-robin-hood)))
;; O'Reilly - Writing GNU Emacs Extensions -- begin
(defalias 'scroll-ahead 'scroll-up)
(defalias 'scroll-behind 'scroll-down)
(defun scroll-line-ahead (&optional n)
"Scroll ahead n lines (defaul = 1)"
(interactive "P")
(scroll-ahead (prefix-numeric-value n)))
(defun scroll-line-behind (&optional n)
"Scroll behind n lines (defaul = 1)"
(interactive "P")
(scroll-behind (prefix-numeric-value n)))
(global-set-key "\C-x\C-q" 'quoted-insert)
(global-set-key "\C-q" 'scroll-line-behind)
(global-set-key "\C-z" 'scroll-line-ahead)
;; O'Reilly - Writing GNU Emacs Extensions -- end
;; erc - begin
(require 'erc)
(erc-autojoin-mode t)
(setq erc-autojoin-channels-alist
'((".*\\" "#startups" "#python-dev")))
(setq erc-hide-list '("JOIN" "PART" "QUIT" "NICK"))
(defun erc-start-or-switch ()
"Connect to ERC, or switch to last active buffer"
(if (get-buffer "") ;; ERC already active?
(erc-track-switch-buffer 1) ;; yes: switch to last active
(when (y-or-n-p "Start ERC? ") ;; no: maybe start ERC
(erc :server ""
:port 6667
:nick "kirubakaran"
:full-name "kirubakaran athmanathan")
(global-set-key (kbd "C-c i") 'erc-start-or-switch)
;; erc - end
;; Ruby REPL
;(autoload 'inf-ruby "inf-ruby" "Run an inferior Ruby process" t)
;(autoload 'inf-ruby-keys "inf-ruby" "" t)
(eval-after-load 'ruby-mode
'(add-hook 'ruby-mode-hook 'inf-ruby-keys))
(setq ruby-indent-level 2)
;; Mark Down
(autoload 'markdown-mode
"markdown-mode.el" "Major mode for editing Markdown files" t)
(setq auto-mode-alist
(cons '("\\.md" . markdown-mode) auto-mode-alist))
(setq org-capture-templates
'(("j" "Journal" entry (file+datetree org-default-notes-file)
"* %?\nEntered on %U\n %i\n %a")))
;; coffeescript
(require 'coffee-mode)
(setq whitespace-action
'(auto-cleanup)) ;; automatically clean up bad whitespace
(setq whitespace-style
'(trailing space-before-tab indentation empty space-after-tab)) ;; only show bad whitespace
(setq coffee-tab-width 2)
;; word-count
(defun wc nil "Count words in buffer"
(shell-command-on-region (point-min) (point-max) "wc -w"))))
(defun wcr (&optional b e)
(interactive "r")
(shell-command-on-region b e "wc -w"))))
(defun wcst nil "Count words in subtree"
(shell-command-on-region (point-min) (point-max) "wc -w"))))
(defun start-day ()
(concat "\n*** " (format-time-string "%b %d (%a)") "\n"
"**** tasks\n"
"***** important & urgent\n"
"***** important\n"
"***** urgent\n"
"***** other\n"
"**** summary\n"
"**** freewriting\n"
" " (my-date-str) "\n"
" \n"
" "
(define-key global-map [f12] 'start-day)
;; jrockway's eproject
;; sass
;; (setq exec-path (cons (expand-file-name "~/.rvm/gems/ruby-1.9.3-p194/bin") exec-path))
;; (add-to-list 'load-path (expand-file-name "~/emacs/scss-mode"))
;; (autoload 'scss-mode "scss-mode")
;; (add-to-list 'auto-mode-alist '("\\.scss\\'" . scss-mode))
;; need to do the equiv of
;; [[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
;; for the above to work
(global-hi-lock-mode 1)
(defalias 'qrr 'query-replace-regexp)
;; collapse org-mode buffer to first level titles
(fset 'collapse-to-title
(&optional arg)
"Keyboard macro."
(interactive "p")
(quote ([134217788 21 134217848 111 114 103 45 103 108
111 tab return tab] 0 "%d")) arg)))
;; Mar 08, 2013 - Wrote wrapper to keep it from triggering in other buffers
(defun collapse-to-title-wrap (&optional arg)
(interactive "p")
(if (string= (buffer-name) "")
(insert "fl")
;;; --- begin :
;; Auto refresh buffers
(global-auto-revert-mode 1)
;; Also auto refresh dired, but be quiet about it
(setq global-auto-revert-non-file-buffers t)
(setq auto-revert-verbose nil)
;; full screen magit-status
(defadvice magit-status (around magit-fullscreen activate)
(window-configuration-to-register :magit-fullscreen)
(defun magit-quit-session ()
"Restores the previous window configuration and kills the magit buffer"
(delete-frame) ;since i am now ,using xmonad to manage emacs frames
(jump-to-register :magit-fullscreen))
(setq magit-status-buffer-switch-function 'switch-to-buffer)
(setq magit-push-always-verify nil)
;; easily move lines up and down
(defun move-line-down ()
(let ((col (current-column)))
(transpose-lines 1))
(move-to-column col)))
(defun move-line-up ()
(let ((col (current-column)))
(transpose-lines -1))
(move-to-column col)))
(global-set-key (kbd "<C-S-down>") 'move-line-down)
(global-set-key (kbd "<C-S-up>") 'move-line-up)
;; opening lines
(defun open-line-below ()
(defun open-line-above ()
(forward-line -1)
;; (global-set-key (kbd "<M-return>") 'open-line-below)
;; (global-set-key (kbd "<M-S-return>") 'open-line-above)
(global-set-key (kbd "<M-S-return>") 'open-line-below)
;; easier way of renaming current buffer file
(defun rename-current-buffer-file ()
"Renames current buffer and file it is visiting."
(let ((name (buffer-name))
(filename (buffer-file-name)))
(if (not (and filename (file-exists-p filename)))
(error "Buffer '%s' is not visiting a file!" name)
(let ((new-name (read-file-name "New name: " filename)))
(if (get-buffer new-name)
(error "A buffer named '%s' already exists!" new-name)
(rename-file filename new-name 1)
(rename-buffer new-name)
(set-visited-file-name new-name)
(set-buffer-modified-p nil)
(message "File '%s' successfully renamed to '%s'"
name (file-name-nondirectory new-name)))))))
(global-set-key (kbd "C-x C-r") 'rename-current-buffer-file)
;;; --- end :
;; --- begin journalhash ---
;; post hash of to firebase
;; view hashes at
;; (add-hook 'after-save-hook 'journal-hash-post)
;; (add-hook 'after-revert-hook 'journal-hash-post)
(defun journal-hash-post ()
(interactive) ;make it available in buffers
(if (or (string= (buffer-name) "")
(string= (buffer-name) "")
(string= (buffer-name) "")
(string= (buffer-name) ""))
(setq journal-hash (md5 (current-buffer)))
(setq data (format "{ \"%s--%s\": \"%s\|%s\" }"
(replace-regexp-in-string "\\." "_"
(format-time-string "%b %d, %Y %H:%M")))
;(message data)
(setq urlend "")
(setq cmd (format "curl -X PATCH -d '%s' %s" data urlend))
(start-process-shell-command "journalhash" nil cmd)
;; --- end journalhash ---
;; show and copy full path of file in current buffer
(defun show-file-name ()
"Show the full path file name in the minibuffer."
(message (buffer-file-name))
(kill-new (file-truename buffer-file-name))
(global-set-key "\C-cz" 'show-file-name)
(setq-default py-shell-name "ipython")
(setq-default py-which-bufname "*IPython*")
(setq py-python-command-args
'("--gui=wx" "--pylab=wx" "-colors" "Linux"))
(setq py-force-py-shell-name-p t)
;; switch to the interpreter after executing code
;(setq py-shell-switch-buffers-on-execute-p t)
;(setq py-switch-buffers-on-execute-p t)
;; don't split windows
(setq py-split-windows-on-execute-p nil)
;; try to automagically figure out indentation
(setq py-smart-indentation t)
;; --- python-mode setup with ipython --- [end]
;; flymake python
;temporarily disabling it while i work on existing code in fp project
;(add-hook 'find-file-hook 'flymake-find-file-hook)
;; (when (load "flymake" t)
;; (defun flymake-pycheckers-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 "~/emacs/" (list local-file))))
;; (add-to-list 'flymake-allowed-file-name-masks
;; '("\\.py\\'" flymake-pycheckers-init)))
;; (require 'flymake-cursor)
(global-set-key (kbd "<f11>") 'hc-toggle-highlight-tabs)
(global-set-key (kbd "S-<f11>") 'hc-toggle-highlight-trailing-whitespace)
;make emacs work with python virtual environments
(setenv "WORKON_HOME" "/home/kiru/pyenv")
(defun dired-keys-additional ()
(local-set-key (kbd "C-c C-e") 'dired-toggle-read-only))
(add-hook 'dired-mode-hook 'dired-keys-additional)
(define-key global-map (kbd "C-S-s") 'ace-jump-mode)
;; Tearing out the Emacs windows manager
;(set 'pop-up-frames 'graphic-only) ;; disabling it until i get back on tiling wm
(set 'gdb-use-separate-io-buffer nil)
(set 'gdb-many-windows nil)
(set 'mouse-autoselect-window nil)
(set 'focus-follows-mouse nil)
;; (set 'ido-decorations '("\n-> " "" "\n " "\n ..." "[" "]" " [No match]"
;; " [Matched]" " [Not readable]" " [Too big]"
;; " [Confirm]"))
(set 'frame-auto-hide-function 'delete-frame)
;; apply theme to new frame
(defun apply-theme (frame)
(select-frame frame)
(if (window-system frame)
(when (string= system-name "hulk")
(set-default-font "Inconsolata-16")))
(add-hook 'after-make-frame-functions 'apply-theme)
;; omit uninteresting files in a dired buffer with Alt-o
;(add-hook 'dired-load-hook '(lambda () (require 'dired-x)))
(setq dired-omit-mode t)
(setq dired-omit-files
(concat dired-omit-files "\\|API_PID-.?"))
(add-hook 'after-init-hook 'my-after-init-hook)
(defun my-after-init-hook ()
;; ido mode, great as it is, isn't great enough
;; this project has done a great job of fixing this
;; (ido-mode 1)
;; (ido-everywhere 1)
;(flx-ido-mode 1)
;(pretty-control-l-mode 1)
;; (define-key magit-status-mode-map (kbd "q") 'magit-quit-session)
;; (define-project-type rails (generic)
;; (or (look-for "Gemfile"))
;; :relevant-files ("\.rb$" "\.js$" "\.css$"))
;; disable ido faces to see flx highlights.
;; (setq ido-use-faces nil)
(setq gc-cons-threshold 20000000)
;; (add-hook 'before-save-hook
;; (lambda ()
;; (yafolding-show-all)
;; (delete-trailing-whitespace)))
(add-hook 'before-save-hook 'delete-trailing-whitespace)
;; for react ---------------------------------------------------------
;; use web-mode for .jsx files
;; (add-to-list 'auto-mode-alist '("\\.jsx$" . web-mode))
;; i'm using rjsx-mode instead
(require 'flycheck)
;; turn on flychecking globally
(add-hook 'after-init-hook #'global-flycheck-mode)
;; disable jshint since we prefer eslint checking
(setq-default flycheck-disabled-checkers
(append flycheck-disabled-checkers
;; use eslint with web-mode for jsx files
(flycheck-add-mode 'javascript-eslint 'web-mode)
;; customize flycheck temp file prefix
(setq-default flycheck-temp-prefix ".flycheck")
;; disable json-jsonlist checking for json files
(setq-default flycheck-disabled-checkers
(append flycheck-disabled-checkers
;; only need exec-path-from-shell on OSX
;; this hopefully sets up path and other vars better
(when (memq window-system '(mac ns))
;; adjust indents for web-mode to 2 spaces
(defun my-web-mode-hook ()
"Hooks for Web mode. Adjust indents"
(setq web-mode-markup-indent-offset 2)
(setq web-mode-css-indent-offset 2)
(setq web-mode-code-indent-offset 2)
(setq web-mode-enable-auto-quoting t)
(add-to-list 'auto-mode-alist '("\\.html?\\'" . web-mode))
(setq web-mode-engines-alist '(("django" . "\\.html\\'")))
(add-hook 'web-mode-hook 'my-web-mode-hook)
;; for better jsx syntax-highlighting in web-mode
;; - courtesy of Patrick @halbtuerke
(defadvice web-mode-highlight-part (around tweak-jsx activate)
(if (equal web-mode-content-type "jsx")
(let ((web-mode-enable-part-face nil))
(add-to-list 'auto-mode-alist '("\\.jsx\\'" . rjsx-mode))
(add-to-list 'auto-mode-alist '("\\.es6\\'" . rjsx-mode))
(add-to-list 'auto-mode-alist '("\\.jsx\\.erb\\'" . rjsx-mode))
(with-eval-after-load 'rjsx
(define-key rjsx-mode-map "<" nil)
(define-key rjsx-mode-map (kbd "C-d") nil))
(key-chord-define-global "z/" 'ag)
(setq ring-bell-function 'ignore)
(key-chord-define-global "z." 'yafolding-toggle-all)
;; now i can move files like i use to with mc
(setq dired-dwim-target t)
;; hugo helpers - begin
(defmacro with-dir (DIR &rest FORMS)
"Execute FORMS in DIR."
(let ((orig-dir (gensym)))
`(progn (setq ,orig-dir default-directory)
(cd ,DIR) ,@FORMS (cd ,orig-dir))))
(setq hugo-dir "/home/kiru/ppp/"
hugo-dir-admin "/home/kiru/ppp/"
hugo-process "Hugo Server"
sync-kirubakaran "Render Rsync"
hugo-server-site "http://localhost:1313/")
(defun krun ()
"Run hugo server if not already running and open its webpage."
(with-dir hugo-dir
(unless (get-process hugo-process)
(start-process hugo-process nil "hugo" "--buildDrafts" "server"))
(browse-url hugo-server-site)))
(defun kend ()
"End hugo server process if running."
(--when-let (get-process hugo-process)
(delete-process it)))
(defun ksync ()
"render and rsync content to server"
(let ((default-directory hugo-dir-admin))
(start-process sync-kirubakaran nil
(concat hugo-dir-admin "render-rsync"))))
;; hugo helpers - end
(require 'helm)
(require 'helm-config)
(helm-mode 1)
(global-set-key (kbd "M-y") 'helm-show-kill-ring)
(global-set-key (kbd "C-c h") 'helm-command-prefix)
(global-unset-key (kbd "C-x c"))
(key-chord-define-global "xm" 'helm-M-x)
(setq helm-M-x-fuzzy-match t)
(global-set-key (kbd "C-x C-f") 'helm-find-files)
(global-set-key (kbd "C-c h o") 'helm-occur)
(setq helm-exit-idle-delay 0)
(setq js-switch-indent-offset 2)
;; Ctrl +, or Ctrl - will change the text size.
(global-set-key (kbd "C-+") 'text-scale-increase)
(global-set-key (kbd "C--") 'text-scale-decrease)
(key-chord-define-global "x," 'beginning-of-buffer)
(key-chord-define-global "x." 'end-of-buffer)
(add-hook 'before-save-hook #'gofmt-before-save)
(require 'use-package)
;; (use-package org-brain :ensure t
;; :init
;; (setq org-brain-path "/home/kiru/ppp/learn/tstbrain/")
;; :config
;; (setq org-id-track-globally t)
;; (setq org-id-locations-file "~/.emacs.d/.org-id-locations")
;; (push '("b" "Brain" plain (function org-brain-goto-end)
;; "* %i%?" :empty-lines 1)
;; org-capture-templates)
;; (setq org-brain-visualize-default-choices 'all)
;; (setq org-brain-title-max-length 12))
;; (load "/home/kiru/opt/org-mind-map.el")
;; (load "/home/kiru/.emacs.d/ox-freemind.el")
;; (defun save-and-export-mindmap ()
;; "Helper to save current org file and export as mindmap."
;; (interactive)
;; (save-buffer)
;; (setq org-mind-map-dot-output '("pdf"))
;; (org-mind-map-write)
;; (setq org-mind-map-dot-output '("pdf" "png" "jpeg" "svg" "eps" "gif" "tiff"))
;; )
;; (key-chord-define-global "zp" 'save-and-export-mindmap)
(require 'lsp-mode)
(setenv "PATH" (concat (getenv "PATH") ":/usr/lib/dart/bin/"))
(setq exec-path (append exec-path '("/usr/lib/dart/bin/")))
(setq lsp-print-io t)
;; M-x shell will pick up .bashrc
(setq shell-command-switch "-ic")
(eval-after-load "term"
'(define-key term-raw-map (kbd "C-c C-y") 'term-paste))
(require 'flymake-python-pyflakes)
(add-hook 'python-mode-hook 'flymake-python-pyflakes-load)
(add-hook 'python-mode-hook 'flymake-mode)
(setq flymake-python-pyflakes-executable "flake8")
(setq exec-path (append exec-path '("/home/kiru/opt/anaconda3/bin/")))
(require 'py-isort)
(add-hook 'before-save-hook 'py-isort-before-save)
(message "***** .emacs loaded *****")
;; --- notes ---
;; use C-x C-f C-c / : to search file by pattern
(global-set-key (kbd "C-c o f") 'helm-open-github-from-file)
(global-set-key (kbd "C-c o c") 'helm-open-github-from-commit)
(global-set-key (kbd "C-c o i") 'helm-open-github-from-issues)
(global-set-key (kbd "C-c o p") 'helm-open-github-from-pull-requests)
;; -------------------------------------------------------------------