summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitmodules6
-rw-r--r--Readme.org8
-rw-r--r--init.el44
-rw-r--r--lisp/ravi-ergodox-mode.el (renamed from ravi-ergodox-mode.el)9
-rw-r--r--lisp/ravi-init-appearance.el428
-rw-r--r--lisp/ravi-init-cpp.el (renamed from ravi-init-cpp.el)69
-rw-r--r--lisp/ravi-init-dired.el (renamed from ravi-init-dired.el)13
-rw-r--r--lisp/ravi-init-files.el (renamed from ravi-init-files.el)30
-rw-r--r--lisp/ravi-init-function.el144
-rw-r--r--lisp/ravi-init-helm.el118
-rw-r--r--lisp/ravi-init-ido.el (renamed from ravi-init-ido.el)35
-rw-r--r--lisp/ravi-init-insertion.el155
-rw-r--r--lisp/ravi-init-layouts.el (renamed from ravi-init-layouts.el)0
-rw-r--r--lisp/ravi-init-maps.el58
-rw-r--r--lisp/ravi-init-marks.el (renamed from ravi-init-marks.el)3
-rw-r--r--lisp/ravi-init-mu.el218
-rw-r--r--lisp/ravi-init-navigation.el (renamed from ravi-init-navigation.el)154
-rw-r--r--lisp/ravi-init-org.el (renamed from ravi-init-org.el)17
-rw-r--r--lisp/ravi-init-python.el (renamed from ravi-init-python.el)95
-rw-r--r--lisp/ravi-init-repl.el (renamed from ravi-init-repl.el)15
-rw-r--r--lisp/ravi-init-tex.el (renamed from ravi-init-tex.el)52
-rw-r--r--lisp/ravi-init-vc.el104
-rw-r--r--lisp/ravi-init-web.el112
-rw-r--r--ravi-init-appearance.el187
-rw-r--r--ravi-init-function.el40
-rw-r--r--ravi-init-insertion.el95
-rw-r--r--ravi-init-vc.el176
m---------site-lisp/mu0
m---------site-lisp/org-reveal0
m---------site-lisp/pdf-tools0
-rw-r--r--site-lisp/whole-line-or-region.el644
31 files changed, 1739 insertions, 1290 deletions
diff --git a/.gitmodules b/.gitmodules
index 1afac73..f5c5373 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -16,12 +16,12 @@
[submodule "site-lisp/sexpdata"]
path = site-lisp/sexpdata
url = https://github.com/tkf/sexpdata.git
-[submodule "site-lisp/org-reveal"]
- path = site-lisp/org-reveal
- url = https://github.com/yjwen/org-reveal.git
[submodule "site-lisp/keyadvice"]
path = site-lisp/keyadvice
url = https://github.com/Fuco1/keyadvice.el.git
[submodule "site-lisp/rtags"]
path = site-lisp/rtags
url = https://github.com/Andersbakken/rtags.git
+[submodule "site-lisp/pdf-tools"]
+ path = site-lisp/pdf-tools
+ url = https://github.com/politza/pdf-tools.git
diff --git a/Readme.org b/Readme.org
index 7d30996..c5f3671 100644
--- a/Readme.org
+++ b/Readme.org
@@ -43,3 +43,11 @@ make
popd
#+END_SRC
May need to install glib2-devel, gmime-devel, xapian-core-devel, libuuid-devel on Fedora.
+
+pdf-tools:
+#+BEGIN_SRC sh
+pushd site-lisp/pdftools
+make -s
+make install-package
+#+END_SRC
+May need to install poppler-devel, poppler-glib-devel on Fedora.
diff --git a/init.el b/init.el
index 8f420c2..f38699a 100644
--- a/init.el
+++ b/init.el
@@ -10,6 +10,10 @@
(when window-system
(tooltip-mode -1)
(tool-bar-mode -1))
+;; Open in full-screen of possible
+(when (fboundp 'toggle-frame-maximized)
+ (setq frame-resize-pixelwise t)
+ (toggle-frame-maximized))
(menu-bar-mode -1)
(setq warning-suppress-types nil)
(set-face-background 'default "black")
@@ -21,6 +25,9 @@
(find-if (lambda (f) (find-font (font-spec :name f))) fonts))
(let ((fontval (font-candidate '"Inconsolata" "Source Code Pro" "Anonymous Pro")))
(when fontval (set-face-attribute 'default nil :font fontval)))
+(when (find-font (font-spec :name "Symbola"))
+ (set-fontset-font "fontset-default" nil
+ (font-spec :size 20 :name "Symbola")))
(setq custom-file (concat ravi/init-dir "custom.el"))
;; Initialize package handling: currently using only the official repository and MELPA
@@ -29,8 +36,8 @@
;("original" . "http://tromey.com/elpa/")
("org" . "http://orgmode.org/elpa/")
;("marmalade" . "http://marmalade-repo.org/packages/")
- ("melpa" . "http://melpa.milkbox.net/packages/")))
-(add-to-list 'load-path ravi/init-dir)
+ ("melpa" . "http://melpa.org/packages/")))
+(add-to-list 'load-path (ravi/emacs-file "lisp/"))
(add-to-list 'load-path (ravi/emacs-file "site-lisp/"))
(setq autoload-file (concat ravi/init-dir "loaddefs.el"))
(setq package-user-dir (concat ravi/init-dir "elpa"))
@@ -78,6 +85,9 @@
result))
;; ---------------------------------------------------------------------
+(defvar ravi/use-helm-instead-of-ido t
+ "Prefer helm to ido")
+
(when (file-exists-p (ravi/emacs-file "local.el"))
(load-file (ravi/emacs-file "local.el"))
)
@@ -94,22 +104,36 @@
(require 's)
(require 'ravi-ergodox-mode)
(if (s-contains? "Ergodox" (shell-command-to-string "xinput"))
- (ravi-ergodox-mode)
+ (progn
+ (ravi-ergodox-mode)
+ (diminish 'ravi-ergodox-mode))
(progn
;; Temporary key-bindings
- (bind-key "<f9>" 'ido-find-file)
- (bind-key "<f8>" 'ido-switch-buffer)
+ (if (and (boundp 'ravi/use-helm-instead-of-ido) ravi/use-helm-instead-of-ido)
+ (progn
+ (bind-key "<f9>" 'helm-find-files)
+ (bind-key "<f8>" 'helm-mini))
+ (progn
+ (bind-key "<f9>" 'ido-find-file)
+ (bind-key "<f8>" 'ido-switch-buffer)))
(bind-key "<f12>" 'undo-tree-undo)))
-(use-package keyadvice
- :load-path ,(ravi/emacs-file "site-lisp/keyadvice")
- )
-
(use-package free-keys
:ensure t
:commands free-keys)
+(defun ravi/add-variables-from-dir-locals (varname hack-varname &optional make-it-local)
+ "Add variable from dir-locals.el to an existing variable as a buffer-local variable"
+ (let ((basic-var (symbol-value varname)))
+ (when (and (boundp hack-varname)
+ (listp (symbol-value hack-varname)))
+ (when make-it-local
+ (make-local-variable varname))
+ (set varname (append basic-var (symbol-value hack-varname))))))
+
+(require 'ravi-init-maps)
(require 'ravi-init-ido)
+(require 'ravi-init-helm)
(require 'ravi-init-marks)
(require 'ravi-init-appearance)
(require 'ravi-init-files)
@@ -124,3 +148,5 @@
(require 'ravi-init-tex)
(require 'ravi-init-repl)
(require 'ravi-init-dired)
+(require 'ravi-init-mu)
+(require 'ravi-init-web)
diff --git a/ravi-ergodox-mode.el b/lisp/ravi-ergodox-mode.el
index 78221ab..a4867be 100644
--- a/ravi-ergodox-mode.el
+++ b/lisp/ravi-ergodox-mode.el
@@ -58,8 +58,13 @@ Each function in the list receive no argument."
(define-key ravi-ergodox-mode-map (kbd "H-m") 'magit-status)
(define-key ravi-ergodox-mode-map (kbd "<f6>") 'ff-find-other-file)
-(define-key ravi-ergodox-mode-map (kbd "<f1>") 'ido-switch-buffer)
-(define-key ravi-ergodox-mode-map (kbd "<f2>") 'ido-find-file)
+(if (and (boundp 'ravi/use-helm-instead-of-ido) ravi/use-helm-instead-of-ido)
+ (progn
+ (define-key ravi-ergodox-mode-map (kbd "<f1>") 'helm-multi-files)
+ (define-key ravi-ergodox-mode-map (kbd "<f2>") 'helm-find-files))
+ (progn
+ (define-key ravi-ergodox-mode-map (kbd "<f1>") 'ido-switch-buffer)
+ (define-key ravi-ergodox-mode-map (kbd "<f2>") 'ido-find-file)))
(defun ravi-ergodox-mode-enable ()
"Turn on ergodox bindings mode."
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
diff --git a/ravi-init-cpp.el b/lisp/ravi-init-cpp.el
index 90ad349..ffa9790 100644
--- a/ravi-init-cpp.el
+++ b/lisp/ravi-init-cpp.el
@@ -77,11 +77,11 @@
(setq-default compilation-directory dirbak))))
((or (and arg (<= (car arg) 4))
(equal compile-command ""))
- (setq-default compile-command (read-from-minibuffer
+ (setq-default compile-command (read-shell-command
"Compile command: "
(if (equal compile-command "")
"make " compile-command)
- nil nil 'compile-history))
+ 'compile-history))
(setq-default compilation-directory default-directory)
(when (not (equal (default-value 'compile-command) ""))
(compile (default-value 'compile-command))))
@@ -89,17 +89,34 @@
(recompile))))
+(use-package dummy-h-mode
+ :mode (("\\.h\\'" . dummy-h-mode))
+ :config
+ (progn
+ ;; Hack to avoid ObjC files since we do not use it
+ (defun ravi/do-not-allow-objc (mode-val)
+ (if (eq mode-val 'objc-mode)
+ nil
+ mode-val))
+ (mapc (lambda (x) (advice-add x :filter-return #'ravi/do-not-allow-objc))
+ '(dummy-h-mode-get-major-mode-by-source-file
+ ;dummy-h-mode-get-major-mode-by-keywords
+ dummy-h-mode-get-major-mode-by-files-directory))
+
+ (setq dummy-h-mode-default-major-mode 'c++-mode))
+ :ensure t)
+
(use-package cc-mode
- :mode (("\\.h\\(h?\\|xx\\|pp\\)\\'" . c++-mode)
+ :mode (("\\.h\\(h\\|xx\\|pp\\)\\'" . c++-mode)
("\\.ccfg\\'" . c++-mode)
("\\.m\\'" . c-mode)
("\\.mm\\'" . c++-mode))
:init
(progn
(use-package doxymacs
- :load-path ,(ravi/emacs-file "site-lisp/doxymacs/lisp")
- :init
+ :load-path (lambda () (ravi/emacs-file "site-lisp/doxymacs/lisp"))
+ :config
(progn
(doxymacs-mode)
(setq doxymacs-file-comment-template
@@ -143,6 +160,11 @@
(indent-according-to-mode)
(forward-line))
+ )
+
+ :config
+ (progn
+
(defun my-c-mode-common-hook ()
(hs-minor-mode 1)
(hs-hide-initial-comment-block)
@@ -154,19 +176,18 @@
(bind-key "C-c p" 'insert-counting-printf c-mode-base-map)
- ;(auto-complete-mode 1)
- ;(bind-key "<A-tab>" 'ac-complete c-mode-base-map)
-
(doxymacs-mode 1)
(doxymacs-font-lock)
- ;(define-key c-mode-base-map [return] 'c-context-line-break)
+ ;(define-key c-mode-base-map [return] 'c-context-line-break)
(bind-key "<return>" 'c-context-line-break c-mode-base-map)
(unbind-key "M-j" c-mode-base-map)
(bind-key "C-c C-i" 'c-includes-current-file c-mode-base-map)
(when (and (featurep 'ravi-ergodox-mode) ravi-ergodox-mode)
(bind-key "H-h" 'compile-dwim c-mode-base-map))
+ (when (functionp 'helm-dash)
+ (setq-local helm-dash-docsets '("C")))
(set (make-local-variable 'parens-require-spaces) t)
(setq fill-column 88)
@@ -185,8 +206,7 @@
(add-to-list 'c-cleanup-list 'defun-close-semi)
(add-to-list 'c-cleanup-list 'list-close-comma)
(add-to-list 'c-cleanup-list 'scope-operator)
- (add-to-list 'c-cleanup-list 'one-liner-defun)
- (add-to-list 'c-cleanup-list 'comment-close-slash)
+ ;; one-liner-defun and comment-close-slash found to be annoying
(font-lock-add-keywords 'c++-mode '(("\\<\\(assert\\|DEBUG\\)("
1 font-lock-warning-face t))))
@@ -211,8 +231,12 @@
(modify-syntax-entry ?_ "w" c++-mode-syntax-table)
(setq c-macro-cppflags "-x c++")
(setq c-macro-prompt-flag t)
+ (when (functionp 'helm-dash)
+ (setq-local helm-dash-docsets '("C" "C++" "Boost" "Qt")))
)
- (add-hook 'c++-mode-hook 'my-c++-mode-hook)
+ (defun ravi/c++-hook-adder ()
+ (add-hook 'c++-mode-hook 'my-c++-mode-hook))
+ (ravi/c++-hook-adder)
;; Stuff from kde-emacs
(defvar kde-header-protection-parts-to-show 1
@@ -268,9 +292,9 @@ this to 3 makes header-protection define KIG_MISC_NEWTYPE_H for a file named
(save-excursion
(let ((start (point-min))
+ (comment-style 'box)
(end)
)
- (setq comment-style 'box)
(goto-char start)
(insert (ravi-license-header))
(setq end (point))
@@ -292,28 +316,19 @@ this to 3 makes header-protection define KIG_MISC_NEWTYPE_H for a file named
(defun ravi-license-insert ()
(progn
(let ((start (point-min))
+ (comment-style 'box)
(end)
)
- (setq comment-style 'box)
(goto-char start)
(insert (ravi-license-header))
(insert "\n")
(setq end (point))
- (comment-region start end)
- )
- )
- )
+ (comment-region start end))))
(defun ravi-auto-insert-cpp ()
(progn
(ravi-license-insert)
- (doxymacs-insert-file-comment)
- )
- )
- )
-
- :config
- (progn
+ (doxymacs-insert-file-comment)))
(defun ravi/add-space-before-paren-c (&rest ignored)
(message "Handler invoked")
@@ -336,7 +351,9 @@ this to 3 makes header-protection define KIG_MISC_NEWTYPE_H for a file named
(unless (looking-at "(") (message "Logic error; opening paren not found"))
(when (looking-back "\\b\\(for\\|while\\|if\\|switch\\|catch\\)")
(insert-char ?\s)))
- (if (looking-at " ") (forward-char) (insert-char ?\s))
+ (if (and (looking-at " ") (not (looking-at " )")))
+ (forward-char)
+ (insert-char ?\s))
)
)
((looking-back ")[[:space:]]*")
diff --git a/ravi-init-dired.el b/lisp/ravi-init-dired.el
index 8db82f9..a82ba6c 100644
--- a/ravi-init-dired.el
+++ b/lisp/ravi-init-dired.el
@@ -90,7 +90,7 @@
Also used for highlighting.")
(use-package dired-rainbow
- :init
+ :config
(progn
(dired-rainbow-define html "#4e9a06" ("htm" "html" "xhtml"))
(dired-rainbow-define xml "DarkGreen" ("xml" "xsd" "xsl" "xslt" "wsdl"))
@@ -105,7 +105,8 @@ Also used for highlighting.")
(dired-rainbow-define executable "#8cc4ff" ("exe" "msi"))
(dired-rainbow-define compressed "#ad7fa8" ("zip" "bz2" "tgz" "txz" "gz" "xz" "z" "Z" "jar" "war" "ear" "rar" "sar" "xpi" "apk" "xz" "tar"))
(dired-rainbow-define packaged "#e6a8df" ("deb" "rpm"))
- (dired-rainbow-define encrypted "LightBlue" ("gpg" "pgp"))))
+ (dired-rainbow-define encrypted "LightBlue" ("gpg" "pgp")))
+ :ensure t)
(add-to-list 'dired-guess-shell-alist-user (list (regexp-opt my-dired-media-files-extensions)
"vlc"))
@@ -115,8 +116,10 @@ Also used for highlighting.")
)
(use-package dired-open
- :ensure t
- )
+ :config
+ (progn
+ (bind-key "E" 'dired-open-xdg dired-mode-map))
+ :ensure t)
(use-package dired-avfs
:ensure t
@@ -138,7 +141,7 @@ Also used for highlighting.")
(guide-key/add-local-guide-key-sequence ",")
(guide-key/add-local-guide-key-sequence "C-t")
)
- (add-hook 'dired-mode-hook 'ravi/dired-guide-key-hook)
+ ;; (add-hook 'dired-mode-hook 'ravi/dired-guide-key-hook)
))
diff --git a/ravi-init-files.el b/lisp/ravi-init-files.el
index 4410d3d..9ac482d 100644
--- a/ravi-init-files.el
+++ b/lisp/ravi-init-files.el
@@ -36,6 +36,7 @@
;; Also auto refresh dired, but be quiet about it
(setq global-auto-revert-non-file-buffers t)
+(setq global-auto-revert-ignore-modes '(TeX-output-mode))
(setq auto-revert-verbose nil)
;; Transparently open compressed files
@@ -57,10 +58,18 @@
(setq-default save-place t)
(setq save-place-file (ravi/emacs-file "past/places"))
-(require 'recentf)
-(setq recentf-save-file (ravi/emacs-file "past/recentf"))
-(recentf-mode 1)
-(setq recentf-max-saved-items 100) ;; just 20 is too recent
+(use-package recentf
+ :init
+ (progn
+ (setq recentf-save-file (ravi/emacs-file "past/recentf"))
+ (setq recentf-max-saved-items 100) ;; just 20 is too recent
+ )
+ :config
+ (progn
+ (add-to-list 'recentf-exclude "/COMMIT_EDITMSG$")
+ (add-to-list 'recentf-exclude "/kmail[[:alnum:]]*\\.tmp$")
+ (add-to-list 'recentf-exclude "/elpa/.*/*-autoloads.el$")
+ ))
(require 'uniquify)
(setq uniquify-buffer-name-style 'post-forward)
@@ -125,7 +134,18 @@ not exist, it is not added to the filecache."
(ravi/emacs-file "past/projectile-bookmarks.eld"))
)
:config
- (projectile-global-mode)
+ (progn
+ (projectile-global-mode)
+
+ (when (and (boundp 'ravi/use-helm-instead-of-ido) ravi/use-helm-instead-of-ido)
+
+ (setq projectile-completion-system 'helm)
+
+ (use-package helm-projectile
+ :config
+ (helm-projectile-on)
+ :ensure t)
+ ))
:diminish projectile-mode
:ensure t
)
diff --git a/lisp/ravi-init-function.el b/lisp/ravi-init-function.el
new file mode 100644
index 0000000..673031a
--- /dev/null
+++ b/lisp/ravi-init-function.el
@@ -0,0 +1,144 @@
+;;; ravi-init-function.el --- functionality
+
+;; 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:
+
+;; Enable functionality
+
+;;; Code:
+
+;; Enable emacs functionality that is disabled by default
+(setq disabled-command-function nil)
+;(setq enable-recursive-minibuffers t)
+
+;; Use emacsclient from other programs
+(require 'server)
+(unless (server-running-p) (server-start))
+
+;; Stolen from prelude
+(defadvice server-visit-files (before parse-numbers-in-lines (files proc &optional nowait) activate)
+ "Open file with emacsclient with cursors positioned on requested line.
+Most of console-based utilities prints filename in format
+'filename:linenumber'. So you may wish to open filename in that format.
+Just call:
+emacsclient filename:linenumber
+and file 'filename' will be opened and cursor set on line 'linenumber'"
+ (ad-set-arg 0
+ (mapcar (lambda (fn)
+ (let ((name (car fn)))
+ (if (string-match "^\\(.*?\\):\\([0-9]+\\)\\(?::\\([0-9]+\\)\\)?$" name)
+ (cons
+ (match-string 1 name)
+ (cons (string-to-number (match-string 2 name))
+ (string-to-number (or (match-string 3 name) ""))))
+ fn))) files)))
+
+;; Combined launcher and toggle-maps
+(defun ravi/setup-toggle-launcher-map ()
+ (bind-keys :map ctl-x-map
+ :prefix-map ravi/setup-toggle-launcher-map
+ :prefix-docstring "Launcher/toggle map"
+ :prefix "t"
+
+ ;; Toggles
+ ("c" . column-number-mode)
+ ("e" . toggle-debug-on-error)
+ ("f" . auto-fill-mode)
+ ("l" . toggle-truncate-lines)
+ ("q" . toggle-debug-on-quit)
+ ;; Generalized version of `read-only-mode'.
+ ("r" . dired-toggle-read-only)
+ ("w" . whitespace-mode)
+
+ ;; Launchers
+ ("P" . package-list-packages)
+ ("p" . proced)
+ ("d" . ediff-buffers)
+ ("F" . find-dired))
+ (autoload 'dired-toggle-read-only "dired" nil t)
+ ;; (add-to-list 'guide-key/guide-key-sequence "C-x t")
+ )
+(ravi/setup-toggle-launcher-map)
+
+;; Start something going on saving a file
+(use-package firestarter
+ :config
+ (progn
+ (firestarter-mode 1))
+ :diminish firestarter-mode
+ :ensure t)
+
+(defun ravi/find-path-name-relative-to-project-root ()
+ "Find path of current buffer file relative to project root"
+ (interactive)
+ (let* ((root-dir (and (buffer-file-name)
+ (or (and (fboundp 'magit-get-top-dir) (magit-get-top-dir))
+ (and (fboundp 'vc-root-dir) (vc-root-dir))
+ (locate-dominating-file (buffer-file-name) ".git")
+ (locate-dominating-file (buffer-file-name) dir-locals-file))))
+ (relative-name (and root-dir
+ (file-relative-name (buffer-file-name) root-dir))))
+ relative-name))
+
+(defun ravi/apply-shell-command-relative-to-project (command-template)
+ "Apply shell command relative to project
+
+COMMAND-TEMPLATE should be a string with the following substitutions allowed:
+
+%p: full path to file name
+
+%r: path relative to project root
+
+%f: file name
+
+%N: unquoted relative path name (should be used extremely carefully)
+"
+ (interactive "sEnter command template: ")
+ (let* ((path (shell-quote-argument (or (buffer-file-name) "")))
+ (rel-name (ravi/find-path-name-relative-to-project-root))
+ (rel-path (shell-quote-argument (or rel-name "")))
+ (file (shell-quote-argument (file-name-nondirectory (or path ""))))
+ (cmd (and rel-name
+ (format-spec command-template
+ (format-spec-make ?p path ?r rel-path ?f file ?N rel-name)))))
+ (if cmd
+ (shell-command cmd)
+ (if (not (buffer-file-name))
+ (message "Not in a file buffer")
+ (message "Unable to find project root")))))
+
+(defvar ravi/shell-command-relative nil
+ "Variable to set in `dir-locals-file' for use with
+`ravi/apply-shell-command-relative-to-project-auto'. See
+`ravi/apply-shell-command-relative-to-project' for more
+details.")
+
+(defun ravi/apply-shell-command-relative-to-project-auto ()
+ "Apply shell command relative to project from variable
+`ravi/shell-command-relative'. See
+`ravi/apply-shell-command-relative-to-project' for more details.
+"
+ (interactive)
+ (when (and (stringp ravi/shell-command-relative)
+ (> (length ravi/shell-command-relative) 0))
+ (ravi/apply-shell-command-relative-to-project ravi/shell-command-relative)))
+
+(provide 'ravi-init-function)
+;;; ravi-init-function.el ends here
diff --git a/lisp/ravi-init-helm.el b/lisp/ravi-init-helm.el
new file mode 100644
index 0000000..40e32af
--- /dev/null
+++ b/lisp/ravi-init-helm.el
@@ -0,0 +1,118 @@
+;;; ravi-init-helm.el --- helm initialization -*- lexical-binding: t; -*-
+
+;; Copyright (C) 2015
+
+;; Author: <ravi@nero.lan>
+;; Keywords: abbrev
+
+;; 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:
+
+;; Initialize helm instead of ido. The code in this file may steal
+;; global keybindings that are currently used for ido-mode/smex.
+
+;;; Code:
+
+(use-package helm
+ :bind (("<escape>" . helm-command-prefix)
+ ("M-x" . helm-M-x)
+ ("<f1>" . helm-multi-files)
+ ("<f2>" . helm-find-files)
+ ("M-y" . helm-show-kill-ring)
+ ("H-`" . helm-all-mark-rings))
+ :init
+ (progn
+ (require 'helm-config)
+ (setq helm-candidate-number-limit 100)
+
+ ;; From https://gist.github.com/antifuchs/9238468
+ (setq helm-idle-delay 0.0 ; update fast sources immediately (doesn't).
+ helm-input-idle-delay 0.01 ; this actually updates things
+ helm-quick-update t
+ helm-M-x-requires-pattern nil
+ helm-ff-skip-boring-files t)
+
+ (setq helm-ff-file-name-history-use-recentf t)
+
+ (helm-mode))
+ :config
+ (progn
+ (unbind-key "C-x c") ; default helm prefix key
+ (bind-key "<tab>" 'helm-execute-persistent-action helm-map)
+ (bind-key "H-<tab>" 'helm-select-action helm-map)
+
+ (use-package helm-proc
+ :commands helm-proc
+ :init
+ (progn
+ (bind-key "q" 'helm-proc helm-command-map))
+ :ensure t)
+
+ (use-package helm-git-grep
+ :commands (helm-git-grep-from-isearch helm-git-grep-from-helm)
+ :init
+ (progn
+ (bind-key "C-c g" 'helm-git-grep-from-helm helm-map)
+ (bind-key "C-c g" 'helm-git-grep-from-isearch isearch-mode-map))
+ :ensure t)
+
+ (use-package helm-ls-git
+ :bind (("C-x v j" . helm-ls-git-ls))
+ :ensure t)
+
+ (use-package helm-ag
+ :config
+ (progn
+ (setq helm-ag-insert-at-point 'symbol))
+ :ensure t)
+
+ (use-package helm-dash
+ :commands (helm-dash
+ helm-dash-at-point
+ helm-dash-install-docset
+ helm-dash-install-user-docset)
+ :init
+ (progn
+ (bind-key "d" 'helm-dash-at-point helm-command-map)
+ (bind-key "D" 'helm-dash helm-command-map))
+ :ensure t))
+ :if ravi/use-helm-instead-of-ido
+ :diminish helm-mode
+ :ensure t)
+
+(use-package helm-swoop
+ :bind (("M-i" . helm-swoop))
+ :commands helm-swoop-from-isearch
+ :init
+ (progn
+ (bind-key "M-i" 'helm-swoop-from-isearch isearch-mode-map)
+ )
+ :config
+ (progn
+ (bind-key "M-i" 'helm-multi-swoop-all-from-helm-swoop helm-swoop-map)
+
+ ;; Save buffer when helm-multi-swoop-edit complete
+ (setq helm-multi-swoop-edit-save t)
+
+ ;; If this value is t, split window inside the current window
+ ;; (setq helm-swoop-split-with-multiple-windows nil)
+
+ ;; Split direcion. 'split-window-vertically or 'split-window-horizontally
+ ;; (setq helm-swoop-split-direction 'split-window-vertically)
+ )
+ :ensure t)
+
+(provide 'ravi-init-helm)
+;;; ravi-init-helm.el ends here
diff --git a/ravi-init-ido.el b/lisp/ravi-init-ido.el
index 9d20034..0997bd4 100644
--- a/ravi-init-ido.el
+++ b/lisp/ravi-init-ido.el
@@ -32,9 +32,8 @@
(progn
(use-package ibuffer-vc
- :ensure t
:commands ibuffer-vc-set-filter-groups-by-vc-root
- )
+ :ensure t)
;; Switching to ibuffer puts the cursor on the most recent past buffer
(defadvice ibuffer (around ibuffer-point-to-most-recent-but-one activate) ()
@@ -43,6 +42,19 @@
ad-do-it
(ibuffer-jump-to-buffer recent-buffer-name)))
+ ;; Show version control status in ibuffer
+ (setq ibuffer-formats
+ '((mark modified read-only vc-status-mini " "
+ (name 18 18 :left :elide)
+ " "
+ (size 9 -1 :right)
+ " "
+ (mode 16 16 :left :elide)
+ " "
+ (vc-status 16 16 :left)
+ " "
+ filename-and-process)))
+
(defun ravi/ibuffer-vc-sort-hook ()
(ibuffer-vc-set-filter-groups-by-vc-root)
(unless (eq ibuffer-sorting-mode 'alphabetic)
@@ -51,6 +63,15 @@
)
)
+(use-package ace-jump-buffer
+ :bind (("M-<f1>" . ace-jump-buffer)
+ ("C-<f1>" . ace-jump-buffer-other-window)
+ ("S-<f1>" . ace-jump-projectile-buffers))
+ ;; :config
+ ;; (progn
+ ;; (bind-key "M-<f1>" 'ido-switch-buffer))
+ :ensure t)
+
;;;_ , ido
(use-package ido
@@ -59,19 +80,20 @@
ido-selected
ido-final-text
ido-show-confirm-message)
+ :if (not ravi/use-helm-instead-of-ido)
:init
(ido-mode 1)
:config
(progn
(use-package ido-hacks
- :init
+ :config
(ido-hacks-mode 1)
:ensure t
)
(use-package flx-ido
- :init
+ :config
(progn
(use-package flx
:ensure t)
@@ -84,13 +106,13 @@
(setq ido-create-new-buffer 'always)
(use-package ido-ubiquitous
- :init
+ :config
(ido-ubiquitous-mode t)
:ensure t
)
(use-package ido-vertical-mode
- :init
+ :config
(ido-vertical-mode 1)
:ensure t
)
@@ -146,6 +168,7 @@
(use-package smex
:init
(global-set-key [remap execute-extended-command] 'smex)
+ :if (not ravi/use-helm-instead-of-ido)
:ensure t
)
diff --git a/lisp/ravi-init-insertion.el b/lisp/ravi-init-insertion.el
new file mode 100644
index 0000000..e75c414
--- /dev/null
+++ b/lisp/ravi-init-insertion.el
@@ -0,0 +1,155 @@
+;;; ravi-init-insertion.el --- inserting text
+
+;; 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:
+
+;; Automatic text insertion
+
+;;; Code:
+
+(require 'autoinsert)
+(auto-insert-mode)
+
+(use-package yasnippet
+ :init
+ (progn
+ (setq yas-snippet-dirs
+ `(,(ravi/emacs-file "snippets")
+ yas-installed-snippets-dir)
+ )
+ )
+ :config
+ (progn
+ (yas-global-mode 1)
+
+ ;; No dropdowns
+ (setq yas/prompt-functions '(yas/ido-prompt yas/completing-prompt))
+
+ ;; Wrap around region
+ (setq yas/wrap-around-region t)
+
+ ;; Automatically create throw-away snippets
+ (use-package auto-yasnippet
+ :bind (("C-<f4>" . aya-create)
+ ("<f4>" . aya-expand))
+ :ensure t)
+ )
+ :ensure t
+ :diminish yas-minor-mode
+ )
+
+;; Default completion (some day via "M-/")
+(require 'hippie-exp)
+(setq hippie-expand-try-functions-list
+ '(yas/hippie-try-expand
+ try-expand-dabbrev
+ try-expand-dabbrev-all-buffers
+ try-expand-dabbrev-from-kill
+ try-complete-file-name-partially
+ try-complete-file-name
+ try-expand-all-abbrevs
+ )
+ )
+
+(use-package company
+ :init
+ (progn
+ (add-hook 'after-init-hook 'global-company-mode))
+ :config
+ (progn
+ (setq company-tooltip-flip-when-above t
+ company-idle-delay 0.1
+ company-show-numbers t
+ company-tooltip-align-annotations t
+ company-require-match nil
+ company-minimum-prefix-length 2
+ company-occurrence-weight-function 'company-occurrence-prefer-any-closest
+ company-dabbrev-downcase nil)
+ (defun ravi/complete-or-indent ()
+ (interactive)
+ (if (company-manual-begin)
+ (company-complete-common)
+ (indent-according-to-mode)))
+ (bind-key "\t" 'ravi/complete-or-indent)
+
+ (bind-keys :map company-active-map
+ ("C-n" . company-select-next)
+ ("C-p" . company-select-previous)
+ ;; Swap filter and search since filter is more useful
+ ("C-s" . company-filter-candidates)
+ ("C-M-s" . company-search-candidates))
+ (bind-keys :map company-search-map
+ ("C-n" . company-select-next)
+ ("C-p" . company-select-previous))
+
+ (use-package company-c-headers
+ :init
+ (progn
+ (add-to-list 'company-backends 'company-c-headers))
+ :config
+ (progn
+ (defun ravi/get-default-include-paths ()
+ (let* ((gcc-out (shell-command-to-string "g++ -E -x c++ - -v < /dev/null"))
+ (gcc-list-match (string-match "#include <...> search starts here:\n\\(.*\\(?:\n.*\\)*?\\)End of search list.\n" gcc-out))
+ (combined-list (match-string 1 gcc-out))
+ ;; Need the following rigamarole to handle paths with spaces in them
+ (path-list-with-spaces (and combined-list (split-string combined-list "\n" t)))
+ (path-list (and path-list-with-spaces (mapcar 's-trim-left path-list-with-spaces))))
+ path-list))
+ (mapc (lambda (dir) (add-to-list 'company-c-headers-path-system dir)) (ravi/get-default-include-paths))
+ )
+ :ensure t)
+
+ (use-package company-quickhelp
+ :config
+ (progn
+ (company-quickhelp-mode 1)
+ ;; Enable company-quickhelp only when company-mode is active
+ (unbind-key "M-h" company-quickhelp-mode-map)
+ (bind-key "M-h" 'company-quickhelp-manual-begin company-active-map))
+ :ensure t)
+
+ (use-package company-statistics
+ :init
+ (setq company-statistics-file (expand-file-name "company-statistics-cache.el"
+ (ravi/emacs-file "past")))
+ :config
+ (progn
+ (company-statistics-mode))
+ :ensure t)
+
+ ;; Get rid of company-semantic as it interferes with clang-based backends
+ (setq company-backends (delete 'company-semantic company-backends))
+ ;; Get rid of company-clang since it is too noisy at this point
+ (setq company-backends (delete 'company-clang company-backends))
+
+ (require 'company-yasnippet)
+ (defun ravi/company-to-yasnippet ()
+ (interactive)
+ (company-abort)
+ (call-interactively 'company-yasnippet))
+ (bind-key "<backtab>" 'ravi/company-to-yasnippet company-active-map)
+ (bind-key "<backtab>" 'company-yasnippet))
+
+ :diminish company-mode
+ :ensure t)
+
+(provide 'ravi-init-insertion)
+;;; ravi-init-insertion.el ends here
diff --git a/ravi-init-layouts.el b/lisp/ravi-init-layouts.el
index f6199ce..f6199ce 100644
--- a/ravi-init-layouts.el
+++ b/lisp/ravi-init-layouts.el
diff --git a/lisp/ravi-init-maps.el b/lisp/ravi-init-maps.el
new file mode 100644
index 0000000..ae4eac6
--- /dev/null
+++ b/lisp/ravi-init-maps.el
@@ -0,0 +1,58 @@
+;;; ravi-init-maps.el --- extra keys -*- lexical-binding: t; -*-
+
+;; Copyright (C) 2015 Ravi R Kiran
+
+;; 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:
+
+;; Extra keybindings
+
+(use-package hydra
+ :ensure t)
+
+(use-package operate-on-number
+ :bind (("M-g M-d" . hydra-operate-on-number/body))
+ :config
+ (progn
+ (defhydra hydra-operate-on-number ()
+ "
+ Arithmetic operations: + - * /
+ Remainder: \\
+ Exponent: \\^
+ Arithmetic shift: < >
+ Base conversion: b o x X #
+ Format: %%%%
+ "
+ ("+" apply-operation-to-number-at-point)
+ ("-" apply-operation-to-number-at-point)
+ ("*" apply-operation-to-number-at-point)
+ ("/" apply-operation-to-number-at-point)
+ ("\\" apply-operation-to-number-at-point)
+ ("^" apply-operation-to-number-at-point)
+ ("<" apply-operation-to-number-at-point)
+ (">" apply-operation-to-number-at-point)
+ ("b" apply-operation-to-number-at-point :exit t)
+ ("o" apply-operation-to-number-at-point :exit t)
+ ("x" apply-operation-to-number-at-point :exit t)
+ ("X" apply-operation-to-number-at-point :exit t)
+ ("#" apply-operation-to-number-at-point :exit t)
+ ("%" apply-operation-to-number-at-point :exit t)))
+ :ensure t)
+
+(provide 'ravi-init-maps)
+;;; ravi-init-maps.el ends here
diff --git a/ravi-init-marks.el b/lisp/ravi-init-marks.el
index 345cead..803b2cb 100644
--- a/ravi-init-marks.el
+++ b/lisp/ravi-init-marks.el
@@ -69,8 +69,9 @@ This is the same as using \\[set-mark-command] with the prefix argument."
(define-key global-map [remap exchange-point-and-mark] 'ravi/exchange-point-and-mark-no-activate)
(use-package browse-kill-ring
- :init (browse-kill-ring-default-keybindings)
+ :config (browse-kill-ring-default-keybindings)
:ensure t
+ :if (not ravi/use-helm-instead-of-ido)
)
(provide 'ravi-init-marks)
diff --git a/lisp/ravi-init-mu.el b/lisp/ravi-init-mu.el
new file mode 100644
index 0000000..2f21a0b
--- /dev/null
+++ b/lisp/ravi-init-mu.el
@@ -0,0 +1,218 @@
+;;; ravi-init-mu.el --- mail
+
+;; Copyright (C) 2014
+
+;; 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:
+
+;; Set up mu4e conditionally
+;; - actual account information should be in local.el
+;; - requires definitions of ravi/mu4e-account-alist
+
+;;; Code:
+
+(defvar ravi/use-mu-for-email nil
+ "Use mu for email")
+(defvar ravi/mu4e-account-alist nil
+ "An alist containing account information for all accounts")
+(defvar ravi/mu4e-update-interval 1800 ; 30 minutes
+ "Basic update interval; all other update intervals are multiples")
+
+(setq message-citation-line-format "On %a %Y-%m-%d %l:%M:%S%p %Z, %f wrote:"
+ message-citation-line-function 'message-insert-formatted-citation-line)
+
+(when ravi/use-mu-for-email
+ (use-package mu4e
+ :load-path (lambda () (ravi/emacs-file "site-lisp/mu/mu4e"))
+ :commands mu4e
+ :init
+ (progn
+ (add-to-list 'Info-additional-directory-list (ravi/emacs-file "site-lisp/mu/mu4e"))
+ (unless ravi/mu4e-account-alist (error "Email account list not found"))
+ (defun ravi/switch-to-mu4e ()
+ (interactive)
+ (let ((buf (or (and (boundp 'mu4e~headers-buffer-name)
+ (get-buffer mu4e~headers-buffer-name))
+ (get-buffer "*mu4e-main*"))))
+ (if buf
+ (if (get-buffer-window buf t)
+ (select-window (get-buffer-window buf t))
+ (switch-to-buffer buf))
+ (mu4e))))
+ (bind-key "C-'" 'ravi/switch-to-mu4e)
+ )
+ :config
+ (progn
+
+ ;; Basic identity for sending mail
+ (require 'smtpmail)
+ (setq send-mail-function 'smtpmail-send-it)
+ (setq message-send-mail-function 'smtpmail-send-it)
+
+ ;; Set up defaults from first account on the list
+ ;; user-full-name
+ ;; smtp-local-domain
+ ;; user-mail-address
+ ;; smtpmail-smtp-user
+ ;; smtpmail-smtp-server
+ ;; mu4e-sent-folder
+ ;; mu4e-trash-folder
+ ;; mu4e-refile-folder
+ (let* ((account (caar ravi/mu4e-account-alist))
+ (account-vars (cdr (assoc account ravi/mu4e-account-alist))))
+ (if account-vars
+ (mapc #'(lambda (var)
+ (set (car var) (cadr var)))
+ account-vars)
+ (error "No email account found")))
+
+ ;; Choose correct SMTP identity wisely
+ (defun ravi/mu4e-set-account ()
+ "Set the account for composing a message."
+ (let* ((account
+ (if mu4e-compose-parent-message
+ (let ((maildir (mu4e-message-field mu4e-compose-parent-message :maildir)))
+ (string-match "/\\(.*?\\)/" maildir)
+ (match-string 1 maildir))
+ (if (= (length ravi/mu4e-account-alist) 1)
+ (caar ravi/mu4e-account-alist)
+ (completing-read (format "Compose with account: (%s) "
+ (mapconcat #'(lambda (var) (car var))
+ ravi/mu4e-account-alist "/"))
+ (mapcar #'(lambda (var) (car var)) ravi/mu4e-account-alist)
+ nil t nil nil (caar ravi/mu4e-account-alist)))))
+ (account-vars (cdr (assoc account ravi/mu4e-account-alist))))
+ (if account-vars
+ (mapc #'(lambda (var)
+ (set (car var) (cadr var)))
+ account-vars)
+ (error "No email account found"))))
+ (add-hook 'mu4e-compose-pre-hook 'ravi/mu4e-set-account)
+
+ (setq mu4e-compose-dont-reply-to-self t)
+ (defun ravi/set-self-addresses ()
+ (setq mu4e-user-mail-address-list (list user-mail-address)))
+ (add-hook 'mu4e-compose-pre-hook 'ravi/set-self-addresses)
+
+ ;; Use async method of sending email, if possible
+ (use-package async
+ :config
+ (progn
+ (require 'smtpmail-async)
+ (setq send-mail-function 'async-smtpmail-send-it)
+ (setq message-send-mail-function 'async-smtpmail-send-it)
+ )
+ :ensure t
+ )
+
+ ;; Basic mu4e configuration parameters
+ (setq mu4e-mu-binary (ravi/emacs-file "site-lisp/mu/mu/mu"))
+ (setq mu4e-maildir "~/.mail")
+
+ ;; Poll accounts only as often as necessary
+ (defvar ravi/mu4e-get-mail-attempts 0
+ "Number of attempts so far to get mail")
+ (defun ravi/check-whether-to-get-mail-for-account (account-info)
+ (let* ((account-interval (assq 'ravi/account-update-interval account-info))
+ (account-update-interval (if account-interval (cadr account-interval) 1)))
+ (if (= (% ravi/mu4e-get-mail-attempts account-update-interval) 0)
+ (concat " " (car account-info))
+ "")))
+ (defun ravi/get-mu4e-get-mail-command ()
+ "Figure out arguments to mbsync"
+ (let ((ravi/all-channels (mapconcat 'ravi/check-whether-to-get-mail-for-account
+ ravi/mu4e-account-alist "")))
+ (setq ravi/mu4e-get-mail-attempts (1+ ravi/mu4e-get-mail-attempts))
+ (if (= (length ravi/all-channels) 0)
+ "true" ;; do nothing command
+ (concat (ravi/emacs-file "site-lisp/isync/src/mbsync") " -q -q" ravi/all-channels)
+ )))
+ (add-hook 'mu4e-update-pre-hook
+ (lambda ()
+ (setq mu4e-get-mail-command (ravi/get-mu4e-get-mail-command))))
+ ;(message "%d: '%s'" ravi/mu4e-get-mail-attempts (ravi/get-mu4e-get-mail-command))
+ ;; Default update command if something goes wrong
+ (setq mu4e-get-mail-command (concat (ravi/emacs-file "site-lisp/isync/src/mbsync") " -a -q -q"))
+ (setq mu4e-update-interval ravi/mu4e-update-interval)
+ (setq mu4e-change-filenames-when-moving t)
+
+ ;; User interface
+ (setq mu4e-html-renderer 'w3m)
+ (setq mu4e-html2text-command "w3m -T text/html")
+ (setq mu4e-view-show-images t)
+ (setq mu4e-view-show-addresses t)
+ (when (boundp 'ravi/mu4e-maildir-shortcuts)
+ (setq mu4e-maildir-shortcuts ravi/mu4e-maildir-shortcuts))
+
+ (add-to-list 'mu4e-view-actions
+ '("ViewInBrowser" . mu4e-action-view-in-browser) t)
+
+ ;; Show summary of all folders
+ (use-package mu4e-maildirs-extension
+ :config
+ (progn
+ (setq mu4e-maildirs-extension-count-command-format
+ (concat mu4e-mu-binary " find %s maildir:%s --fields 'i' | wc -l"))
+ (mu4e-maildirs-extension))
+ :ensure t)
+
+ ;; Display desktop notifications
+ (use-package mu4e-alert
+ :config
+ (progn
+ (mu4e-alert-set-default-style 'libnotify)
+ (mu4e-alert-disable-mode-line-display)
+ (mu4e-alert-enable-notifications))
+ :ensure t)
+
+ (setq message-citation-line-function 'message-insert-formatted-citation-line)
+ (setq message-kill-buffer-on-exit t)
+ (setq mu4e-compose-signature-auto-include nil)
+ (bind-key "C-c C-d" 'ravi/erase-from-point mu4e-compose-mode-map)
+
+ ;; Allow attaching files from dired
+ (require 'gnus-dired)
+ ;; make the `gnus-dired-mail-buffers' function also work on
+ ;; message-mode derived modes, such as mu4e-compose-mode
+ (defun gnus-dired-mail-buffers ()
+ "Return a list of active message buffers."
+ (let (buffers)
+ (save-current-buffer
+ (dolist (buffer (buffer-list t))
+ (set-buffer buffer)
+ (when (and (derived-mode-p 'message-mode)
+ (null message-sent-message-via))
+ (push (buffer-name buffer) buffers))))
+ (nreverse buffers)))
+ (setq gnus-dired-mail-mode 'mu4e-user-agent)
+ (add-hook 'dired-mode-hook 'turn-on-gnus-dired-mode)
+
+ (when ravi/use-helm-instead-of-ido
+ (add-to-list 'helm-find-files-actions
+ '("Attach files for mu4e" . helm-mu4e-attach) t)
+
+ (defun helm-mu4e-attach (_file)
+ (gnus-dired-attach (helm-marked-candidates))))
+
+ (imagemagick-register-types)
+ )
+ )
+ )
+
+(provide 'ravi-init-mu)
+;;; ravi-init-mu.el ends here
diff --git a/ravi-init-navigation.el b/lisp/ravi-init-navigation.el
index c0a5a82..569e164 100644
--- a/ravi-init-navigation.el
+++ b/lisp/ravi-init-navigation.el
@@ -25,17 +25,17 @@
;;; Code:
(use-package region-bindings-mode
- :init (region-bindings-mode-enable)
:config
(progn
+ (region-bindings-mode-enable)
(bind-key "f" 'forward-word region-bindings-mode-map)
(bind-key "b" 'backward-word region-bindings-mode-map)
;; HJKL cluster to replace arrow keys
(bind-key "h" 'backward-char region-bindings-mode-map)
(bind-key "l" 'forward-char region-bindings-mode-map)
- (bind-key "j" 'previous-line region-bindings-mode-map)
- (bind-key "k" 'next-line region-bindings-mode-map)
+ (bind-key "k" 'previous-line region-bindings-mode-map)
+ (bind-key "j" 'next-line region-bindings-mode-map)
;; Most of the time, we mark regions to copy
(bind-key "w" 'kill-ring-save region-bindings-mode-map)
@@ -43,10 +43,25 @@
:ensure t
)
-(use-package ace-jump-mode
- :bind ("M-h" . ace-jump-mode)
- :ensure t
- )
+(use-package avy
+ :bind (("M-h" . avy-goto-word-1)
+ ("M-H" . avy-goto-word-0)
+ ("M-g g" . avy-goto-line)
+ ("M-g M-g" . avy-goto-line))
+ :config
+ (progn
+ (setq avy-keys '(?a ?s ?d ?f ?g ?h ?j ?k ?l ?r ?u ?t ?y ?w ?o ?e ?i))
+ (setq avy-style 'at-full
+ avy-background t))
+ :ensure t)
+
+(use-package ace-isearch
+ :config
+ (progn
+ (setq ace-isearch-use-ace-jump nil) ; prefer dedicated key for ace-jump
+ (global-ace-isearch-mode +1))
+ :disabled t ; helm-swoop has a dedicated key now
+ :ensure t)
(use-package jump-char
:bind (("M-m" . jump-char-forward))
@@ -59,7 +74,9 @@
)
(use-package expand-region
- :bind ("C-=" . er/expand-region)
+ :config
+ (progn
+ (bind-key "C-=" 'er/expand-region))
:ensure t
)
@@ -82,7 +99,7 @@
(use-package fold-this
:commands fold-this
- :init
+ :config
(progn
(bind-key "t" 'fold-this region-bindings-mode-map))
:ensure t
@@ -90,7 +107,7 @@
(use-package indirect
:commands indirect-region
- :init
+ :config
(progn
(bind-key "I" 'indirect-region region-bindings-mode-map))
)
@@ -104,6 +121,7 @@
(use-package god-mode
:bind (("<escape>" . god-local-mode))
+ :disabled t ; less useful than I thought
:ensure t
)
@@ -120,10 +138,25 @@
(require 'smartparens-config)
(add-hook 'emacs-lisp-mode-hook 'smartparens-mode)
(add-hook 'emacs-lisp-mode-hook 'sp-use-smartparens-bindings)
+ (use-package minor-mode-hack :ensure t)
+ (raise-minor-mode-map-alist 'region-bindings-mode)
)
:ensure t
)
+(use-package corral
+ :bind (("M-9" . corral-parentheses-backward)
+ ("M-0" . corral-parentheses-forward)
+ ("M-[" . corral-brackets-backward)
+ ("M-]" . corral-brackets-forward)
+ ("M-{" . corral-braces-backward)
+ ("M-}" . corral-braces-forward)
+ ("M-\"" . corral-double-quotes-backward))
+ :config
+ (progn
+ (setq corral-preserve-point t))
+ :ensure t)
+
;; Marking and moving lines
(defun ravi/pull-up-a-line()
@@ -210,16 +243,38 @@
(add-hook 'prog-mode-hook 'turn-on-whole-line-or-region-mode)
)
:diminish whole-line-or-region-mode
+ :ensure t
)
+;; This must be after enabling whole-line-or-region
+(use-package easy-kill
+ :config
+ (progn
+ (global-set-key [remap kill-ring-save] 'easy-kill)
+ (global-set-key [remap whole-line-or-region-kill-ring-save] 'easy-kill))
+ :ensure t)
+
;; grep and friends
(use-package wgrep
- :ensure t
- )
-
-(use-package grep
- :bind (("H-g" . grep)))
+ :ensure t)
+
+(if (executable-find "ag")
+ ;; Prefer the silver-searcher if available
+ (use-package ag
+ :bind (("H-g" . ag)
+ ("H-G" . ag-files)
+ ("M-s g" . grep))
+ :config
+ (progn
+ (setq ag-highlight-search t)
+ (setq ag-reuse-buffers t)
+ (use-package wgrep-ag
+ :ensure t))
+ :ensure t)
+ ;; Use grep if ag is not available on the system
+ (use-package grep
+ :bind (("H-g" . grep))))
(use-package highlight-symbol
:bind (("H-n" . ravi/highlight-symbol-next)
@@ -230,8 +285,8 @@
(progn
(defvar ravi/highlight-symbol-overlay-map
(let ((map (make-sparse-keymap)))
- (define-key map (kbd "j") 'highlight-symbol-prev)
- (define-key map (kbd "k") 'highlight-symbol-next)
+ (define-key map (kbd "k") 'highlight-symbol-prev)
+ (define-key map (kbd "j") 'highlight-symbol-next)
(define-key map (kbd "s") 'highlight-symbol-query-replace)
(define-key map (kbd "o") 'highlight-symbol-occur)
map))
@@ -240,6 +295,7 @@
(highlight-symbol-next)
(set-temporary-overlay-map ravi/highlight-symbol-overlay-map t))
)
+ :disabled t ; M-s . suffices for my needs
:ensure t
)
@@ -259,6 +315,46 @@
)
)
+;; Delete via isearch
+(defun zap-to-isearch (rbeg rend)
+ "Kill the region between the mark and the closest portion of
+ the isearch match string. The behaviour is meant to be analogous
+ to zap-to-char; let's call it zap-to-isearch. The deleted region
+ does not include the isearch word. This is meant to be bound only
+ in isearch mode.
+
+ The point of this function is that oftentimes you want to delete
+ some portion of text, one end of which happens to be an active
+ isearch word. The observation to make is that if you use isearch
+ a lot to move the cursor around (as you should, it is much more
+ efficient than using the arrows), it happens a lot that you could
+ just delete the active region between the mark and the point, not
+ include the isearch word."
+ (interactive "r")
+ (when (not mark-active)
+ (error "Mark is not active"))
+ (let* ((isearch-bounds (list isearch-other-end (point)))
+ (ismin (apply 'min isearch-bounds))
+ (ismax (apply 'max isearch-bounds))
+ )
+ (if (< (mark) ismin)
+ (kill-region (mark) ismin)
+ (if (> (mark) ismax)
+ (kill-region ismax (mark))
+ (error "Internal error in isearch kill function.")))
+ (isearch-exit)
+ ))
+(bind-key "M-z" 'zap-to-isearch isearch-mode-map)
+
+;; Exit isearch at the beginning
+(defun isearch-exit-other-end (rbeg rend)
+ "Exit isearch, but at the other end of the search string.
+ This is useful when followed by an immediate kill."
+ (interactive "r")
+ (isearch-exit)
+ (goto-char isearch-other-end))
+(bind-key "<C-return>" 'isearch-exit-other-end isearch-mode-map)
+
;; Search the web
(use-package webjump
:bind ("C-x g" . webjump)
@@ -278,6 +374,30 @@
)
)
+(use-package anzu
+ :demand t
+ :bind (("C-%" . anzu-query-replace)
+ ("C-M-%" . anzu-query-replace-regexp))
+ :config
+ (progn
+ (global-anzu-mode))
+ :diminish anzu-mode
+ :ensure anzu)
+
+(use-package swoop
+ :bind (("M-s s" . hydra-swoop/body))
+ :config
+ (progn
+ (defhydra hydra-swoop ()
+ "swoop"
+ ("s" swoop)
+ ("m" swoop-multi "multi")
+ ("r" swoop-pcre "pcre")
+ ("b" swoop-back-to-last-position "back")))
+ :ensure t)
+
+(require 'midnight)
+
;; to do: add zeal-at-point
(provide 'ravi-init-navigation)
diff --git a/ravi-init-org.el b/lisp/ravi-init-org.el
index e2ed68f..523f564 100644
--- a/ravi-init-org.el
+++ b/lisp/ravi-init-org.el
@@ -33,11 +33,19 @@
("H--" . org-agenda))
:config
(progn
- (use-package htmlize
- :ensure t)
+ (use-package htmlize :ensure t)
(use-package ox-reveal
- :load-path ,(ravi/emacs-file "site-lisp/org-reveal")
- )
+ :config
+ (progn
+ (setq org-reveal-slide-number nil)
+ (setq org-reveal-theme "night")
+ (setq org-reveal-transition "linear")
+ (setq org-reveal-mathjax t)
+ (setq org-reveal-mathjax-url "./MathJax/MathJax.js?config=TeX-AMS-MML_HTMLorMML"))
+ :ensure t)
+ (use-package ox-rst :ensure t)
+ (use-package ox-impress-js :ensure t)
+
(setq org-src-fontify-natively t)
(setq org-modules (quote (org-bbdb
org-bibtex
@@ -45,6 +53,7 @@
org-gnus
org-id
org-info)))
+ (setq org-use-speed-commands t)
)
)
diff --git a/ravi-init-python.el b/lisp/ravi-init-python.el
index 29aae57..7993092 100644
--- a/ravi-init-python.el
+++ b/lisp/ravi-init-python.el
@@ -51,12 +51,18 @@
;; python-shell-completion-module-string-code ""
;; )
+ (when (functionp 'helm-dash)
+ (setq-local helm-dash-docsets '("Python 2" "NumPy")))
+
;; I'd really prefer indentation by 2 spaces, but have too much existing
;; python code with indentation at 4 spaces.
(setq python-indent-offset 4)
)
- (add-to-list 'smart-tab-disabled-major-modes 'inferior-python-mode)
+ (bind-key "<return>" 'newline-and-indent python-mode-map)
+
+ ;; We no longer use smart-tab-mode
+ ;(add-to-list 'smart-tab-disabled-major-modes 'inferior-python-mode)
(define-auto-insert "\\.py\\'" 'ravi/auto-insert-py)
(defun ravi/auto-insert-py ()
@@ -76,55 +82,12 @@
:ensure t
)
- ;; Use pymacs+ropemacs for code completion plus documentation browsing.
- ;; The main issue is that this requires both python-side and emacs-side
- ;; support, and hence cannot be installed as a package from MELPA.
- (use-package pymacs
- :disabled t
- :init
- (progn
- ;; Many bindings provide same functionality as from other packages.
- (setq ropemacs-global-prefix nil)
- ;(setq ropemancs-local-prefix nil)
- ;(setq ropemacs-enable-shortcuts nil)
- )
- :config
- (progn
- (pymacs-load "ropemacs" "rope-")
- (bind-key "C-c C-d" 'rope-show-calltip python-mode-map)
-
- ;; Auto-complete sources; see
- ;; http://www.cx4a.org/pub/auto-complete-python.el
- (defvar ac-ropemacs-completions-cache nil)
-
- (defvar ac-source-ropemacs
- '((init
- . (lambda ()
- (setq ac-ropemacs-completions-cache
- (mapcar
- (lambda (completion)
- (concat ac-prefix completion))
- (ignore-errors
- (rope-completions))))))
- (candidates . (lambda ()
- (all-completions ac-prefix ac-ropemacs-completions-cache)))))
-
- (defun ac-ropemacs-setup ()
- (ac-ropemacs-require)
- ;(setq ac-sources (append (list 'ac-source-ropemacs) ac-sources))
- (setq ac-omni-completion-sources '(("\\." ac-source-ropemacs))))
-
- (add-hook 'python-mode-hook 'ac-ropemacs-setup)
-
- )
- )
-
;; Use jedi.el for code completion plus documentation browsing.
;; The main issue is that this requires both python-side and emacs-side
;; support, but the python-side support cannot be installed as a package
;; from MELPA. Fedora does not provide python-epc as an RPM either. We
;; work around it by adding sexpdata, jedi and python-epc as git submodules.
- (use-package jedi
+ (use-package jedi-core
:config
(progn
(defun ravi/jedi-setup ()
@@ -140,15 +103,35 @@
basic-server-args))
(jedi:setup)))
+ ;; Override pos-tip support to automatically delete tooltip
+ (defun ravi/jedi:tooltip-show (string)
+ (cond
+ ((and (memq 'pos-tip jedi:tooltip-method) window-system
+ (featurep 'pos-tip))
+ (pos-tip-show (jedi:string-fill-paragraph string)
+ 'popup-tip-face nil nil 5))
+ ((and (memq 'popup jedi:tooltip-method)
+ (featurep 'popup))
+ (popup-tip string))
+ (t (when (stringp string)
+ (let ((message-log-max nil))
+ (message string))))))
+ (fset 'jedi:tooltip-show 'ravi/jedi:tooltip-show)
+
(defun ravi/python-jedi-hook-installer ()
- (setq jedi:complete-on-dot t)
+ ;; (setq jedi:complete-on-dot t) ; needs auto-complete
(add-hook 'hack-local-variables-hook 'ravi/jedi-setup nil t))
(add-hook 'python-mode-hook 'ravi/python-jedi-hook-installer)
)
:ensure t
- :disabled nil
)
+ (use-package company-jedi
+ :config
+ (progn
+ (add-to-list 'company-backends 'company-jedi))
+ :ensure t)
+
(use-package sphinx-doc
:config
(progn
@@ -156,7 +139,23 @@
(sphinx-doc-mode 1))
(add-hook 'python-mode-hook 'ravi/sphinx-doc-setup)
)
- :diminish t
+ :diminish sphinx-doc-mode
+ :ensure t)
+
+ (use-package python-docstring
+ :config
+ (progn
+ (defun ravi/python-docstring-mode-setup ()
+ (python-docstring-mode 1))
+ (add-hook 'python-mode-hook 'ravi/python-docstring-mode-setup))
+ :diminish python-docstring-mode
+ :ensure t)
+
+ (use-package electric-operator
+ :config
+ (progn
+ (add-hook 'python-mode-hook #'electric-operator-mode))
+ ;; :diminish electric-operator
:ensure t)
)
)
diff --git a/ravi-init-repl.el b/lisp/ravi-init-repl.el
index fbca1ed..3191bb3 100644
--- a/ravi-init-repl.el
+++ b/lisp/ravi-init-repl.el
@@ -35,7 +35,7 @@
(use-package octave-mod
:mode ("\\.m\\'" . octave-mode)
- :init
+ :config
(progn
(defun ravi/octave-shell-switch-to-shell ()
"Make sure that `inferior-octave-buffer' exists and is displayed."
@@ -56,12 +56,21 @@
(add-hook 'octave-mode-hook 'rtog/activate)
(add-hook 'emacs-lisp-mode-hook 'rtog/activate)
+ (defun ravi/repl-toggle-or-compile-dwim ()
+ (interactive)
+ (if (or rtog/--last-buffer (assoc major-mode rtog/mode-repl-alist))
+ (call-interactively 'rtog/toggle-repl)
+ (call-interactively 'compile-dwim)))
+
; The default keybinding is not great
(unbind-key "C-c C-z" repl-toggle-mode-map)
- (bind-key "<f5>" 'rtog/toggle-repl repl-toggle-mode-map)
+ (bind-key "<f5>" 'ravi/repl-toggle-or-compile-dwim repl-toggle-mode-map)
)
- :diminish t
+ :diminish repl-toggle-mode
:ensure t)
+;; Calc and friends
+(bind-key "H-c" 'calc)
+
(provide 'ravi-init-repl)
;;; ravi-init-repl.el ends here
diff --git a/ravi-init-tex.el b/lisp/ravi-init-tex.el
index 4bb9349..56545e8 100644
--- a/ravi-init-tex.el
+++ b/lisp/ravi-init-tex.el
@@ -43,17 +43,13 @@
;; fix the "bug" in SP regexp wrap that treats ' as "word"
(modify-syntax-entry ?' ".")
- (use-package ac-math
- :ensure t
- )
-
(require 'smartparens-latex)
(sp-local-pair 'latex-mode "\\begin" "\\end")
(sp-local-tag 'latex-mode "\\ba" "\\begin{align*}" "\\end{align*}")
(use-package preview)
(use-package font-latex)
- (fset 'tex-font-lock-suscript 'ignore)
+ (fset 'tex-font-lock-subscript 'ignore)
(sp-with-modes '(tex-mode plain-tex-mode latex-mode)
(sp-local-pair "\\[" nil :post-handlers '(my-latex-math-block-indent)))
@@ -101,6 +97,11 @@
(bind-key "M-n" 'my-end-of-environment LaTeX-mode-map)
(bind-key "M-p" 'my-beginning-of-environment LaTeX-mode-map)
+ ;; Use okular rather than evince
+ (setq TeX-view-program-selection
+ '((output-dvi "Okular")
+ (output-pdf "Okular")))
+
;; fix italian quote highlight
(push '("\"<" "\">") font-latex-quote-list)
@@ -130,6 +131,23 @@ starting with \\ and followed by a block of text enclosed in {}."
(bind-key "C-c d" 'my-latex-remove-command LaTeX-mode-map)
(bind-key "M-RET" 'LaTeX-insert-item LaTeX-mode-map)
+ (use-package company-math
+ :config
+ (progn
+ (defun ravi/company-math-setup ()
+ (setq-local company-backends
+ (append '(company-math-symbols-latex company-latex-commands)
+ company-backends)))
+ (add-hook 'TeX-mode-hook 'ravi/company-math-setup))
+ :ensure t)
+
+ (use-package latex-extra
+ :config
+ (progn
+ (add-hook 'LaTeX-mode-hook 'latex-extra-mode))
+ :diminish latex-extra-mode
+ :ensure t)
+
(defun my-LaTeX-preview-math ()
(interactive)
(let ((b (save-excursion (while (texmathp) (backward-char 1)) (1- (point))))
@@ -146,31 +164,27 @@ starting with \\ and followed by a block of text enclosed in {}."
(TeX-fold-mode t)
(smartparens-mode 1)
- (keyadvice-mode t)
(LaTeX-add-environments
'("derivation" LaTeX-env-label))
(TeX-add-symbols '("emph" 1))
- (setq fill-column 100000)
+ (setq fill-column 88)
+
+ ;; Add XeLaTeX support to AucTeX
+ (add-to-list 'TeX-command-list '("XeLaTeX" "%`xelatex%(mode)%' %t" TeX-run-TeX nil t))
+ (setq TeX-command-default "XeLaTeX")
+ (setq TeX-save-query nil)
+ (setq TeX-show-compilation t)
- (setq ac-sources
- (append '(ac-source-math-unicode ac-source-math-latex ac-source-latex-commands)
- ac-sources))
- (auto-complete-mode 1)
+ (when (functionp 'helm-dash)
+ (setq-local helm-dash-docsets '("LaTeX")))
(message "LaTeX mode init complete."))
;; ACUTeX replaces latex-mode-hook with LaTeX-mode-hook
(add-hook 'LaTeX-mode-hook 'my-LaTeX-mode-init)
- ;; Why does this not work?
- (keyadvice-add-advice (kbd "`")
- (if (and (eq major-mode 'latex-mode) (texmathp))
- (let* ((events (let ((overriding-local-map LaTeX-math-keymap))
- (read-key-sequence "math: ")))
- (binding (lookup-key LaTeX-math-keymap events)))
- (call-interactively binding))
- keyadvice-do-it))))
+ ))
)
)
diff --git a/lisp/ravi-init-vc.el b/lisp/ravi-init-vc.el
new file mode 100644
index 0000000..a28a75a
--- /dev/null
+++ b/lisp/ravi-init-vc.el
@@ -0,0 +1,104 @@
+;;; ravi-init-vc.el --- vc control
+
+;; Copyright (C) 2013
+
+;; Author: <ravi@nero.lan>
+;; Keywords: vc
+
+;; 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:
+
+;; Version control initialization
+
+;;; Code:
+
+;; Git
+(use-package magit
+ :bind (("<M-f3>" . magit-status)
+ ("C-x v B" . magit-blame)
+ ("C-x v F" . magit-file-log))
+ :config
+ (progn
+ (setq-default
+ magit-process-popup-time 10
+ magit-diff-refine-hunk t
+ magit-completing-read-function (if ravi/use-helm-instead-of-ido
+ 'helm--completing-read-default
+ 'magit-ido-completing-read))
+
+ (setq magit-restore-window-configuration t)
+
+ (use-package magit-svn
+ :config (add-hook 'magit-mode-hook 'magit-svn-mode)
+ :ensure t)
+ )
+ :ensure t)
+(use-package git-gutter
+ :config
+ (progn
+ (use-package git-gutter-fringe
+ :ensure t)
+ (global-git-gutter-mode 1)
+ )
+ :ensure t
+ :diminish git-gutter-mode
+ )
+(use-package gitignore-mode
+ :ensure t)
+(use-package gitconfig-mode
+ :ensure t)
+(use-package git-messenger
+ :bind ("C-x v p" . git-messenger:popup-message)
+ :ensure t)
+(use-package git-timemachine
+ :bind ("C-x v t" . git-timemachine)
+ :ensure t)
+(use-package vc-git
+ :bind ("C-x v f" . vc-git-grep))
+
+;; Stolen almost entirely from Fuco (Matus Goljer)
+(use-package ediff
+ :config
+ (progn
+ (defvar my-ediff-before-config nil "Window configuration before ediff.")
+ (defvar my-ediff-after-config nil "Window configuration after ediff.")
+
+ (defun my-ediff-before-setup ()
+ "Function to be called before any buffers or window setup for
+ ediff."
+ (setq my-ediff-before-config (current-window-configuration))
+ (set-register ?b (list my-ediff-before-config (point-marker))))
+
+ (defun my-ediff-after-setup ()
+ "Function to be called after buffers and window setup for ediff."
+ (setq my-ediff-after-config (current-window-configuration))
+ (set-register ?e (list my-ediff-after-config (point-marker))))
+
+ (defun my-ediff-quit ()
+ "Function to be called when ediff quits."
+ (when my-ediff-before-config
+ (set-window-configuration my-ediff-before-config))
+ ;; clean up ediff bullshit
+ (->> (buffer-list)
+ (-map 'buffer-name)
+ (--select (string-match-p "\\*[Ee]diff" it))
+ (-map 'kill-buffer)))
+
+ (add-hook 'ediff-before-setup-hook 'my-ediff-before-setup)
+ (add-hook 'ediff-after-setup-windows-hook 'my-ediff-after-setup 'append)
+ (add-hook 'ediff-quit-hook 'my-ediff-quit)))
+
+(provide 'ravi-init-vc)
+;;; ravi-init-vc.el ends here
diff --git a/lisp/ravi-init-web.el b/lisp/ravi-init-web.el
new file mode 100644
index 0000000..85446ef
--- /dev/null
+++ b/lisp/ravi-init-web.el
@@ -0,0 +1,112 @@
+;;; ravi-init-web.el --- Web development -*- lexical-binding: t; -*-
+
+;; Copyright (C) 2014
+
+;; 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:
+
+;; Web development tools
+
+;;; Code:
+
+(use-package emmet-mode
+ :commands (emmet-mode)
+ :init
+ (progn
+ (add-hook 'css-mode-hook 'emmet-mode)
+ (add-hook 'sgml-mode-hook 'emmet-mode))
+ :config
+ (progn
+ (unbind-key "C-j" emmet-mode-keymap)
+ (bind-key "M-r" 'emmet-expand-line emmet-mode-keymap))
+ :ensure t
+ :diminish emmet-mode)
+
+;; Javascript
+(use-package js2-mode
+ :mode (("\\.js$" . js2-mode)
+ ("\\.json$" . js2-mode)
+ ("Jakefile$" . js2-mode))
+ ;; :interpreter ("node" . js2-mode)
+ :config
+ (progn
+
+ (use-package js2-refactor
+ :config
+ (progn
+ (js2r-add-keybindings-with-prefix "C-c C-m"))
+ :ensure t)
+
+ (defun ravi/js2-mode-hook ()
+ (emmet-mode)
+ (setq js2-basic-offset 2)
+ (when (functionp 'helm-dash)
+ (setq-local helm-dash-docsets '("JavaScript" "jQuery" "jQuery UI"))))
+ (add-hook 'js2-mode-hook 'ravi/js2-mode-hook))
+ :ensure t
+ )
+
+;; Interact with the browser
+(use-package skewer-mode
+ :config
+ (progn
+ (skewer-setup))
+ :ensure t)
+
+;; HTML with web-mode
+(use-package web-mode
+ :mode (("\\.html" . web-mode))
+ :config
+ (progn
+
+ ;; Make it work with smartparens
+ (defun ravi/web-mode-sp-hook ()
+ (setq web-mode-enable-auto-pairing nil)
+ (smartparens-mode)
+ (sp-use-smartparens-bindings))
+ (add-hook 'web-mode-hook 'ravi/web-mode-sp-hook)
+ (add-hook 'web-mode-hook 'emmet-mode)
+ (defun sp-web-mode-is-code-context (id action context)
+ (when (and
+ (eq action 'insert)
+ (not (or (get-text-property (point) 'part-side) (get-text-property (point) 'block-side))))
+ t))
+ (sp-local-pair 'web-mode "<" nil :when '(sp-web-mode-is-code-context))
+
+ (defun ravi/web-mode-extra-hook ()
+ (when (functionp 'helm-dash)
+ (setq-local helm-dash-docsets '("HTML"))))
+ (add-hook 'web-mode-hook 'ravi/web-mode-extra-hook)
+
+ ;; Customization
+ (setq web-mode-enable-current-element-highlight t)
+ (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-part-face t)
+ )
+
+ :ensure t)
+
+(defun ravi/css-mode-extra-hook ()
+ (when (functionp 'helm-dash)
+ (setq-local helm-dash-docsets '("CSS"))))
+(add-hook 'css-mode-hook 'ravi/css-mode-extra-hook)
+
+(provide 'ravi-init-web)
+;;; ravi-init-web.el ends here
diff --git a/ravi-init-appearance.el b/ravi-init-appearance.el
deleted file mode 100644
index a028712..0000000
--- a/ravi-init-appearance.el
+++ /dev/null
@@ -1,187 +0,0 @@
-;;; 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)
-
-(set-face-background 'cursor "LightSteelBlue1")
-
-;; 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)
- (add-hook 'before-save-hook 'whitespace-cleanup)
- )
- ; No need for 'ensure: t' since whitespace mode is built in
- :diminish global-whitespace-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)
-
-;; Easily navigate sillycased words
-;(global-subword-mode 1)
-
-;; Keep cursor away from edges when scrolling up/down
-(use-package smooth-scrolling
- :ensure t
- )
-
-;; Enable automatic indentation, if possible
-(bind-key "<return>" 'newline-and-indent prog-mode-map)
-(bind-key "<return>" 'newline-and-indent emacs-lisp-mode-map)
-
-;; 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))))))
-
-;; 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
- ))
- (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
- :ensure t
- )
-
-(bind-key "C-h a" 'apropos)
-
-(use-package popwin
- :commands popwin-mode
- :config
- (progn
- (push '("*Pp Eval Output*" :height 15) popwin:special-display-config))
- :ensure t
- )
-
-(use-package import-popwin
- :bind (("M-i" . import-popwin))
- :ensure t
- )
-
-(bind-key "M-o" 'other-window)
-
-(provide 'ravi-init-appearance)
-;;; ravi-init-appearance.el ends here
diff --git a/ravi-init-function.el b/ravi-init-function.el
deleted file mode 100644
index b4dc744..0000000
--- a/ravi-init-function.el
+++ /dev/null
@@ -1,40 +0,0 @@
-;;; ravi-init-function.el --- functionality
-
-;; 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:
-
-;; Enable functionality
-
-;;; Code:
-
-;; Enable emacs functionality that is disabled by default
-(put 'eval-expression 'disabled nil)
-;(put 'set-goal-column 'disabled nil)
-(put 'narrow-to-page 'disabled nil)
-(put 'narrow-to-region 'disabled nil)
-(put 'downcase-region 'disabled nil)
-(put 'upcase-region 'disabled nil)
-;(setq enable-recursive-minibuffers t)
-
-;; Use emacsclient from other programs
-(server-start)
-
-(provide 'ravi-init-function)
-;;; ravi-init-function.el ends here
diff --git a/ravi-init-insertion.el b/ravi-init-insertion.el
deleted file mode 100644
index 3849e3b..0000000
--- a/ravi-init-insertion.el
+++ /dev/null
@@ -1,95 +0,0 @@
-;;; ravi-init-insertion.el --- inserting text
-
-;; 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:
-
-;; Automatic text insertion
-
-;;; Code:
-
-(require 'autoinsert)
-(auto-insert-mode)
-
-(use-package yasnippet
- :init
- (progn
- (setq yas-snippet-dirs
- `(,(ravi/emacs-file "snippets")
- )
- )
- (yas-global-mode 1)
- )
- :config
- (progn
- ;; No dropdowns
- (setq yas/prompt-functions '(yas/ido-prompt yas/completing-prompt))
-
- ;; Wrap around region
- (setq yas/wrap-around-region t)
- )
- :ensure t
- :diminish yas-minor-mode
- )
-
-;; Default completion (some day via "M-/")
-(require 'hippie-exp)
-(setq hippie-expand-try-functions-list
- '(yas/hippie-try-expand
- try-expand-dabbrev
- try-expand-dabbrev-all-buffers
- try-expand-dabbrev-from-kill
- try-complete-file-name-partially
- try-complete-file-name
- try-expand-all-abbrevs
- )
- )
-
-;; Use smart-tab for TAB-completion but this means that we do not use TAB with auto-complete for now.
-(use-package smart-tab
- :init
- (setq smart-tab-using-hippie-expand t)
- :config
- (global-smart-tab-mode 1)
- :ensure t
- :diminish smart-tab-mode
- )
-
-(use-package auto-complete
- :diminish auto-complete-mode
- :init
- (progn
- (use-package pos-tip :ensure t)
- (use-package auto-complete-config)
- (setq ac-comphist-file (ravi/emacs-file "past/ac-comphist.dat"))
- (ac-config-default))
-
- :config
- (progn
- (ac-set-trigger-key "<M-f7>")
- (setq ac-use-menu-map t)
-
- ;(bind-key "A-M-?" 'ac-last-help)
- ;(unbind-key "C-s" ac-completing-map)
- )
- :ensure t
- )
-
-(provide 'ravi-init-insertion)
-;;; ravi-init-insertion.el ends here
diff --git a/ravi-init-vc.el b/ravi-init-vc.el
deleted file mode 100644
index 406e05b..0000000
--- a/ravi-init-vc.el
+++ /dev/null
@@ -1,176 +0,0 @@
-;;; ravi-init-vc.el --- vc control
-
-;; Copyright (C) 2013
-
-;; Author: <ravi@nero.lan>
-;; Keywords: vc
-
-;; 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:
-
-;; Version control initialization
-
-;;; Code:
-
-;; Git
-(use-package magit
- :bind ("<M-f3>" . magit-status)
- :config
- (progn
- (setq-default
- magit-process-popup-time 10
- magit-diff-refine-hunk t
- magit-completing-read-function 'magit-ido-completing-read
- )
-
- ; Since magit-mode-quit-window is used by all magit windows (such as logs),
- ; and since mucking with magit's keymap also leads to the same results, we
- ; avoid showing magit-status in a fullscreen window until another solution
- ; is found.
- ;(require 'fullframe)
- ;(fullframe magit-status magit-mode-quit-window :magit-fullscreen nil)
-
- (setq magit-restore-window-configuration t)
-
- (use-package vc-git
- :defer t
- :bind ("C-x v f" . vc-git-grep)
- :config
- (progn
- (global-magit-wip-save-mode)
- (diminish 'magit-wip-save-mode)
- )
- )
- ;(after-load 'magit-key-mode
- ; (require 'magit-svn))
-
- (after-load 'compile
- (dolist (defn (list '(git-svn-updated "^\t[A-Z]\t\\(.*\\)$" 1 nil nil 0 1)
- '(git-svn-needs-update "^\\(.*\\): needs update$" 1 nil nil 2 1)))
- (add-to-list 'compilation-error-regexp-alist-alist defn)
- (add-to-list 'compilation-error-regexp-alist (car defn))))
-
- (use-package magit-svn
- :config (add-hook 'magit-mode-hook 'turn-on-magit-svn)
- :ensure t
- )
-
- (defvar git-svn--available-commands nil "Cached list of git svn subcommands")
-
- (defun git-svn (dir)
- "Run a git svn subcommand in DIR."
- (interactive "DSelect directory: ")
- (unless git-svn--available-commands
- (setq git-svn--available-commands
- (sanityinc/string-all-matches
- "^ \\([a-z\\-]+\\) +"
- (shell-command-to-string "git svn help") 1)))
- (let* ((default-directory (vc-git-root dir))
- (compilation-buffer-name-function (lambda (major-mode-name) "*git-svn*")))
- (compile (concat "git svn "
- (ido-completing-read "git-svn command: "
- git-svn--available-commands nil t))))
- )
-
- (defun magit-toggle-whitespace ()
- (interactive)
- (if (member "-w" magit-diff-options)
- (magit-dont-ignore-whitespace)
- (magit-ignore-whitespace)))
-
- (defun magit-ignore-whitespace ()
- (interactive)
- (add-to-list 'magit-diff-options "-w")
- (magit-refresh))
-
- (defun magit-dont-ignore-whitespace ()
- (interactive)
- (setq magit-diff-options (remove "-w" magit-diff-options))
- (magit-refresh))
-
- (bind-key "W" 'magit-toggle-whitespace magit-status-mode-map)
-
- (defun magit-just-amend ()
- (interactive)
- (save-window-excursion
- (magit-with-refresh
- (shell-command "git --no-pager commit --amend --reuse-message=HEAD"))))
- (bind-key "C-a" 'magit-just-amend magit-status-mode-map)
-
- )
- :ensure t
- )
-(use-package git-gutter
- :config
- (progn
- (use-package git-gutter-fringe
- :ensure t
- )
- (global-git-gutter-mode 1)
- )
- :ensure t
- :diminish git-gutter-mode
- )
-(use-package git-commit-mode
- :ensure t
- )
-(use-package git-rebase-mode
- :ensure t
- )
-(use-package gitignore-mode
- :ensure t
- )
-(use-package gitconfig-mode
- :ensure t
- )
-(use-package git-messenger
- :ensure t
- :bind ("C-x v p" . git-messenger:popup-message)
- )
-
-;; Stolen almost entirely from Fuco (Matus Goljer)
-(use-package ediff
- :config
- (progn
- (defvar my-ediff-before-config nil "Window configuration before ediff.")
- (defvar my-ediff-after-config nil "Window configuration after ediff.")
-
- (defun my-ediff-before-setup ()
- "Function to be called before any buffers or window setup for
- ediff."
- (setq my-ediff-before-config (current-window-configuration))
- (set-register ?b (list my-ediff-before-config (point-marker))))
-
- (defun my-ediff-after-setup ()
- "Function to be called after buffers and window setup for ediff."
- (setq my-ediff-after-config (current-window-configuration))
- (set-register ?e (list my-ediff-after-config (point-marker))))
-
- (defun my-ediff-quit ()
- "Function to be called when ediff quits."
- (when my-ediff-before-config
- (set-window-configuration my-ediff-before-config))
- ;; clean up ediff bullshit
- (->> (buffer-list)
- (-map 'buffer-name)
- (--select (string-match-p "\\*[Ee]diff" it))
- (-map 'kill-buffer)))
-
- (add-hook 'ediff-before-setup-hook 'my-ediff-before-setup)
- (add-hook 'ediff-after-setup-windows-hook 'my-ediff-after-setup 'append)
- (add-hook 'ediff-quit-hook 'my-ediff-quit)))
-
-(provide 'ravi-init-vc)
-;;; ravi-init-vc.el ends here
diff --git a/site-lisp/mu b/site-lisp/mu
-Subproject b44be2fcd8cef62871e1a73343033a212b54997
+Subproject 7981845daad7318a214162ac5580a29edd0d1e7
diff --git a/site-lisp/org-reveal b/site-lisp/org-reveal
deleted file mode 160000
-Subproject e7b9cb41babd9d7a0873e8e10fe178c6be99085
diff --git a/site-lisp/pdf-tools b/site-lisp/pdf-tools
new file mode 160000
+Subproject 787762d3ad86fcba2ce81889f56968dc8b475d9
diff --git a/site-lisp/whole-line-or-region.el b/site-lisp/whole-line-or-region.el
deleted file mode 100644
index 3b08d9f..0000000
--- a/site-lisp/whole-line-or-region.el
+++ /dev/null
@@ -1,644 +0,0 @@
-;;; @(#) whole-line-or-region.el -- operate on current line if region undefined
-;;; @(#) $Id: whole-line-or-region.el,v 1.3 2008/12/06 03:31:32 joe Exp $
-
-;; This file is not part of Emacs
-
-;; Copyright (C) 2001 by Joseph L. Casadonte Jr.
-;; Author: Joe Casadonte (emacs@northbound-train.com)
-;; Maintainer: Joe Casadonte (emacs@northbound-train.com)
-;; Created: July 1, 2001
-;; Keywords: kill yank cut copy paste whole lines
-;; Latest Version: http://www.northbound-train.com/emacs.html
-
-;; COPYRIGHT NOTICE
-
-;; 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 2, 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; see the file COPYING. If not, write to the
-;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-;; Boston, MA 02111-1307, USA.
-
-;;; Commentary:
-;;
-;; This minor mode allows functions to operate on the current line if
-;; they would normally operate on a region and region is currently
-;; undefined.
-;;
-;; The primary use for this is to kill (cut) the current line if no
-;; region is defined, and kill-region is invoked. It basically saves
-;; you the effort of going to the begining of the line, selecting the
-;; text up to the end of the line, and killing. Similarly, when
-;; yanking, it's smart enough to know that the string to be yanked
-;; was killed as a whole line, and it should be yanked as one, too.
-;; So you don't need to position yourself at the start of the line
-;; before yanking. If region *is* defined, though, all functions act
-;; as normal.
-;;
-;; The inspiration for this came from an old editor I used to use
-;; (brief maybe?), that did this exact thing for you. It was a handy
-;; feature to have, and I definitely wanted it when I moved to Emacs.
-;; I've extended the concept slightly, to let you copy N whole lines,
-;; using the standard prefix method.
-;;
-;; NOTE: This package will behave unexpectedly (and indeed is nearly
-;; useless) if `transient-mark-mode' is off, as there is then always
-;; a region defined.
-;;
-;; NOTE: I haven't gotten this to work under XEmacs (though I
-;; honestly haven't tried real hard).
-
-;;; Usage:
-;;
-;; M-x `whole-line-or-region-mode'
-
-;; Toggles whole-line-or-region-mode on & off. Optional arg turns
-;; whole-line-or-region-mode on iff arg is a positive integer. Then
-;; just call functions `copy-region-as-kill', `kill-region',
-;; `kill-ring-save' and `yank' as you normally would.
-;;
-;; To turn the mode on automatically whenever Emacs starts, customize
-;; `whole-line-or-region-mode' (which see).
-
-;;; Extending Package:
-;;
-;; I've tried to make the base functions as generic as possible so
-;; that this same concept can be used for other region-based
-;; functions. The only function I've thought of to date to extend in
-;; this manner is `comment-dwim'. Examples using `comment-dwim'
-;; follow.
-;;
-;; In order to extend this package for additional region-based
-;; functions, you must understand how those functions work, and write
-;; a new stub function that will be used to replace it. One of two
-;; whole-line-or-region functions must be called from within that
-;; stub; which one to use depends on whether or not the original
-;; function wants region passed into it, or assumes region is defined
-;; before being called.
-;;
-;; Using `kill-region' as an example, looking at its definition we
-;; see that it takes two arguments, BEG and END. Looking at it
-;; another way, it's interactive declaration is "r", which says to
-;; pass in the current region. Because of this, the stub function
-;; for it should call `whole-line-or-region-call-with-region':
-;;
-;; (defun whole-line-or-region-kill-region (prefix)
-;; "Kill region or PREFIX whole lines."
-;; (interactive "*p")
-;; (whole-line-or-region-call-with-region 'kill-region prefix t))
-;;
-;; The first argument to `whole-line-or-region-call-with-region' is
-;; the function being replaced. The second is the value for prefix,
-;; so that the stub can operate on more than just one line (e.g. C-u
-;; 12 M-w would copy 12 whole lines). Other arguments are explained
-;; in the function documentation.
-;;
-;; The function `comment-dwim', on the other hand, expects region to
-;; be defined coming in, so its stub should call into the other
-;; whole-line stub, `whole-line-or-region-call-with-prefix'. There are
-;; things to consider, though. The original `comment-dwim' wants a
-;; raw prefix value, but it doesn't use it to work over a variable
-;; number of lines; rather it uses it to signal what DWIM really
-;; does. Sort of defeats the purpose of a DWIM command, if you ask
-;; me -- it should be simple enough to determine from the current
-;; context what DWIMs should do. I digress, however.....
-;;
-;; The "proper" way to write a whole-line version of `comment-dwim'
-;; would be like the following:
-;;
-;; (defun whole-line-or-region-comment-dwim (raw-prefix)
-;; "Call `comment-dwim' on current region or current line."
-;; (interactive "*P")
-;; (whole-line-or-region-call-with-prefix 'comment-dwim 1 nil t raw-prefix))
-;;
-;; The arguments for `whole-line-or-region-call-with-prefix' are
-;; basically the same as for `whole-line-or-region-call-with-region',
-;; but how each of them call the original function differs. The
-;; first one calls it with two arguments (i.e. region's BEG & END)
-;; and the second one sets mark (i.e. defines region) and passes in
-;; prefix (raw or processed, depending).
-;;
-;; So the above example for `comment-dwim' would call the original
-;; function with the current region (if defined) or the current line
-;; (the second argument, the number of lines to operate on, being
-;; hard-coded to 1), also passing in the raw prefix, for use within
-;; the original function. It retains its original semantics and just
-;; saves you from having to mark the current line.
-;;
-;; It could instead be defined like so:
-;;
-;; (defun whole-line-or-region-comment-dwim-2 (prefix)
-;; "Call `comment-dwim' on region or PREFIX whole lines."
-;; (interactive "*p")
-;; (whole-line-or-region-call-with-prefix 'comment-dwim prefix nil t))
-;;
-;; What this version does is override the normal behavior of the
-;; prefix arg to `comment-dwim', and instead uses it to indicate how
-;; many lines the whole-line version will comment out -- no prefix
-;; value is passed to the original function in this case. This is
-;; the version that I use, as it's just more intuitive for me.
-;;
-;; After defining the new stub, however you do it, the package needs
-;; to know about it so that it can toggle its use on and off as the
-;; mode toggles on and off. For that you need to customize the
-;; variable `whole-line-or-region-extensions-alist', telling it the
-;; original function name (`comment-dwim') and the new one
-;; (`whole-line-or-region-comment-dwim-2'). If you want to limit the
-;; redefinition to a specific keymap then specify that as well;
-;; otherwise, the rebinding will occur in the global keymap.
-;; Rebinding occurs via `substitute-key-definition' (which see).
-
-;;; To Do:
-;;
-;; o Nothing, at the moment.
-
-;;; Comments:
-;;
-;; Any comments, suggestions, bug reports or upgrade requests are welcome.
-;; Please send them to Joe Casadonte (emacs@northbound-train.com).
-;;
-;; This version of whole-line-or-region was developed and tested with NTEmacs
-;; 22.2.1 under Windows XP Pro. Please, let me know if it works with
-;; other OS and versions of Emacs.
-
-;;; Change Log:
-;;
-;; see http://www.northbound-train.com/emacs/whole-line-or-region.log
-
-;;; **************************************************************************
-;;; **************************************************************************
-;;; **************************************************************************
-;;; **************************************************************************
-;;; **************************************************************************
-;;; Code:
-
-(eval-when-compile
- ;; silence the old byte-compiler
- (defvar byte-compile-dynamic nil)
- (set (make-local-variable 'byte-compile-dynamic) t))
-
-;;; **************************************************************************
-;;; ***** version related routines
-;;; **************************************************************************
-(defconst whole-line-or-region-version
- "$Revision: 1.3 $"
- "Version number for 'whole-line-or-region' package.")
-
-;; ---------------------------------------------------------------------------
-(defun whole-line-or-region-version-number ()
- "Return 'whole-line-or-region' version number."
- (string-match "[0123456789.]+" whole-line-or-region-version)
- (match-string 0 whole-line-or-region-version))
-
-;; ---------------------------------------------------------------------------
-(defun whole-line-or-region-display-version ()
- "Display 'whole-line-or-region' version."
- (interactive)
- (message "whole-line-or-region version <%s>." (whole-line-or-region-version-number)))
-
-;;; **************************************************************************
-;;; ***** customization
-;;; **************************************************************************
-(defgroup whole-line-or-region nil
- "Customization group for whole-line-or-region minor mode."
- :group 'editing-basics
- :group 'convenience)
-
-;; ---------------------------------------------------------------------------
-(defun whole-line-or-region-customize ()
- "Customization of the group 'whole-line-or-region'."
- (interactive)
- (customize-group "whole-line-or-region"))
-
-;; ---------------------------------------------------------------------------
-(defcustom whole-line-or-region-mode nil
- "Non-nil if whole-line-or-region minor mode is enabled.
-
-Setting this variable directly does not take effect; use either
-\\[customize] or the function `whole-line-or-region-mode'."
- :set (lambda (symbol value)
- (whole-line-or-region-mode (or value 0)))
- :initialize 'custom-initialize-default
- :type 'boolean
- :group 'whole-line-or-region)
-
-;; ---------------------------------------------------------------------------
-(defcustom whole-line-or-region-extensions-alist '(
- (copy-region-as-kill whole-line-or-region-copy-region-as-kill nil)
- (kill-region whole-line-or-region-kill-region nil)
- (kill-ring-save whole-line-or-region-kill-ring-save nil)
- (yank whole-line-or-region-yank nil)
- )
- "List of functions for whole-line-or-region to swap.
-
-When whole-line-or-region is activated, all original functions will be
-replaced with their whole-line counterparts in the global keymap,
-unless the optional keymap is specified (in which case it will be
-replace in that map only). Similarly, when whole-line-or-region is
-de-activated, the functions will be swapped back.
-
-The default is to map the following:
-
- o `copy-region-as-kill' -> `whole-line-or-region-copy-region-as-kill'
- o `kill-region' -> `whole-line-or-region-kill-region'
- o `kill-ring-save' -> `whole-line-or-region-kill-ring-save'
- o `yank' -> `whole-line-or-region-yank'
-
-In addition, the following functions are provided by the package for
-your convenience:
-
- o `whole-line-or-region-delete'
- o `whole-line-or-region-comment-dwim'
- o `whole-line-or-region-comment-dwim-2'
-
-See the individual functions for more information on what they do and
-suggested mappings."
- :type '(repeat
- (list :tag "Function Mappings:"
- (function :tag "Original Function")
- (function :tag "Whole-line Version")
- (variable :tag "Keymap (optional)")
- ))
- :group 'whole-line-or-region
- :set (lambda (symbol newval)
- (set symbol newval)
- (when whole-line-or-region-mode
- (whole-line-or-region-bind-keys)))
- )
-
-;; ---------------------------------------------------------------------------
-(defcustom whole-line-or-region-mode-line-string " WLR"
- "String to display in mode-line when 'whole-line-or-region' is active.
-
-Must start with a space. Changes will take effect next time emacs is
-started."
- :type 'string
- :group 'whole-line-or-region)
-
-;; ---------------------------------------------------------------------------
-(defcustom whole-line-or-region-load-hook nil
- "Hook to run when package is loaded."
- :type 'hook
- :group 'whole-line-or-region)
-
-;; ---------------------------------------------------------------------------
-(defcustom whole-line-or-region-on-hook nil
- "Hook called when 'whole-line-or-region' mode is turned on."
- :type 'hook
- :group 'whole-line-or-region)
-
-;; ---------------------------------------------------------------------------
-(defcustom whole-line-or-region-off-hook nil
- "Hook called when 'whole-line-or-region' mode is turned off."
- :type 'hook
- :group 'whole-line-or-region)
-
-;;; **************************************************************************
-;;; ***** minor mode functions
-;;; **************************************************************************
-; (defvar whole-line-or-region-mode nil )
-
-;;; --------------------------------------------------------------------------
-;;;###autoload
-(defun whole-line-or-region-mode (&optional arg)
- "Toggle use of whole-line-or-region minor mode.
-
-This minor mode allows functions to operate on the current line if
-they would normally operate on a region and region is currently
-undefined.
-
-Optional ARG turns mode on iff ARG is a positive integer."
- (interactive "P")
-
- ;; toggle on and off
- (let ((old-mode whole-line-or-region-mode))
- (setq whole-line-or-region-mode
- (if arg (or (listp arg)
- (> (prefix-numeric-value arg) 0))
- (not whole-line-or-region-mode)))
-
- (when (not (equal old-mode whole-line-or-region-mode))
- ;; enable/disable advice
- (if whole-line-or-region-mode
- (whole-line-or-region-bind-keys)
- (whole-line-or-region-restore-keys))
-
- (run-hooks (if whole-line-or-region-mode
- 'whole-line-or-region-on-hook
- 'whole-line-or-region-off-hook))
- )))
-
-;; ---------------------------------------------------------------------------
-;; add to minor-mode-alist if not there already
-(or
- (assq 'whole-line-or-region-mode minor-mode-alist)
- (setq minor-mode-alist
- (cons
- (list 'whole-line-or-region-mode whole-line-or-region-mode-line-string)
- minor-mode-alist)))
-
-;;; **************************************************************************
-;;; ***** interactive functions (used by default)
-;;; **************************************************************************
-;;;###autoload
-(defun whole-line-or-region-copy-region-as-kill (prefix)
- "Copy region or PREFIX whole lines."
- (interactive "p")
- (whole-line-or-region-call-with-region 'copy-region-as-kill prefix t))
-
-;;; --------------------------------------------------------------------------
-;; (defalias 'whole-line-or-region-copy 'whole-line-or-region-copy-region-as-kill)
-
-;;; **************************************************************************
-;;;###autoload
-(defun whole-line-or-region-kill-region (prefix)
- "Kill (cut) region or PREFIX whole lines."
- (interactive "*p")
- (whole-line-or-region-call-with-region 'kill-region prefix t))
-
-;;; **************************************************************************
-;;;###autoload
-(defun whole-line-or-region-kill-ring-save (prefix)
- "Copy region or PREFIX whole lines."
- (interactive "p")
- (whole-line-or-region-call-with-region 'kill-ring-save prefix t))
-
-;;; **************************************************************************
-;;;###autoload
-(defun whole-line-or-region-yank (raw-prefix &optional string-in)
- "Yank (paste) previously killed text.
-
-If the text to be yanked was killed with a whole-line-or-region
-function *as* a whole-line, then paste it as a whole line (i.e. do not
-break up the current line, and do not force the user to move point).
-
-RAW-PREFIX is used to determine which string to yank, just as `yank'
-would normally use it.
-
-Optionally, pass in string to be \"yanked\" via STRING-IN."
- (interactive "*P")
-
- ;; figure out what yank would do normally
- (let ((string-to-yank (or string-in (current-kill
- (cond ((listp raw-prefix) 0)
- ((eq raw-prefix '-) -1)
- (t (1- raw-prefix))) t)))
- (saved-column (current-column)))
-
- ;; check for whole-line prop in yanked text
- (if (get-text-property 0 'whole-line-or-region string-to-yank)
- (let ((beg (line-beginning-position)))
- ;; goto beg of line and yank
- (beginning-of-line)
- (if string-in
- ;; insert "manually"
- (insert string-in)
- ;; just yank as normal
- (yank raw-prefix))
-
- ;; a whole-line killed from end of file may not have a
- ;; trailing newline -- add one, in these cases
- (when (not (string-match "\n$" string-to-yank))
- (insert "\n")
- (previous-line 1))
-
- ;; restore state of being....
- (move-to-column saved-column)
- (remove-text-properties beg (+ beg 1) '(whole-line-or-region nil)))
-
- ;; no whole-line-or-region mark
- (if string-in
- ;; insert "manually"
- (progn
- (when (and delete-selection-mode
- mark-active)
- (delete-active-region))
- (insert string-in))
- ;; just yank as normal
- (yank raw-prefix)))
- ))
-
-;;; --------------------------------------------------------------------------
-;; in case delete-selection-mode (delsel.el) is being used
-(if (string-match "Emacs 21" (emacs-version))
- (put 'whole-line-or-region-yank 'delete-selection 'yank)
- (put 'whole-line-or-region-yank 'delete-selection t))
-
-;;; **************************************************************************
-;;; alternate interactive functions
-;;; **************************************************************************
-;;;###autoload
-(defun whole-line-or-region-delete (prefix)
- "Delete region or PREFIX whole lines."
- (interactive "*p")
- (whole-line-or-region-call-with-region 'delete-region prefix))
-
-;;; **************************************************************************
-;;;###autoload
-(defun whole-line-or-region-comment-dwim (raw-prefix)
- "Call `comment-dwim' on current region or current line.
-
-See `comment-dwim' for details of RAW-PREFIX usage."
- (interactive "*P")
- (whole-line-or-region-call-with-prefix 'comment-dwim 1 nil t raw-prefix))
-
-;;; **************************************************************************
-;;;###autoload
-(defun whole-line-or-region-comment-dwim-2 (prefix)
- "Call `comment-dwim' on region or PREFIX whole lines."
- (interactive "*p")
- (whole-line-or-region-call-with-prefix 'comment-dwim prefix nil t))
-
-;;; **************************************************************************
-;;; ***** internal functions
-;;; **************************************************************************
-(defun whole-line-or-region-call-with-region (fn &optional cnt mark-as-whole send-prefix prefix)
- "Calls FN on region or CNT whole lines.
-
-If region is defined simply call FN, passing in the start and end of
-the current region.
-
-If region is not currently defined, then define it temporarily as the
-current line. Additionally, if CNT is set, expand region to cover the
-next CNT whole lines (or previous CNT whole lines, if CNT is
-negative). Before FN is called, mark the temporary region with a
-special property if MARK-AS-WHOLE is non-nil (this is useful if the
-text could be worked on with some future whole-line-or-region
-function, and it makes sense to understand the context in which FN was
-originally called, e.g. killing and yanking text; see
-`whole-line-or-region-yank' for an example).
-
-In either case, if SEND-PREFIX is non-nil, then PREFIX is passed into
-FN as a third argument."
- (whole-line-or-region-base-call fn fn t nil nil cnt mark-as-whole send-prefix prefix))
-
-;;; **************************************************************************
-(defun whole-line-or-region-call-with-prefix (fn &optional cnt mark-as-whole send-prefix prefix)
- "Calls FN on region or CNT whole lines.
-
-If region is defined simply call FN.
-
-If region is not currently defined, then define it temporarily as the
-current line. Additionally, if CNT is set, expand region to cover the
-next CNT whole lines (or previous CNT whole lines, if CNT is
-negative). Before FN is called, mark the temporary region with a
-special property if MARK-AS-WHOLE is non-nil (this is useful if the
-text could be worked on with some future whole-line-or-region
-function, and it makes sense to understand the context in which FN was
-originally called, e.g. killing and yanking text; see
-`whole-line-or-region-yank' for an example).
-
-In either case, if SEND-PREFIX is non-nil, then PREFIX is passed into
-FN as the sole argument."
- (whole-line-or-region-base-call fn fn nil nil nil cnt mark-as-whole send-prefix prefix))
-
-;;; **************************************************************************
-(defun whole-line-or-region-base-call (norm-fn wlr-fn
- &optional beg-end pre-args post-args
- cnt mark-as-whole send-prefix prefix)
- "Calls FN on region or CNT whole lines.
-
-If region is defined simply call NORM-FN.
-
-If region is not currently defined, then define it temporarily as the
-current line. Additionally, if CNT is set, expand region to cover the
-next CNT whole lines (or previous CNT whole lines, if CNT is
-negative). Before WLR-FN is called, mark the temporary region with a
-special property if MARK-AS-WHOLE is non-nil (this is useful if the
-text could be worked on with some future whole-line-or-region
-function, and it makes sense to understand the context in which WLR-FN was
-originally called, e.g. killing and yanking text; see
-`whole-line-or-region-yank' for an example).
-
-In either case, if BEG-END is non-nil, then pass into FN the start and
-end of the current region. PRE-ARGS and POST-ARGS are lists of
-arguments to be passed into FN before \(PRE-ARGS) and/or after
-\(POST-ARGS) the start and end of the current region (but only if
-BEG-END is non-nil). Finally, if SEND-PREFIX is non-nil, then PREFIX
-is passed into FN before POST-ARGS."
-
- ;; region is defined, so just do what should normally be done
- (if (and mark-active
- (/= (point) (mark)))
- ;; just call it, but make sure to pass all of the arguments....
- (let (args)
- (when pre-args
- (whole-line-or-region-append-to-list 'args pre-args))
-
- (when beg-end
- (whole-line-or-region-append-to-list 'args (point))
- (whole-line-or-region-append-to-list 'args (mark)))
-
- (when send-prefix
- (whole-line-or-region-append-to-list 'args (list prefix)))
-
- (when post-args
- (whole-line-or-region-append-to-list 'args post-args))
-
- (apply 'funcall norm-fn args))
-
- ;; no region defined, act on whole line
- (let ((saved-column (current-column))
- (current-mod-state (buffer-modified-p))
- beg end)
- (save-excursion
- (setq beg (line-beginning-position))
- (set-mark beg)
-
- ;; add whole-line property, sometimes
- (when mark-as-whole
- (let ((inhibit-read-only t))
- (put-text-property beg (+ beg 1) 'whole-line-or-region t)
- (set-buffer-modified-p current-mod-state)))
-
- (setq end (line-beginning-position (+ (or cnt 1) 1)))
- (goto-char end)
-
- (let (args)
- (when pre-args
- (whole-line-or-region-append-to-list 'args pre-args))
-
- (when beg-end
- (whole-line-or-region-append-to-list 'args beg)
- (whole-line-or-region-append-to-list 'args end))
-
- (when send-prefix
- (whole-line-or-region-append-to-list 'args (list prefix)))
-
- (when post-args
- (whole-line-or-region-append-to-list 'args post-args))
-
- (apply 'funcall wlr-fn args))
-
- ;; remove whole-line property, sometimes
- (when mark-as-whole
- (let ((inhibit-read-only t)
- (current-mod-state (buffer-modified-p)))
- (remove-text-properties beg (+ beg 1) '(whole-line-or-region nil))
- (set-buffer-modified-p current-mod-state)))
- )
-
- (move-to-column saved-column))
- ))
-
-;;; **************************************************************************
-(defun whole-line-or-region-bind-keys (&optional switch)
- "Bind keys according to `whole-line-or-region-extensions-alist'.
-
-With optional SWITCH, restore keys instead."
- (let ((gmap (current-global-map))
- (ext-alist whole-line-or-region-extensions-alist)
- elem orig wlr map)
- (while ext-alist
- (setq elem (car ext-alist))
- (setq ext-alist (cdr ext-alist))
-
- (setq orig (nth 0 elem))
- (setq wlr (nth 1 elem))
- (setq map (nth 2 elem))
-
- (if switch
- (substitute-key-definition wlr orig (or map gmap))
- (substitute-key-definition orig wlr (or map gmap)))
- )))
-
-;;; **************************************************************************
-(defun whole-line-or-region-restore-keys ()
- "Restore keys according to `whole-line-or-region-extensions-alist'."
- (whole-line-or-region-bind-keys t))
-
-;;; **************************************************************************
-(defun whole-line-or-region-append-to-list (list-var element)
- "Add to the value of LIST-VAR the element ELEMENT if it isn't there yet.
-
-The test for presence of ELEMENT is done with `equal'.
-If ELEMENT is added, it is added at the beginning of the list,
-unless the optional argument APPEND is non-nil, in which case
-ELEMENT is added at the end.
-
-If you want to use `whole-line-or-region-append-to-list' on a variable that is not defined
-until a certain package is loaded, you should put the call to `whole-line-or-region-append-to-list'
-into a hook function that will be run only after loading the package.
-`eval-after-load' provides one way to do this. In some cases
-other hooks, such as major mode hooks, can do the job."
- (set list-var
- (append (symbol-value list-var) (if (listp element) element (list element)))
- ))
-
-;;; **************************************************************************
-;;; ***** we're done
-;;; **************************************************************************
-(provide 'whole-line-or-region)
-(run-hooks 'whole-line-or-region-load-hook)
-
-;;; whole-line-or-region.el ends here
-;;; **************************************************************************
-;;;; ***** EOF ***** EOF ***** EOF ***** EOF ***** EOF *************