Skip to content

Instantly share code, notes, and snippets.

@rnagasam
Created November 6, 2018 02:29
Show Gist options
  • Save rnagasam/bbd2a9b4d3622121f5e486da73315f69 to your computer and use it in GitHub Desktop.
Save rnagasam/bbd2a9b4d3622121f5e486da73315f69 to your computer and use it in GitHub Desktop.
New init
;; (require 'org)
;; (org-babel-load-file
;; (expand-file-name "cfg.org"
;; user-emacs-directory))
;; --------------------------------------------------------------------
(setq user-full-name "Ramana Nagasamudram"
user-mail-address "rnagasam@stevens.edu")
(require 'package)
(add-to-list 'package-archives
'("melpa" . "http://melpa.milkbox.net/packages/") t)
(package-initialize)
(setq custom-file "~/.emacs.d/custom.el")
(load custom-file)
(add-to-list 'load-path "~/.emacs.d/lisp/")
(when (and (fboundp 'server-running-p)
(not (server-running-p)))
(server-start))
(defalias 'yes-or-no-p 'y-or-n-p)
(setq inhibit-startup-screen t
inhibit-splash-screen t
visual-bell 1
ring-bell-function 'ignore)
(setq column-number-mode 1
size-indication-mode 1)
(setq delete-by-moving-to-trash t)
(toggle-scroll-bar -1)
(tool-bar-mode -1)
(show-paren-mode 1)
(global-subword-mode 1)
(setq language-environment "UTF-8")
(put 'narrow-to-region 'disabled nil)
(put 'narrowprg-to-page 'disabled nil)
(put 'narrow-to-defun 'disabled nil)
(put 'upcase-region 'disabled nil)
(put 'dired-find-alternate-file 'disabled nil)
(cd (getenv "HOME"))
(setq-default buffer-file-coding-systems 'utf-8-unix)
(setq-default default-buffer-file-coding-system 'utf-8-unix)
(set-default-coding-systems 'utf-8-unix)
(prefer-coding-system 'utf-8-unix)
(when (boundp 'w32-pipe-read-delay)
(setq w32-pipe-read-delay 0))
(define-key global-map (kbd "C-c M-o") 'comint-clear-buffer)
(setq reb-re-syntax 'string)
(add-hook 'text-mode-hook 'turn-on-auto-fill)
(setq ispell-program-name "hunspell")
(setq ispell-local-dictionary "en_US")
(setq ispell-local-dictionary-alias
'(("en_US" "[[:alpha:]]" "[^[:alpha:]]" "[']"
nil ("-d" "en_US") nil utf-8)))
(setq ispell-personal-dictionary "C:/Users/rnaga/.ispell")
(require 'ispell)
(define-key global-map (kbd "C--") 'other-window)
(winner-mode 1)
(define-key global-map (kbd "C-c ,") 'winner-undo)
(define-key global-map (kbd "C-c .") 'winner-redo)
(windmove-default-keybindings) ; Shift-<arrow> to move between windows
(require 'ido)
(setq ido-enable-flex-matching t
ido-use-virtual-buffers nil
ido-everywhere t
ido-use-filename-at-point 'guess
ido-use-url-at-point t
ido-enable-tramp-completion t
ido-case-fold t)
(ido-mode 1)
(require 'smex)
(setq smex-save-file (expand-file-name ".smex-items" user-emacs-directory))
(smex-initialize)
(defadvice smex (around space-inserts-hyphen activate compile)
(let ((ido-cannot-complete-command
`(lambda ()
(interactive)
(if (string= " " (this-command-keys))
(insert ?-)
(funcall ,ido-cannot-complete-command)))))
ad-do-it))
(define-key global-map (kbd "M-x") 'smex)
(define-key global-map (kbd "M-X") 'smex-major-mode-commands)
(define-key global-map (kbd "C-c C-c M-x") 'execute-extended-command)
(require 'company)
(setq company-global-modes '(not shell-mode))
(add-to-list 'company-backends 'company-c-headers)
(global-company-mode 1)
(company-quickhelp-mode)
(define-key global-map (kbd "C-x g") 'magit-status)
(define-key global-map (kbd "C-x M-g") 'magit-dispatch-popup)
(setq magit-git-executable "git") ; helps for remote machines
; -------------------- CYGWIN --------------------
;; Sets your shell to use cygwin's bash, if Emacs finds it's running
;; under Windows and c:\cygwin exists. Assumes that C:\cygwin\bin is
;; not already in your Windows Path (it generally should not be).
;; https://www.emacswiki.org/emacs/NTEmacsWithCygwin
;; (require 'cygwin-mount)
;; (cygwin-mount-activate)
;; (require 'fakecygpty)
;; (fakecygpty-activate)
;; (require 'setup-cygwin)
;; (let* ((cygwin-root "c:/cygwin64")
;; (cygwin-bin (concat cygwin-root "/bin")))
;; (when (and (eq 'windows-nt system-type)
;; (file-readable-p cygwin-root))
;; (setq exec-path (cons cygwin-bin exec-path))
;; (setenv "PATH" (concat cygwin-bin ";" (getenv "PATH")))
;; ;; By default use Windows HOME.
;; ;; Otherwise set it manually using `setenv`
;; ;; (setenv "HOME" "/cygdrive/c/Users/rnaga")
;; ;; (setq shell-file-name "bash")
;; ;; (setq shell-command-switch "-c")
;; ;; (setenv "SHELL" shell-file-name)
;; ;; (setq explicit-shell-file-name shell-file-name)
;; ;; (setq ediff-shell shell-file-name)
;; ;; This removes unsightly ^M characters that would otherwise
;; ;; appear in the output of java applications
;; (add-hook 'comint-output-filter-functions 'comint-strip-ctrl-m)))
;; Switch between bash and dos shell
;; (defun set-shell-bash ()
;; "Set `M-x shell` to use Cygwin bash"
;; (interactive)
;; (setq shell-file-name "bash")
;; (setq shell-command-switch "-c")
;; (setq explicit-shell-file-name shell-file-name)
;; (setenv "SHELL" shell-file-name))
;; (defun set-shell-cmd ()
;; "Set `M-x shell` to use cmdproxy"
;; (interactive)
;; (setq shell-file-name "cmdproxy")
;; (setq explicity-shell-file-name shell-file-name)
;; (setenv "SHELL" shell-file-name))
;; (set-shell-bash)
; -------------------- CYGWIN --------------------
(require 'paredit)
(autoload 'enabled-paredit-mode "paredit"
"Psuedo-structural editing of Lisp code." t)
(add-hook 'emacs-lisp-mode-hook #'enable-paredit-mode)
(add-hook 'eval-expression-minibuffer-setup-hook #'enable-paredit-mode)
(add-hook 'ielm-mode-hook #'enable-paredit-mode)
(add-hook 'lisp-mode-hook #'enable-paredit-mode)
(add-hook 'lisp-interaction-mode-hook #'enable-paredit-mode)
(add-hook 'scheme-mode-hook #'enable-paredit-mode)
(define-key paredit-mode-map (kbd "C-*") 'paredit-forward-slurp-sexp)
(require 'autopair)
(autopair-global-mode)
(add-hook 'comint-mode-hook #'(lambda () (autopair-mode -1)))
(require 'geiser)
(setq geiser-active-implementations '(chez))
(add-hook 'geiser-repl-mode-hook #'(lambda () (autopair-mode -1)))
(require 'slime)
(setq slime-lisp-implementations
'((sbcl ("c:/Program Files/Steel Bank Common Lisp/1.4.2/sbcl.exe"
"--core"
"c:/Program Files/Steel Bank Common Lisp/1.4.2/sbcl.core"))))
(slime-setup)
(setq slime-contribs '(slime-fancy slime-company))
(add-hook 'slime-repl-mode-hook #'(lambda () (autopair-mode -1)))
(require 'cider)
(add-hook 'cider-repl-mode-hook #'(lambda () (autopair-mode -1)))
(require 'sml-mode)
(require 'python)
(define-key python-mode-map [remap backward-sentence] nil)
(define-key python-mode-map [remap-forward-sentence] nil)
(add-hook 'python-mode-hook #'(lambda () (highlight-indentation-mode -1)))
(require 'elpy)
(elpy-enable)
(setq elpy-rpc-python-command "C:/Python27/python.exe")
(setq c-default-style "linux")
(add-hook 'c-mode-hook 'c-turn-on-eldoc-mode)
(add-hook 'java-mode-hook
#'(lambda ()
(setq c-basic-offset 2
tab-width 2
indent-tabs-mode t)))
(setq TeX-auto-save t)
(setq TeX-parse-self t)
(setq TeX-auto-untabify t)
(setq-default TeX-master nil)
(add-hook 'LaTeX-mode-hook 'LaTeX-math-mode)
(require 'emmet-mode)
(add-hook 'sgml-mode-hook 'emmet-mode)
(add-hook 'html-mode-hook 'emmet-mode)
(add-hook 'css-mode-hook 'emmet-mode)
(setq emmet-move-cursor-between-quotes t)
(setq proof-auto-raise-buffers t
proof-three-window-enable t
proof-output-tooltips t
proof-script-fly-past-comments t
proof-follow-mode 'followdown)
(setq company-coq-disabled-features '(prettify-symbols))
(add-hook 'coq-mode-hook #'company-coq-mode)
;; Org
(require 'org)
(require 'org-agenda)
(setq org-log-done 'time
org-export-mark-todo-in-toc t
org-enforce-todo-dependencies t
org-enforce-todo-checkbox-dependencies t)
(setq org-agenda-files '("~/org/tasks.org")
org-agenda-window-setup 'current-window)
(setq org-capture-templates
'(("t" "Todo" entry (file "~/org/tasks.org")
"* TODO %?\n %i\n %a" :empty-lines 1)))
(define-key global-map (kbd "C-c l") 'org-store-link)
(define-key global-map (kbd "C-c a") 'org-agenda)
(define-key org-mode-map (kbd "C-c .") nil)
(define-key org-mode-map (kbd "C-c ,") nil)
(define-key org-agenda-mode-map (kbd "C-c ,") nil)
(define-key global-map (kbd "C-c c") 'org-capture)
(add-hook 'org-mode-hook 'turn-on-auto-fill)
(require 'ob)
(org-babel-do-load-languages
'org-babel-load-languages
'((python . t)
(emacs-lisp . t)
(scheme . t)
(dot . t)
(ditaa . t)
(java . t)
(calc . t)
(plantuml . t)
(shell . t)
(octave . t)
(makefile . t)))
(setq org-confirm-babel-evaluate nil
org-src-fontify-natively t
org-src-tab-acts-natively t
org-src-preserve-indentation t
org-src-window-setup 'current-window
org-plantuml-jar-path "~/src/plantuml/plantuml.jar")
(require 'tramp)
(setq tramp-debug-buffer t)
(setq tramp-verbose 10)
(add-to-list 'tramp-remote-path 'tramp-own-remote-path)
(connection-local-set-profile-variables
'remote-bash
'((explicit-shell-file-name . "/usr/pkg/bin/bash")
(explicit-bash-args . ("-i"))
(shell-command-switch . "-ic")))
(connection-local-set-profiles
'(:application tramp :protocol "plink" :machine "Dev" :user "rmn")
'remote-bash)
(defun eval-and-comment ()
"Evaluate the preceding S-expression and insert
the result as a comment."
(interactive)
(save-excursion
(let ((value (eval (elisp--preceding-sexp))))
(insert (format " ; => %S" value)))))
(define-key lisp-interaction-mode-map (kbd "C-c C-x C-e") 'eval-and-comment)
;; Byte compile all your dotfiles
;; http://emacsredux.com/blog/2013/06/25/boost-performance-by-leveraging-byte-compilation/
(defun byte-compile-init-dir ()
"Byte compile all your dotfiles"
(interactive)
(byte-recompile-directory user-emacs-directory 0))
(defun remove-elc-on-save ()
"If you are saving an elisp file, the file may no longer be valid"
(add-hook 'after-save-hook
#'(lambda ()
(let ((comp-file (concat buffer-file-name "c")))
(if (file-exists-p comp-file)
(delete-file comp-file))))
nil
t))
(add-hook 'emacs-lisp-mode-hook 'remove-elc-on-save)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment