summaryrefslogtreecommitdiffstats
path: root/lisp/ravi-init-appearance.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/ravi-init-appearance.el')
-rw-r--r--lisp/ravi-init-appearance.el428
1 files changed, 428 insertions, 0 deletions
diff --git a/lisp/ravi-init-appearance.el b/lisp/ravi-init-appearance.el
new file mode 100644
index 0000000..fe81dcb
--- /dev/null
+++ b/lisp/ravi-init-appearance.el
@@ -0,0 +1,428 @@
+;;; ravi-init-appearance.el --- Emacs appearance
+
+;; Copyright (C) 2013
+
+;; Author: <ravi@nero.lan>
+;; Keywords:
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; Customization of emacs appearance
+
+;;; Code:
+
+;; No splash screen please
+(setq inhibit-startup-message t)
+
+;; Allow pasting selection outside of Emacs
+(setq x-select-enable-clipboard t)
+
+;; Show keystrokes in progress
+(setq echo-keystrokes 0.1)
+
+;; Real emacs knights don't use shift to mark things
+(setq shift-select-mode nil)
+
+;; Enable syntax highlighting for older Emacsen that have it off
+(global-font-lock-mode t)
+(setq font-lock-maximum-decoration t)
+
+;; Sounds.
+;; Turn off sound.
+(setq bell-volume 0)
+(setq sound-alist nil)
+
+(add-to-list 'default-frame-alist '(cursor-color . "#ffb90f") t)
+
+;; Answering just 'y' or 'n' will do
+(defalias 'yes-or-no-p 'y-or-n-p)
+
+;; Customization of modeline.
+(line-number-mode 1)
+(column-number-mode 1)
+(display-time)
+
+;; Change the way the buffer name is displayed in the modeline.
+(setq-default mode-line-buffer-identification '("%17b"))
+
+;; Undo/redo window configuration with C-c <left>/<right>
+(winner-mode 1)
+
+;; Never insert tabs
+(set-default 'indent-tabs-mode nil)
+
+;; Show me empty lines after buffer end (replaced, see below)
+;(set-default 'indicate-empty-lines t)
+
+(use-package whitespace
+ :init
+ (setq whitespace-style '(face trailing indentation tabs))
+ :config
+ (progn
+ (global-whitespace-mode 1))
+ ; No need for 'ensure: t' since whitespace mode is built in
+ :diminish global-whitespace-mode
+ )
+
+(use-package ws-butler
+ :config
+ (progn
+ (ws-butler-global-mode 1))
+ :diminish ws-butler-mode
+ :ensure t)
+
+(diminish 'abbrev-mode)
+
+;; Handling end of files.
+(setq require-final-newline t)
+;; Prevent addition of lines at end of file when down arrow is pressed.
+(setq next-line-add-newlines nil)
+
+;; Kill the entire line, please
+(setq kill-whole-line t)
+
+;; Delete hungrily
+(use-package hungry-delete
+ :commands (hungry-delete-forward hungry-delete-backward)
+ :bind (("C-d" . hungry-delete-forward))
+ :init
+ (progn
+ (defun jschaf/hungry-delete-backward (n &optional killflag)
+ "Delete non-vertical whitespace backwards on first key press.
+Delete all whitespace on a successive key press."
+ (interactive "p\nP")
+ (if (eq last-command 'jschaf/hungry-delete-backward)
+ (hungry-delete-backward n killflag)
+ (let ((hungry-delete-chars-to-skip " \t\f\v"))
+ (hungry-delete-backward n killflag))))
+ ;;(define-key global-map [remap backward-delete-char-untabify] 'jschaf/hungry-delete-backward)
+ (define-key global-map [remap backward-delete-char-untabify] 'hungry-delete-backward)
+ )
+ :ensure t)
+
+;; Easier compaction of whitespace
+(use-package shrink-whitespace
+ :bind (("M-SPC" . shrink-whitespace))
+ :ensure t)
+
+(setq sentence-end-double-space nil)
+(use-package unfill
+ :bind (("M-q" . toggle-fill-unfill))
+ :ensure t)
+
+(use-package subword
+ :config
+ (global-superword-mode 1)
+ :diminish superword-mode)
+
+;; Make word-navigation more palatable
+(use-package syntax-subword
+ :init
+ (progn
+ (setq syntax-subword-skip-spaces t))
+ :config
+ (progn
+ (defun ravi/turn-on-syntax-subword-mode ()
+ (interactive)
+ (syntax-subword-mode 1))
+ (add-hook 'prog-mode-hook 'ravi/turn-on-syntax-subword-mode))
+ :ensure t)
+
+(use-package rectangle-utils
+ :bind (("C-x R" . rectangle-menu))
+ :ensure t)
+
+;; Keep cursor away from edges when scrolling up/down
+(use-package smooth-scrolling
+ :ensure t)
+
+;; Enable automatic indentation, if possible
+(use-package smart-newline
+ :commands (smart-newline)
+ :init
+ (progn
+ (bind-key "<return>" 'smart-newline prog-mode-map)
+ (bind-key "<return>" 'smart-newline emacs-lisp-mode-map))
+ :ensure t)
+
+;; Case toggling: from Oleg Krehel http://oremacs.com/2014/12/25/ode-to-toggle/
+(defun oremacs/char-upcasep (letter)
+ (eq letter (upcase letter)))
+
+(defun oremacs/capitalize-word-toggle ()
+ (interactive)
+ (let ((start
+ (car
+ (save-excursion
+ (backward-word)
+ (bounds-of-thing-at-point 'symbol)))))
+ (if start
+ (save-excursion
+ (goto-char start)
+ (funcall
+ (if (oremacs/char-upcasep (char-after))
+ 'downcase-region
+ 'upcase-region)
+ start (1+ start)))
+ (capitalize-word -1))))
+;; (bind-key "M-c" 'oremacs/capitalize-word-toggle)
+
+(defun oremacs/upcase-word-toggle ()
+ (interactive)
+ (let ((bounds (bounds-of-thing-at-point 'symbol))
+ beg end
+ (regionp
+ (if (eq this-command last-command)
+ (get this-command 'regionp)
+ (put this-command 'regionp nil))))
+ (cond
+ ((or (region-active-p) regionp)
+ (setq beg (region-beginning)
+ end (region-end))
+ (put this-command 'regionp t))
+ (bounds
+ (setq beg (car bounds)
+ end (cdr bounds)))
+ (t
+ (setq beg (point)
+ end (1+ beg))))
+ (save-excursion
+ (goto-char (1- beg))
+ (and (re-search-forward "[A-Za-z]" end t)
+ (funcall (if (oremacs/char-upcasep (char-before))
+ 'downcase-region
+ 'upcase-region)
+ beg end)))))
+;; (bind-key "M-l" 'oremacs/upcase-word-toggle)
+
+(use-package fix-word
+ :bind (("M-u" . fix-word-upcase)
+ ("M-l" . fix-word-downcase)
+ ("M-c" . fix-word-capitalize))
+ :ensure t)
+
+;; Zap up to char is more useful than zap-char
+(use-package zop-to-char
+ :bind (("M-z" . zop-up-to-char)
+ ("M-Z" . zop-to-char))
+ :ensure t)
+
+;; Automatic indentation of yanked text
+(dolist (command '(yank yank-pop))
+ (eval `(defadvice ,command (after indent-region activate)
+ (and (not current-prefix-arg)
+ (member major-mode '(emacs-lisp-mode lisp-mode
+ clojure-mode scheme-mode
+ haskell-mode ruby-mode
+ rspec-mode python-mode
+ c-mode c++-mode
+ objc-mode latex-mode
+ plain-tex-mode))
+ (let ((mark-even-if-inactive transient-mark-mode))
+ (indent-region (region-beginning) (region-end) nil))))))
+
+(defun ravi/erase-from-point (&optional prefix)
+ "Erase part of buffer after point (or before point with a prefix)"
+ (interactive "P")
+ (if (consp prefix)
+ (delete-region (point-min) (point))
+ (delete-region (point) (point-max))))
+
+(use-package comment-dwim-2
+ :bind (("M-;" . comment-dwim-2))
+ :ensure t)
+
+;; To do: change to different keybinding
+(use-package string-inflection
+ :bind (("C-c c" . hydra-string-inflection/body))
+ :config
+ (progn
+ (defhydra hydra-string-inflection ()
+ ("c" string-inflection-all-cycle "all")
+ ("r" string-inflection-ruby-style-cycle "ruby")
+ ("j" string-inflection-java-style-cycle "java")
+ ("<return>" nil)))
+ :ensure t)
+
+;; Keep my navigation simple
+(setq line-move-visual nil)
+
+;; Represent undo-history as an actual tree (visualize with C-x u)
+(use-package undo-tree
+ :init
+ (setq undo-tree-mode-lighter "")
+ :config
+ (progn
+ (global-undo-tree-mode)
+ (setq undo-tree-auto-save-history t)
+ (setq undo-tree-history-directory-alist
+ `(("." . ,(expand-file-name "undotree/" (ravi/emacs-file "past")))))
+ )
+ :ensure t
+ )
+
+;; Discover emacs
+;; Since discover.el replaces keymaps wholesale for "C-x r" and "M-s", it overrides
+;; our additions to them. So we use guide-key for "C-x r" and "M-s".
+(use-package discover
+ :config
+ (progn
+ (add-hook 'dired-mode-hook 'discover-turn-on-in-dired)
+ )
+ :disabled t ;; unstable API and hosing user-provided keybindings
+ :ensure t
+ )
+
+;; Help for prefix key-bindings not in discover-mode
+(use-package guide-key
+ :config
+ (progn
+ (setq guide-key/guide-key-sequence '("C-c p" ;; projectile
+ "C-c d" ;; doxymacs
+ "C-x 4" ;; other-window
+ "C-x r" ;; rectangles/registers
+ "M-s" ;; isearch
+ "C-x v" ;; version control
+ "M-g" ;; movement
+ "C-x 5" ;; frames
+ "C-x n" ;; narrowing
+ ))
+ (when (and (boundp ravi/use-helm-instead-of-ido) ravi/use-helm-instead-of-ido)
+ (add-to-list 'guide-key/guide-key-sequence "<escape>")
+ (add-to-list 'guide-key/guide-key-sequence "<escape> C-c")
+ (add-to-list 'guide-key/guide-key-sequence "<escape> C-x")
+ (add-to-list 'guide-key/guide-key-sequence "<escape> C-x r")
+ (add-to-list 'guide-key/guide-key-sequence "<escape> ESC"))
+
+ (guide-key-mode 1)
+
+ (use-package guide-key-tip
+ :config
+ (progn
+ (setq guide-key-tip/enabled t))
+ :ensure t
+ :disabled t ;; popups don't always go away; need to file a bug report
+ )
+ )
+ :diminish guide-key-mode
+ :disabled t
+ :ensure t
+ )
+
+(use-package which-key
+ :config
+ (progn
+ (which-key-mode))
+ :diminish which-key-mode
+ :ensure t)
+
+(bind-key "C-h a" 'apropos)
+
+(use-package popwin
+ :config
+ (progn
+ (popwin-mode 1)
+ (push '("*Pp Eval Output*" :height 15) popwin:special-display-config))
+ :ensure t)
+
+(use-package temp-buffer-browse
+ :config
+ (progn
+ (temp-buffer-browse-mode 1))
+ :diminish temp-buffer-browse-mode
+ :disabled t ; emacs historical issues make this unworkable
+ :ensure t)
+
+(use-package import-popwin
+ :bind (("M-I" . import-popwin))
+ :ensure t)
+
+(use-package ace-window
+ :bind (("M-o" . ace-window)
+ ("M-O" . ravi/dispatched-ace-window))
+ :config
+ (progn
+ (set-face-attribute 'aw-leading-char-face nil :foreground "deep sky blue" :weight 'bold :height 3.0)
+ (set-face-attribute 'aw-mode-line-face nil :inherit 'mode-line-buffer-id :foreground "lawn green")
+ (setq aw-keys '(?d ?f ?g ?h ?j ?k ?l ?i ?e)
+ ;; aw-dispatch-always t
+ aw-dispatch-alist
+ '((?x aw-delete-window "Ace - Delete Window")
+ (?c aw-swap-window "Ace - Swap Window")
+ (?n aw-flip-window)
+ (?v aw-split-window-vert "Ace - Split Vert Window")
+ (?h aw-split-window-horz "Ace - Split Horz Window")
+ (?m delete-other-windows "Ace - Maximize Window")
+ (?g delete-other-windows)
+ (?b balance-windows)
+ (?u winner-undo)
+ (?r winner-redo)))
+
+ (defun ravi/dispatched-ace-window (arg)
+ "Select window with dispatch always present"
+ (interactive "p")
+ (let ((aw-dispatch-always t))
+ (ace-window arg)))
+
+ (defun ravi/hide-tool-tip (&rest args)
+ (when (display-graphic-p)
+ (x-hide-tip)))
+ (advice-add 'ace-window :before 'ravi/hide-tool-tip)
+
+ (when (package-installed-p 'hydra)
+ (defhydra hydra-window-size (:color red)
+ "Windows size"
+ ("h" shrink-window-horizontally "shrink horizontal")
+ ("j" shrink-window "shrink vertical")
+ ("k" enlarge-window "enlarge vertical")
+ ("l" enlarge-window-horizontally "enlarge horizontal"))
+ (defhydra hydra-window-frame (:color red)
+ "Frame"
+ ("f" make-frame "new frame")
+ ("x" delete-frame "delete frame"))
+ (defhydra hydra-window-scroll (:color red)
+ "Scroll other window"
+ ("n" joe-scroll-other-window "scroll")
+ ("p" joe-scroll-other-window-down "scroll down"))
+ (add-to-list 'aw-dispatch-alist '(?w hydra-window-size/body) t)
+ (add-to-list 'aw-dispatch-alist '(?o hydra-window-scroll/body) t)
+ (add-to-list 'aw-dispatch-alist '(?\; hydra-window-frame/body) t)))
+ :ensure t)
+
+(defun ravi/split-window-vertically-and-switch (prefix)
+ (interactive "P")
+ (split-window-vertically (if (consp prefix) nil prefix))
+ (other-window 1)
+ (unless (consp prefix) (switch-to-next-buffer)))
+(bind-key "C-x 2" 'ravi/split-window-vertically-and-switch)
+
+(defun ravi/split-window-horizontally-and-switch (prefix)
+ (interactive "P")
+ (split-window-horizontally (if (consp prefix) nil prefix))
+ (other-window 1)
+ (unless (consp prefix) (switch-to-next-buffer)))
+(bind-key "C-x 3" 'ravi/split-window-horizontally-and-switch)
+
+(use-package pdf-tools
+ ;; Install this locally; no update from MELPA needed.
+ ;; :mode (("\\.pdf\\'" . pdf-view-mode)) ;; errors first use; to do.
+ :config
+ (progn
+ (setq-default pdf-view-display-size 'fit-page)
+ (pdf-tools-install)))
+
+(provide 'ravi-init-appearance)
+;;; ravi-init-appearance.el ends here