From 6f892cb95981d78d72cbecbc4b2b794afbde65af Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Mon, 26 May 2014 22:08:13 -0700 Subject: Better window switching diff --git a/ravi-init-appearance.el b/ravi-init-appearance.el index a028712..b6349af 100644 --- a/ravi-init-appearance.el +++ b/ravi-init-appearance.el @@ -181,7 +181,13 @@ :ensure t ) -(bind-key "M-o" 'other-window) +(use-package ace-window + :bind (("M-o" . ace-window)) + :init + (progn + (setq aw-keys '(?a ?s ?d ?f ?g ?h ?j ?k ?l ?i ?e))) + :ensure t + ) (provide 'ravi-init-appearance) ;;; ravi-init-appearance.el ends here -- cgit v0.10.1 From bd580c768b7a7eaf9cf5ad2da7a3d7d58ba11834 Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Tue, 27 May 2014 07:56:10 -0700 Subject: Handle nested parantheses diff --git a/ravi-init-cpp.el b/ravi-init-cpp.el index 2d47008..1690a91 100644 --- a/ravi-init-cpp.el +++ b/ravi-init-cpp.el @@ -326,7 +326,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:]]*") -- cgit v0.10.1 From 72a3e082b1d067061a93d737a2f6fc6a4440aaa4 Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Sun, 8 Jun 2014 17:06:24 -0700 Subject: Finally fix new frame cursor color problem diff --git a/ravi-init-appearance.el b/ravi-init-appearance.el index b6349af..a0c39ff 100644 --- a/ravi-init-appearance.el +++ b/ravi-init-appearance.el @@ -45,7 +45,7 @@ (setq bell-volume 0) (setq sound-alist nil) -(set-face-background 'cursor "LightSteelBlue1") +(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) -- cgit v0.10.1 From df42da5bb2c9ef48e68122620b94a9d888a37b9a Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Sun, 8 Jun 2014 21:17:59 -0700 Subject: Remove useless files from recentf-list diff --git a/ravi-init-files.el b/ravi-init-files.el index 4410d3d..9c1c8cb 100644 --- a/ravi-init-files.el +++ b/ravi-init-files.el @@ -57,10 +57,15 @@ (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 + (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) -- cgit v0.10.1 From a30584b63f320d4b4a120182fe72ea947b1becc7 Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Mon, 16 Jun 2014 21:50:43 -0700 Subject: Enable popwin-mode by default diff --git a/ravi-init-appearance.el b/ravi-init-appearance.el index a0c39ff..7e8d152 100644 --- a/ravi-init-appearance.el +++ b/ravi-init-appearance.el @@ -169,9 +169,9 @@ (bind-key "C-h a" 'apropos) (use-package popwin - :commands popwin-mode - :config + :init (progn + (popwin-mode 1) (push '("*Pp Eval Output*" :height 15) popwin:special-display-config)) :ensure t ) -- cgit v0.10.1 From c78ec7ffcbda35eca20b55f882386324b2bf1164 Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Fri, 27 Jun 2014 08:51:39 -0700 Subject: Add ace-jump-line-mode with keybinding diff --git a/ravi-init-navigation.el b/ravi-init-navigation.el index c0a5a82..8f06b7f 100644 --- a/ravi-init-navigation.el +++ b/ravi-init-navigation.el @@ -44,7 +44,8 @@ ) (use-package ace-jump-mode - :bind ("M-h" . ace-jump-mode) + :bind (("M-h" . ace-jump-mode) + ("M-H" . ace-jump-line-mode)) :ensure t ) -- cgit v0.10.1 From b43998e615cfff774e8ebeb8499e96422458794a Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Sat, 28 Jun 2014 13:19:19 -0700 Subject: More useful zap-to-char diff --git a/ravi-init-appearance.el b/ravi-init-appearance.el index 7e8d152..2147234 100644 --- a/ravi-init-appearance.el +++ b/ravi-init-appearance.el @@ -99,6 +99,11 @@ (bind-key "" 'newline-and-indent prog-mode-map) (bind-key "" 'newline-and-indent emacs-lisp-mode-map) +;; Zap up to char is more useful than zap-char +(autoload 'zap-up-to-char "misc" "Kill up to, but not including ARGth occurrence of CHAR.") +(bind-key "M-z" 'zap-up-to-char) +(bind-key "M-Z" 'zap-to-char) + ;; Automatic indentation of yanked text (dolist (command '(yank yank-pop)) (eval `(defadvice ,command (after indent-region activate) -- cgit v0.10.1 From 7c4297d2b03adf96df7b411b5865f30327fb9ce2 Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Sat, 28 Jun 2014 13:26:23 -0700 Subject: More sequences with guide-key help diff --git a/ravi-init-appearance.el b/ravi-init-appearance.el index 2147234..f52164a 100644 --- a/ravi-init-appearance.el +++ b/ravi-init-appearance.el @@ -156,6 +156,10 @@ "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 )) (guide-key-mode 1) -- cgit v0.10.1 From 0ac8a5b93928ad57133af8639e5745c51b1e8d59 Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Sat, 28 Jun 2014 13:39:45 -0700 Subject: Less modeline clutter diff --git a/ravi-init-repl.el b/ravi-init-repl.el index fbca1ed..c83dad3 100644 --- a/ravi-init-repl.el +++ b/ravi-init-repl.el @@ -60,7 +60,7 @@ (unbind-key "C-c C-z" repl-toggle-mode-map) (bind-key "" 'rtog/toggle-repl repl-toggle-mode-map) ) - :diminish t + :diminish repl-toggle-mode :ensure t) (provide 'ravi-init-repl) diff --git a/ravi-init-vc.el b/ravi-init-vc.el index 406e05b..1dd0952 100644 --- a/ravi-init-vc.el +++ b/ravi-init-vc.el @@ -43,6 +43,7 @@ ;(fullframe magit-status magit-mode-quit-window :magit-fullscreen nil) (setq magit-restore-window-configuration t) + (diminish 'magit-auto-revert-mode) (use-package vc-git :defer t -- cgit v0.10.1 From 1e07f4169095ae9f8e62c7554a9f553076438a41 Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Sat, 28 Jun 2014 13:53:04 -0700 Subject: Raise region-bindings-mode to higher priority than smartparens diff --git a/ravi-init-navigation.el b/ravi-init-navigation.el index 8f06b7f..36e823b 100644 --- a/ravi-init-navigation.el +++ b/ravi-init-navigation.el @@ -121,6 +121,8 @@ (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 ) -- cgit v0.10.1 From 0ecc73c6b9996e2235d43be0d44288fe7aecc9ec Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Sat, 5 Jul 2014 15:48:24 -0700 Subject: More isearch goodies from EmacsWiki diff --git a/ravi-init-navigation.el b/ravi-init-navigation.el index 36e823b..391be8b 100644 --- a/ravi-init-navigation.el +++ b/ravi-init-navigation.el @@ -262,6 +262,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 "" 'isearch-exit-other-end isearch-mode-map) + ;; Search the web (use-package webjump :bind ("C-x g" . webjump) -- cgit v0.10.1 From 4b59e24822a44d1ce1df091546a251a5bb64d21b Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Sat, 5 Jul 2014 16:16:51 -0700 Subject: More ways to look at git history diff --git a/ravi-init-vc.el b/ravi-init-vc.el index 1dd0952..e4b273e 100644 --- a/ravi-init-vc.el +++ b/ravi-init-vc.el @@ -26,7 +26,8 @@ ;; Git (use-package magit - :bind ("" . magit-status) + :bind (("" . magit-status) + ("C-x v F" . magit-file-log)) :config (progn (setq-default @@ -54,6 +55,7 @@ (diminish 'magit-wip-save-mode) ) ) + ;(after-load 'magit-key-mode ; (require 'magit-svn)) @@ -140,6 +142,12 @@ :ensure t :bind ("C-x v p" . git-messenger:popup-message) ) +(use-package git-timemachine + :ensure t + :bind ("C-x v t" . git-timemachine) + ) +(use-package magit-blame + :bind (("C-x v B" . magit-blame-mode))) ;; Stolen almost entirely from Fuco (Matus Goljer) (use-package ediff -- cgit v0.10.1 From 5e5775741bc886f2ef1c7473c322d52d5c20ec12 Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Sun, 6 Jul 2014 22:01:01 -0700 Subject: Set up mu for email diff --git a/init.el b/init.el index 8f420c2..ece90b3 100644 --- a/init.el +++ b/init.el @@ -124,3 +124,4 @@ (require 'ravi-init-tex) (require 'ravi-init-repl) (require 'ravi-init-dired) +(require 'ravi-init-mu) diff --git a/ravi-init-mu.el b/ravi-init-mu.el new file mode 100644 index 0000000..63d5844 --- /dev/null +++ b/ravi-init-mu.el @@ -0,0 +1,146 @@ +;;; ravi-init-mu.el --- mail + +;; Copyright (C) 2014 + +;; Author: +;; 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 . + +;;; Commentary: + +;; Set up mu4e conditionally +;; - actual account information should be in local.el +;; - requires definitions of ravi/mu4e-account-alist + +;;; Code: + +(when ravi/use-mu-for-email + (use-package mu4e + :load-path ,(ravi/emacs-file "site-lisp/mu/mu4e") + :commands mu4e + :init + (progn + (unless ravi/mu4e-account-alist (error "Email account list not found"))) + :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) + + ;; 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") + + ;; Currently, poll all accounts all the time == to do: fix mail intervals per account + (setq mu4e-get-mail-command (concat (ravi/emacs-file "site-lisp/isync/src/mbsync") " -a -q -q")) + (if (boundp 'ravi/mu4e-update-interval) + (setq mu4e-update-interval ravi/mu4e-update-interval) + (setq mu4e-update-interval 1800)) ; pull every 30 minutes + + ;; User interface + (setq mu4e-html-renderer 'w3m) + (setq mu4e-html2text-command "w3m -T text/html") + (setq mu4e-view-show-images 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 (mu4e-maildirs-extension) ; does not work with mu now + :ensure t + ) + + ;; 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) + + (add-to-list 'smart-tab-disabled-major-modes 'mu4e-compose-mode) + (imagemagick-register-types) + (add-to-list 'Info-default-directory-list (ravi/emacs-file "site-lisp/mu/mu4e")) + ) + ) + ) + +(provide 'ravi-init-mu) +;;; ravi-init-mu.el ends here -- cgit v0.10.1 From eed3dd09cfbccae4e7cb60be636cae3382d98709 Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Tue, 8 Jul 2014 09:46:15 -0700 Subject: Set up defaults and prevent answering to self diff --git a/ravi-init-mu.el b/ravi-init-mu.el index 63d5844..e2a040f 100644 --- a/ravi-init-mu.el +++ b/ravi-init-mu.el @@ -26,12 +26,20 @@ ;;; 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") + (when ravi/use-mu-for-email (use-package mu4e :load-path ,(ravi/emacs-file "site-lisp/mu/mu4e") :commands mu4e :init (progn + (add-to-list 'Info-default-directory-list (ravi/emacs-file "site-lisp/mu/mu4e")) (unless ravi/mu4e-account-alist (error "Email account list not found"))) :config (progn @@ -81,6 +89,11 @@ (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 @@ -98,9 +111,8 @@ ;; Currently, poll all accounts all the time == to do: fix mail intervals per account (setq mu4e-get-mail-command (concat (ravi/emacs-file "site-lisp/isync/src/mbsync") " -a -q -q")) - (if (boundp 'ravi/mu4e-update-interval) - (setq mu4e-update-interval ravi/mu4e-update-interval) - (setq mu4e-update-interval 1800)) ; pull every 30 minutes + (setq mu4e-update-interval ravi/mu4e-update-interval) + (setq mu4e-change-filenames-when-moving t) ;; User interface (setq mu4e-html-renderer 'w3m) @@ -137,7 +149,6 @@ (add-to-list 'smart-tab-disabled-major-modes 'mu4e-compose-mode) (imagemagick-register-types) - (add-to-list 'Info-default-directory-list (ravi/emacs-file "site-lisp/mu/mu4e")) ) ) ) -- cgit v0.10.1 From 713a9d42b4c277df9031cfab14b85f15b5166387 Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Wed, 9 Jul 2014 09:26:17 -0700 Subject: Use correct additional info path diff --git a/ravi-init-mu.el b/ravi-init-mu.el index e2a040f..3514f75 100644 --- a/ravi-init-mu.el +++ b/ravi-init-mu.el @@ -39,7 +39,7 @@ :commands mu4e :init (progn - (add-to-list 'Info-default-directory-list (ravi/emacs-file "site-lisp/mu/mu4e")) + (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"))) :config (progn -- cgit v0.10.1 From f680edd9ad274468c8e3c6c2f586885d488f9f44 Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Wed, 9 Jul 2014 21:05:10 -0700 Subject: Enable file/directory name completion diff --git a/ravi-init-cpp.el b/ravi-init-cpp.el index 1690a91..3163b60 100644 --- a/ravi-init-cpp.el +++ b/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)))) -- cgit v0.10.1 From ac402b4cb60fe54afecdc3888ed8d35e26316245 Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Wed, 9 Jul 2014 21:15:11 -0700 Subject: Keybinding to start email diff --git a/ravi-init-mu.el b/ravi-init-mu.el index 3514f75..f26bcd2 100644 --- a/ravi-init-mu.el +++ b/ravi-init-mu.el @@ -36,7 +36,7 @@ (when ravi/use-mu-for-email (use-package mu4e :load-path ,(ravi/emacs-file "site-lisp/mu/mu4e") - :commands mu4e + :bind (("C-'" . mu4e)) :init (progn (add-to-list 'Info-additional-directory-list (ravi/emacs-file "site-lisp/mu/mu4e")) -- cgit v0.10.1 From 5af7ab8b827c83d1193c2ee867a686d1407b29f3 Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Sun, 13 Jul 2014 21:02:37 -0700 Subject: Different update rates for different accounts diff --git a/ravi-init-mu.el b/ravi-init-mu.el index f26bcd2..53dcbd2 100644 --- a/ravi-init-mu.el +++ b/ravi-init-mu.el @@ -109,7 +109,29 @@ (setq mu4e-mu-binary (ravi/emacs-file "site-lisp/mu/mu/mu")) (setq mu4e-maildir "~/.mail") - ;; Currently, poll all accounts all the time == to do: fix mail intervals per account + ;; 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) -- cgit v0.10.1 From 221aefd7684a856fcc8877014875dec520638126 Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Fri, 19 Sep 2014 21:23:00 -0700 Subject: Better message citation diff --git a/ravi-init-mu.el b/ravi-init-mu.el index 53dcbd2..3a2de1a 100644 --- a/ravi-init-mu.el +++ b/ravi-init-mu.el @@ -153,6 +153,7 @@ ) ;; Allow attaching files from dired + (setq message-citation-line-function 'message-insert-formatted-citation-line) (require 'gnus-dired) ;; make the `gnus-dired-mail-buffers' function also work on ;; message-mode derived modes, such as mu4e-compose-mode -- cgit v0.10.1 From 8122f44f83f16aa5c9b3019618cd664e1da77b15 Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Sun, 28 Sep 2014 20:43:55 -0700 Subject: Move to newer mu diff --git a/site-lisp/mu b/site-lisp/mu index b44be2f..ff25bf1 160000 --- a/site-lisp/mu +++ b/site-lisp/mu @@ -1 +1 @@ -Subproject commit b44be2fcd8cef62871e1a73343033a212b549975 +Subproject commit ff25bf1a2511ae7d125ec34d251a229d3a985858 -- cgit v0.10.1 From df5c0c1cacaf2906c406ba8cd19b6c57f74e139b Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Sat, 18 Oct 2014 21:44:34 -0700 Subject: Add default yasnippet snipper dir to snippet dir list diff --git a/ravi-init-insertion.el b/ravi-init-insertion.el index 3849e3b..2c4e342 100644 --- a/ravi-init-insertion.el +++ b/ravi-init-insertion.el @@ -32,7 +32,7 @@ (progn (setq yas-snippet-dirs `(,(ravi/emacs-file "snippets") - ) + yas-installed-snippets-dir) ) (yas-global-mode 1) ) -- cgit v0.10.1 From e20d4e3edb97b6c3719b9e4d1fe2d9795e06d178 Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Sun, 19 Oct 2014 15:25:47 -0700 Subject: Switch to existing mu4e window if possible diff --git a/ravi-init-mu.el b/ravi-init-mu.el index 3a2de1a..1477629 100644 --- a/ravi-init-mu.el +++ b/ravi-init-mu.el @@ -36,11 +36,23 @@ (when ravi/use-mu-for-email (use-package mu4e :load-path ,(ravi/emacs-file "site-lisp/mu/mu4e") - :bind (("C-'" . 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"))) + (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 -- cgit v0.10.1 From e4de3de683236f76dd9e2c73e8d0c6209db1264d Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Sun, 19 Oct 2014 15:33:03 -0700 Subject: Do not enable signature diff --git a/ravi-init-mu.el b/ravi-init-mu.el index 1477629..d1bc3b4 100644 --- a/ravi-init-mu.el +++ b/ravi-init-mu.el @@ -164,8 +164,9 @@ :ensure t ) - ;; Allow attaching files from dired (setq message-citation-line-function 'message-insert-formatted-citation-line) + (setq mu4e-compose-signature-auto-include nil) + ;; 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 -- cgit v0.10.1 From 8a06ac77a6979520ae98a428e651ce7a2357b367 Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Sun, 2 Nov 2014 13:53:06 -0800 Subject: Simplify throwaway snippets diff --git a/ravi-init-insertion.el b/ravi-init-insertion.el index 2c4e342..8c1e640 100644 --- a/ravi-init-insertion.el +++ b/ravi-init-insertion.el @@ -43,6 +43,12 @@ ;; Wrap around region (setq yas/wrap-around-region t) + + ;; Automatically create throw-away snippets + (use-package auto-yasnippet + :bind (("C-" . aya-create) + ("" . aya-expand)) + :ensure t) ) :ensure t :diminish yas-minor-mode -- cgit v0.10.1 From 5c1da46756e59301996f21cc8026ddb811cf7822 Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Mon, 3 Nov 2014 08:07:46 -0800 Subject: Do not keep old message buffers around diff --git a/ravi-init-mu.el b/ravi-init-mu.el index d1bc3b4..7e74cda 100644 --- a/ravi-init-mu.el +++ b/ravi-init-mu.el @@ -165,6 +165,7 @@ ) (setq message-citation-line-function 'message-insert-formatted-citation-line) + (setq message-kill-buffer-on-exit t) (setq mu4e-compose-signature-auto-include nil) ;; Allow attaching files from dired (require 'gnus-dired) -- cgit v0.10.1 From 0ab3bac82e50b8f1e3de0ab3f1d2510ac519dd7a Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Mon, 3 Nov 2014 08:46:49 -0800 Subject: Start replacement of auto-complete with company-mode diff --git a/ravi-init-cpp.el b/ravi-init-cpp.el index 3163b60..53d52ca 100644 --- a/ravi-init-cpp.el +++ b/ravi-init-cpp.el @@ -144,9 +144,6 @@ (bind-key "C-c p" 'insert-counting-printf c-mode-base-map) - ;(auto-complete-mode 1) - ;(bind-key "" 'ac-complete c-mode-base-map) - (doxymacs-mode 1) (doxymacs-font-lock) diff --git a/ravi-init-insertion.el b/ravi-init-insertion.el index 8c1e640..aea9cee 100644 --- a/ravi-init-insertion.el +++ b/ravi-init-insertion.el @@ -67,35 +67,28 @@ ) ) -;; 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 +(use-package company :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)) - + (add-hook 'after-init-hook 'global-company-mode)) :config (progn - (ac-set-trigger-key "") - (setq ac-use-menu-map t) - - ;(bind-key "A-M-?" 'ac-last-help) - ;(unbind-key "C-s" ac-completing-map) - ) - :ensure t - ) + (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)) + + :ensure t) (provide 'ravi-init-insertion) ;;; ravi-init-insertion.el ends here diff --git a/ravi-init-mu.el b/ravi-init-mu.el index 7e74cda..2be3347 100644 --- a/ravi-init-mu.el +++ b/ravi-init-mu.el @@ -184,7 +184,6 @@ (setq gnus-dired-mail-mode 'mu4e-user-agent) (add-hook 'dired-mode-hook 'turn-on-gnus-dired-mode) - (add-to-list 'smart-tab-disabled-major-modes 'mu4e-compose-mode) (imagemagick-register-types) ) ) diff --git a/ravi-init-python.el b/ravi-init-python.el index 29aae57..1ac8766 100644 --- a/ravi-init-python.el +++ b/ravi-init-python.el @@ -146,7 +146,7 @@ (add-hook 'python-mode-hook 'ravi/python-jedi-hook-installer) ) :ensure t - :disabled nil + :disabled t ; casualty of removing auto-complete ) (use-package sphinx-doc diff --git a/ravi-init-tex.el b/ravi-init-tex.el index 4bb9349..298de5d 100644 --- a/ravi-init-tex.el +++ b/ravi-init-tex.el @@ -43,10 +43,6 @@ ;; 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*}") @@ -154,11 +150,6 @@ starting with \\ and followed by a block of text enclosed in {}." (setq fill-column 100000) - (setq ac-sources - (append '(ac-source-math-unicode ac-source-math-latex ac-source-latex-commands) - ac-sources)) - (auto-complete-mode 1) - (message "LaTeX mode init complete.")) ;; ACUTeX replaces latex-mode-hook with LaTeX-mode-hook (add-hook 'LaTeX-mode-hook 'my-LaTeX-mode-init) -- cgit v0.10.1 From f816cb61c00317e04b756cd9e506ed6dbc377edc Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Sun, 9 Nov 2014 21:52:52 -0800 Subject: Easy fetching of values from dir-locals diff --git a/init.el b/init.el index ece90b3..a4d51da 100644 --- a/init.el +++ b/init.el @@ -109,6 +109,15 @@ :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-ido) (require 'ravi-init-marks) (require 'ravi-init-appearance) -- cgit v0.10.1 From 1fc2772c4da507e4f3200dec8db390a0be7f754a Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Sun, 9 Nov 2014 21:53:24 -0800 Subject: Hungry delete everywhere The commented out line is the preferred version once a newer version of the package is available from MELPA. diff --git a/ravi-init-appearance.el b/ravi-init-appearance.el index f52164a..75a8305 100644 --- a/ravi-init-appearance.el +++ b/ravi-init-appearance.el @@ -87,6 +87,25 @@ ;; 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) + ;; Easily navigate sillycased words ;(global-subword-mode 1) -- cgit v0.10.1 From 070af4e075264d6c1f1e26d1a7a5a811d0d5dad8 Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Sun, 9 Nov 2014 21:54:24 -0800 Subject: More company-mode setup: c-headers and yasnippet diff --git a/ravi-init-insertion.el b/ravi-init-insertion.el index aea9cee..4bb9fc5 100644 --- a/ravi-init-insertion.el +++ b/ravi-init-insertion.el @@ -86,7 +86,33 @@ (if (company-manual-begin) (company-complete-common) (indent-according-to-mode))) - (bind-key "\t" 'ravi/complete-or-indent)) + (bind-key "\t" 'ravi/complete-or-indent) + + (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) + + ;; 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) + (bind-key "" 'company-yasnippet)) :ensure t) -- cgit v0.10.1 From 23573722da8832fc785db6e8fd66759355da6b94 Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Sun, 9 Nov 2014 21:55:05 -0800 Subject: Use ag for faster search if we can diff --git a/ravi-init-navigation.el b/ravi-init-navigation.el index 391be8b..6e457bb 100644 --- a/ravi-init-navigation.el +++ b/ravi-init-navigation.el @@ -221,8 +221,19 @@ :ensure t ) -(use-package grep - :bind (("H-g" . grep))) +(if (executable-find "ag") + ;; Prefer the silver-searcher if available + (use-package ag + :bind (("H-g" . ag) + ("H-G" . ag-files)) + :config + (progn + (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) -- cgit v0.10.1 From 11706907dfc5abffe11ffc029438f00a93d53989 Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Tue, 11 Nov 2014 20:59:15 -0800 Subject: Unfill from Sacha Chua diff --git a/ravi-init-appearance.el b/ravi-init-appearance.el index 75a8305..caff195 100644 --- a/ravi-init-appearance.el +++ b/ravi-init-appearance.el @@ -106,6 +106,16 @@ Delete all whitespace on a successive key press." ) :ensure t) +(setq sentence-end-double-space nil) +(defun sacha/unfill-paragraph (&optional region) + "Takes a multi-line paragraph and makes it into a single line of text." + (interactive (progn + (barf-if-buffer-read-only) + (list t))) + (let ((fill-column (point-max))) + (fill-paragraph nil region))) +(bind-key "M-Q" 'sacha/unfill-paragraph) + ;; Easily navigate sillycased words ;(global-subword-mode 1) -- cgit v0.10.1 From 7215171524778f5f80aae5fb9c5b805cee2e767c Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Thu, 20 Nov 2014 08:17:55 -0800 Subject: Configure ag to be more grep-like diff --git a/ravi-init-navigation.el b/ravi-init-navigation.el index 6e457bb..875f805 100644 --- a/ravi-init-navigation.el +++ b/ravi-init-navigation.el @@ -228,6 +228,8 @@ ("H-G" . ag-files)) :config (progn + (setq ag-highlight-search t) + (setq ag-reuse-buffers t) (use-package wgrep-ag :ensure t)) :ensure t) -- cgit v0.10.1 From 0515b77ef4f5c5cb3db05a5c76d009bb6e43be88 Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Thu, 20 Nov 2014 08:18:16 -0800 Subject: Try out ace-jump-buffer diff --git a/ravi-ergodox-mode.el b/ravi-ergodox-mode.el index 78221ab..8e05c5a 100644 --- a/ravi-ergodox-mode.el +++ b/ravi-ergodox-mode.el @@ -58,7 +58,7 @@ 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 "") 'ff-find-other-file) -(define-key ravi-ergodox-mode-map (kbd "") 'ido-switch-buffer) +;(define-key ravi-ergodox-mode-map (kbd "") 'ido-switch-buffer) (define-key ravi-ergodox-mode-map (kbd "") 'ido-find-file) (defun ravi-ergodox-mode-enable () diff --git a/ravi-init-ido.el b/ravi-init-ido.el index 9d20034..dc4b6a1 100644 --- a/ravi-init-ido.el +++ b/ravi-init-ido.el @@ -51,6 +51,15 @@ ) ) +(use-package ace-jump-buffer + :bind (("" . ace-jump-buffer) + ("C-" . ace-jump-buffer-other-window) + ("S-" . ace-jump-projectile-buffers)) + :config + (progn + (bind-key "M-" 'ido-switch-buffer)) + :ensure t) + ;;;_ , ido (use-package ido -- cgit v0.10.1 From ff55ada1317d11219c015052b6cd423a56f83cad Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Thu, 27 Nov 2014 14:53:15 -0800 Subject: Commenting fixes Use comment-dwim-2 and do not set comment-style globally in header insertion. diff --git a/ravi-init-appearance.el b/ravi-init-appearance.el index caff195..8c5b173 100644 --- a/ravi-init-appearance.el +++ b/ravi-init-appearance.el @@ -147,6 +147,10 @@ Delete all whitespace on a successive key press." (let ((mark-even-if-inactive transient-mark-mode)) (indent-region (region-beginning) (region-end) nil)))))) +(use-package comment-dwim-2 + :bind (("M-;" . comment-dwim-2)) + :ensure t) + ;; Keep my navigation simple (setq line-move-visual nil) diff --git a/ravi-init-cpp.el b/ravi-init-cpp.el index 53d52ca..62e1563 100644 --- a/ravi-init-cpp.el +++ b/ravi-init-cpp.el @@ -255,9 +255,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)) @@ -279,9 +279,9 @@ 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") -- cgit v0.10.1 From b8dacf7bb25b0026fb9a280b4c9fdc9d7c5a1226 Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Sat, 13 Dec 2014 17:14:38 -0800 Subject: Remove annoying c cleanups diff --git a/ravi-init-cpp.el b/ravi-init-cpp.el index 62e1563..4ae7910 100644 --- a/ravi-init-cpp.el +++ b/ravi-init-cpp.el @@ -172,8 +172,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)))) -- cgit v0.10.1 From 9d0b429f55558fe71a4c8618a656cbc7ee8eaee2 Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Sat, 13 Dec 2014 17:15:50 -0800 Subject: Bye bye, smart-tab-mode relic diff --git a/ravi-init-python.el b/ravi-init-python.el index 1ac8766..6edc232 100644 --- a/ravi-init-python.el +++ b/ravi-init-python.el @@ -56,7 +56,8 @@ (setq python-indent-offset 4) ) - (add-to-list 'smart-tab-disabled-major-modes 'inferior-python-mode) + ;; 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 () -- cgit v0.10.1 From ee759ac6b364f752e59c6864ebbd7bb2d30ae481 Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Sat, 13 Dec 2014 21:19:22 -0800 Subject: Try to open maximized if possible diff --git a/init.el b/init.el index a4d51da..6a70734 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") -- cgit v0.10.1 From 8f54ff1365ffa39654348a1bcd1236a618844bef Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Sat, 13 Dec 2014 21:31:16 -0800 Subject: Almost always, I need to switch to newly split window diff --git a/ravi-init-appearance.el b/ravi-init-appearance.el index 8c5b173..24c2e9a 100644 --- a/ravi-init-appearance.el +++ b/ravi-init-appearance.el @@ -231,5 +231,17 @@ Delete all whitespace on a successive key press." :ensure t ) +(defun ravi/split-window-vertically-and-switch () + (interactive) + (split-window-vertically) + (other-window 1)) +(bind-key "C-x 2" 'ravi/split-window-vertically-and-switch) + +(defun ravi/split-window-horizontally-and-switch () + (interactive) + (split-window-horizontally) + (other-window 1)) +(bind-key "C-x 3" 'ravi/split-window-horizontally-and-switch) + (provide 'ravi-init-appearance) ;;; ravi-init-appearance.el ends here -- cgit v0.10.1 From 92016421ef6d1ca263eb595d372e1c1f79517bfa Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Sat, 13 Dec 2014 21:46:59 -0800 Subject: Disable god-mode since I never use it diff --git a/ravi-init-navigation.el b/ravi-init-navigation.el index 875f805..91755a4 100644 --- a/ravi-init-navigation.el +++ b/ravi-init-navigation.el @@ -105,6 +105,7 @@ (use-package god-mode :bind (("" . god-local-mode)) + :disabled t ; less useful than I thought :ensure t ) -- cgit v0.10.1 From a5f22374cd818d6a1a681ef1d463317624820a15 Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Sun, 14 Dec 2014 20:01:39 -0800 Subject: Make split window even more useful: switch to next buffer diff --git a/ravi-init-appearance.el b/ravi-init-appearance.el index 24c2e9a..e847d73 100644 --- a/ravi-init-appearance.el +++ b/ravi-init-appearance.el @@ -231,16 +231,18 @@ Delete all whitespace on a successive key press." :ensure t ) -(defun ravi/split-window-vertically-and-switch () - (interactive) - (split-window-vertically) - (other-window 1)) +(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 () - (interactive) - (split-window-horizontally) - (other-window 1)) +(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) (provide 'ravi-init-appearance) -- cgit v0.10.1 From 9c8c3b81c2816d0673b347166f0be2fd860472db Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Sun, 14 Dec 2014 20:07:37 -0800 Subject: Don't need as much hand-holding now diff --git a/ravi-init-function.el b/ravi-init-function.el index b4dc744..671d45c 100644 --- a/ravi-init-function.el +++ b/ravi-init-function.el @@ -1,9 +1,9 @@ ;;; ravi-init-function.el --- functionality -;; Copyright (C) 2013 +;; Copyright (C) 2013 ;; Author: -;; Keywords: +;; 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 @@ -25,16 +25,11 @@ ;;; 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 disabled-command-function nil) ;(setq enable-recursive-minibuffers t) ;; Use emacsclient from other programs -(server-start) +(unless (server-running-p) (server-start)) (provide 'ravi-init-function) ;;; ravi-init-function.el ends here -- cgit v0.10.1 From 5a1d32fef21a373950c1213235f162081d7f9af4 Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Sun, 14 Dec 2014 20:17:32 -0800 Subject: Diminish modeline clutter even more diff --git a/init.el b/init.el index 6a70734..85dda61 100644 --- a/init.el +++ b/init.el @@ -98,7 +98,9 @@ (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 "" 'ido-find-file) diff --git a/ravi-init-appearance.el b/ravi-init-appearance.el index e847d73..23b50c0 100644 --- a/ravi-init-appearance.el +++ b/ravi-init-appearance.el @@ -79,6 +79,8 @@ :diminish global-whitespace-mode ) +(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. diff --git a/ravi-init-insertion.el b/ravi-init-insertion.el index 4bb9fc5..c347853 100644 --- a/ravi-init-insertion.el +++ b/ravi-init-insertion.el @@ -114,6 +114,7 @@ (require 'company-yasnippet) (bind-key "" 'company-yasnippet)) + :diminish t :ensure t) (provide 'ravi-init-insertion) -- cgit v0.10.1 From d52cca0fae889d43e4d2ca017d64224afde9d391 Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Sun, 14 Dec 2014 21:27:32 -0800 Subject: Initial support for web development diff --git a/init.el b/init.el index 85dda61..0f5391c 100644 --- a/init.el +++ b/init.el @@ -140,3 +140,4 @@ (require 'ravi-init-repl) (require 'ravi-init-dired) (require 'ravi-init-mu) +(require 'ravi-init-web) diff --git a/ravi-init-web.el b/ravi-init-web.el new file mode 100644 index 0000000..69948e5 --- /dev/null +++ b/ravi-init-web.el @@ -0,0 +1,82 @@ +;;; ravi-init-web.el --- Web development -*- lexical-binding: t; -*- + +;; Copyright (C) 2014 + +;; Author: +;; 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 . + +;;; Commentary: + +;; Web development tools + +;;; Code: + +;; 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 () + (setq js2-basic-offset 2)) + (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)) + (add-hook 'web-mode-hook 'ravi/web-mode-sp-hook) + (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)) + + ;; 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) + +(provide 'ravi-init-web) +;;; ravi-init-web.el ends here -- cgit v0.10.1 From ad4bbe8ae28aa88707e4434a8aeaee4803c09da6 Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Sun, 14 Dec 2014 21:44:34 -0800 Subject: The cognitive load of ace-jump-buffer is too high diff --git a/ravi-ergodox-mode.el b/ravi-ergodox-mode.el index 8e05c5a..78221ab 100644 --- a/ravi-ergodox-mode.el +++ b/ravi-ergodox-mode.el @@ -58,7 +58,7 @@ 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 "") 'ff-find-other-file) -;(define-key ravi-ergodox-mode-map (kbd "") 'ido-switch-buffer) +(define-key ravi-ergodox-mode-map (kbd "") 'ido-switch-buffer) (define-key ravi-ergodox-mode-map (kbd "") 'ido-find-file) (defun ravi-ergodox-mode-enable () diff --git a/ravi-init-ido.el b/ravi-init-ido.el index dc4b6a1..e99a5d8 100644 --- a/ravi-init-ido.el +++ b/ravi-init-ido.el @@ -52,12 +52,12 @@ ) (use-package ace-jump-buffer - :bind (("" . ace-jump-buffer) + :bind (("M-" . ace-jump-buffer) ("C-" . ace-jump-buffer-other-window) ("S-" . ace-jump-projectile-buffers)) - :config - (progn - (bind-key "M-" 'ido-switch-buffer)) + ;; :config + ;; (progn + ;; (bind-key "M-" 'ido-switch-buffer)) :ensure t) ;;;_ , ido -- cgit v0.10.1 From 63b9e018d9765f79069a4716e3a9b7b2e8bcdf0c Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Sun, 4 Jan 2015 21:57:05 -0800 Subject: Try helm to see whether I like it diff --git a/init.el b/init.el index 0f5391c..2dc9598 100644 --- a/init.el +++ b/init.el @@ -82,6 +82,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")) ) @@ -103,8 +106,13 @@ (diminish 'ravi-ergodox-mode)) (progn ;; Temporary key-bindings - (bind-key "" 'ido-find-file) - (bind-key "" 'ido-switch-buffer) + (if (and (boundp 'ravi/use-helm-instead-of-ido) ravi/use-helm-instead-of-ido) + (progn + (bind-key "" 'helm-find-files) + (bind-key "" 'helm-mini)) + (progn + (bind-key "" 'ido-find-file) + (bind-key "" 'ido-switch-buffer))) (bind-key "" 'undo-tree-undo))) (use-package keyadvice @@ -125,6 +133,7 @@ (set varname (append basic-var (symbol-value hack-varname)))))) (require 'ravi-init-ido) +(require 'ravi-init-helm) (require 'ravi-init-marks) (require 'ravi-init-appearance) (require 'ravi-init-files) diff --git a/ravi-ergodox-mode.el b/ravi-ergodox-mode.el index 78221ab..8e1c2e8 100644 --- a/ravi-ergodox-mode.el +++ b/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 "") 'ff-find-other-file) -(define-key ravi-ergodox-mode-map (kbd "") 'ido-switch-buffer) -(define-key ravi-ergodox-mode-map (kbd "") '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 "") 'helm-mini) + (define-key ravi-ergodox-mode-map (kbd "") 'helm-find-files)) + (progn + (define-key ravi-ergodox-mode-map (kbd "") 'ido-switch-buffer) + (define-key ravi-ergodox-mode-map (kbd "") 'ido-find-file))) (defun ravi-ergodox-mode-enable () "Turn on ergodox bindings mode." diff --git a/ravi-init-appearance.el b/ravi-init-appearance.el index 23b50c0..16730a8 100644 --- a/ravi-init-appearance.el +++ b/ravi-init-appearance.el @@ -196,6 +196,9 @@ Delete all whitespace on a successive key press." "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 "")) + (guide-key-mode 1) (use-package guide-key-tip diff --git a/ravi-init-files.el b/ravi-init-files.el index 9c1c8cb..44d1683 100644 --- a/ravi-init-files.el +++ b/ravi-init-files.el @@ -130,7 +130,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/ravi-init-helm.el b/ravi-init-helm.el new file mode 100644 index 0000000..c09595d --- /dev/null +++ b/ravi-init-helm.el @@ -0,0 +1,86 @@ +;;; ravi-init-helm.el --- helm initialization -*- lexical-binding: t; -*- + +;; Copyright (C) 2015 + +;; Author: +;; 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 . + +;;; 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 (("" . helm-command-prefix) + ("M-x" . helm-M-x) + ("" . helm-mini) + ("" . 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 "" 'helm-execute-persistent-action helm-map) + (bind-key "H-" 'helm-select-action helm-map) + + (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-from-all-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) + + (use-package helm-descbinds + :bind (("C-h b" . helm-descbinds)) + :ensure t)) + :if ravi/use-helm-instead-of-ido + :diminish helm-mode + :ensure t) + +(provide 'ravi-init-helm) +;;; ravi-init-helm.el ends here diff --git a/ravi-init-ido.el b/ravi-init-ido.el index e99a5d8..7aec0ce 100644 --- a/ravi-init-ido.el +++ b/ravi-init-ido.el @@ -68,6 +68,7 @@ ido-selected ido-final-text ido-show-confirm-message) + :if (not ravi/use-helm-instead-of-ido) :init (ido-mode 1) @@ -155,6 +156,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/ravi-init-marks.el b/ravi-init-marks.el index 345cead..4288b6b 100644 --- a/ravi-init-marks.el +++ b/ravi-init-marks.el @@ -71,6 +71,7 @@ This is the same as using \\[set-mark-command] with the prefix argument." (use-package browse-kill-ring :init (browse-kill-ring-default-keybindings) :ensure t + :if (not ravi/use-helm-instead-of-ido) ) (provide 'ravi-init-marks) -- cgit v0.10.1 From 98347158813947d9f364b0a4ac361a0f46676e02 Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Wed, 7 Jan 2015 21:27:45 -0800 Subject: Use helm interface for ag diff --git a/ravi-init-helm.el b/ravi-init-helm.el index c09595d..2a527a4 100644 --- a/ravi-init-helm.el +++ b/ravi-init-helm.el @@ -75,6 +75,9 @@ ) :ensure t) + (use-package helm-ag + :ensure t) + (use-package helm-descbinds :bind (("C-h b" . helm-descbinds)) :ensure t)) -- cgit v0.10.1 From c6998021f6202e7bc22691ac18bf105f8da991f8 Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Thu, 8 Jan 2015 08:08:48 -0800 Subject: More efficient isearch/ace-jump/swoop diff --git a/ravi-init-navigation.el b/ravi-init-navigation.el index 91755a4..edb9e86 100644 --- a/ravi-init-navigation.el +++ b/ravi-init-navigation.el @@ -49,6 +49,12 @@ :ensure t ) +(use-package ace-isearch + :config + (progn + (global-ace-isearch-mode +1)) + :ensure t) + (use-package jump-char :bind (("M-m" . jump-char-forward)) :ensure t -- cgit v0.10.1 From ab39fb98a7a7a116427961e93a46f3738cb27935 Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Thu, 8 Jan 2015 08:18:06 -0800 Subject: Even better automatic indentation on newlines diff --git a/ravi-init-appearance.el b/ravi-init-appearance.el index 16730a8..c227b99 100644 --- a/ravi-init-appearance.el +++ b/ravi-init-appearance.el @@ -127,8 +127,13 @@ Delete all whitespace on a successive key press." ) ;; Enable automatic indentation, if possible -(bind-key "" 'newline-and-indent prog-mode-map) -(bind-key "" 'newline-and-indent emacs-lisp-mode-map) +(use-package smart-newline + :commands (smart-newline) + :init + (progn + (bind-key "" 'smart-newline prog-mode-map) + (bind-key "" 'smart-newline emacs-lisp-mode-map)) + :ensure t) ;; Zap up to char is more useful than zap-char (autoload 'zap-up-to-char "misc" "Kill up to, but not including ARGth occurrence of CHAR.") -- cgit v0.10.1 From e6634c32069c4b384bbaf2888f9f1c5e2a379ddd Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Thu, 8 Jan 2015 08:38:01 -0800 Subject: Better case toggling diff --git a/ravi-init-appearance.el b/ravi-init-appearance.el index c227b99..8ed039a 100644 --- a/ravi-init-appearance.el +++ b/ravi-init-appearance.el @@ -135,6 +135,56 @@ Delete all whitespace on a successive key press." (bind-key "" '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) + ;; Zap up to char is more useful than zap-char (autoload 'zap-up-to-char "misc" "Kill up to, but not including ARGth occurrence of CHAR.") (bind-key "M-z" 'zap-up-to-char) -- cgit v0.10.1 From 9f2026b2b64f78fab284ef2a32755a9416e1f08b Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Thu, 8 Jan 2015 08:47:15 -0800 Subject: Better unicode default font Fedora package gdouros-symbola-fonts diff --git a/init.el b/init.el index 2dc9598..18c060f 100644 --- a/init.el +++ b/init.el @@ -25,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 -- cgit v0.10.1 From 7ecfa4342e27a5c0f7d0690cf1b27a59ba84f0a8 Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Mon, 26 Jan 2015 09:37:03 -0800 Subject: Emmet mode and smartparens in web-mode diff --git a/ravi-init-web.el b/ravi-init-web.el index 69948e5..b845c0e 100644 --- a/ravi-init-web.el +++ b/ravi-init-web.el @@ -24,6 +24,19 @@ ;;; 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 t) + ;; Javascript (use-package js2-mode :mode (("\\.js$" . js2-mode) @@ -40,6 +53,7 @@ :ensure t) (defun ravi/js2-mode-hook () + (emmet-mode) (setq js2-basic-offset 2)) (add-hook 'js2-mode-hook 'ravi/js2-mode-hook)) :ensure t @@ -60,8 +74,12 @@ ;; Make it work with smartparens (defun ravi/web-mode-sp-hook () - (setq web-mode-enable-auto-pairing nil)) + (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) + (require 'web-mode-expansions) ; do not know why this is not automatically done (defun sp-web-mode-is-code-context (id action context) (when (and (eq action 'insert) @@ -76,6 +94,7 @@ (setq web-mode-code-indent-offset 2) (setq web-mode-enable-part-face t) ) + :ensure t) (provide 'ravi-init-web) -- cgit v0.10.1 From ebba54241105a78479b3438afcefa39cdbc35323 Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Mon, 2 Feb 2015 09:14:04 -0800 Subject: Make helm-swoop and helm-descbinds work before helm is loaded diff --git a/ravi-init-helm.el b/ravi-init-helm.el index 2a527a4..700e120 100644 --- a/ravi-init-helm.el +++ b/ravi-init-helm.el @@ -53,37 +53,37 @@ (bind-key "" 'helm-execute-persistent-action helm-map) (bind-key "H-" 'helm-select-action helm-map) - (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-from-all-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) - (use-package helm-ag - :ensure t) - - (use-package helm-descbinds - :bind (("C-h b" . helm-descbinds)) :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) + +(use-package helm-descbinds + :bind (("C-h b" . helm-descbinds)) + :ensure t) + (provide 'ravi-init-helm) ;;; ravi-init-helm.el ends here -- cgit v0.10.1 From 58dfdefa78eb100dd53e3b6c817ddddafffb50cd Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Mon, 2 Feb 2015 09:14:38 -0800 Subject: I type too slow and run into ace-jump unexpectedly diff --git a/ravi-init-navigation.el b/ravi-init-navigation.el index edb9e86..e239150 100644 --- a/ravi-init-navigation.el +++ b/ravi-init-navigation.el @@ -52,6 +52,7 @@ (use-package ace-isearch :config (progn + (setq ace-isearch-use-ace-jump nil) ; prefer dedicated key for ace-jump (global-ace-isearch-mode +1)) :ensure t) -- cgit v0.10.1 From 1e17be3ccc50f0b80234062837516359f1b104da Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Mon, 2 Feb 2015 09:15:29 -0800 Subject: Initialize expand region as soon as possible This is because expand-region sets up a lot of autoloads for different modes, which gets messed up when expand-region is loaded on demand after these modes. diff --git a/ravi-init-navigation.el b/ravi-init-navigation.el index e239150..6e4deb7 100644 --- a/ravi-init-navigation.el +++ b/ravi-init-navigation.el @@ -67,7 +67,10 @@ ) (use-package expand-region - :bind ("C-=" . er/expand-region) + :config + (progn + (bind-key "C-=" 'er/expand-region)) + :idle (require 'expand-region) :ensure t ) diff --git a/ravi-init-web.el b/ravi-init-web.el index b845c0e..13dd758 100644 --- a/ravi-init-web.el +++ b/ravi-init-web.el @@ -79,7 +79,6 @@ (sp-use-smartparens-bindings)) (add-hook 'web-mode-hook 'ravi/web-mode-sp-hook) (add-hook 'web-mode-hook 'emmet-mode) - (require 'web-mode-expansions) ; do not know why this is not automatically done (defun sp-web-mode-is-code-context (id action context) (when (and (eq action 'insert) -- cgit v0.10.1 From d77dc5d02a6b07235c44b976b0fba2fa0688f224 Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Mon, 9 Feb 2015 09:36:13 -0800 Subject: More company mode improvements diff --git a/ravi-init-insertion.el b/ravi-init-insertion.el index c347853..b373dff 100644 --- a/ravi-init-insertion.el +++ b/ravi-init-insertion.el @@ -106,6 +106,16 @@ ) :ensure t) + (use-package company-quickhelp + :config + (company-quickhelp-mode 1) + :ensure t) + + (use-package company-statistics + :config + (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 -- cgit v0.10.1 From a315e3eddcabaa8d210d3e3cb8e8dffd18eb959b Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Mon, 9 Feb 2015 09:36:33 -0800 Subject: Better zap-to-char diff --git a/ravi-init-appearance.el b/ravi-init-appearance.el index 8ed039a..44fb30f 100644 --- a/ravi-init-appearance.el +++ b/ravi-init-appearance.el @@ -186,9 +186,10 @@ Delete all whitespace on a successive key press." (bind-key "M-l" 'oremacs/upcase-word-toggle) ;; Zap up to char is more useful than zap-char -(autoload 'zap-up-to-char "misc" "Kill up to, but not including ARGth occurrence of CHAR.") -(bind-key "M-z" 'zap-up-to-char) -(bind-key "M-Z" 'zap-to-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)) -- cgit v0.10.1 From 5e690d128bc8fe08d4c895807bf3971ae22afac5 Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Thu, 12 Feb 2015 20:04:47 -0800 Subject: Do not change whitespace automatically everywhere diff --git a/ravi-init-appearance.el b/ravi-init-appearance.el index 44fb30f..035dc1d 100644 --- a/ravi-init-appearance.el +++ b/ravi-init-appearance.el @@ -72,13 +72,18 @@ (setq whitespace-style '(face trailing indentation tabs)) :config (progn - (global-whitespace-mode 1) - (add-hook 'before-save-hook 'whitespace-cleanup) - ) + (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. -- cgit v0.10.1 From b93a115ea08bab1a3db8ed42c397738a2df8ed32 Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Thu, 12 Feb 2015 20:05:20 -0800 Subject: Move statistics file and diminish properly diff --git a/ravi-init-insertion.el b/ravi-init-insertion.el index b373dff..8ce47cb 100644 --- a/ravi-init-insertion.el +++ b/ravi-init-insertion.el @@ -112,8 +112,12 @@ :ensure t) (use-package company-statistics + :init + (setq company-statistics-file (expand-file-name "company-statistics-cache.el" + (ravi/emacs-file "past"))) :config - (company-statistics-mode) + (progn + (company-statistics-mode)) :ensure t) ;; Get rid of company-semantic as it interferes with clang-based backends @@ -124,7 +128,7 @@ (require 'company-yasnippet) (bind-key "" 'company-yasnippet)) - :diminish t + :diminish company-mode :ensure t) (provide 'ravi-init-insertion) -- cgit v0.10.1 From b0835e3a63dfdbed72461de80cd8c0e679f83219 Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Sun, 1 Mar 2015 22:10:08 -0800 Subject: Explicit keybinding for xdg-open diff --git a/ravi-init-dired.el b/ravi-init-dired.el index 8db82f9..51cacb8 100644 --- a/ravi-init-dired.el +++ b/ravi-init-dired.el @@ -115,8 +115,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 -- cgit v0.10.1 From 13919f123f3009340c39c2029ba599e60c193ca6 Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Sun, 1 Mar 2015 22:10:50 -0800 Subject: Extra autocompletion for LaTeX diff --git a/ravi-init-tex.el b/ravi-init-tex.el index 298de5d..e61cac4 100644 --- a/ravi-init-tex.el +++ b/ravi-init-tex.el @@ -49,7 +49,7 @@ (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))) @@ -97,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) @@ -126,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)))) -- cgit v0.10.1 From c95c7232c3981110c1b8b1efb0d3a397c4e55c27 Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Mon, 16 Mar 2015 11:38:48 -0700 Subject: Tex/LaTeX changes - set fill column correctly - remove keyadvice since it never worked - add XeLaTeX support - do not auto revert tex output; it only makes sense manually diff --git a/init.el b/init.el index 18c060f..973d04b 100644 --- a/init.el +++ b/init.el @@ -118,10 +118,6 @@ (bind-key "" 'ido-switch-buffer))) (bind-key "" 'undo-tree-undo))) -(use-package keyadvice - :load-path ,(ravi/emacs-file "site-lisp/keyadvice") - ) - (use-package free-keys :ensure t :commands free-keys) diff --git a/ravi-init-files.el b/ravi-init-files.el index 44d1683..96d4dc5 100644 --- a/ravi-init-files.el +++ b/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 diff --git a/ravi-init-tex.el b/ravi-init-tex.el index e61cac4..d7725e9 100644 --- a/ravi-init-tex.el +++ b/ravi-init-tex.el @@ -164,26 +164,24 @@ 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) (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)))) + )) ) ) -- cgit v0.10.1 From 44fc78e2eeb38576b73956ed1be64a78381a16a5 Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Mon, 16 Mar 2015 11:58:49 -0700 Subject: Make more use of helm diff --git a/ravi-ergodox-mode.el b/ravi-ergodox-mode.el index 8e1c2e8..e393a39 100644 --- a/ravi-ergodox-mode.el +++ b/ravi-ergodox-mode.el @@ -60,8 +60,8 @@ Each function in the list receive no argument." (define-key ravi-ergodox-mode-map (kbd "") 'ff-find-other-file) (if (and (boundp 'ravi/use-helm-instead-of-ido) ravi/use-helm-instead-of-ido) (progn - (define-key ravi-ergodox-mode-map (kbd "") 'helm-mini) - (define-key ravi-ergodox-mode-map (kbd "") 'helm-find-files)) + (define-key ravi-ergodox-mode-map (kbd "") 'helm-multi-files) + (define-key ravi-ergodox-mode-map (kbd "") 'helm-locate)) (progn (define-key ravi-ergodox-mode-map (kbd "") 'ido-switch-buffer) (define-key ravi-ergodox-mode-map (kbd "") 'ido-find-file))) diff --git a/ravi-init-helm.el b/ravi-init-helm.el index 700e120..5ff7f9d 100644 --- a/ravi-init-helm.el +++ b/ravi-init-helm.el @@ -28,8 +28,8 @@ (use-package helm :bind (("" . helm-command-prefix) ("M-x" . helm-M-x) - ("" . helm-mini) - ("" . helm-find-files) + ("" . helm-multi-files) + ("" . helm-locate) ("M-y" . helm-show-kill-ring) ("H-`" . helm-all-mark-rings)) :init -- cgit v0.10.1 From 1a6dcba31616ead152aea297430024b48d8833fc Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Mon, 16 Mar 2015 12:48:21 -0700 Subject: Update mu4e and have another attempt at fixing the citation line diff --git a/ravi-init-mu.el b/ravi-init-mu.el index 2be3347..66b9631 100644 --- a/ravi-init-mu.el +++ b/ravi-init-mu.el @@ -33,6 +33,9 @@ (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 ,(ravi/emacs-file "site-lisp/mu/mu4e") diff --git a/site-lisp/mu b/site-lisp/mu index ff25bf1..33804f6 160000 --- a/site-lisp/mu +++ b/site-lisp/mu @@ -1 +1 @@ -Subproject commit ff25bf1a2511ae7d125ec34d251a229d3a985858 +Subproject commit 33804f63d852dc222050c9e606059138d5e4557a -- cgit v0.10.1 From b15d1c09836007f29158905f99316b25bb1bf9f5 Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Mon, 16 Mar 2015 21:11:02 -0700 Subject: Try to follow vim-like navigation diff --git a/ravi-init-navigation.el b/ravi-init-navigation.el index 6e4deb7..9a7da61 100644 --- a/ravi-init-navigation.el +++ b/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) -- cgit v0.10.1 From b94602dccfa28b997b1fc1f2e0373d997f4b95ce Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Mon, 16 Mar 2015 21:11:37 -0700 Subject: Upgrade to use-package 2.0 Fix changed semantics for init and for load-path diff --git a/ravi-init-cpp.el b/ravi-init-cpp.el index 4ae7910..5fe9e8f 100644 --- a/ravi-init-cpp.el +++ b/ravi-init-cpp.el @@ -98,8 +98,8 @@ :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 @@ -133,6 +133,11 @@ (indent-according-to-mode) (forward-line)) + ) + + :config + (progn + (defun my-c-mode-common-hook () (hs-minor-mode 1) (hs-hide-initial-comment-block) @@ -147,7 +152,7 @@ (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 "" 'c-context-line-break c-mode-base-map) (unbind-key "M-j" c-mode-base-map) @@ -285,21 +290,12 @@ this to 3 makes header-protection define KIG_MISC_NEWTYPE_H for a file named (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") diff --git a/ravi-init-dired.el b/ravi-init-dired.el index 51cacb8..0c8fab2 100644 --- a/ravi-init-dired.el +++ b/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")) diff --git a/ravi-init-files.el b/ravi-init-files.el index 96d4dc5..9ac482d 100644 --- a/ravi-init-files.el +++ b/ravi-init-files.el @@ -63,6 +63,9 @@ (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$") diff --git a/ravi-init-ido.el b/ravi-init-ido.el index 7aec0ce..93af3e6 100644 --- a/ravi-init-ido.el +++ b/ravi-init-ido.el @@ -75,13 +75,13 @@ :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) @@ -94,13 +94,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 ) diff --git a/ravi-init-insertion.el b/ravi-init-insertion.el index 8ce47cb..65ff9db 100644 --- a/ravi-init-insertion.el +++ b/ravi-init-insertion.el @@ -34,10 +34,11 @@ `(,(ravi/emacs-file "snippets") yas-installed-snippets-dir) ) - (yas-global-mode 1) ) :config (progn + (yas-global-mode 1) + ;; No dropdowns (setq yas/prompt-functions '(yas/ido-prompt yas/completing-prompt)) diff --git a/ravi-init-marks.el b/ravi-init-marks.el index 4288b6b..803b2cb 100644 --- a/ravi-init-marks.el +++ b/ravi-init-marks.el @@ -69,7 +69,7 @@ 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) ) diff --git a/ravi-init-mu.el b/ravi-init-mu.el index 66b9631..b123da2 100644 --- a/ravi-init-mu.el +++ b/ravi-init-mu.el @@ -38,7 +38,7 @@ (when ravi/use-mu-for-email (use-package mu4e - :load-path ,(ravi/emacs-file "site-lisp/mu/mu4e") + :load-path (lambda () (ravi/emacs-file "site-lisp/mu/mu4e")) :commands mu4e :init (progn diff --git a/ravi-init-navigation.el b/ravi-init-navigation.el index 9a7da61..5a6054d 100644 --- a/ravi-init-navigation.el +++ b/ravi-init-navigation.el @@ -70,7 +70,6 @@ :config (progn (bind-key "C-=" 'er/expand-region)) - :idle (require 'expand-region) :ensure t ) @@ -80,7 +79,7 @@ ("C->" . mc/mark-next-like-this) ("C-<" . mc/mark-previous-like-this) ("C-c C-<" . mc/mark-all-like-this)) - :init + :config (progn (setq mc/list-file (ravi/emacs-file "past/mc-lists.el")) (bind-key "a" 'mc/mark-all-like-this region-bindings-mode-map) @@ -93,7 +92,7 @@ (use-package fold-this :commands fold-this - :init + :config (progn (bind-key "t" 'fold-this region-bindings-mode-map)) :ensure t @@ -101,7 +100,7 @@ (use-package indirect :commands indirect-region - :init + :config (progn (bind-key "I" 'indirect-region region-bindings-mode-map)) ) diff --git a/ravi-init-org.el b/ravi-init-org.el index e2ed68f..004d2f6 100644 --- a/ravi-init-org.el +++ b/ravi-init-org.el @@ -36,7 +36,7 @@ (use-package htmlize :ensure t) (use-package ox-reveal - :load-path ,(ravi/emacs-file "site-lisp/org-reveal") + :load-path (lambda () (ravi/emacs-file "site-lisp/org-reveal")) ) (setq org-src-fontify-natively t) (setq org-modules (quote (org-bbdb diff --git a/ravi-init-repl.el b/ravi-init-repl.el index c83dad3..8cc343b 100644 --- a/ravi-init-repl.el +++ b/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." -- cgit v0.10.1 From a6e94a30a835ea389fe8fc40df162ff327035ccb Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Mon, 16 Mar 2015 21:17:17 -0700 Subject: Move main emacs directory out of load path This follows the official emacs recommendation for lisp code inside emacs.d. diff --git a/init.el b/init.el index 973d04b..260f65d 100644 --- a/init.el +++ b/init.el @@ -37,7 +37,7 @@ ("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) +(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")) diff --git a/lisp/ravi-ergodox-mode.el b/lisp/ravi-ergodox-mode.el new file mode 100644 index 0000000..e393a39 --- /dev/null +++ b/lisp/ravi-ergodox-mode.el @@ -0,0 +1,83 @@ +;;; ravi-ergodox-mode.el --- Keybindings fof Ergodox keyboard + +;; Copyright (C) 2014 Ravikiran Rajagopal + +;; Author: Ravikiran Rajagopal +;; Keywords: convenience, hardware + +;; 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 . + +;;; Commentary: + +;; Set up keymap for ergodox bindings + +;;; Code: + +(defgroup ravi-ergodox-mode nil + "Keybindings for ergodox." + :group 'ravi-ergodox-mode) + +(defvar ravi-ergodox-mode-map (make-sparse-keymap) + "Keymaps for command `ravi-ergodox-mode-map'.") + +(defcustom ravi-ergodox-mode-disable-predicates nil + "List of predicates that disable the mode. +Each function in the list receive no argument." + :group 'ravi-ergodox-mode) + +(defcustom ravi-ergodox-mode-disabled-modes nil + "Modes where `ravi-ergodox-mode' should not activate." + :group 'ravi-ergodox-mode + :type '(repeat symbol)) + +(define-minor-mode ravi-ergodox-mode + "Enable Ergodox keyboard special bindings." + :lighter " RE" :group 'convenience + :keymap ravi-ergodox-mode-map + :global t + (if ravi-ergodox-mode + (progn + (setq x-meta-keysym 'super) + (setq x-super-keysym 'meta)) + (progn + (setq x-meta-keysym nil) + (setq x-super-keysym nil)) + ) + ) + +(define-key ravi-ergodox-mode-map (kbd "H-m") 'magit-status) +(define-key ravi-ergodox-mode-map (kbd "") 'ff-find-other-file) +(if (and (boundp 'ravi/use-helm-instead-of-ido) ravi/use-helm-instead-of-ido) + (progn + (define-key ravi-ergodox-mode-map (kbd "") 'helm-multi-files) + (define-key ravi-ergodox-mode-map (kbd "") 'helm-locate)) + (progn + (define-key ravi-ergodox-mode-map (kbd "") 'ido-switch-buffer) + (define-key ravi-ergodox-mode-map (kbd "") 'ido-find-file))) + +(defun ravi-ergodox-mode-enable () + "Turn on ergodox bindings mode." + (and (not (memq major-mode ravi-ergodox-mode-disabled-modes)) + (not (catch 'disable + (dolist (pred ravi-ergodox-mode-disable-predicates) + (and (funcall pred) + (throw 'disable t))))) + (ravi-ergodox-mode 1))) + +(defun ravi-ergodox-mode-disable () + "Turn off ergodox bindings mode." + (ravi-ergodox-mode -1)) + +(provide 'ravi-ergodox-mode) +;;; ravi-ergodox-mode.el ends here diff --git a/lisp/ravi-init-appearance.el b/lisp/ravi-init-appearance.el new file mode 100644 index 0000000..035dc1d --- /dev/null +++ b/lisp/ravi-init-appearance.el @@ -0,0 +1,315 @@ +;;; ravi-init-appearance.el --- Emacs appearance + +;; Copyright (C) 2013 + +;; Author: +;; 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 . + +;;; 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 / +(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) + +(setq sentence-end-double-space nil) +(defun sacha/unfill-paragraph (&optional region) + "Takes a multi-line paragraph and makes it into a single line of text." + (interactive (progn + (barf-if-buffer-read-only) + (list t))) + (let ((fill-column (point-max))) + (fill-paragraph nil region))) +(bind-key "M-Q" 'sacha/unfill-paragraph) + +;; 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 +(use-package smart-newline + :commands (smart-newline) + :init + (progn + (bind-key "" 'smart-newline prog-mode-map) + (bind-key "" '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) + +;; 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)))))) + +(use-package comment-dwim-2 + :bind (("M-;" . comment-dwim-2)) + :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 "")) + + (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 + :init + (progn + (popwin-mode 1) + (push '("*Pp Eval Output*" :height 15) popwin:special-display-config)) + :ensure t + ) + +(use-package import-popwin + :bind (("M-i" . import-popwin)) + :ensure t + ) + +(use-package ace-window + :bind (("M-o" . ace-window)) + :init + (progn + (setq aw-keys '(?a ?s ?d ?f ?g ?h ?j ?k ?l ?i ?e))) + :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) + +(provide 'ravi-init-appearance) +;;; ravi-init-appearance.el ends here diff --git a/lisp/ravi-init-cpp.el b/lisp/ravi-init-cpp.el new file mode 100644 index 0000000..5fe9e8f --- /dev/null +++ b/lisp/ravi-init-cpp.el @@ -0,0 +1,418 @@ +;;; ravi-init-cpp.el --- C/C++ handling + +;; Copyright (C) 2013 + +;; Author: +;; 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 . + +;;; Commentary: + +;; C/C++ initialization + +;;; Code: + +; Generate a random string (of letters and numbers) of a given length +(defun ravi-random-ucn-string (len) + (coerce (loop for i below len for x = (random 36) collect + (+ x + (cond ((< x 10) 48) + ((< x 36) (- 65 10)) + ))) + 'string)) + +(use-package cmake-mode + :mode (("CMakeLists\\.txt\\'" . cmake-mode) + ("\\.cmake\\'" . cmake-mode)) + ;:ensure t + ) + +(defvar get-buffer-compile-command (lambda (file) (cons file 1))) +(make-variable-buffer-local 'get-buffer-compile-command) + +(setq-default compile-command "") + +(defun compile-dwim (&optional arg) + "Compile Do What I Mean. + Compile using `compile-command'. + When `compile-command' is empty prompt for its default value. + With prefix C-u always prompt for the default value of + `compile-command'. + With prefix C-u C-u prompt for buffer local compile command with + suggestion from `get-buffer-compile-command'. An empty input removes + the local compile command for the current buffer." + (interactive "P") + (cond + ((and arg (> (car arg) 4)) + (let ((cmd (read-from-minibuffer + "Buffer local compile command: " + (funcall get-buffer-compile-command + (or (file-relative-name (buffer-file-name)) "")) + nil nil 'compile-history))) + (cond ((equal cmd "") + (kill-local-variable 'compile-command) + (kill-local-variable 'compilation-directory)) + (t + (set (make-local-variable 'compile-command) cmd) + (set (make-local-variable 'compilation-directory) + default-directory)))) + (when (not (equal compile-command "")) + ;; `compile' changes the default value of + ;; compilation-directory but this is a buffer local + ;; compilation + (let ((dirbak (default-value 'compilation-directory))) + (compile compile-command) + (setq-default compilation-directory dirbak)))) + ((or (and arg (<= (car arg) 4)) + (equal compile-command "")) + (setq-default compile-command (read-shell-command + "Compile command: " + (if (equal compile-command "") + "make " compile-command) + 'compile-history)) + (setq-default compilation-directory default-directory) + (when (not (equal (default-value 'compile-command) "")) + (compile (default-value 'compile-command)))) + (t + (recompile)))) + + +(use-package cc-mode + + :mode (("\\.h\\(h?\\|xx\\|pp\\)\\'" . c++-mode) + ("\\.ccfg\\'" . c++-mode) + ("\\.m\\'" . c-mode) + ("\\.mm\\'" . c++-mode)) + :init + (progn + (use-package doxymacs + :load-path (lambda () (ravi/emacs-file "site-lisp/doxymacs/lisp")) + :config + (progn + (doxymacs-mode) + (setq doxymacs-file-comment-template + '("/**" > n + " * " (doxymacs-doxygen-command-char) "file" > n + " * " > n + " * " (doxymacs-doxygen-command-char) "brief " + (p "Brief description of this file: ") > n + " */" > n) + ) + (setq doxymacs-external-xml-parser-executable + (ravi/emacs-file "site-lisp/doxymacs/c/doxymacs_parser")) + (setq doxymacs-use-external-xml-parser t) + (setq doxymacs-command-character "\\") + ) + :diminish doxymacs-mode + ) + + (defvar printf-index 0) + + (defun insert-counting-printf (arg) + (interactive "P") + (if arg + (setq printf-index 0)) + (if t + (insert (format "std::cerr << \"step %d..\" << std::endl;\n" + (setq printf-index (1+ printf-index)))) + (insert (format "printf(\"step %d..\\n\");\n" + (setq printf-index (1+ printf-index))))) + (forward-line -1) + (indent-according-to-mode) + (forward-line)) + + ) + + :config + (progn + + (defun my-c-mode-common-hook () + (hs-minor-mode 1) + (hs-hide-initial-comment-block) + (hide-ifdef-mode 1) + (which-function-mode 1) + + (diminish 'hs-minor-mode) + (diminish 'hide-ifdef-mode) + + (bind-key "C-c p" 'insert-counting-printf c-mode-base-map) + + (doxymacs-mode 1) + (doxymacs-font-lock) + + ;(define-key c-mode-base-map [return] 'c-context-line-break) + (bind-key "" '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)) + + (set (make-local-variable 'parens-require-spaces) t) + (setq fill-column 88) + + (bind-key "M-q" 'c-fill-paragraph c-mode-base-map) + + (c-toggle-electric-state 1) + (c-toggle-auto-newline 1) + (c-toggle-hungry-state 1) + + (c-set-style "stroustrup") + (setq c-basic-offset 2) + (setq c-recognize-knr-p nil) + (modify-syntax-entry ?_ "w" c-mode-syntax-table) + (add-to-list 'c-cleanup-list 'empty-defun-braces) + (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) + ;; 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)))) + + (add-hook 'c-mode-common-hook 'my-c-mode-common-hook) + + (defun my-c++-mode-hook () + (setq c-offsets-alist + (append '((statement-cont . c-lineup-math) + (inline-open . 0)) + c-offsets-alist)) + (let ((innamespaceindent (if (and (buffer-file-name) + (string-equal "ccfg" (file-name-extension (buffer-file-name)))) + 2 0)) + ) + (setq c-offsets-alist + (append `((innamespace . ,innamespaceindent) + ) + c-offsets-alist)) + ) + + (modify-syntax-entry ?_ "w" c++-mode-syntax-table) + (setq c-macro-cppflags "-x c++") + (setq c-macro-prompt-flag t) + ) + (add-hook 'c++-mode-hook 'my-c++-mode-hook) + + ;; Stuff from kde-emacs + (defvar kde-header-protection-parts-to-show 1 + "Set this variable to the number of parts from the file name you want to +be used for the defined word in the header-protection function.. E.g. setting +this to 3 makes header-protection define KIG_MISC_NEWTYPE_H for a file named +/home/domi/src/kdenonbeta/kig/misc/newtype.h") + + (defun kde-header-protection-definable-string () + (let* ((definablestring (concat "_" (ravi-random-ucn-string 6)) ) + (f (buffer-file-name)) + (parts (nreverse (split-string f "/"))) + (i) + (first-iter t) + (iters (min (length parts) kde-header-protection-parts-to-show))) + (dotimes (i iters) + (let ((part (pop parts))) + (setq definablestring + (concat + (upcase (replace-regexp-in-string "[\\.-]" "_" part)) + (if (not first-iter) "_" "") + definablestring + ) + ) + (setq first-iter nil) + ) + ) + definablestring + ) + ) + + ;; Creates the ifndef/define/endif statements necessary for a header file + (defun header-protection () + (interactive) + (let ((s (kde-header-protection-definable-string))) + (save-excursion + (goto-char (point-min)) + (insert "#ifndef " s "\n#define " s "\n\n") + (goto-char (point-max)) + (insert "\n#endif\n") + ) + ) + ) + + (defun ravi-start-c++-header () + "Start a new C++ header by inserting include guards ( see \ + header-protection function ), inserting a license statement \ + and putting (point) at the correct position" + (interactive) + (header-protection) + (insert "\n") + (beginning-of-buffer) + + (save-excursion + (let ((start (point-min)) + (comment-style 'box) + (end) + ) + (goto-char start) + (insert (ravi-license-header)) + (setq end (point)) + (comment-region start end) + ) + ) + + (end-of-buffer) + (next-line -3) + (insert "\n") + (doxymacs-insert-file-comment) + ) + + (setq auto-insert-query nil) + (define-auto-insert "\\.\\([Cc]\\|cc\\|cpp\\|cxx\\|tcc\\)\\'" + 'ravi-auto-insert-cpp) + (define-auto-insert "\\.\\([Hh]\\|hh\\|hpp\\)\\'" 'ravi-start-c++-header) + + (defun ravi-license-insert () + (progn + (let ((start (point-min)) + (comment-style 'box) + (end) + ) + (goto-char start) + (insert (ravi-license-header)) + (insert "\n") + (setq end (point)) + (comment-region start end)))) + + (defun ravi-auto-insert-cpp () + (progn + (ravi-license-insert) + (doxymacs-insert-file-comment))) + + (defun ravi/add-space-before-paren-c (&rest ignored) + (message "Handler invoked") + (when (looking-back "\\b\\(for\\|while\\|if\\|switch\\)(") + (save-excursion + (backward-char) + (insert-char ?\s) + ) + )) + + (defadvice c-electric-paren (after ravi/add-space-around-parens activate) + (unless (c-in-literal) + (cond + ((looking-back "([[:space:]]*") + (progn + ;; Open parenthesis was the last command; add a space before it if + ;; necessary, and ensure that the point is placed after a space + (save-excursion + (re-search-backward "([[:space:]]*") + (unless (looking-at "(") (message "Logic error; opening paren not found")) + (when (looking-back "\\b\\(for\\|while\\|if\\|switch\\|catch\\)") + (insert-char ?\s))) + (if (and (looking-at " ") (not (looking-at " )"))) + (forward-char) + (insert-char ?\s)) + ) + ) + ((looking-back ")[[:space:]]*") + ;; Closing parenthesis was the last command; add spaces if necessary + (progn + ;; Compact empty function calls + (when (looking-back "([[:space:]]+)[[:space:]]*") + (save-excursion + (re-search-backward ")[[:space:]]*") + (delete-horizontal-space) + ) + ) + + ;; Add space before closing parenthesis + (unless (looking-back "()[[:space:]]*") + (save-excursion + (re-search-backward ")[[:space:]]*") + (unless (looking-at ")") (message "Logic error; closing paren not found")) + (unless (looking-back " ") (insert-char ?\s))) + ) + + (let (need-to-add-newline) + (save-excursion + (c-backward-sexp) + (c-backward-syntactic-ws) + ;; FIXME: do-while loops are not handled correctly + (setq need-to-add-newline (looking-back "\\b\\(for\\|while\\|if\\|switch\\|catch\\)")) + ) + (when need-to-add-newline (c-newline-and-indent))) + ) + ) + )) + ) + + (defadvice c-electric-semi&comma (after ravi/add-space-after-comma activate) + (cond + ((looking-back ",") + (if (looking-at " [^)]") (forward-char) (insert-char ?\s))) + ((looking-back ") ;[[:space:]\n]*") + (save-excursion + (re-search-backward " ;[[:space:]\n]*") + (delete-char 1))))) + + ;; Do not activate region as it interferes with region-bindings-mode + (defadvice c-electric-brace (after ravi/do-not-activate-region activate) + (deactivate-mark)) + + (defmacro ravi/fake-send-key (key-to-bind char-to-bind) + (let ((command (key-binding key-to-bind))) + (setq last-command-event char-to-bind) + (setq this-command command) + (call-interactively command)) + ) + + (defun ravi/insert-closing-delimiter() + (interactive) + (if (c-in-literal) + (self-insert-command) + (progn + ;; Find nearest unmatched opening delimiter + (let (brace-type) + (save-excursion + (backward-up-list) + (cond + ((looking-at "{") (setq brace-type 'brace-type-brace)) + ((looking-at "(") (setq brace-type 'brace-type-paren)) + ((looking-at "\\[") (setq brace-type 'brace-type-square)) + (t (setq brace-type 'brace-type-none)) + )) + (cond + ((eq brace-type 'brace-type-brace) (ravi/fake-send-key "}" ?\})) + ((eq brace-type 'brace-type-paren) (ravi/fake-send-key ")" ?\))) + ; Uncommenting the line below would lead to infinite recursion + ;((eq 'brace-type 'brace-type-square) (ravi/fake-send-key "]" ?\])) + (t (self-insert-command 1)) + ) + )))) + + (bind-key "]" 'ravi/insert-closing-delimiter c-mode-base-map) + + (bind-key "" 'compile-dwim c-mode-base-map) + + (bind-key "" 'hs-hide-block c-mode-base-map) + (bind-key "" 'hs-show-block c-mode-base-map) + + (setq hide-ifdef-initially nil) + (bind-key "" 'hide-ifdef-block c-mode-base-map) + (bind-key "" 'show-ifdef-block c-mode-base-map) + + ;; (setq c-syntactic-indentation nil) + ) + ) + +(provide 'ravi-init-cpp) +;;; ravi-init-cpp.el ends here diff --git a/lisp/ravi-init-dired.el b/lisp/ravi-init-dired.el new file mode 100644 index 0000000..0c8fab2 --- /dev/null +++ b/lisp/ravi-init-dired.el @@ -0,0 +1,149 @@ +;;; ravi-init-dired.el --- dired setup + +;; Copyright (C) 2014 + +;; Author: +;; 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 . + +;;; Commentary: + +;; Mostly stolen from Fuco's configuration + +;; Dired setup + +;;; Code: + +(use-package dired + :defer t + :config + (progn + (defun ravi/dired-init-hook () + (dired-filter-mode t) + (visual-line-mode -1) + (toggle-truncate-lines 1)) + (add-hook 'dired-mode-hook 'ravi/dired-init-hook) + + (use-package image-dired) + (use-package dired-aux) + (use-package dired-x + :config + (defun dired-virtual-revert (&optional _arg _noconfirm) + "Enable revert for virtual direds." + (let ((m (dired-file-name-at-point)) + (buffer-modified (buffer-modified-p))) + (goto-char 1) + (dired-next-subdir 1) + (dired-do-redisplay nil t) + (while (dired-next-subdir 1 t) + (dired-do-redisplay nil t)) + (when m (dired-goto-file m)) + (set-buffer-modified-p buffer-modified)))) + + (use-package dired-details + :commands dired-details-toggle + :ensure t + ) + (use-package w32-browser + :commands dired-w32-browser + :ensure t + ) + + (use-package dired-subtree + :ensure t + :config + (progn + (bind-keys :map dired-mode-map + :prefix "," + :prefix-map dired-subtree-map + :prefix-docstring "Dired subtree map." + ("/" . dired-subtree-apply-filter) + ("k" . dired-subtree-remove) + ("n" . dired-subtree-next-sibling) + ("p" . dired-subtree-previous-sibling) + ("u" . dired-subtree-up) + ("d" . dired-subtree-down) + ("a" . dired-subtree-beginning) + ("e" . dired-subtree-end) + ("m" . dired-subtree-mark-subtree) + ("u" . dired-subtree-unmark-subtree) + ("C-o C-f" . dired-subtree-only-this-file) + ("C-o C-d" . dired-subtree-only-this-directory)) + (bind-key "e" 'dired-subtree-insert dired-mode-map)) + ) + + (defconst my-dired-media-files-extensions '("mp3" "mp4" "MP3" "MP4" "avi" "mpg" "flv" "ogg") + "Media file extensions that should launch in VLC. + +Also used for highlighting.") + + (use-package dired-rainbow + :config + (progn + (dired-rainbow-define html "#4e9a06" ("htm" "html" "xhtml")) + (dired-rainbow-define xml "DarkGreen" ("xml" "xsd" "xsl" "xslt" "wsdl")) + + (dired-rainbow-define document "#fce94f" ("doc" "docx" "odt" "pdb" "pdf" "ps" "rtf")) + (dired-rainbow-define media "#ce5c00" my-dired-media-files-extensions) + (dired-rainbow-define image "#ff4b4b" ("jpg" "png" "jpeg" "gif")) + + (dired-rainbow-define log "#c17d11" ("log")) + (dired-rainbow-define sourcefile "#fcaf3e" ("py" "c" "cc" "h" "java" "pl" "rb")) + + (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"))) + :ensure t) + + (add-to-list 'dired-guess-shell-alist-user (list (regexp-opt my-dired-media-files-extensions) + "vlc")) + + (use-package dired-filter + :ensure t + ) + + (use-package dired-open + :config + (progn + (bind-key "E" 'dired-open-xdg dired-mode-map)) + :ensure t) + + (use-package dired-avfs + :ensure t + :disabled t ; avfs not in Fedora repositories yet + ) + + (require 'dash) + (--each '(dired-do-rename + dired-do-copy + dired-create-directory + wdired-abort-changes) + (eval `(defadvice ,it (after revert-buffer activate) + (revert-buffer)))) + + (defun ravi/dired-guide-key-hook () + (guide-key/add-local-guide-key-sequence "%") + (guide-key/add-local-guide-key-sequence "*") + (guide-key/add-local-guide-key-sequence "/") + (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) + + )) + +(provide 'ravi-init-dired) +;;; ravi-init-dired.el ends here diff --git a/lisp/ravi-init-files.el b/lisp/ravi-init-files.el new file mode 100644 index 0000000..9ac482d --- /dev/null +++ b/lisp/ravi-init-files.el @@ -0,0 +1,159 @@ +;;; ravi-init-files.el --- file-handling + +;; Copyright (C) 2013 + +;; Author: +;; 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 . + +;;; Commentary: + +;; File handling + +;;; Code: + +(setq auto-save-list-file-prefix (ravi/emacs-file "past/auto-save-list/.saves-")) +(setq delete-auto-save-files t) +(setq dired-listing-switches "-Flag") +(setq completion-ignored-extensions + (append completion-ignored-extensions + (quote (".bak" ".#*#" ".ps" ".pdf")))) + +;; Auto refresh buffers +(global-auto-revert-mode 1) + +;; Also auto refresh dired, but be quiet about it +(setq global-auto-revert-non-file-buffers t) +(setq global-auto-revert-ignore-modes '(TeX-output-mode)) +(setq auto-revert-verbose nil) + +;; Transparently open compressed files +(auto-compression-mode t) + +;; UTF-8 please +(setq locale-coding-system 'utf-8) ; pretty +(set-terminal-coding-system 'utf-8) ; pretty +(set-keyboard-coding-system 'utf-8) ; pretty +(set-selection-coding-system 'utf-8) ; please +(prefer-coding-system 'utf-8) ; with sugar on top + +(setq history-length 100) +(setq savehist-file (ravi/emacs-file "past/history")) +(savehist-mode 1) +(setq history-delete-duplicates t) + +(require 'saveplace) +(setq-default save-place t) +(setq save-place-file (ravi/emacs-file "past/places")) + +(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) +(setq uniquify-after-kill-buffer-p t) ; rename after killing uniquified +(setq uniquify-ignore-buffers-re "^\\*") ; don't muck with special buffers + +(setq minibuffer-completion-confirm t) +(setq find-file-confirm-nonexistent-file t) +(setq find-file-visit-truename t) + +;; Automatic loading of file trees +(defun ravi-check-dir-accessible-p (name) + "Check whether NAME is accessible as a directory" + (let* ((topname (file-name-as-directory name)) + (name-exists (and (file-exists-p topname) + (file-directory-p topname) + (file-accessible-directory-p topname) + topname))) + name-exists + )) + +(defun ravi-filecache-add-tree (root recursive simple) + "Add list of directories to filecache for easy opening. +ROOT is the root of the tree to be added. RECURSIVE is a list of +relative paths whose subdirectories are added recursively, while +relative paths in SIMPLE are added non-recursively. If a path does +not exist, it is not added to the filecache." + + (let ((topname (ravi-check-dir-accessible-p root)) + (dirval nil)) + (when topname + (dolist (dir recursive) + (setq dirval (ravi-check-dir-accessible-p + (expand-file-name dir topname))) + (and dirval + (file-cache-add-directory-recursively dirval))) + (dolist (dir simple) + (setq dirval (ravi-check-dir-accessible-p + (expand-file-name dir topname))) + (and dirval + (file-cache-add-directory dirval))) + ))) + +;; Write backup files to own directory +(make-directory (ravi/emacs-file "past/backups/") t) +(setq backup-by-copying t) +(setq backup-directory-alist + `(("." . ,(ravi/emacs-file "past/backups/")) + (,tramp-file-name-regexp nil))) + +;; Make backups of files, even when they're in version control +(setq vc-make-backup-files t) + +;; Git/svn/etc. projects +(use-package projectile + :init + (progn + (use-package pkg-info + :ensure t + ) + (setq projectile-known-projects-file + (ravi/emacs-file "past/projectile-bookmarks.eld")) + ) + :config + (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 + ) + +;; Use emacsclient as external editor for kmail +(add-to-list 'auto-mode-alist + (cons (concat temporary-file-directory ".*/kmail[[:alnum:]]*.tmp\\'") 'message-mode)) +(setq gnus-message-highlight-citation t) + +(provide 'ravi-init-files) +;;; ravi-init-files.el ends here diff --git a/lisp/ravi-init-function.el b/lisp/ravi-init-function.el new file mode 100644 index 0000000..671d45c --- /dev/null +++ b/lisp/ravi-init-function.el @@ -0,0 +1,35 @@ +;;; ravi-init-function.el --- functionality + +;; Copyright (C) 2013 + +;; Author: +;; 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 . + +;;; 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 +(unless (server-running-p) (server-start)) + +(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..5ff7f9d --- /dev/null +++ b/lisp/ravi-init-helm.el @@ -0,0 +1,89 @@ +;;; ravi-init-helm.el --- helm initialization -*- lexical-binding: t; -*- + +;; Copyright (C) 2015 + +;; Author: +;; 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 . + +;;; 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 (("" . helm-command-prefix) + ("M-x" . helm-M-x) + ("" . helm-multi-files) + ("" . helm-locate) + ("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 "" 'helm-execute-persistent-action helm-map) + (bind-key "H-" 'helm-select-action helm-map) + + (use-package helm-ag + :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) + +(use-package helm-descbinds + :bind (("C-h b" . helm-descbinds)) + :ensure t) + +(provide 'ravi-init-helm) +;;; ravi-init-helm.el ends here diff --git a/lisp/ravi-init-ido.el b/lisp/ravi-init-ido.el new file mode 100644 index 0000000..93af3e6 --- /dev/null +++ b/lisp/ravi-init-ido.el @@ -0,0 +1,164 @@ +;;; ravi-init-ido.el --- ido initialization + +;; Copyright (C) 2013 + +;; Author: +;; 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 . + +;;; Commentary: + +;; Ido initialization + +;;; Code: + +;; Almost all of the code below is stolen from jwiegley's .emacs.d. + +(use-package ibuffer + :bind ("C-x C-b" . ibuffer) + :config + (progn + + (use-package ibuffer-vc + :ensure t + :commands ibuffer-vc-set-filter-groups-by-vc-root + ) + + ;; Switching to ibuffer puts the cursor on the most recent past buffer + (defadvice ibuffer (around ibuffer-point-to-most-recent-but-one activate) () + "Open ibuffer with cursor pointed to most recent buffer name" + (let ((recent-buffer-name (buffer-name (other-buffer (current-buffer) t)))) + ad-do-it + (ibuffer-jump-to-buffer recent-buffer-name))) + + (defun ravi/ibuffer-vc-sort-hook () + (ibuffer-vc-set-filter-groups-by-vc-root) + (unless (eq ibuffer-sorting-mode 'alphabetic) + (ibuffer-do-sort-by-alphabetic))) + (add-hook 'ibuffer-hook 'ravi/ibuffer-vc-sort-hook) + ) + ) + +(use-package ace-jump-buffer + :bind (("M-" . ace-jump-buffer) + ("C-" . ace-jump-buffer-other-window) + ("S-" . ace-jump-projectile-buffers)) + ;; :config + ;; (progn + ;; (bind-key "M-" 'ido-switch-buffer)) + :ensure t) + +;;;_ , ido + +(use-package ido + :defines (ido-cur-item + ido-require-match + 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 + :config + (ido-hacks-mode 1) + :ensure t + ) + + (use-package flx-ido + :config + (progn + (use-package flx + :ensure t) + (flx-ido-mode 1) + ) + :ensure t + ) + (setq ido-use-filename-at-point 'guess) + (setq ido-use-virtual-buffers t) + (setq ido-create-new-buffer 'always) + + (use-package ido-ubiquitous + :config + (ido-ubiquitous-mode t) + :ensure t + ) + + (use-package ido-vertical-mode + :config + (ido-vertical-mode 1) + :ensure t + ) + + (defun ido-smart-select-text () + "Select the current completed item. Do NOT descend into directories." + (interactive) + (when (and (or (not ido-require-match) + (if (memq ido-require-match + '(confirm confirm-after-completion)) + (if (or (eq ido-cur-item 'dir) + (eq last-command this-command)) + t + (setq ido-show-confirm-message t) + nil)) + (ido-existing-item-p)) + (not ido-incomplete-regexp)) + (when ido-current-directory + (setq ido-exit 'takeprompt) + (unless (and ido-text (= 0 (length ido-text))) + (let ((match (ido-name (car ido-matches)))) + (throw 'ido + (setq ido-selected + (if match + (replace-regexp-in-string "/\\'" "" match) + ido-text) + ido-text ido-selected + ido-final-text ido-text))))) + (exit-minibuffer))) + + (add-hook 'ido-minibuffer-setup-hook + #'(lambda () + (bind-key "" 'ido-smart-select-text + ido-file-completion-map))) + + (defun ido-switch-buffer-tiny-frame (buffer) + (interactive (list (ido-read-buffer "Buffer: " nil t))) + (with-selected-frame + (make-frame '((width . 80) + (height . 22) + (left-fringe . 0) + (right-fringe . 0) + (vertical-scroll-bars . nil) + (unsplittable . t) + (has-modeline-p . nil) + ;;(background-color . "grey80") + (minibuffer . nil))) + (switch-to-buffer buffer) + (set (make-local-variable 'mode-line-format) nil))) + + (bind-key "C-x 5 t" 'ido-switch-buffer-tiny-frame))) + +(use-package smex + :init + (global-set-key [remap execute-extended-command] 'smex) + :if (not ravi/use-helm-instead-of-ido) + :ensure t + ) + +(provide 'ravi-init-ido) +;;; ravi-init-ido.el ends here diff --git a/lisp/ravi-init-insertion.el b/lisp/ravi-init-insertion.el new file mode 100644 index 0000000..65ff9db --- /dev/null +++ b/lisp/ravi-init-insertion.el @@ -0,0 +1,136 @@ +;;; ravi-init-insertion.el --- inserting text + +;; Copyright (C) 2013 + +;; Author: +;; 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 . + +;;; 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-" . aya-create) + ("" . 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) + + (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 + (company-quickhelp-mode 1) + :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) + (bind-key "" 'company-yasnippet)) + + :diminish company-mode + :ensure t) + +(provide 'ravi-init-insertion) +;;; ravi-init-insertion.el ends here diff --git a/lisp/ravi-init-layouts.el b/lisp/ravi-init-layouts.el new file mode 100644 index 0000000..f6199ce --- /dev/null +++ b/lisp/ravi-init-layouts.el @@ -0,0 +1,57 @@ +;;; ravi-init-layouts.el --- layouts + +;; Copyright (C) 2014 + +;; Author: +;; 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 . + +;;; Commentary: + +;; Uses undocumented emacs API + +;;; Code: + +(require 'quail) + +(quail-define-package + "english-prog" "English programmer" "EN-P" t + "English programmer's keyboard." + nil t nil nil t nil nil nil nil nil t) + +(quail-define-rules + ("!" ?1) + ("@" ?2) + ("#" ?3) + ("$" ?4) + ("%" ?5) + ("^" ?6) + ("&" ?7) + ("*" ?8) + ("(" ?9) + (")" ?0) + ("1" ?!) + ("2" ?@) + ("3" ?#) + ("4" ?$) + ("5" ?%) + ("6" ?^) + ("7" ?&) + ("8" ?*) + ("9" ?\() + ("0" ?\))) + +(provide 'ravi-init-layouts) +;;; ravi-init-layouts.el ends here diff --git a/lisp/ravi-init-marks.el b/lisp/ravi-init-marks.el new file mode 100644 index 0000000..803b2cb --- /dev/null +++ b/lisp/ravi-init-marks.el @@ -0,0 +1,78 @@ +;;; ravi-init-marks.el --- Handling the mark + +;; Copyright (C) 2013 + +;; Author: +;; 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 . + +;;; Commentary: + +;; Handling the mark + +;;; Code: + +;; Show active region +(transient-mark-mode 1) +(make-variable-buffer-local 'transient-mark-mode) +(put 'transient-mark-mode 'permanent-local t) +(setq-default transient-mark-mode t) + +;; When popping the mark, continue popping until the cursor actually moves +;; Also, if the last command was a copy - skip past all the expand-region cruft. +;; Stolen from Magnar Sveen's emacs.d on github. +(defadvice pop-to-mark-command (around ensure-new-position activate) + (let ((p (point))) + (when (eq last-command 'save-region-or-current-line) + ad-do-it + ad-do-it + ad-do-it) + (dotimes (i 10) + (when (= p (point)) ad-do-it)))) + +;; Allow mark-based navigation even in transient-mark-mode; see +;; http://www.masteringemacs.org/articles/2010/12/22/fixing-mark-commands-transient-mark-mode/ + +(defun ravi/push-mark-no-activate () + "Pushes `point' to `mark-ring' and does not activate the region +Equivalent to \\[set-mark-command] when \\[transient-mark-mode] is disabled" + (interactive) + (push-mark (point) t nil) + (message "Pushed mark to ring")) +(bind-key "C-`" 'ravi/push-mark-no-activate) + +(defun ravi/jump-to-mark () + "Jumps to the local mark, respecting the `mark-ring' order. +This is the same as using \\[set-mark-command] with the prefix argument." + (interactive) + (set-mark-command 1)) +(bind-key "M-`" 'ravi/jump-to-mark) + +; Prevents C-x C-x from highlighting region +(defun ravi/exchange-point-and-mark-no-activate () + "Identical to \\[exchange-point-and-mark] but will not activate the region." + (interactive) + (exchange-point-and-mark) + (deactivate-mark nil)) +(define-key global-map [remap exchange-point-and-mark] 'ravi/exchange-point-and-mark-no-activate) + +(use-package browse-kill-ring + :config (browse-kill-ring-default-keybindings) + :ensure t + :if (not ravi/use-helm-instead-of-ido) + ) + +(provide 'ravi-init-marks) +;;; ravi-init-marks.el ends here diff --git a/lisp/ravi-init-mu.el b/lisp/ravi-init-mu.el new file mode 100644 index 0000000..b123da2 --- /dev/null +++ b/lisp/ravi-init-mu.el @@ -0,0 +1,196 @@ +;;; ravi-init-mu.el --- mail + +;; Copyright (C) 2014 + +;; Author: +;; 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 . + +;;; 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) + (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 (mu4e-maildirs-extension) ; does not work with mu now + :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) + ;; 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) + + (imagemagick-register-types) + ) + ) + ) + +(provide 'ravi-init-mu) +;;; ravi-init-mu.el ends here diff --git a/lisp/ravi-init-navigation.el b/lisp/ravi-init-navigation.el new file mode 100644 index 0000000..5a6054d --- /dev/null +++ b/lisp/ravi-init-navigation.el @@ -0,0 +1,350 @@ +;;; ravi-init-navigation.el --- navigation utilities + +;; Copyright (C) 2013 + +;; Author: +;; 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 . + +;;; Commentary: + +;; Buffer navigation utilities + +;;; Code: + +(use-package region-bindings-mode + :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 "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) + ) + :ensure t + ) + +(use-package ace-jump-mode + :bind (("M-h" . ace-jump-mode) + ("M-H" . ace-jump-line-mode)) + :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)) + :ensure t) + +(use-package jump-char + :bind (("M-m" . jump-char-forward)) + :ensure t + ) + +(use-package imenu-anywhere + :bind ("s-." . imenu-anywhere) + :ensure t + ) + +(use-package expand-region + :config + (progn + (bind-key "C-=" 'er/expand-region)) + :ensure t + ) + +(use-package multiple-cursors + :bind (("C-S-c C-S-c" . mc/edit-lines) + + ("C->" . mc/mark-next-like-this) + ("C-<" . mc/mark-previous-like-this) + ("C-c C-<" . mc/mark-all-like-this)) + :config + (progn + (setq mc/list-file (ravi/emacs-file "past/mc-lists.el")) + (bind-key "a" 'mc/mark-all-like-this region-bindings-mode-map) + (bind-key "p" 'mc/mark-previous-like-this region-bindings-mode-map) + (bind-key "n" 'mc/mark-next-like-this region-bindings-mode-map) + (bind-key "m" 'mc/mark-more-like-this-extended region-bindings-mode-map) + ) + :ensure t + ) + +(use-package fold-this + :commands fold-this + :config + (progn + (bind-key "t" 'fold-this region-bindings-mode-map)) + :ensure t + ) + +(use-package indirect + :commands indirect-region + :config + (progn + (bind-key "I" 'indirect-region region-bindings-mode-map)) + ) + +(use-package visual-regexp + :bind (("C-c r" . vr/replace) + ("C-c q" . vr/query-replace) + ("C-c m" . vr/mc-mark)) + :ensure t + ) + +(use-package god-mode + :bind (("" . god-local-mode)) + :disabled t ; less useful than I thought + :ensure t + ) + +(bind-key "" 'ff-find-other-file) + +(setq compilation-scroll-output 'first-error) + +(use-package smartparens + :commands (smartparens-mode show-smartparens-mode) + :init + (show-smartparens-global-mode 1) + :config + (progn + (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 + ) + +;; Marking and moving lines + +(defun ravi/pull-up-a-line() + "Pull up the next line" + (interactive) + (join-line -1) + ) + +(bind-key "M-j" 'ravi/pull-up-a-line) + +(use-package move-lines + :bind (("" . move-lines-down) + ("" . move-lines-up) + ) + ) + +;; From Kyle Sherman's comment at +;; http://emacs-fu.blogspot.com/2010/01/duplicating-lines-and-commenting-them.html +;; \todo Make this work someday with regions too. +(defun ravi/kyle-sherman-duplicate-line (&optional comment line) + "Duplicate the line containing the point. +\nIf COMMENT is non-nil, also comment out the original line. + If LINE is non-nil, duplicate that line instead." + (interactive "P") + (let ((col (current-column))) + (save-excursion + (when line + (goto-line line)) + (let ((line (buffer-substring (point-at-bol) (point-at-eol)))) + (when comment + (comment-region (point-at-bol) (point-at-eol))) + (goto-char (point-at-eol)) + (if (eobp) + (newline) + (forward-line 1)) + (open-line 1) + (insert line))) + (forward-line 1) + (move-to-column col))) + +;; C-: duplicates line, C-u C-: comments first line +(bind-key "C-:" 'ravi/kyle-sherman-duplicate-line) + +(defun ravi/back-to-indentation-or-beginning () (interactive) + (if (bolp) (back-to-indentation) + (beginning-of-line))) +(bind-key "C-a" 'ravi/back-to-indentation-or-beginning) + +(defun ravi/Fuco-point-in-comment () + "Determine if the point is inside a comment" + (interactive) + (let ((syn (syntax-ppss))) + (and (nth 8 syn) + (not (nth 3 syn))))) + +(defun ravi/Fuco-end-of-code-or-line+ (arg) + "Move to the end of line. If already there, move to the end of code. + + Comments are recognized in any mode that sets syntax-ppss properly." + (interactive "P") + (let ((eoc (save-excursion + (move-end-of-line arg) + (while (ravi/Fuco-point-in-comment) + (backward-char)) + (skip-chars-backward " \t") + (point)))) + (cond ((eolp) + (move-end-of-line arg) + (while (ravi/Fuco-point-in-comment) + (backward-char)) + (skip-chars-backward " \t")) + (t + (move-end-of-line arg))))) +(bind-key "C-e" 'ravi/Fuco-end-of-code-or-line+) + +;; Use current line for region-based commands if no region selected +(use-package whole-line-or-region + :config + (progn + (defun turn-on-whole-line-or-region-mode() + (interactive) + (whole-line-or-region-mode 1) + ) + (add-hook 'prog-mode-hook 'turn-on-whole-line-or-region-mode) + ) + :diminish whole-line-or-region-mode + ) + +;; grep and friends + +(use-package wgrep + :ensure t + ) + +(if (executable-find "ag") + ;; Prefer the silver-searcher if available + (use-package ag + :bind (("H-g" . ag) + ("H-G" . ag-files)) + :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) + ("H-N" . highlight-symbol-prev) + ("H-s" . highlight-symbol-query-replace)) + :commands highlight-symbol-next + :config + (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 "s") 'highlight-symbol-query-replace) + (define-key map (kbd "o") 'highlight-symbol-occur) + map)) + (defun ravi/highlight-symbol-next () + (interactive) + (highlight-symbol-next) + (set-temporary-overlay-map ravi/highlight-symbol-overlay-map t)) + ) + :ensure t + ) + +(let ((ad-redefinition-action 'accept)) + (use-package color-moccur + :commands (isearch-moccur isearch-all) + :bind ("M-s O" . moccur) + :init + (progn + (bind-key "M-o" 'isearch-moccur isearch-mode-map) + (bind-key "M-O" 'isearch-moccur-all isearch-mode-map)) + + :config + (use-package moccur-edit) + + :ensure t + ) + ) + +;; 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 "" 'isearch-exit-other-end isearch-mode-map) + +;; Search the web +(use-package webjump + :bind ("C-x g" . webjump) + :config + (progn + ;; Suggest word at point if possible + (defun webjump-read-string (prompt) + (let* ((prompt (concat prompt (if (word-at-point) (concat " (default: " (word-at-point) ")")) ": ")) + (input (read-string prompt))) + (if (webjump-null-or-blank-string-p input) (word-at-point) input))) + + ;; C++ reference + (add-to-list 'webjump-sites + '("cpp" . [simple-query "en.cppreference.com" + "http://en.cppreference.com/mwiki/index.php?title=Special:Search&search=" + ""])) + ) + ) + +;; to do: add zeal-at-point + +(provide 'ravi-init-navigation) +;;; ravi-init-navigation.el ends here diff --git a/lisp/ravi-init-org.el b/lisp/ravi-init-org.el new file mode 100644 index 0000000..004d2f6 --- /dev/null +++ b/lisp/ravi-init-org.el @@ -0,0 +1,53 @@ +;;; ravi-init-org.el --- org initialization + +;; Copyright (C) 2014 + +;; Author: +;; 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 . + +;;; Commentary: + +;; Org mode initialization + +;;; Code: + +(use-package org + :ensure org-plus-contrib + :mode ("\\.org\\'" . org-mode) + + ;; The following lines are always needed. Choose your own keys. + :bind (("C-c l" . org-store-link) + ("H--" . org-agenda)) + :config + (progn + (use-package htmlize + :ensure t) + (use-package ox-reveal + :load-path (lambda () (ravi/emacs-file "site-lisp/org-reveal")) + ) + (setq org-src-fontify-natively t) + (setq org-modules (quote (org-bbdb + org-bibtex + org-crypt + org-gnus + org-id + org-info))) + ) + ) + +(provide 'ravi-init-org) +;;; ravi-init-org.el ends here + diff --git a/lisp/ravi-init-python.el b/lisp/ravi-init-python.el new file mode 100644 index 0000000..6edc232 --- /dev/null +++ b/lisp/ravi-init-python.el @@ -0,0 +1,166 @@ +;;; ravi-init-python.el --- python support + +;; Copyright (C) 2013 + +;; Author: +;; 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 . + +;;; Commentary: + +;; Python programming setup + +;;; Code: + +(use-package python + :mode ("\\.py\\'" . python-mode) + :commands python-shell-switch-to-shell + :config + (progn + + (add-hook 'python-mode-hook 'ravi/python-mode-hook) + (defun ravi/python-mode-hook() + ;; Set ipython as our interpreter + (setq python-shell-interpreter "ipython" + python-shell-interpreter-args "--pylab" + python-shell-prompt-regexp "In \\[[0-9]+\\]: " + python-shell-prompt-output-regexp "Out\\[[0-9]+\\]: " + python-shell-completion-setup-code + "from IPython.core.completerlib import module_completion" + python-shell-completion-module-string-code + "';'.join(module_completion('''%s'''))\n" + python-shell-completion-string-code + "';'.join(get_ipython().Completer.all_completions('''%s'''))\n" + ) + + ;; For ipython 0.10, uncomment the following: + ;; (setq python-shell-completion-string-code + ;; "';'.join(__IP.complete('''%s'''))\n" + ;; python-shell-completion-module-string-code "" + ;; ) + + ;; 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) + ) + + ;; 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 () + (progn + (insert "#!/usr/bin/env python\n\n") + ) + ) + + (use-package virtualenvwrapper + :config + (progn + (venv-initialize-interactive-shells) + (venv-initialize-eshell) + (setq venv-location (expand-file-name "~/usr/local/venv/")) + ) + + :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 + :config + (progn + (defun ravi/jedi-setup () + (let ((basic-server-args (list + "--sys-path" (ravi/emacs-file "site-lisp/python-epc") + "--sys-path" (ravi/emacs-file "site-lisp/sexpdata") + "--sys-path" (ravi/emacs-file "site-lisp/jedi")) + )) + (set (make-local-variable 'jedi:server-args) + (if (and (boundp 'extra-jedi-args) + (listp extra-jedi-args)) + (append basic-server-args extra-jedi-args) + basic-server-args)) + (jedi:setup))) + + (defun ravi/python-jedi-hook-installer () + (setq jedi:complete-on-dot t) + (add-hook 'hack-local-variables-hook 'ravi/jedi-setup nil t)) + (add-hook 'python-mode-hook 'ravi/python-jedi-hook-installer) + ) + :ensure t + :disabled t ; casualty of removing auto-complete + ) + + (use-package sphinx-doc + :config + (progn + (defun ravi/sphinx-doc-setup () + (sphinx-doc-mode 1)) + (add-hook 'python-mode-hook 'ravi/sphinx-doc-setup) + ) + :diminish t + :ensure t) + ) + ) + +(provide 'ravi-init-python) + diff --git a/lisp/ravi-init-repl.el b/lisp/ravi-init-repl.el new file mode 100644 index 0000000..8cc343b --- /dev/null +++ b/lisp/ravi-init-repl.el @@ -0,0 +1,67 @@ +;;; ravi-init-repl.el --- REPL utilities + +;; Copyright (C) 2014 + +;; Author: +;; 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 . + +;;; Commentary: + +;; Read-eval-print-loop support + +;;; Code: + +(use-package comint + :defer t + :config + (progn + (bind-key "" 'comint-previous-matching-input-from-input comint-mode-map) + (bind-key "" 'comint-next-matching-input-from-input comint-mode-map) + ) + ) + +(use-package octave-mod + :mode ("\\.m\\'" . octave-mode) + :config + (progn + (defun ravi/octave-shell-switch-to-shell () + "Make sure that `inferior-octave-buffer' exists and is displayed." + (interactive) + (if (get-buffer inferior-octave-buffer) + (pop-to-buffer (get-buffer inferior-octave-buffer)) + (inferior-octave nil))) ) + ) + +(use-package repl-toggle + :config + (progn + (setq rtog/mode-repl-alist '((python-mode . python-shell-switch-to-shell) + (octave-mode . ravi/octave-shell-switch-to-shell) + (emacs-lisp-mode . ielm))) + (setq rtog/goto-buffer-fun 'pop-to-buffer) + (add-hook 'python-mode-hook 'rtog/activate) + (add-hook 'octave-mode-hook 'rtog/activate) + (add-hook 'emacs-lisp-mode-hook 'rtog/activate) + + ; The default keybinding is not great + (unbind-key "C-c C-z" repl-toggle-mode-map) + (bind-key "" 'rtog/toggle-repl repl-toggle-mode-map) + ) + :diminish repl-toggle-mode + :ensure t) + +(provide 'ravi-init-repl) +;;; ravi-init-repl.el ends here diff --git a/lisp/ravi-init-tex.el b/lisp/ravi-init-tex.el new file mode 100644 index 0000000..d7725e9 --- /dev/null +++ b/lisp/ravi-init-tex.el @@ -0,0 +1,189 @@ +;;; ravi-init-tex.el --- tex and friends + +;; Copyright (C) 2014 + +;; Author: +;; 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 . + +;;; Commentary: + +;; TeX and LaTeX support + +;;; Code: + +(use-package tex-site + :ensure auctex + :mode ("\\.tex\\'" . TeX-latex-mode) + :commands (TeX-latex-mode + TeX-mode + tex-mode + LaTeX-mode + latex-mode) + :config + (progn + (use-package latex + :config + (progn + (use-package reftex + :defer t + :diminish reftex-mode) + ;; fix the "bug" in SP regexp wrap that treats ' as "word" + (modify-syntax-entry ?' ".") + + (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-subscript 'ignore) + + (sp-with-modes '(tex-mode plain-tex-mode latex-mode) + (sp-local-pair "\\[" nil :post-handlers '(my-latex-math-block-indent))) + + (defun my-latex-math-block-indent (a action c) + (when (eq action 'insert) + (newline-and-indent) + (save-excursion (newline)))) + + (defun my-latex-compile () + (interactive) + (save-buffer) + (TeX-command "LaTeX" 'TeX-master-file nil)) + (bind-key "C-M-x" 'my-latex-compile LaTeX-mode-map) + + (defvar my-latex-wrap-choices '("emph" + "textsc")) + (defvar my-latex-wrap-history nil) + + (defun my-latex-wrap (macro-name) + (interactive (list (ido-completing-read + "Macro> " + my-latex-wrap-choices + nil 'confirm nil my-latex-wrap-history))) + (when (use-region-p) + (let ((b (region-beginning)) + (e (region-end))) + (goto-char e) + (insert "}") + (goto-char b) + (insert "\\" macro-name "{")))) + (bind-key "C-c w" 'my-latex-wrap LaTeX-mode-map) + + (defun my-end-of-environment () + (interactive) + (LaTeX-mark-environment) + (end-of-region)) + + (defun my-beginning-of-environment () + (interactive) + (LaTeX-mark-environment) + (beginning-of-region) + (deactivate-mark)) + + (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) + + (defun my-latex-remove-command () + "Unwrap the expression that point is in or before, also +removing the command name. By command we understand a symbol +starting with \\ and followed by a block of text enclosed in {}." + (interactive) + (let ((ok (sp-get-enclosing-sexp))) + (cond + ;; we're inside the { } block + (ok + (progn + (save-excursion + (goto-char (sp-get ok :beg)) + (zap-to-char -1 ?\\ )) + (sp-splice-sexp))) + ;; test if we are in looking at the command fromt he front + ((looking-at "\\\\") + (zap-up-to-char 1 ?{) + (sp-unwrap-sexp)) + ;; otherwise we're inside the command name + (t + (zap-to-char -1 ?\\ ) + (zap-up-to-char 1 ?{) + (sp-unwrap-sexp))))) + (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)))) + (e (save-excursion (while (texmathp) (forward-char 1)) (point)))) + (preview-region b e))) + (bind-key "C-" 'my-LaTeX-preview-math preview-map) + + (defun my-LaTeX-mode-init () + (setq TeX-auto-save t) + (setq TeX-parse-self t) + (TeX-PDF-mode t) + (setq reftex-plug-into-AUCTeX t) + (reftex-mode t) + (TeX-fold-mode t) + + (smartparens-mode 1) + + (LaTeX-add-environments + '("derivation" LaTeX-env-label)) + (TeX-add-symbols '("emph" 1)) + + (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) + + (message "LaTeX mode init complete.")) + ;; ACUTeX replaces latex-mode-hook with LaTeX-mode-hook + (add-hook 'LaTeX-mode-hook 'my-LaTeX-mode-init) + + )) + ) + ) + +(provide 'ravi-init-tex) +;;; ravi-init-tex.el ends here diff --git a/lisp/ravi-init-vc.el b/lisp/ravi-init-vc.el new file mode 100644 index 0000000..e4b273e --- /dev/null +++ b/lisp/ravi-init-vc.el @@ -0,0 +1,185 @@ +;;; ravi-init-vc.el --- vc control + +;; Copyright (C) 2013 + +;; Author: +;; 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 . + +;;; Commentary: + +;; Version control initialization + +;;; Code: + +;; Git +(use-package magit + :bind (("" . magit-status) + ("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 '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) + (diminish 'magit-auto-revert-mode) + + (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) + ) +(use-package git-timemachine + :ensure t + :bind ("C-x v t" . git-timemachine) + ) +(use-package magit-blame + :bind (("C-x v B" . magit-blame-mode))) + +;; 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..13dd758 --- /dev/null +++ b/lisp/ravi-init-web.el @@ -0,0 +1,100 @@ +;;; ravi-init-web.el --- Web development -*- lexical-binding: t; -*- + +;; Copyright (C) 2014 + +;; Author: +;; 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 . + +;;; 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 t) + +;; 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)) + (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)) + + ;; 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) + +(provide 'ravi-init-web) +;;; ravi-init-web.el ends here diff --git a/ravi-ergodox-mode.el b/ravi-ergodox-mode.el deleted file mode 100644 index e393a39..0000000 --- a/ravi-ergodox-mode.el +++ /dev/null @@ -1,83 +0,0 @@ -;;; ravi-ergodox-mode.el --- Keybindings fof Ergodox keyboard - -;; Copyright (C) 2014 Ravikiran Rajagopal - -;; Author: Ravikiran Rajagopal -;; Keywords: convenience, hardware - -;; 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 . - -;;; Commentary: - -;; Set up keymap for ergodox bindings - -;;; Code: - -(defgroup ravi-ergodox-mode nil - "Keybindings for ergodox." - :group 'ravi-ergodox-mode) - -(defvar ravi-ergodox-mode-map (make-sparse-keymap) - "Keymaps for command `ravi-ergodox-mode-map'.") - -(defcustom ravi-ergodox-mode-disable-predicates nil - "List of predicates that disable the mode. -Each function in the list receive no argument." - :group 'ravi-ergodox-mode) - -(defcustom ravi-ergodox-mode-disabled-modes nil - "Modes where `ravi-ergodox-mode' should not activate." - :group 'ravi-ergodox-mode - :type '(repeat symbol)) - -(define-minor-mode ravi-ergodox-mode - "Enable Ergodox keyboard special bindings." - :lighter " RE" :group 'convenience - :keymap ravi-ergodox-mode-map - :global t - (if ravi-ergodox-mode - (progn - (setq x-meta-keysym 'super) - (setq x-super-keysym 'meta)) - (progn - (setq x-meta-keysym nil) - (setq x-super-keysym nil)) - ) - ) - -(define-key ravi-ergodox-mode-map (kbd "H-m") 'magit-status) -(define-key ravi-ergodox-mode-map (kbd "") 'ff-find-other-file) -(if (and (boundp 'ravi/use-helm-instead-of-ido) ravi/use-helm-instead-of-ido) - (progn - (define-key ravi-ergodox-mode-map (kbd "") 'helm-multi-files) - (define-key ravi-ergodox-mode-map (kbd "") 'helm-locate)) - (progn - (define-key ravi-ergodox-mode-map (kbd "") 'ido-switch-buffer) - (define-key ravi-ergodox-mode-map (kbd "") 'ido-find-file))) - -(defun ravi-ergodox-mode-enable () - "Turn on ergodox bindings mode." - (and (not (memq major-mode ravi-ergodox-mode-disabled-modes)) - (not (catch 'disable - (dolist (pred ravi-ergodox-mode-disable-predicates) - (and (funcall pred) - (throw 'disable t))))) - (ravi-ergodox-mode 1))) - -(defun ravi-ergodox-mode-disable () - "Turn off ergodox bindings mode." - (ravi-ergodox-mode -1)) - -(provide 'ravi-ergodox-mode) -;;; ravi-ergodox-mode.el ends here diff --git a/ravi-init-appearance.el b/ravi-init-appearance.el deleted file mode 100644 index 035dc1d..0000000 --- a/ravi-init-appearance.el +++ /dev/null @@ -1,315 +0,0 @@ -;;; ravi-init-appearance.el --- Emacs appearance - -;; Copyright (C) 2013 - -;; Author: -;; 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 . - -;;; 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 / -(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) - -(setq sentence-end-double-space nil) -(defun sacha/unfill-paragraph (&optional region) - "Takes a multi-line paragraph and makes it into a single line of text." - (interactive (progn - (barf-if-buffer-read-only) - (list t))) - (let ((fill-column (point-max))) - (fill-paragraph nil region))) -(bind-key "M-Q" 'sacha/unfill-paragraph) - -;; 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 -(use-package smart-newline - :commands (smart-newline) - :init - (progn - (bind-key "" 'smart-newline prog-mode-map) - (bind-key "" '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) - -;; 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)))))) - -(use-package comment-dwim-2 - :bind (("M-;" . comment-dwim-2)) - :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 "")) - - (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 - :init - (progn - (popwin-mode 1) - (push '("*Pp Eval Output*" :height 15) popwin:special-display-config)) - :ensure t - ) - -(use-package import-popwin - :bind (("M-i" . import-popwin)) - :ensure t - ) - -(use-package ace-window - :bind (("M-o" . ace-window)) - :init - (progn - (setq aw-keys '(?a ?s ?d ?f ?g ?h ?j ?k ?l ?i ?e))) - :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) - -(provide 'ravi-init-appearance) -;;; ravi-init-appearance.el ends here diff --git a/ravi-init-cpp.el b/ravi-init-cpp.el deleted file mode 100644 index 5fe9e8f..0000000 --- a/ravi-init-cpp.el +++ /dev/null @@ -1,418 +0,0 @@ -;;; ravi-init-cpp.el --- C/C++ handling - -;; Copyright (C) 2013 - -;; Author: -;; 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 . - -;;; Commentary: - -;; C/C++ initialization - -;;; Code: - -; Generate a random string (of letters and numbers) of a given length -(defun ravi-random-ucn-string (len) - (coerce (loop for i below len for x = (random 36) collect - (+ x - (cond ((< x 10) 48) - ((< x 36) (- 65 10)) - ))) - 'string)) - -(use-package cmake-mode - :mode (("CMakeLists\\.txt\\'" . cmake-mode) - ("\\.cmake\\'" . cmake-mode)) - ;:ensure t - ) - -(defvar get-buffer-compile-command (lambda (file) (cons file 1))) -(make-variable-buffer-local 'get-buffer-compile-command) - -(setq-default compile-command "") - -(defun compile-dwim (&optional arg) - "Compile Do What I Mean. - Compile using `compile-command'. - When `compile-command' is empty prompt for its default value. - With prefix C-u always prompt for the default value of - `compile-command'. - With prefix C-u C-u prompt for buffer local compile command with - suggestion from `get-buffer-compile-command'. An empty input removes - the local compile command for the current buffer." - (interactive "P") - (cond - ((and arg (> (car arg) 4)) - (let ((cmd (read-from-minibuffer - "Buffer local compile command: " - (funcall get-buffer-compile-command - (or (file-relative-name (buffer-file-name)) "")) - nil nil 'compile-history))) - (cond ((equal cmd "") - (kill-local-variable 'compile-command) - (kill-local-variable 'compilation-directory)) - (t - (set (make-local-variable 'compile-command) cmd) - (set (make-local-variable 'compilation-directory) - default-directory)))) - (when (not (equal compile-command "")) - ;; `compile' changes the default value of - ;; compilation-directory but this is a buffer local - ;; compilation - (let ((dirbak (default-value 'compilation-directory))) - (compile compile-command) - (setq-default compilation-directory dirbak)))) - ((or (and arg (<= (car arg) 4)) - (equal compile-command "")) - (setq-default compile-command (read-shell-command - "Compile command: " - (if (equal compile-command "") - "make " compile-command) - 'compile-history)) - (setq-default compilation-directory default-directory) - (when (not (equal (default-value 'compile-command) "")) - (compile (default-value 'compile-command)))) - (t - (recompile)))) - - -(use-package cc-mode - - :mode (("\\.h\\(h?\\|xx\\|pp\\)\\'" . c++-mode) - ("\\.ccfg\\'" . c++-mode) - ("\\.m\\'" . c-mode) - ("\\.mm\\'" . c++-mode)) - :init - (progn - (use-package doxymacs - :load-path (lambda () (ravi/emacs-file "site-lisp/doxymacs/lisp")) - :config - (progn - (doxymacs-mode) - (setq doxymacs-file-comment-template - '("/**" > n - " * " (doxymacs-doxygen-command-char) "file" > n - " * " > n - " * " (doxymacs-doxygen-command-char) "brief " - (p "Brief description of this file: ") > n - " */" > n) - ) - (setq doxymacs-external-xml-parser-executable - (ravi/emacs-file "site-lisp/doxymacs/c/doxymacs_parser")) - (setq doxymacs-use-external-xml-parser t) - (setq doxymacs-command-character "\\") - ) - :diminish doxymacs-mode - ) - - (defvar printf-index 0) - - (defun insert-counting-printf (arg) - (interactive "P") - (if arg - (setq printf-index 0)) - (if t - (insert (format "std::cerr << \"step %d..\" << std::endl;\n" - (setq printf-index (1+ printf-index)))) - (insert (format "printf(\"step %d..\\n\");\n" - (setq printf-index (1+ printf-index))))) - (forward-line -1) - (indent-according-to-mode) - (forward-line)) - - ) - - :config - (progn - - (defun my-c-mode-common-hook () - (hs-minor-mode 1) - (hs-hide-initial-comment-block) - (hide-ifdef-mode 1) - (which-function-mode 1) - - (diminish 'hs-minor-mode) - (diminish 'hide-ifdef-mode) - - (bind-key "C-c p" 'insert-counting-printf c-mode-base-map) - - (doxymacs-mode 1) - (doxymacs-font-lock) - - ;(define-key c-mode-base-map [return] 'c-context-line-break) - (bind-key "" '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)) - - (set (make-local-variable 'parens-require-spaces) t) - (setq fill-column 88) - - (bind-key "M-q" 'c-fill-paragraph c-mode-base-map) - - (c-toggle-electric-state 1) - (c-toggle-auto-newline 1) - (c-toggle-hungry-state 1) - - (c-set-style "stroustrup") - (setq c-basic-offset 2) - (setq c-recognize-knr-p nil) - (modify-syntax-entry ?_ "w" c-mode-syntax-table) - (add-to-list 'c-cleanup-list 'empty-defun-braces) - (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) - ;; 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)))) - - (add-hook 'c-mode-common-hook 'my-c-mode-common-hook) - - (defun my-c++-mode-hook () - (setq c-offsets-alist - (append '((statement-cont . c-lineup-math) - (inline-open . 0)) - c-offsets-alist)) - (let ((innamespaceindent (if (and (buffer-file-name) - (string-equal "ccfg" (file-name-extension (buffer-file-name)))) - 2 0)) - ) - (setq c-offsets-alist - (append `((innamespace . ,innamespaceindent) - ) - c-offsets-alist)) - ) - - (modify-syntax-entry ?_ "w" c++-mode-syntax-table) - (setq c-macro-cppflags "-x c++") - (setq c-macro-prompt-flag t) - ) - (add-hook 'c++-mode-hook 'my-c++-mode-hook) - - ;; Stuff from kde-emacs - (defvar kde-header-protection-parts-to-show 1 - "Set this variable to the number of parts from the file name you want to -be used for the defined word in the header-protection function.. E.g. setting -this to 3 makes header-protection define KIG_MISC_NEWTYPE_H for a file named -/home/domi/src/kdenonbeta/kig/misc/newtype.h") - - (defun kde-header-protection-definable-string () - (let* ((definablestring (concat "_" (ravi-random-ucn-string 6)) ) - (f (buffer-file-name)) - (parts (nreverse (split-string f "/"))) - (i) - (first-iter t) - (iters (min (length parts) kde-header-protection-parts-to-show))) - (dotimes (i iters) - (let ((part (pop parts))) - (setq definablestring - (concat - (upcase (replace-regexp-in-string "[\\.-]" "_" part)) - (if (not first-iter) "_" "") - definablestring - ) - ) - (setq first-iter nil) - ) - ) - definablestring - ) - ) - - ;; Creates the ifndef/define/endif statements necessary for a header file - (defun header-protection () - (interactive) - (let ((s (kde-header-protection-definable-string))) - (save-excursion - (goto-char (point-min)) - (insert "#ifndef " s "\n#define " s "\n\n") - (goto-char (point-max)) - (insert "\n#endif\n") - ) - ) - ) - - (defun ravi-start-c++-header () - "Start a new C++ header by inserting include guards ( see \ - header-protection function ), inserting a license statement \ - and putting (point) at the correct position" - (interactive) - (header-protection) - (insert "\n") - (beginning-of-buffer) - - (save-excursion - (let ((start (point-min)) - (comment-style 'box) - (end) - ) - (goto-char start) - (insert (ravi-license-header)) - (setq end (point)) - (comment-region start end) - ) - ) - - (end-of-buffer) - (next-line -3) - (insert "\n") - (doxymacs-insert-file-comment) - ) - - (setq auto-insert-query nil) - (define-auto-insert "\\.\\([Cc]\\|cc\\|cpp\\|cxx\\|tcc\\)\\'" - 'ravi-auto-insert-cpp) - (define-auto-insert "\\.\\([Hh]\\|hh\\|hpp\\)\\'" 'ravi-start-c++-header) - - (defun ravi-license-insert () - (progn - (let ((start (point-min)) - (comment-style 'box) - (end) - ) - (goto-char start) - (insert (ravi-license-header)) - (insert "\n") - (setq end (point)) - (comment-region start end)))) - - (defun ravi-auto-insert-cpp () - (progn - (ravi-license-insert) - (doxymacs-insert-file-comment))) - - (defun ravi/add-space-before-paren-c (&rest ignored) - (message "Handler invoked") - (when (looking-back "\\b\\(for\\|while\\|if\\|switch\\)(") - (save-excursion - (backward-char) - (insert-char ?\s) - ) - )) - - (defadvice c-electric-paren (after ravi/add-space-around-parens activate) - (unless (c-in-literal) - (cond - ((looking-back "([[:space:]]*") - (progn - ;; Open parenthesis was the last command; add a space before it if - ;; necessary, and ensure that the point is placed after a space - (save-excursion - (re-search-backward "([[:space:]]*") - (unless (looking-at "(") (message "Logic error; opening paren not found")) - (when (looking-back "\\b\\(for\\|while\\|if\\|switch\\|catch\\)") - (insert-char ?\s))) - (if (and (looking-at " ") (not (looking-at " )"))) - (forward-char) - (insert-char ?\s)) - ) - ) - ((looking-back ")[[:space:]]*") - ;; Closing parenthesis was the last command; add spaces if necessary - (progn - ;; Compact empty function calls - (when (looking-back "([[:space:]]+)[[:space:]]*") - (save-excursion - (re-search-backward ")[[:space:]]*") - (delete-horizontal-space) - ) - ) - - ;; Add space before closing parenthesis - (unless (looking-back "()[[:space:]]*") - (save-excursion - (re-search-backward ")[[:space:]]*") - (unless (looking-at ")") (message "Logic error; closing paren not found")) - (unless (looking-back " ") (insert-char ?\s))) - ) - - (let (need-to-add-newline) - (save-excursion - (c-backward-sexp) - (c-backward-syntactic-ws) - ;; FIXME: do-while loops are not handled correctly - (setq need-to-add-newline (looking-back "\\b\\(for\\|while\\|if\\|switch\\|catch\\)")) - ) - (when need-to-add-newline (c-newline-and-indent))) - ) - ) - )) - ) - - (defadvice c-electric-semi&comma (after ravi/add-space-after-comma activate) - (cond - ((looking-back ",") - (if (looking-at " [^)]") (forward-char) (insert-char ?\s))) - ((looking-back ") ;[[:space:]\n]*") - (save-excursion - (re-search-backward " ;[[:space:]\n]*") - (delete-char 1))))) - - ;; Do not activate region as it interferes with region-bindings-mode - (defadvice c-electric-brace (after ravi/do-not-activate-region activate) - (deactivate-mark)) - - (defmacro ravi/fake-send-key (key-to-bind char-to-bind) - (let ((command (key-binding key-to-bind))) - (setq last-command-event char-to-bind) - (setq this-command command) - (call-interactively command)) - ) - - (defun ravi/insert-closing-delimiter() - (interactive) - (if (c-in-literal) - (self-insert-command) - (progn - ;; Find nearest unmatched opening delimiter - (let (brace-type) - (save-excursion - (backward-up-list) - (cond - ((looking-at "{") (setq brace-type 'brace-type-brace)) - ((looking-at "(") (setq brace-type 'brace-type-paren)) - ((looking-at "\\[") (setq brace-type 'brace-type-square)) - (t (setq brace-type 'brace-type-none)) - )) - (cond - ((eq brace-type 'brace-type-brace) (ravi/fake-send-key "}" ?\})) - ((eq brace-type 'brace-type-paren) (ravi/fake-send-key ")" ?\))) - ; Uncommenting the line below would lead to infinite recursion - ;((eq 'brace-type 'brace-type-square) (ravi/fake-send-key "]" ?\])) - (t (self-insert-command 1)) - ) - )))) - - (bind-key "]" 'ravi/insert-closing-delimiter c-mode-base-map) - - (bind-key "" 'compile-dwim c-mode-base-map) - - (bind-key "" 'hs-hide-block c-mode-base-map) - (bind-key "" 'hs-show-block c-mode-base-map) - - (setq hide-ifdef-initially nil) - (bind-key "" 'hide-ifdef-block c-mode-base-map) - (bind-key "" 'show-ifdef-block c-mode-base-map) - - ;; (setq c-syntactic-indentation nil) - ) - ) - -(provide 'ravi-init-cpp) -;;; ravi-init-cpp.el ends here diff --git a/ravi-init-dired.el b/ravi-init-dired.el deleted file mode 100644 index 0c8fab2..0000000 --- a/ravi-init-dired.el +++ /dev/null @@ -1,149 +0,0 @@ -;;; ravi-init-dired.el --- dired setup - -;; Copyright (C) 2014 - -;; Author: -;; 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 . - -;;; Commentary: - -;; Mostly stolen from Fuco's configuration - -;; Dired setup - -;;; Code: - -(use-package dired - :defer t - :config - (progn - (defun ravi/dired-init-hook () - (dired-filter-mode t) - (visual-line-mode -1) - (toggle-truncate-lines 1)) - (add-hook 'dired-mode-hook 'ravi/dired-init-hook) - - (use-package image-dired) - (use-package dired-aux) - (use-package dired-x - :config - (defun dired-virtual-revert (&optional _arg _noconfirm) - "Enable revert for virtual direds." - (let ((m (dired-file-name-at-point)) - (buffer-modified (buffer-modified-p))) - (goto-char 1) - (dired-next-subdir 1) - (dired-do-redisplay nil t) - (while (dired-next-subdir 1 t) - (dired-do-redisplay nil t)) - (when m (dired-goto-file m)) - (set-buffer-modified-p buffer-modified)))) - - (use-package dired-details - :commands dired-details-toggle - :ensure t - ) - (use-package w32-browser - :commands dired-w32-browser - :ensure t - ) - - (use-package dired-subtree - :ensure t - :config - (progn - (bind-keys :map dired-mode-map - :prefix "," - :prefix-map dired-subtree-map - :prefix-docstring "Dired subtree map." - ("/" . dired-subtree-apply-filter) - ("k" . dired-subtree-remove) - ("n" . dired-subtree-next-sibling) - ("p" . dired-subtree-previous-sibling) - ("u" . dired-subtree-up) - ("d" . dired-subtree-down) - ("a" . dired-subtree-beginning) - ("e" . dired-subtree-end) - ("m" . dired-subtree-mark-subtree) - ("u" . dired-subtree-unmark-subtree) - ("C-o C-f" . dired-subtree-only-this-file) - ("C-o C-d" . dired-subtree-only-this-directory)) - (bind-key "e" 'dired-subtree-insert dired-mode-map)) - ) - - (defconst my-dired-media-files-extensions '("mp3" "mp4" "MP3" "MP4" "avi" "mpg" "flv" "ogg") - "Media file extensions that should launch in VLC. - -Also used for highlighting.") - - (use-package dired-rainbow - :config - (progn - (dired-rainbow-define html "#4e9a06" ("htm" "html" "xhtml")) - (dired-rainbow-define xml "DarkGreen" ("xml" "xsd" "xsl" "xslt" "wsdl")) - - (dired-rainbow-define document "#fce94f" ("doc" "docx" "odt" "pdb" "pdf" "ps" "rtf")) - (dired-rainbow-define media "#ce5c00" my-dired-media-files-extensions) - (dired-rainbow-define image "#ff4b4b" ("jpg" "png" "jpeg" "gif")) - - (dired-rainbow-define log "#c17d11" ("log")) - (dired-rainbow-define sourcefile "#fcaf3e" ("py" "c" "cc" "h" "java" "pl" "rb")) - - (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"))) - :ensure t) - - (add-to-list 'dired-guess-shell-alist-user (list (regexp-opt my-dired-media-files-extensions) - "vlc")) - - (use-package dired-filter - :ensure t - ) - - (use-package dired-open - :config - (progn - (bind-key "E" 'dired-open-xdg dired-mode-map)) - :ensure t) - - (use-package dired-avfs - :ensure t - :disabled t ; avfs not in Fedora repositories yet - ) - - (require 'dash) - (--each '(dired-do-rename - dired-do-copy - dired-create-directory - wdired-abort-changes) - (eval `(defadvice ,it (after revert-buffer activate) - (revert-buffer)))) - - (defun ravi/dired-guide-key-hook () - (guide-key/add-local-guide-key-sequence "%") - (guide-key/add-local-guide-key-sequence "*") - (guide-key/add-local-guide-key-sequence "/") - (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) - - )) - -(provide 'ravi-init-dired) -;;; ravi-init-dired.el ends here diff --git a/ravi-init-files.el b/ravi-init-files.el deleted file mode 100644 index 9ac482d..0000000 --- a/ravi-init-files.el +++ /dev/null @@ -1,159 +0,0 @@ -;;; ravi-init-files.el --- file-handling - -;; Copyright (C) 2013 - -;; Author: -;; 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 . - -;;; Commentary: - -;; File handling - -;;; Code: - -(setq auto-save-list-file-prefix (ravi/emacs-file "past/auto-save-list/.saves-")) -(setq delete-auto-save-files t) -(setq dired-listing-switches "-Flag") -(setq completion-ignored-extensions - (append completion-ignored-extensions - (quote (".bak" ".#*#" ".ps" ".pdf")))) - -;; Auto refresh buffers -(global-auto-revert-mode 1) - -;; Also auto refresh dired, but be quiet about it -(setq global-auto-revert-non-file-buffers t) -(setq global-auto-revert-ignore-modes '(TeX-output-mode)) -(setq auto-revert-verbose nil) - -;; Transparently open compressed files -(auto-compression-mode t) - -;; UTF-8 please -(setq locale-coding-system 'utf-8) ; pretty -(set-terminal-coding-system 'utf-8) ; pretty -(set-keyboard-coding-system 'utf-8) ; pretty -(set-selection-coding-system 'utf-8) ; please -(prefer-coding-system 'utf-8) ; with sugar on top - -(setq history-length 100) -(setq savehist-file (ravi/emacs-file "past/history")) -(savehist-mode 1) -(setq history-delete-duplicates t) - -(require 'saveplace) -(setq-default save-place t) -(setq save-place-file (ravi/emacs-file "past/places")) - -(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) -(setq uniquify-after-kill-buffer-p t) ; rename after killing uniquified -(setq uniquify-ignore-buffers-re "^\\*") ; don't muck with special buffers - -(setq minibuffer-completion-confirm t) -(setq find-file-confirm-nonexistent-file t) -(setq find-file-visit-truename t) - -;; Automatic loading of file trees -(defun ravi-check-dir-accessible-p (name) - "Check whether NAME is accessible as a directory" - (let* ((topname (file-name-as-directory name)) - (name-exists (and (file-exists-p topname) - (file-directory-p topname) - (file-accessible-directory-p topname) - topname))) - name-exists - )) - -(defun ravi-filecache-add-tree (root recursive simple) - "Add list of directories to filecache for easy opening. -ROOT is the root of the tree to be added. RECURSIVE is a list of -relative paths whose subdirectories are added recursively, while -relative paths in SIMPLE are added non-recursively. If a path does -not exist, it is not added to the filecache." - - (let ((topname (ravi-check-dir-accessible-p root)) - (dirval nil)) - (when topname - (dolist (dir recursive) - (setq dirval (ravi-check-dir-accessible-p - (expand-file-name dir topname))) - (and dirval - (file-cache-add-directory-recursively dirval))) - (dolist (dir simple) - (setq dirval (ravi-check-dir-accessible-p - (expand-file-name dir topname))) - (and dirval - (file-cache-add-directory dirval))) - ))) - -;; Write backup files to own directory -(make-directory (ravi/emacs-file "past/backups/") t) -(setq backup-by-copying t) -(setq backup-directory-alist - `(("." . ,(ravi/emacs-file "past/backups/")) - (,tramp-file-name-regexp nil))) - -;; Make backups of files, even when they're in version control -(setq vc-make-backup-files t) - -;; Git/svn/etc. projects -(use-package projectile - :init - (progn - (use-package pkg-info - :ensure t - ) - (setq projectile-known-projects-file - (ravi/emacs-file "past/projectile-bookmarks.eld")) - ) - :config - (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 - ) - -;; Use emacsclient as external editor for kmail -(add-to-list 'auto-mode-alist - (cons (concat temporary-file-directory ".*/kmail[[:alnum:]]*.tmp\\'") 'message-mode)) -(setq gnus-message-highlight-citation t) - -(provide 'ravi-init-files) -;;; ravi-init-files.el ends here diff --git a/ravi-init-function.el b/ravi-init-function.el deleted file mode 100644 index 671d45c..0000000 --- a/ravi-init-function.el +++ /dev/null @@ -1,35 +0,0 @@ -;;; ravi-init-function.el --- functionality - -;; Copyright (C) 2013 - -;; Author: -;; 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 . - -;;; 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 -(unless (server-running-p) (server-start)) - -(provide 'ravi-init-function) -;;; ravi-init-function.el ends here diff --git a/ravi-init-helm.el b/ravi-init-helm.el deleted file mode 100644 index 5ff7f9d..0000000 --- a/ravi-init-helm.el +++ /dev/null @@ -1,89 +0,0 @@ -;;; ravi-init-helm.el --- helm initialization -*- lexical-binding: t; -*- - -;; Copyright (C) 2015 - -;; Author: -;; 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 . - -;;; 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 (("" . helm-command-prefix) - ("M-x" . helm-M-x) - ("" . helm-multi-files) - ("" . helm-locate) - ("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 "" 'helm-execute-persistent-action helm-map) - (bind-key "H-" 'helm-select-action helm-map) - - (use-package helm-ag - :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) - -(use-package helm-descbinds - :bind (("C-h b" . helm-descbinds)) - :ensure t) - -(provide 'ravi-init-helm) -;;; ravi-init-helm.el ends here diff --git a/ravi-init-ido.el b/ravi-init-ido.el deleted file mode 100644 index 93af3e6..0000000 --- a/ravi-init-ido.el +++ /dev/null @@ -1,164 +0,0 @@ -;;; ravi-init-ido.el --- ido initialization - -;; Copyright (C) 2013 - -;; Author: -;; 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 . - -;;; Commentary: - -;; Ido initialization - -;;; Code: - -;; Almost all of the code below is stolen from jwiegley's .emacs.d. - -(use-package ibuffer - :bind ("C-x C-b" . ibuffer) - :config - (progn - - (use-package ibuffer-vc - :ensure t - :commands ibuffer-vc-set-filter-groups-by-vc-root - ) - - ;; Switching to ibuffer puts the cursor on the most recent past buffer - (defadvice ibuffer (around ibuffer-point-to-most-recent-but-one activate) () - "Open ibuffer with cursor pointed to most recent buffer name" - (let ((recent-buffer-name (buffer-name (other-buffer (current-buffer) t)))) - ad-do-it - (ibuffer-jump-to-buffer recent-buffer-name))) - - (defun ravi/ibuffer-vc-sort-hook () - (ibuffer-vc-set-filter-groups-by-vc-root) - (unless (eq ibuffer-sorting-mode 'alphabetic) - (ibuffer-do-sort-by-alphabetic))) - (add-hook 'ibuffer-hook 'ravi/ibuffer-vc-sort-hook) - ) - ) - -(use-package ace-jump-buffer - :bind (("M-" . ace-jump-buffer) - ("C-" . ace-jump-buffer-other-window) - ("S-" . ace-jump-projectile-buffers)) - ;; :config - ;; (progn - ;; (bind-key "M-" 'ido-switch-buffer)) - :ensure t) - -;;;_ , ido - -(use-package ido - :defines (ido-cur-item - ido-require-match - 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 - :config - (ido-hacks-mode 1) - :ensure t - ) - - (use-package flx-ido - :config - (progn - (use-package flx - :ensure t) - (flx-ido-mode 1) - ) - :ensure t - ) - (setq ido-use-filename-at-point 'guess) - (setq ido-use-virtual-buffers t) - (setq ido-create-new-buffer 'always) - - (use-package ido-ubiquitous - :config - (ido-ubiquitous-mode t) - :ensure t - ) - - (use-package ido-vertical-mode - :config - (ido-vertical-mode 1) - :ensure t - ) - - (defun ido-smart-select-text () - "Select the current completed item. Do NOT descend into directories." - (interactive) - (when (and (or (not ido-require-match) - (if (memq ido-require-match - '(confirm confirm-after-completion)) - (if (or (eq ido-cur-item 'dir) - (eq last-command this-command)) - t - (setq ido-show-confirm-message t) - nil)) - (ido-existing-item-p)) - (not ido-incomplete-regexp)) - (when ido-current-directory - (setq ido-exit 'takeprompt) - (unless (and ido-text (= 0 (length ido-text))) - (let ((match (ido-name (car ido-matches)))) - (throw 'ido - (setq ido-selected - (if match - (replace-regexp-in-string "/\\'" "" match) - ido-text) - ido-text ido-selected - ido-final-text ido-text))))) - (exit-minibuffer))) - - (add-hook 'ido-minibuffer-setup-hook - #'(lambda () - (bind-key "" 'ido-smart-select-text - ido-file-completion-map))) - - (defun ido-switch-buffer-tiny-frame (buffer) - (interactive (list (ido-read-buffer "Buffer: " nil t))) - (with-selected-frame - (make-frame '((width . 80) - (height . 22) - (left-fringe . 0) - (right-fringe . 0) - (vertical-scroll-bars . nil) - (unsplittable . t) - (has-modeline-p . nil) - ;;(background-color . "grey80") - (minibuffer . nil))) - (switch-to-buffer buffer) - (set (make-local-variable 'mode-line-format) nil))) - - (bind-key "C-x 5 t" 'ido-switch-buffer-tiny-frame))) - -(use-package smex - :init - (global-set-key [remap execute-extended-command] 'smex) - :if (not ravi/use-helm-instead-of-ido) - :ensure t - ) - -(provide 'ravi-init-ido) -;;; ravi-init-ido.el ends here diff --git a/ravi-init-insertion.el b/ravi-init-insertion.el deleted file mode 100644 index 65ff9db..0000000 --- a/ravi-init-insertion.el +++ /dev/null @@ -1,136 +0,0 @@ -;;; ravi-init-insertion.el --- inserting text - -;; Copyright (C) 2013 - -;; Author: -;; 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 . - -;;; 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-" . aya-create) - ("" . 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) - - (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 - (company-quickhelp-mode 1) - :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) - (bind-key "" '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/ravi-init-layouts.el deleted file mode 100644 index f6199ce..0000000 --- a/ravi-init-layouts.el +++ /dev/null @@ -1,57 +0,0 @@ -;;; ravi-init-layouts.el --- layouts - -;; Copyright (C) 2014 - -;; Author: -;; 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 . - -;;; Commentary: - -;; Uses undocumented emacs API - -;;; Code: - -(require 'quail) - -(quail-define-package - "english-prog" "English programmer" "EN-P" t - "English programmer's keyboard." - nil t nil nil t nil nil nil nil nil t) - -(quail-define-rules - ("!" ?1) - ("@" ?2) - ("#" ?3) - ("$" ?4) - ("%" ?5) - ("^" ?6) - ("&" ?7) - ("*" ?8) - ("(" ?9) - (")" ?0) - ("1" ?!) - ("2" ?@) - ("3" ?#) - ("4" ?$) - ("5" ?%) - ("6" ?^) - ("7" ?&) - ("8" ?*) - ("9" ?\() - ("0" ?\))) - -(provide 'ravi-init-layouts) -;;; ravi-init-layouts.el ends here diff --git a/ravi-init-marks.el b/ravi-init-marks.el deleted file mode 100644 index 803b2cb..0000000 --- a/ravi-init-marks.el +++ /dev/null @@ -1,78 +0,0 @@ -;;; ravi-init-marks.el --- Handling the mark - -;; Copyright (C) 2013 - -;; Author: -;; 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 . - -;;; Commentary: - -;; Handling the mark - -;;; Code: - -;; Show active region -(transient-mark-mode 1) -(make-variable-buffer-local 'transient-mark-mode) -(put 'transient-mark-mode 'permanent-local t) -(setq-default transient-mark-mode t) - -;; When popping the mark, continue popping until the cursor actually moves -;; Also, if the last command was a copy - skip past all the expand-region cruft. -;; Stolen from Magnar Sveen's emacs.d on github. -(defadvice pop-to-mark-command (around ensure-new-position activate) - (let ((p (point))) - (when (eq last-command 'save-region-or-current-line) - ad-do-it - ad-do-it - ad-do-it) - (dotimes (i 10) - (when (= p (point)) ad-do-it)))) - -;; Allow mark-based navigation even in transient-mark-mode; see -;; http://www.masteringemacs.org/articles/2010/12/22/fixing-mark-commands-transient-mark-mode/ - -(defun ravi/push-mark-no-activate () - "Pushes `point' to `mark-ring' and does not activate the region -Equivalent to \\[set-mark-command] when \\[transient-mark-mode] is disabled" - (interactive) - (push-mark (point) t nil) - (message "Pushed mark to ring")) -(bind-key "C-`" 'ravi/push-mark-no-activate) - -(defun ravi/jump-to-mark () - "Jumps to the local mark, respecting the `mark-ring' order. -This is the same as using \\[set-mark-command] with the prefix argument." - (interactive) - (set-mark-command 1)) -(bind-key "M-`" 'ravi/jump-to-mark) - -; Prevents C-x C-x from highlighting region -(defun ravi/exchange-point-and-mark-no-activate () - "Identical to \\[exchange-point-and-mark] but will not activate the region." - (interactive) - (exchange-point-and-mark) - (deactivate-mark nil)) -(define-key global-map [remap exchange-point-and-mark] 'ravi/exchange-point-and-mark-no-activate) - -(use-package browse-kill-ring - :config (browse-kill-ring-default-keybindings) - :ensure t - :if (not ravi/use-helm-instead-of-ido) - ) - -(provide 'ravi-init-marks) -;;; ravi-init-marks.el ends here diff --git a/ravi-init-mu.el b/ravi-init-mu.el deleted file mode 100644 index b123da2..0000000 --- a/ravi-init-mu.el +++ /dev/null @@ -1,196 +0,0 @@ -;;; ravi-init-mu.el --- mail - -;; Copyright (C) 2014 - -;; Author: -;; 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 . - -;;; 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) - (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 (mu4e-maildirs-extension) ; does not work with mu now - :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) - ;; 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) - - (imagemagick-register-types) - ) - ) - ) - -(provide 'ravi-init-mu) -;;; ravi-init-mu.el ends here diff --git a/ravi-init-navigation.el b/ravi-init-navigation.el deleted file mode 100644 index 5a6054d..0000000 --- a/ravi-init-navigation.el +++ /dev/null @@ -1,350 +0,0 @@ -;;; ravi-init-navigation.el --- navigation utilities - -;; Copyright (C) 2013 - -;; Author: -;; 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 . - -;;; Commentary: - -;; Buffer navigation utilities - -;;; Code: - -(use-package region-bindings-mode - :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 "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) - ) - :ensure t - ) - -(use-package ace-jump-mode - :bind (("M-h" . ace-jump-mode) - ("M-H" . ace-jump-line-mode)) - :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)) - :ensure t) - -(use-package jump-char - :bind (("M-m" . jump-char-forward)) - :ensure t - ) - -(use-package imenu-anywhere - :bind ("s-." . imenu-anywhere) - :ensure t - ) - -(use-package expand-region - :config - (progn - (bind-key "C-=" 'er/expand-region)) - :ensure t - ) - -(use-package multiple-cursors - :bind (("C-S-c C-S-c" . mc/edit-lines) - - ("C->" . mc/mark-next-like-this) - ("C-<" . mc/mark-previous-like-this) - ("C-c C-<" . mc/mark-all-like-this)) - :config - (progn - (setq mc/list-file (ravi/emacs-file "past/mc-lists.el")) - (bind-key "a" 'mc/mark-all-like-this region-bindings-mode-map) - (bind-key "p" 'mc/mark-previous-like-this region-bindings-mode-map) - (bind-key "n" 'mc/mark-next-like-this region-bindings-mode-map) - (bind-key "m" 'mc/mark-more-like-this-extended region-bindings-mode-map) - ) - :ensure t - ) - -(use-package fold-this - :commands fold-this - :config - (progn - (bind-key "t" 'fold-this region-bindings-mode-map)) - :ensure t - ) - -(use-package indirect - :commands indirect-region - :config - (progn - (bind-key "I" 'indirect-region region-bindings-mode-map)) - ) - -(use-package visual-regexp - :bind (("C-c r" . vr/replace) - ("C-c q" . vr/query-replace) - ("C-c m" . vr/mc-mark)) - :ensure t - ) - -(use-package god-mode - :bind (("" . god-local-mode)) - :disabled t ; less useful than I thought - :ensure t - ) - -(bind-key "" 'ff-find-other-file) - -(setq compilation-scroll-output 'first-error) - -(use-package smartparens - :commands (smartparens-mode show-smartparens-mode) - :init - (show-smartparens-global-mode 1) - :config - (progn - (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 - ) - -;; Marking and moving lines - -(defun ravi/pull-up-a-line() - "Pull up the next line" - (interactive) - (join-line -1) - ) - -(bind-key "M-j" 'ravi/pull-up-a-line) - -(use-package move-lines - :bind (("" . move-lines-down) - ("" . move-lines-up) - ) - ) - -;; From Kyle Sherman's comment at -;; http://emacs-fu.blogspot.com/2010/01/duplicating-lines-and-commenting-them.html -;; \todo Make this work someday with regions too. -(defun ravi/kyle-sherman-duplicate-line (&optional comment line) - "Duplicate the line containing the point. -\nIf COMMENT is non-nil, also comment out the original line. - If LINE is non-nil, duplicate that line instead." - (interactive "P") - (let ((col (current-column))) - (save-excursion - (when line - (goto-line line)) - (let ((line (buffer-substring (point-at-bol) (point-at-eol)))) - (when comment - (comment-region (point-at-bol) (point-at-eol))) - (goto-char (point-at-eol)) - (if (eobp) - (newline) - (forward-line 1)) - (open-line 1) - (insert line))) - (forward-line 1) - (move-to-column col))) - -;; C-: duplicates line, C-u C-: comments first line -(bind-key "C-:" 'ravi/kyle-sherman-duplicate-line) - -(defun ravi/back-to-indentation-or-beginning () (interactive) - (if (bolp) (back-to-indentation) - (beginning-of-line))) -(bind-key "C-a" 'ravi/back-to-indentation-or-beginning) - -(defun ravi/Fuco-point-in-comment () - "Determine if the point is inside a comment" - (interactive) - (let ((syn (syntax-ppss))) - (and (nth 8 syn) - (not (nth 3 syn))))) - -(defun ravi/Fuco-end-of-code-or-line+ (arg) - "Move to the end of line. If already there, move to the end of code. - - Comments are recognized in any mode that sets syntax-ppss properly." - (interactive "P") - (let ((eoc (save-excursion - (move-end-of-line arg) - (while (ravi/Fuco-point-in-comment) - (backward-char)) - (skip-chars-backward " \t") - (point)))) - (cond ((eolp) - (move-end-of-line arg) - (while (ravi/Fuco-point-in-comment) - (backward-char)) - (skip-chars-backward " \t")) - (t - (move-end-of-line arg))))) -(bind-key "C-e" 'ravi/Fuco-end-of-code-or-line+) - -;; Use current line for region-based commands if no region selected -(use-package whole-line-or-region - :config - (progn - (defun turn-on-whole-line-or-region-mode() - (interactive) - (whole-line-or-region-mode 1) - ) - (add-hook 'prog-mode-hook 'turn-on-whole-line-or-region-mode) - ) - :diminish whole-line-or-region-mode - ) - -;; grep and friends - -(use-package wgrep - :ensure t - ) - -(if (executable-find "ag") - ;; Prefer the silver-searcher if available - (use-package ag - :bind (("H-g" . ag) - ("H-G" . ag-files)) - :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) - ("H-N" . highlight-symbol-prev) - ("H-s" . highlight-symbol-query-replace)) - :commands highlight-symbol-next - :config - (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 "s") 'highlight-symbol-query-replace) - (define-key map (kbd "o") 'highlight-symbol-occur) - map)) - (defun ravi/highlight-symbol-next () - (interactive) - (highlight-symbol-next) - (set-temporary-overlay-map ravi/highlight-symbol-overlay-map t)) - ) - :ensure t - ) - -(let ((ad-redefinition-action 'accept)) - (use-package color-moccur - :commands (isearch-moccur isearch-all) - :bind ("M-s O" . moccur) - :init - (progn - (bind-key "M-o" 'isearch-moccur isearch-mode-map) - (bind-key "M-O" 'isearch-moccur-all isearch-mode-map)) - - :config - (use-package moccur-edit) - - :ensure t - ) - ) - -;; 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 "" 'isearch-exit-other-end isearch-mode-map) - -;; Search the web -(use-package webjump - :bind ("C-x g" . webjump) - :config - (progn - ;; Suggest word at point if possible - (defun webjump-read-string (prompt) - (let* ((prompt (concat prompt (if (word-at-point) (concat " (default: " (word-at-point) ")")) ": ")) - (input (read-string prompt))) - (if (webjump-null-or-blank-string-p input) (word-at-point) input))) - - ;; C++ reference - (add-to-list 'webjump-sites - '("cpp" . [simple-query "en.cppreference.com" - "http://en.cppreference.com/mwiki/index.php?title=Special:Search&search=" - ""])) - ) - ) - -;; to do: add zeal-at-point - -(provide 'ravi-init-navigation) -;;; ravi-init-navigation.el ends here diff --git a/ravi-init-org.el b/ravi-init-org.el deleted file mode 100644 index 004d2f6..0000000 --- a/ravi-init-org.el +++ /dev/null @@ -1,53 +0,0 @@ -;;; ravi-init-org.el --- org initialization - -;; Copyright (C) 2014 - -;; Author: -;; 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 . - -;;; Commentary: - -;; Org mode initialization - -;;; Code: - -(use-package org - :ensure org-plus-contrib - :mode ("\\.org\\'" . org-mode) - - ;; The following lines are always needed. Choose your own keys. - :bind (("C-c l" . org-store-link) - ("H--" . org-agenda)) - :config - (progn - (use-package htmlize - :ensure t) - (use-package ox-reveal - :load-path (lambda () (ravi/emacs-file "site-lisp/org-reveal")) - ) - (setq org-src-fontify-natively t) - (setq org-modules (quote (org-bbdb - org-bibtex - org-crypt - org-gnus - org-id - org-info))) - ) - ) - -(provide 'ravi-init-org) -;;; ravi-init-org.el ends here - diff --git a/ravi-init-python.el b/ravi-init-python.el deleted file mode 100644 index 6edc232..0000000 --- a/ravi-init-python.el +++ /dev/null @@ -1,166 +0,0 @@ -;;; ravi-init-python.el --- python support - -;; Copyright (C) 2013 - -;; Author: -;; 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 . - -;;; Commentary: - -;; Python programming setup - -;;; Code: - -(use-package python - :mode ("\\.py\\'" . python-mode) - :commands python-shell-switch-to-shell - :config - (progn - - (add-hook 'python-mode-hook 'ravi/python-mode-hook) - (defun ravi/python-mode-hook() - ;; Set ipython as our interpreter - (setq python-shell-interpreter "ipython" - python-shell-interpreter-args "--pylab" - python-shell-prompt-regexp "In \\[[0-9]+\\]: " - python-shell-prompt-output-regexp "Out\\[[0-9]+\\]: " - python-shell-completion-setup-code - "from IPython.core.completerlib import module_completion" - python-shell-completion-module-string-code - "';'.join(module_completion('''%s'''))\n" - python-shell-completion-string-code - "';'.join(get_ipython().Completer.all_completions('''%s'''))\n" - ) - - ;; For ipython 0.10, uncomment the following: - ;; (setq python-shell-completion-string-code - ;; "';'.join(__IP.complete('''%s'''))\n" - ;; python-shell-completion-module-string-code "" - ;; ) - - ;; 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) - ) - - ;; 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 () - (progn - (insert "#!/usr/bin/env python\n\n") - ) - ) - - (use-package virtualenvwrapper - :config - (progn - (venv-initialize-interactive-shells) - (venv-initialize-eshell) - (setq venv-location (expand-file-name "~/usr/local/venv/")) - ) - - :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 - :config - (progn - (defun ravi/jedi-setup () - (let ((basic-server-args (list - "--sys-path" (ravi/emacs-file "site-lisp/python-epc") - "--sys-path" (ravi/emacs-file "site-lisp/sexpdata") - "--sys-path" (ravi/emacs-file "site-lisp/jedi")) - )) - (set (make-local-variable 'jedi:server-args) - (if (and (boundp 'extra-jedi-args) - (listp extra-jedi-args)) - (append basic-server-args extra-jedi-args) - basic-server-args)) - (jedi:setup))) - - (defun ravi/python-jedi-hook-installer () - (setq jedi:complete-on-dot t) - (add-hook 'hack-local-variables-hook 'ravi/jedi-setup nil t)) - (add-hook 'python-mode-hook 'ravi/python-jedi-hook-installer) - ) - :ensure t - :disabled t ; casualty of removing auto-complete - ) - - (use-package sphinx-doc - :config - (progn - (defun ravi/sphinx-doc-setup () - (sphinx-doc-mode 1)) - (add-hook 'python-mode-hook 'ravi/sphinx-doc-setup) - ) - :diminish t - :ensure t) - ) - ) - -(provide 'ravi-init-python) - diff --git a/ravi-init-repl.el b/ravi-init-repl.el deleted file mode 100644 index 8cc343b..0000000 --- a/ravi-init-repl.el +++ /dev/null @@ -1,67 +0,0 @@ -;;; ravi-init-repl.el --- REPL utilities - -;; Copyright (C) 2014 - -;; Author: -;; 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 . - -;;; Commentary: - -;; Read-eval-print-loop support - -;;; Code: - -(use-package comint - :defer t - :config - (progn - (bind-key "" 'comint-previous-matching-input-from-input comint-mode-map) - (bind-key "" 'comint-next-matching-input-from-input comint-mode-map) - ) - ) - -(use-package octave-mod - :mode ("\\.m\\'" . octave-mode) - :config - (progn - (defun ravi/octave-shell-switch-to-shell () - "Make sure that `inferior-octave-buffer' exists and is displayed." - (interactive) - (if (get-buffer inferior-octave-buffer) - (pop-to-buffer (get-buffer inferior-octave-buffer)) - (inferior-octave nil))) ) - ) - -(use-package repl-toggle - :config - (progn - (setq rtog/mode-repl-alist '((python-mode . python-shell-switch-to-shell) - (octave-mode . ravi/octave-shell-switch-to-shell) - (emacs-lisp-mode . ielm))) - (setq rtog/goto-buffer-fun 'pop-to-buffer) - (add-hook 'python-mode-hook 'rtog/activate) - (add-hook 'octave-mode-hook 'rtog/activate) - (add-hook 'emacs-lisp-mode-hook 'rtog/activate) - - ; The default keybinding is not great - (unbind-key "C-c C-z" repl-toggle-mode-map) - (bind-key "" 'rtog/toggle-repl repl-toggle-mode-map) - ) - :diminish repl-toggle-mode - :ensure t) - -(provide 'ravi-init-repl) -;;; ravi-init-repl.el ends here diff --git a/ravi-init-tex.el b/ravi-init-tex.el deleted file mode 100644 index d7725e9..0000000 --- a/ravi-init-tex.el +++ /dev/null @@ -1,189 +0,0 @@ -;;; ravi-init-tex.el --- tex and friends - -;; Copyright (C) 2014 - -;; Author: -;; 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 . - -;;; Commentary: - -;; TeX and LaTeX support - -;;; Code: - -(use-package tex-site - :ensure auctex - :mode ("\\.tex\\'" . TeX-latex-mode) - :commands (TeX-latex-mode - TeX-mode - tex-mode - LaTeX-mode - latex-mode) - :config - (progn - (use-package latex - :config - (progn - (use-package reftex - :defer t - :diminish reftex-mode) - ;; fix the "bug" in SP regexp wrap that treats ' as "word" - (modify-syntax-entry ?' ".") - - (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-subscript 'ignore) - - (sp-with-modes '(tex-mode plain-tex-mode latex-mode) - (sp-local-pair "\\[" nil :post-handlers '(my-latex-math-block-indent))) - - (defun my-latex-math-block-indent (a action c) - (when (eq action 'insert) - (newline-and-indent) - (save-excursion (newline)))) - - (defun my-latex-compile () - (interactive) - (save-buffer) - (TeX-command "LaTeX" 'TeX-master-file nil)) - (bind-key "C-M-x" 'my-latex-compile LaTeX-mode-map) - - (defvar my-latex-wrap-choices '("emph" - "textsc")) - (defvar my-latex-wrap-history nil) - - (defun my-latex-wrap (macro-name) - (interactive (list (ido-completing-read - "Macro> " - my-latex-wrap-choices - nil 'confirm nil my-latex-wrap-history))) - (when (use-region-p) - (let ((b (region-beginning)) - (e (region-end))) - (goto-char e) - (insert "}") - (goto-char b) - (insert "\\" macro-name "{")))) - (bind-key "C-c w" 'my-latex-wrap LaTeX-mode-map) - - (defun my-end-of-environment () - (interactive) - (LaTeX-mark-environment) - (end-of-region)) - - (defun my-beginning-of-environment () - (interactive) - (LaTeX-mark-environment) - (beginning-of-region) - (deactivate-mark)) - - (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) - - (defun my-latex-remove-command () - "Unwrap the expression that point is in or before, also -removing the command name. By command we understand a symbol -starting with \\ and followed by a block of text enclosed in {}." - (interactive) - (let ((ok (sp-get-enclosing-sexp))) - (cond - ;; we're inside the { } block - (ok - (progn - (save-excursion - (goto-char (sp-get ok :beg)) - (zap-to-char -1 ?\\ )) - (sp-splice-sexp))) - ;; test if we are in looking at the command fromt he front - ((looking-at "\\\\") - (zap-up-to-char 1 ?{) - (sp-unwrap-sexp)) - ;; otherwise we're inside the command name - (t - (zap-to-char -1 ?\\ ) - (zap-up-to-char 1 ?{) - (sp-unwrap-sexp))))) - (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)))) - (e (save-excursion (while (texmathp) (forward-char 1)) (point)))) - (preview-region b e))) - (bind-key "C-" 'my-LaTeX-preview-math preview-map) - - (defun my-LaTeX-mode-init () - (setq TeX-auto-save t) - (setq TeX-parse-self t) - (TeX-PDF-mode t) - (setq reftex-plug-into-AUCTeX t) - (reftex-mode t) - (TeX-fold-mode t) - - (smartparens-mode 1) - - (LaTeX-add-environments - '("derivation" LaTeX-env-label)) - (TeX-add-symbols '("emph" 1)) - - (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) - - (message "LaTeX mode init complete.")) - ;; ACUTeX replaces latex-mode-hook with LaTeX-mode-hook - (add-hook 'LaTeX-mode-hook 'my-LaTeX-mode-init) - - )) - ) - ) - -(provide 'ravi-init-tex) -;;; ravi-init-tex.el ends here diff --git a/ravi-init-vc.el b/ravi-init-vc.el deleted file mode 100644 index e4b273e..0000000 --- a/ravi-init-vc.el +++ /dev/null @@ -1,185 +0,0 @@ -;;; ravi-init-vc.el --- vc control - -;; Copyright (C) 2013 - -;; Author: -;; 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 . - -;;; Commentary: - -;; Version control initialization - -;;; Code: - -;; Git -(use-package magit - :bind (("" . magit-status) - ("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 '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) - (diminish 'magit-auto-revert-mode) - - (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) - ) -(use-package git-timemachine - :ensure t - :bind ("C-x v t" . git-timemachine) - ) -(use-package magit-blame - :bind (("C-x v B" . magit-blame-mode))) - -;; 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/ravi-init-web.el b/ravi-init-web.el deleted file mode 100644 index 13dd758..0000000 --- a/ravi-init-web.el +++ /dev/null @@ -1,100 +0,0 @@ -;;; ravi-init-web.el --- Web development -*- lexical-binding: t; -*- - -;; Copyright (C) 2014 - -;; Author: -;; 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 . - -;;; 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 t) - -;; 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)) - (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)) - - ;; 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) - -(provide 'ravi-init-web) -;;; ravi-init-web.el ends here -- cgit v0.10.1 From 7ee2ca9f480f19b894cc76823321db1d8bafc93c Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Mon, 16 Mar 2015 21:37:58 -0700 Subject: Smart newline does not work well with python indenting Diminish according to use-package 2.0 diff --git a/lisp/ravi-init-python.el b/lisp/ravi-init-python.el index 6edc232..de89b82 100644 --- a/lisp/ravi-init-python.el +++ b/lisp/ravi-init-python.el @@ -56,6 +56,8 @@ (setq python-indent-offset 4) ) + (bind-key "" 'newline-and-indent python-mode-map) + ;; We no longer use smart-tab-mode ;(add-to-list 'smart-tab-disabled-major-modes 'inferior-python-mode) @@ -157,7 +159,7 @@ (sphinx-doc-mode 1)) (add-hook 'python-mode-hook 'ravi/sphinx-doc-setup) ) - :diminish t + :diminish sphinx-doc-mode :ensure t) ) ) -- cgit v0.10.1 From d500f901002d147c621cd98e0f8371c0e8950274 Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Wed, 18 Mar 2015 08:02:45 -0700 Subject: We need easy access to find-files diff --git a/lisp/ravi-ergodox-mode.el b/lisp/ravi-ergodox-mode.el index e393a39..a4867be 100644 --- a/lisp/ravi-ergodox-mode.el +++ b/lisp/ravi-ergodox-mode.el @@ -61,7 +61,7 @@ Each function in the list receive no argument." (if (and (boundp 'ravi/use-helm-instead-of-ido) ravi/use-helm-instead-of-ido) (progn (define-key ravi-ergodox-mode-map (kbd "") 'helm-multi-files) - (define-key ravi-ergodox-mode-map (kbd "") 'helm-locate)) + (define-key ravi-ergodox-mode-map (kbd "") 'helm-find-files)) (progn (define-key ravi-ergodox-mode-map (kbd "") 'ido-switch-buffer) (define-key ravi-ergodox-mode-map (kbd "") 'ido-find-file))) diff --git a/lisp/ravi-init-helm.el b/lisp/ravi-init-helm.el index 5ff7f9d..07eba30 100644 --- a/lisp/ravi-init-helm.el +++ b/lisp/ravi-init-helm.el @@ -29,7 +29,7 @@ :bind (("" . helm-command-prefix) ("M-x" . helm-M-x) ("" . helm-multi-files) - ("" . helm-locate) + ("" . helm-find-files) ("M-y" . helm-show-kill-ring) ("H-`" . helm-all-mark-rings)) :init -- cgit v0.10.1 From 78820acd210831226e2082396c2871f0782b0901 Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Wed, 18 Mar 2015 08:04:32 -0700 Subject: Use jedi with company for completion diff --git a/lisp/ravi-init-python.el b/lisp/ravi-init-python.el index de89b82..c94e016 100644 --- a/lisp/ravi-init-python.el +++ b/lisp/ravi-init-python.el @@ -127,7 +127,7 @@ ;; 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 () @@ -144,14 +144,19 @@ (jedi:setup))) (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 t ; casualty of removing auto-complete ) + (use-package company-jedi + :config + (progn + (add-to-list 'company-backends 'company-jedi)) + :ensure t) + (use-package sphinx-doc :config (progn -- cgit v0.10.1 From c6014d55db60d68e6dd2d1b8702f49f6874d5c7e Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Sun, 22 Mar 2015 21:27:52 -0700 Subject: Use new location for MELPA diff --git a/init.el b/init.el index 260f65d..6325bb4 100644 --- a/init.el +++ b/init.el @@ -36,7 +36,7 @@ ;("original" . "http://tromey.com/elpa/") ("org" . "http://orgmode.org/elpa/") ;("marmalade" . "http://marmalade-repo.org/packages/") - ("melpa" . "http://melpa.milkbox.net/packages/"))) + ("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")) -- cgit v0.10.1 From 1a5a52d9482f63d6719285a0aeeff6c3b2842987 Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Sun, 22 Mar 2015 21:28:17 -0700 Subject: Automatically determine mode for C/C++ header files diff --git a/lisp/ravi-init-cpp.el b/lisp/ravi-init-cpp.el index 5fe9e8f..e1bdac5 100644 --- a/lisp/ravi-init-cpp.el +++ b/lisp/ravi-init-cpp.el @@ -89,9 +89,16 @@ (recompile)))) +(use-package dummy-h-mode + :mode (("\\.h\\'" . dummy-h-mode)) + :config + (progn + (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)) -- cgit v0.10.1 From 109dfac9ffb591561343f8c5db7690587182f5e7 Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Sun, 22 Mar 2015 21:28:46 -0700 Subject: Process search via helm diff --git a/lisp/ravi-init-helm.el b/lisp/ravi-init-helm.el index 07eba30..6b8abe2 100644 --- a/lisp/ravi-init-helm.el +++ b/lisp/ravi-init-helm.el @@ -53,6 +53,13 @@ (bind-key "" 'helm-execute-persistent-action helm-map) (bind-key "H-" '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-ag :ensure t)) :if ravi/use-helm-instead-of-ido -- cgit v0.10.1 From ca979abbcd60fbb8960473f104c1c24d33280ead Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Sun, 22 Mar 2015 21:29:01 -0700 Subject: Remove helm-descbinds since it misses too many keys diff --git a/lisp/ravi-init-helm.el b/lisp/ravi-init-helm.el index 6b8abe2..1c05949 100644 --- a/lisp/ravi-init-helm.el +++ b/lisp/ravi-init-helm.el @@ -88,9 +88,5 @@ ) :ensure t) -(use-package helm-descbinds - :bind (("C-h b" . helm-descbinds)) - :ensure t) - (provide 'ravi-init-helm) ;;; ravi-init-helm.el ends here -- cgit v0.10.1 From 9da0d4d673005096bcf0269d80334b0e02bd43b9 Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Sun, 22 Mar 2015 21:33:07 -0700 Subject: Swap keybindings for import-popwin and helm-swoop Helm-swoop is used much more frequently. diff --git a/lisp/ravi-init-appearance.el b/lisp/ravi-init-appearance.el index 035dc1d..0b32c6f 100644 --- a/lisp/ravi-init-appearance.el +++ b/lisp/ravi-init-appearance.el @@ -285,7 +285,7 @@ Delete all whitespace on a successive key press." ) (use-package import-popwin - :bind (("M-i" . import-popwin)) + :bind (("M-I" . import-popwin)) :ensure t ) diff --git a/lisp/ravi-init-helm.el b/lisp/ravi-init-helm.el index 1c05949..89cc4b1 100644 --- a/lisp/ravi-init-helm.el +++ b/lisp/ravi-init-helm.el @@ -67,7 +67,7 @@ :ensure t) (use-package helm-swoop - :bind (("M-I" . helm-swoop)) + :bind (("M-i" . helm-swoop)) :commands helm-swoop-from-isearch :init (progn -- cgit v0.10.1 From 34cda020aa2a6bce1cdaaa05a1c1ae1b7a51ce1e Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Sun, 22 Mar 2015 21:33:49 -0700 Subject: Conform to vim-like navigation diff --git a/lisp/ravi-init-navigation.el b/lisp/ravi-init-navigation.el index 5a6054d..d8a1441 100644 --- a/lisp/ravi-init-navigation.el +++ b/lisp/ravi-init-navigation.el @@ -256,8 +256,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)) -- cgit v0.10.1 From 8c3336f0de47ca9ce0d9b30d57be61813a5d8418 Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Sun, 22 Mar 2015 21:51:21 -0700 Subject: More helm for use with helm diff --git a/lisp/ravi-init-appearance.el b/lisp/ravi-init-appearance.el index 0b32c6f..febb20e 100644 --- a/lisp/ravi-init-appearance.el +++ b/lisp/ravi-init-appearance.el @@ -258,7 +258,11 @@ Delete all whitespace on a successive key press." "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 "")) + (add-to-list 'guide-key/guide-key-sequence "") + (add-to-list 'guide-key/guide-key-sequence " C-c") + (add-to-list 'guide-key/guide-key-sequence " C-x") + (add-to-list 'guide-key/guide-key-sequence " C-x r") + (add-to-list 'guide-key/guide-key-sequence " ESC")) (guide-key-mode 1) -- cgit v0.10.1 From 0d7d772701b930d9ec8870c0ec48912d3865b709 Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Sun, 22 Mar 2015 21:51:58 -0700 Subject: Interface to git grep diff --git a/lisp/ravi-init-helm.el b/lisp/ravi-init-helm.el index 89cc4b1..e5a5f21 100644 --- a/lisp/ravi-init-helm.el +++ b/lisp/ravi-init-helm.el @@ -60,6 +60,14 @@ (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-ag :ensure t)) :if ravi/use-helm-instead-of-ido diff --git a/lisp/ravi-init-navigation.el b/lisp/ravi-init-navigation.el index d8a1441..39bd91a 100644 --- a/lisp/ravi-init-navigation.el +++ b/lisp/ravi-init-navigation.el @@ -54,6 +54,7 @@ (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 -- cgit v0.10.1 From 491632cd4a84347b80059abaee8f53af12bf764c Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Thu, 9 Apr 2015 09:59:15 -0700 Subject: Make keybindings available early diff --git a/lisp/ravi-init-navigation.el b/lisp/ravi-init-navigation.el index 39bd91a..30aa1ce 100644 --- a/lisp/ravi-init-navigation.el +++ b/lisp/ravi-init-navigation.el @@ -80,7 +80,7 @@ ("C->" . mc/mark-next-like-this) ("C-<" . mc/mark-previous-like-this) ("C-c C-<" . mc/mark-all-like-this)) - :config + :init (progn (setq mc/list-file (ravi/emacs-file "past/mc-lists.el")) (bind-key "a" 'mc/mark-all-like-this region-bindings-mode-map) -- cgit v0.10.1 From 7fd4e2a5cee186e09591fe4b8ba5d5d8c0987da4 Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Thu, 9 Apr 2015 10:17:33 -0700 Subject: Get ox-reveal from repository diff --git a/.gitmodules b/.gitmodules index 85544e8..b6f9968 100644 --- a/.gitmodules +++ b/.gitmodules @@ -16,9 +16,6 @@ [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 diff --git a/lisp/ravi-init-org.el b/lisp/ravi-init-org.el index 004d2f6..2e46fe3 100644 --- a/lisp/ravi-init-org.el +++ b/lisp/ravi-init-org.el @@ -33,11 +33,11 @@ ("H--" . org-agenda)) :config (progn - (use-package htmlize - :ensure t) - (use-package ox-reveal - :load-path (lambda () (ravi/emacs-file "site-lisp/org-reveal")) - ) + (use-package htmlize :ensure t) + (use-package ox-reveal :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 diff --git a/site-lisp/org-reveal b/site-lisp/org-reveal deleted file mode 160000 index e7b9cb4..0000000 --- a/site-lisp/org-reveal +++ /dev/null @@ -1 +0,0 @@ -Subproject commit e7b9cb41babd9d7a0873e8e10fe178c6be99085c -- cgit v0.10.1 From 8cfa7de9280f7faa1eacfc8076389773de546eb4 Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Thu, 9 Apr 2015 10:17:51 -0700 Subject: Diminish properly with use-package 2.0 diff --git a/lisp/ravi-init-web.el b/lisp/ravi-init-web.el index 13dd758..925191e 100644 --- a/lisp/ravi-init-web.el +++ b/lisp/ravi-init-web.el @@ -35,7 +35,7 @@ (unbind-key "C-j" emmet-mode-keymap) (bind-key "M-r" 'emmet-expand-line emmet-mode-keymap)) :ensure t - :diminish t) + :diminish emmet-mode) ;; Javascript (use-package js2-mode -- cgit v0.10.1 From 8e1333673a91ac150b3477ac4fbc27bad5e3e9db Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Sun, 12 Apr 2015 21:37:46 -0700 Subject: Set up org-reveal to match our defaults diff --git a/lisp/ravi-init-org.el b/lisp/ravi-init-org.el index 2e46fe3..814add2 100644 --- a/lisp/ravi-init-org.el +++ b/lisp/ravi-init-org.el @@ -34,7 +34,15 @@ :config (progn (use-package htmlize :ensure t) - (use-package ox-reveal :ensure t) + (use-package ox-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) -- cgit v0.10.1 From 2dc11302d3241ae3d3e9fdc1286b03ed76cba3bc Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Thu, 7 May 2015 21:51:43 -0700 Subject: Show email addresses by default diff --git a/lisp/ravi-init-mu.el b/lisp/ravi-init-mu.el index b123da2..d514f0f 100644 --- a/lisp/ravi-init-mu.el +++ b/lisp/ravi-init-mu.el @@ -155,6 +155,7 @@ (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)) -- cgit v0.10.1 From dc3a0d756d120256d6464b466764615d89b2dca6 Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Thu, 7 May 2015 21:52:16 -0700 Subject: Easy buffer part erasure diff --git a/lisp/ravi-init-appearance.el b/lisp/ravi-init-appearance.el index febb20e..fdee7fc 100644 --- a/lisp/ravi-init-appearance.el +++ b/lisp/ravi-init-appearance.el @@ -210,6 +210,13 @@ Delete all whitespace on a successive key press." (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) diff --git a/lisp/ravi-init-mu.el b/lisp/ravi-init-mu.el index d514f0f..de87132 100644 --- a/lisp/ravi-init-mu.el +++ b/lisp/ravi-init-mu.el @@ -171,6 +171,7 @@ (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 -- cgit v0.10.1 From 97926b56d290504c3d28896c452d85fb4bf0447f Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Fri, 8 May 2015 14:03:15 -0700 Subject: Nicer interface for isearch diff --git a/lisp/ravi-init-navigation.el b/lisp/ravi-init-navigation.el index 30aa1ce..1327bcc 100644 --- a/lisp/ravi-init-navigation.el +++ b/lisp/ravi-init-navigation.el @@ -345,6 +345,17 @@ ) ) +(use-package anzu + :demand t + :bind (("C-%" . anzu-query-replace) + ("C-M-%" . anzu-query-replace-regexp)) + :config + (progn + (global-anzu-mode)) + :ensure anzu) + +(require 'midnight) + ;; to do: add zeal-at-point (provide 'ravi-init-navigation) -- cgit v0.10.1 From 466f08ddf9eb5bf000c5f097ffb540aefbb2fd9e Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Fri, 8 May 2015 14:03:36 -0700 Subject: calc is used too often diff --git a/lisp/ravi-init-repl.el b/lisp/ravi-init-repl.el index 8cc343b..5ff6b52 100644 --- a/lisp/ravi-init-repl.el +++ b/lisp/ravi-init-repl.el @@ -63,5 +63,8 @@ :diminish repl-toggle-mode :ensure t) +;; Calc and friends +(bind-key "H-c" 'calc) + (provide 'ravi-init-repl) ;;; ravi-init-repl.el ends here -- cgit v0.10.1 From cc849b235e17774813215adb676103ccecc79128 Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Mon, 11 May 2015 09:34:50 -0700 Subject: Diminish anzu diff --git a/lisp/ravi-init-navigation.el b/lisp/ravi-init-navigation.el index 1327bcc..9e744d3 100644 --- a/lisp/ravi-init-navigation.el +++ b/lisp/ravi-init-navigation.el @@ -352,6 +352,7 @@ :config (progn (global-anzu-mode)) + :diminish anzu-mode :ensure anzu) (require 'midnight) -- cgit v0.10.1 From bdf469437b168eba31ab8645031ea8a5e23ff5a3 Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Mon, 11 May 2015 09:35:03 -0700 Subject: Add map to operate on number diff --git a/init.el b/init.el index 6325bb4..f38699a 100644 --- a/init.el +++ b/init.el @@ -131,6 +131,7 @@ (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) diff --git a/lisp/ravi-init-maps.el b/lisp/ravi-init-maps.el new file mode 100644 index 0000000..b6855c1 --- /dev/null +++ b/lisp/ravi-init-maps.el @@ -0,0 +1,59 @@ +;;; ravi-init-maps.el --- extra keys -*- lexical-binding: t; -*- + +;; Copyright (C) 2015 Ravi R Kiran + +;; Author: +;; 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 . + +;;; 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 # +Choices: " + ("+" 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) ; need to file bug report + )) + :ensure t) + +;; To do: launcher map, toggle map + +(provide 'ravi-init-maps) +;;; ravi-init-maps.el ends here -- cgit v0.10.1 From 9f0e4dbe746da6f6ef3e0d560ff4f3d94b04734a Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Wed, 13 May 2015 13:41:02 -0700 Subject: Bug in hydra.el is finally fixed diff --git a/lisp/ravi-init-maps.el b/lisp/ravi-init-maps.el index b6855c1..825bdc1 100644 --- a/lisp/ravi-init-maps.el +++ b/lisp/ravi-init-maps.el @@ -30,12 +30,14 @@ :config (progn (defhydra hydra-operate-on-number () - "Arithmetic operations: + - * / -Remainder: \\ -Exponent: ^ -Arithmetic shift:< > -Base conversion: b o x X # -Choices: " + " + 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) @@ -49,8 +51,7 @@ Choices: " ("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) ; need to file bug report - )) + ("%" apply-operation-to-number-at-point :exit t))) :ensure t) ;; To do: launcher map, toggle map -- cgit v0.10.1 From 76f3568bb0912238ded82b2b926d2a1438b468f0 Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Wed, 13 May 2015 14:00:19 -0700 Subject: Launcher/toggle map diff --git a/lisp/ravi-init-maps.el b/lisp/ravi-init-maps.el index 825bdc1..c96256a 100644 --- a/lisp/ravi-init-maps.el +++ b/lisp/ravi-init-maps.el @@ -54,7 +54,27 @@ ("%" apply-operation-to-number-at-point :exit t))) :ensure t) -;; To do: launcher map, toggle map +;; Combined launcher and toggle-maps +(defhydra hydra-launch-toggle-map () + "Launcher/toggle" + + ;; Toggles + ("c" column-number-mode "column-number-mode") + ("e" toggle-debug-on-error "toggle-debug-on-error") + ("f" auto-fill-mode "auto-fill-mode") + ("l" toggle-truncate-lines "toggle-truncate-lines") + ("q" toggle-debug-on-quit "toggle-debug-on-quit") + ;; Generalized version of `read-only-mode'. + ("r" dired-toggle-read-only "dired-toggle-read-only") + ;(autoload 'dired-toggle-read-only "dired" nil t) + ("w" whitespace-mode "whitespace-mode") + + ;; Launchers + ("P" package-list-packages "package-list-packages") + ("p" proced "proced") + ("d" ediff-buffers "ediff-buffers") + ("F" find-dired "find-dired")) +(bind-key "M-g M-t" 'hydra-launch-toggle-map/body) (provide 'ravi-init-maps) ;;; ravi-init-maps.el ends here -- cgit v0.10.1 From 9191102ec03af4d37440c0c38daad90a43d16472 Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Wed, 13 May 2015 14:00:36 -0700 Subject: Use swoop for PCRE diff --git a/lisp/ravi-init-navigation.el b/lisp/ravi-init-navigation.el index 9e744d3..3ceb9a1 100644 --- a/lisp/ravi-init-navigation.el +++ b/lisp/ravi-init-navigation.el @@ -355,6 +355,18 @@ :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 -- cgit v0.10.1 From 054fac86e0aeb630d13128a2f31fba5184429f7f Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Wed, 13 May 2015 14:03:23 -0700 Subject: Get package from repositories diff --git a/lisp/ravi-init-navigation.el b/lisp/ravi-init-navigation.el index 3ceb9a1..60ab3e7 100644 --- a/lisp/ravi-init-navigation.el +++ b/lisp/ravi-init-navigation.el @@ -224,6 +224,7 @@ (add-hook 'prog-mode-hook 'turn-on-whole-line-or-region-mode) ) :diminish whole-line-or-region-mode + :ensure t ) ;; grep and friends 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 ************* -- cgit v0.10.1 From 0c1e84879a89d69c791feda99aeb1f7bf31483fa Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Thu, 14 May 2015 09:02:22 -0700 Subject: Add dash documentation browsing diff --git a/lisp/ravi-init-helm.el b/lisp/ravi-init-helm.el index e5a5f21..f560db6 100644 --- a/lisp/ravi-init-helm.el +++ b/lisp/ravi-init-helm.el @@ -69,6 +69,17 @@ :ensure t) (use-package helm-ag + :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 -- cgit v0.10.1 From b72c3d9051d3d87cd231d642a3d3c215c915c40e Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Fri, 15 May 2015 21:12:52 -0700 Subject: Use normal keybinding setup for toggle/launcher map diff --git a/lisp/ravi-init-function.el b/lisp/ravi-init-function.el index 671d45c..ee85393 100644 --- a/lisp/ravi-init-function.el +++ b/lisp/ravi-init-function.el @@ -31,5 +31,29 @@ ;; Use emacsclient from other programs (unless (server-running-p) (server-start)) +;; Combined launcher and toggle-maps +(defun ravi/setup-toggle-launcher-map () + (define-prefix-command 'ravi/toggle-launcher-map) + (bind-key "t" 'ravi/toggle-launcher-map ctl-x-map) + + ;; Toggles + (bind-key "c" 'column-number-mode ravi/toggle-launcher-map) + (bind-key "e" 'toggle-debug-on-error ravi/toggle-launcher-map) + (bind-key "f" 'auto-fill-mode ravi/toggle-launcher-map) + (bind-key "l" 'toggle-truncate-lines ravi/toggle-launcher-map) + (bind-key "q" 'toggle-debug-on-quit ravi/toggle-launcher-map) + ;; Generalized version of `read-only-mode'. + (bind-key "r" 'dired-toggle-read-only ravi/toggle-launcher-map) + (autoload 'dired-toggle-read-only "dired" nil t) + (bind-key "w" 'whitespace-mode ravi/toggle-launcher-map) + + ;; Launchers + (bind-key "P" 'package-list-packages ravi/toggle-launcher-map) + (bind-key "p" 'proced ravi/toggle-launcher-map) + (bind-key "d" 'ediff-buffers ravi/toggle-launcher-map) + (bind-key "F" 'find-dired ravi/toggle-launcher-map) + (add-to-list 'guide-key/guide-key-sequence "C-x t")) +(ravi/setup-toggle-launcher-map) + (provide 'ravi-init-function) ;;; ravi-init-function.el ends here diff --git a/lisp/ravi-init-maps.el b/lisp/ravi-init-maps.el index c96256a..ae4eac6 100644 --- a/lisp/ravi-init-maps.el +++ b/lisp/ravi-init-maps.el @@ -54,27 +54,5 @@ ("%" apply-operation-to-number-at-point :exit t))) :ensure t) -;; Combined launcher and toggle-maps -(defhydra hydra-launch-toggle-map () - "Launcher/toggle" - - ;; Toggles - ("c" column-number-mode "column-number-mode") - ("e" toggle-debug-on-error "toggle-debug-on-error") - ("f" auto-fill-mode "auto-fill-mode") - ("l" toggle-truncate-lines "toggle-truncate-lines") - ("q" toggle-debug-on-quit "toggle-debug-on-quit") - ;; Generalized version of `read-only-mode'. - ("r" dired-toggle-read-only "dired-toggle-read-only") - ;(autoload 'dired-toggle-read-only "dired" nil t) - ("w" whitespace-mode "whitespace-mode") - - ;; Launchers - ("P" package-list-packages "package-list-packages") - ("p" proced "proced") - ("d" ediff-buffers "ediff-buffers") - ("F" find-dired "find-dired")) -(bind-key "M-g M-t" 'hydra-launch-toggle-map/body) - (provide 'ravi-init-maps) ;;; ravi-init-maps.el ends here -- cgit v0.10.1 From 8addc135dcd458551a105e12341c9f3e0efa81dc Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Sat, 16 May 2015 11:46:10 -0700 Subject: Enable helm-dash wherever possible diff --git a/lisp/ravi-init-cpp.el b/lisp/ravi-init-cpp.el index e1bdac5..9a0faaf 100644 --- a/lisp/ravi-init-cpp.el +++ b/lisp/ravi-init-cpp.el @@ -166,6 +166,8 @@ (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) @@ -209,8 +211,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 diff --git a/lisp/ravi-init-python.el b/lisp/ravi-init-python.el index c94e016..049f5ef 100644 --- a/lisp/ravi-init-python.el +++ b/lisp/ravi-init-python.el @@ -51,6 +51,9 @@ ;; 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) diff --git a/lisp/ravi-init-tex.el b/lisp/ravi-init-tex.el index d7725e9..56545e8 100644 --- a/lisp/ravi-init-tex.el +++ b/lisp/ravi-init-tex.el @@ -177,6 +177,9 @@ starting with \\ and followed by a block of text enclosed in {}." (setq TeX-save-query nil) (setq TeX-show-compilation t) + (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) diff --git a/lisp/ravi-init-web.el b/lisp/ravi-init-web.el index 925191e..85446ef 100644 --- a/lisp/ravi-init-web.el +++ b/lisp/ravi-init-web.el @@ -54,7 +54,9 @@ (defun ravi/js2-mode-hook () (emmet-mode) - (setq js2-basic-offset 2)) + (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 ) @@ -86,6 +88,11 @@ 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) @@ -96,5 +103,10 @@ :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 -- cgit v0.10.1 From 9bd9a00a0d3412a88624027c8028b58f2bb3b60a Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Sat, 16 May 2015 12:02:14 -0700 Subject: More versatile cut diff --git a/lisp/ravi-init-navigation.el b/lisp/ravi-init-navigation.el index 60ab3e7..b444121 100644 --- a/lisp/ravi-init-navigation.el +++ b/lisp/ravi-init-navigation.el @@ -227,6 +227,14 @@ :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 -- cgit v0.10.1 From 1859872533f8897d3e444488daa7e014e7421cb0 Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Sat, 16 May 2015 12:15:06 -0700 Subject: Cleverer line positioning from emacsclient diff --git a/lisp/ravi-init-function.el b/lisp/ravi-init-function.el index ee85393..da87931 100644 --- a/lisp/ravi-init-function.el +++ b/lisp/ravi-init-function.el @@ -31,6 +31,24 @@ ;; Use emacsclient from other programs (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 () (define-prefix-command 'ravi/toggle-launcher-map) -- cgit v0.10.1 From af710ca4689534d2221fa5a9705d2e7017deb0de Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Mon, 18 May 2015 09:45:32 -0700 Subject: Switch to yasnippet seamlessly diff --git a/lisp/ravi-init-insertion.el b/lisp/ravi-init-insertion.el index 65ff9db..512e578 100644 --- a/lisp/ravi-init-insertion.el +++ b/lisp/ravi-init-insertion.el @@ -127,6 +127,11 @@ (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 "" 'ravi/company-to-yasnippet) (bind-key "" 'company-yasnippet)) :diminish company-mode -- cgit v0.10.1 From 9d2ed4ac5ab9d43d6b6917ce4da36622f98058b0 Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Mon, 18 May 2015 09:45:47 -0700 Subject: Grep is still useful even when ag is present diff --git a/lisp/ravi-init-navigation.el b/lisp/ravi-init-navigation.el index b444121..3c14c23 100644 --- a/lisp/ravi-init-navigation.el +++ b/lisp/ravi-init-navigation.el @@ -238,14 +238,14 @@ ;; grep and friends (use-package wgrep - :ensure t - ) + :ensure t) (if (executable-find "ag") ;; Prefer the silver-searcher if available (use-package ag :bind (("H-g" . ag) - ("H-G" . ag-files)) + ("H-G" . ag-files) + ("M-s g" . grep)) :config (progn (setq ag-highlight-search t) -- cgit v0.10.1 From 11ba816c065aa64eb3b2de33e70fd7d2ca609335 Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Mon, 25 May 2015 21:13:19 -0700 Subject: Simplify launcher map using bind-keys diff --git a/lisp/ravi-init-function.el b/lisp/ravi-init-function.el index da87931..d1c8230 100644 --- a/lisp/ravi-init-function.el +++ b/lisp/ravi-init-function.el @@ -51,25 +51,27 @@ and file 'filename' will be opened and cursor set on line 'linenumber'" ;; Combined launcher and toggle-maps (defun ravi/setup-toggle-launcher-map () - (define-prefix-command 'ravi/toggle-launcher-map) - (bind-key "t" 'ravi/toggle-launcher-map ctl-x-map) + (bind-keys :map ctl-x-map + :prefix-map ravi/setup-toggle-launcher-map + :prefix-docstring "Launcher/toggle map" + :prefix "t" - ;; Toggles - (bind-key "c" 'column-number-mode ravi/toggle-launcher-map) - (bind-key "e" 'toggle-debug-on-error ravi/toggle-launcher-map) - (bind-key "f" 'auto-fill-mode ravi/toggle-launcher-map) - (bind-key "l" 'toggle-truncate-lines ravi/toggle-launcher-map) - (bind-key "q" 'toggle-debug-on-quit ravi/toggle-launcher-map) - ;; Generalized version of `read-only-mode'. - (bind-key "r" 'dired-toggle-read-only ravi/toggle-launcher-map) - (autoload 'dired-toggle-read-only "dired" nil t) - (bind-key "w" 'whitespace-mode ravi/toggle-launcher-map) + ;; 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 - (bind-key "P" 'package-list-packages ravi/toggle-launcher-map) - (bind-key "p" 'proced ravi/toggle-launcher-map) - (bind-key "d" 'ediff-buffers ravi/toggle-launcher-map) - (bind-key "F" 'find-dired ravi/toggle-launcher-map) + ;; 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) -- cgit v0.10.1 From 789ada565df8119f6bb2cf68c392579e4886d8d4 Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Mon, 25 May 2015 21:32:23 -0700 Subject: Camel-case conversions The default keybinding is temporary. diff --git a/lisp/ravi-init-appearance.el b/lisp/ravi-init-appearance.el index fdee7fc..ed24a85 100644 --- a/lisp/ravi-init-appearance.el +++ b/lisp/ravi-init-appearance.el @@ -221,6 +221,18 @@ Delete all whitespace on a successive key press." :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") + ("" nil))) + :ensure t) + ;; Keep my navigation simple (setq line-move-visual nil) -- cgit v0.10.1 From 8be2c0a728d3e6242e0c67f8c019a36b7167f9af Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Mon, 25 May 2015 21:59:28 -0700 Subject: Another way to switch to stuff within a project diff --git a/lisp/ravi-init-helm.el b/lisp/ravi-init-helm.el index f560db6..72d9b0a 100644 --- a/lisp/ravi-init-helm.el +++ b/lisp/ravi-init-helm.el @@ -68,6 +68,10 @@ (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 :ensure t) -- cgit v0.10.1 From 2b04c2ccb07aa60a773f8241c47281aea5a5a2dc Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Mon, 25 May 2015 22:04:25 -0700 Subject: No longer need highlight-symbol in emacs 24.4+ diff --git a/lisp/ravi-init-navigation.el b/lisp/ravi-init-navigation.el index 3c14c23..084b976 100644 --- a/lisp/ravi-init-navigation.el +++ b/lisp/ravi-init-navigation.el @@ -276,6 +276,7 @@ (highlight-symbol-next) (set-temporary-overlay-map ravi/highlight-symbol-overlay-map t)) ) + :disabled t ; M-s . suffices for my needs :ensure t ) -- cgit v0.10.1 From fb6ed706027d6b4d0bc3d2958dbb21fb732a896f Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Mon, 25 May 2015 22:18:23 -0700 Subject: avy is more customizable than ace-jump diff --git a/lisp/ravi-init-navigation.el b/lisp/ravi-init-navigation.el index 084b976..c8cf64d 100644 --- a/lisp/ravi-init-navigation.el +++ b/lisp/ravi-init-navigation.el @@ -43,11 +43,16 @@ :ensure t ) -(use-package ace-jump-mode - :bind (("M-h" . ace-jump-mode) - ("M-H" . ace-jump-line-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-style 'at-full + avy-background t)) + :ensure t) (use-package ace-isearch :config -- cgit v0.10.1 From d1f333f2578a9fc9a802411a9d8dd4dfe33b479a Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Mon, 25 May 2015 22:44:56 -0700 Subject: Easier bracket wrappers diff --git a/lisp/ravi-init-navigation.el b/lisp/ravi-init-navigation.el index c8cf64d..c90355b 100644 --- a/lisp/ravi-init-navigation.el +++ b/lisp/ravi-init-navigation.el @@ -143,6 +143,19 @@ :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() -- cgit v0.10.1 From f69ea21f3ce3ced598211efd71fcf02ae8f52595 Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Tue, 26 May 2015 10:59:55 -0700 Subject: More functionality with buffer-switching diff --git a/lisp/ravi-init-appearance.el b/lisp/ravi-init-appearance.el index ed24a85..5cfac60 100644 --- a/lisp/ravi-init-appearance.el +++ b/lisp/ravi-init-appearance.el @@ -314,11 +314,43 @@ Delete all whitespace on a successive key press." (use-package ace-window :bind (("M-o" . ace-window)) - :init + :config (progn - (setq aw-keys '(?a ?s ?d ?f ?g ?h ?j ?k ?l ?i ?e))) - :ensure t - ) + (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))) + + (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") -- cgit v0.10.1 From d88c60046ed5de5bc5123f19b863014dc3d76df0 Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Sat, 30 May 2015 17:24:52 -0700 Subject: Avoid ObjC since we use .m for octave/matlab diff --git a/lisp/ravi-init-cpp.el b/lisp/ravi-init-cpp.el index 9a0faaf..40a29da 100644 --- a/lisp/ravi-init-cpp.el +++ b/lisp/ravi-init-cpp.el @@ -93,6 +93,16 @@ :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) -- cgit v0.10.1 From 6fd19a8402fb4b11d39a1abb5965bb5bf8d7d024 Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Sat, 30 May 2015 22:07:21 -0700 Subject: More keys for ace-jump diff --git a/lisp/ravi-init-navigation.el b/lisp/ravi-init-navigation.el index c90355b..569e164 100644 --- a/lisp/ravi-init-navigation.el +++ b/lisp/ravi-init-navigation.el @@ -50,6 +50,7 @@ ("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) -- cgit v0.10.1 From aa2abd8d05eee20e8c5586a6bc4174dc281e7c9b Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Tue, 9 Jun 2015 22:02:14 -0700 Subject: Smarter whitespace compaction diff --git a/lisp/ravi-init-appearance.el b/lisp/ravi-init-appearance.el index 5cfac60..cc7c3b5 100644 --- a/lisp/ravi-init-appearance.el +++ b/lisp/ravi-init-appearance.el @@ -113,6 +113,11 @@ Delete all whitespace on a successive key press." ) :ensure t) +;; Easier compaction of whitespace +(use-package shrink-whitespace + :bind (("M-SPC" . shrink-whitespace)) + :ensure t) + (setq sentence-end-double-space nil) (defun sacha/unfill-paragraph (&optional region) "Takes a multi-line paragraph and makes it into a single line of text." -- cgit v0.10.1 From e19267afbf539f9ad8863eb5380832ec66695621 Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Tue, 9 Jun 2015 22:02:32 -0700 Subject: Move from toggles to repetitions diff --git a/lisp/ravi-init-appearance.el b/lisp/ravi-init-appearance.el index cc7c3b5..fbf9769 100644 --- a/lisp/ravi-init-appearance.el +++ b/lisp/ravi-init-appearance.el @@ -165,7 +165,7 @@ Delete all whitespace on a successive key press." 'upcase-region) start (1+ start))) (capitalize-word -1)))) -(bind-key "M-c" 'oremacs/capitalize-word-toggle) +;; (bind-key "M-c" 'oremacs/capitalize-word-toggle) (defun oremacs/upcase-word-toggle () (interactive) @@ -193,7 +193,13 @@ Delete all whitespace on a successive key press." 'downcase-region 'upcase-region) beg end))))) -(bind-key "M-l" 'oremacs/upcase-word-toggle) +;; (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 -- cgit v0.10.1 From e7f577c0ebbb3740d15f80345cb23f0a94cfe5f0 Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Tue, 16 Jun 2015 21:38:06 -0700 Subject: More utilities for rectangles with long lines diff --git a/lisp/ravi-init-appearance.el b/lisp/ravi-init-appearance.el index fbf9769..d959aaf 100644 --- a/lisp/ravi-init-appearance.el +++ b/lisp/ravi-init-appearance.el @@ -128,13 +128,13 @@ Delete all whitespace on a successive key press." (fill-paragraph nil region))) (bind-key "M-Q" 'sacha/unfill-paragraph) -;; Easily navigate sillycased words -;(global-subword-mode 1) +(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 - ) + :ensure t) ;; Enable automatic indentation, if possible (use-package smart-newline -- cgit v0.10.1 From d0240c9f8cd1a5880d08755fb08203ca8beff800 Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Tue, 16 Jun 2015 21:38:30 -0700 Subject: Show vc status in ibuffer diff --git a/lisp/ravi-init-ido.el b/lisp/ravi-init-ido.el index 93af3e6..0997bd4 100644 --- a/lisp/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) -- cgit v0.10.1 From 8bf0e8909fb02b8dfa7bd257e57d84b71469c1ef Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Tue, 16 Jun 2015 21:38:46 -0700 Subject: Sphinx docstring highlights diff --git a/lisp/ravi-init-python.el b/lisp/ravi-init-python.el index 049f5ef..7c433ea 100644 --- a/lisp/ravi-init-python.el +++ b/lisp/ravi-init-python.el @@ -169,6 +169,15 @@ ) :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) ) ) -- cgit v0.10.1 From 17946ac4802744dfe7f496c1dc72bc8b33e32841 Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Wed, 17 Jun 2015 22:03:11 -0700 Subject: Use unfill from package rather than home-brewed version diff --git a/lisp/ravi-init-appearance.el b/lisp/ravi-init-appearance.el index d959aaf..344c764 100644 --- a/lisp/ravi-init-appearance.el +++ b/lisp/ravi-init-appearance.el @@ -119,14 +119,9 @@ Delete all whitespace on a successive key press." :ensure t) (setq sentence-end-double-space nil) -(defun sacha/unfill-paragraph (&optional region) - "Takes a multi-line paragraph and makes it into a single line of text." - (interactive (progn - (barf-if-buffer-read-only) - (list t))) - (let ((fill-column (point-max))) - (fill-paragraph nil region))) -(bind-key "M-Q" 'sacha/unfill-paragraph) +(use-package unfill + :bind (("M-q" . toggle-fill-unfill)) + :ensure t) (use-package rectangle-utils :bind (("C-x R" . rectangle-menu)) -- cgit v0.10.1 From 59f6467ed96e71fe662b9cbc9cdbbcab721db63a Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Wed, 17 Jun 2015 22:03:46 -0700 Subject: Try different method for managing temporary buffers diff --git a/lisp/ravi-init-appearance.el b/lisp/ravi-init-appearance.el index 344c764..317ac8d 100644 --- a/lisp/ravi-init-appearance.el +++ b/lisp/ravi-init-appearance.el @@ -308,15 +308,20 @@ Delete all whitespace on a successive key press." (use-package popwin :init (progn - (popwin-mode 1) + ;; (popwin-mode 1) ; disabled for now, try temp-buffer-browse (push '("*Pp Eval Output*" :height 15) popwin:special-display-config)) - :ensure t - ) + :ensure t) + +(use-package temp-buffer-browse + :config + (progn + (temp-buffer-browse-mode 1)) + :diminish temp-buffer-browse-mode + :ensure t) (use-package import-popwin :bind (("M-I" . import-popwin)) - :ensure t - ) + :ensure t) (use-package ace-window :bind (("M-o" . ace-window)) -- cgit v0.10.1 From f02be9d1d201ca5273bcf32a18cc44508c22e7ae Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Fri, 19 Jun 2015 09:15:18 -0700 Subject: Shut up magit warning diff --git a/lisp/ravi-init-vc.el b/lisp/ravi-init-vc.el index e4b273e..11e3143 100644 --- a/lisp/ravi-init-vc.el +++ b/lisp/ravi-init-vc.el @@ -28,6 +28,9 @@ (use-package magit :bind (("" . magit-status) ("C-x v F" . magit-file-log)) + :init + (progn + (setq magit-last-seen-setup-instructions "1.4.0")) :config (progn (setq-default -- cgit v0.10.1 From b7483688014391aacc37ce7ea71f660831694233 Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Sat, 20 Jun 2015 21:30:44 -0700 Subject: Bug fix: add missing keymap diff --git a/lisp/ravi-init-insertion.el b/lisp/ravi-init-insertion.el index 512e578..e36cc94 100644 --- a/lisp/ravi-init-insertion.el +++ b/lisp/ravi-init-insertion.el @@ -131,7 +131,7 @@ (interactive) (company-abort) (call-interactively 'company-yasnippet)) - (bind-key "" 'ravi/company-to-yasnippet) + (bind-key "" 'ravi/company-to-yasnippet company-active-map) (bind-key "" 'company-yasnippet)) :diminish company-mode -- cgit v0.10.1 From 24af4244c8cb19cd982f860fd8b7e2e1d02da874 Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Wed, 24 Jun 2015 22:10:35 -0700 Subject: Move back to popwin mode diff --git a/lisp/ravi-init-appearance.el b/lisp/ravi-init-appearance.el index 317ac8d..ed58b57 100644 --- a/lisp/ravi-init-appearance.el +++ b/lisp/ravi-init-appearance.el @@ -308,7 +308,7 @@ Delete all whitespace on a successive key press." (use-package popwin :init (progn - ;; (popwin-mode 1) ; disabled for now, try temp-buffer-browse + (popwin-mode 1) (push '("*Pp Eval Output*" :height 15) popwin:special-display-config)) :ensure t) @@ -317,6 +317,7 @@ Delete all whitespace on a successive key press." (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 -- cgit v0.10.1 From d46e633c8660ab7c41ab26971025b1dfe858b888 Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Wed, 24 Jun 2015 22:53:10 -0700 Subject: Add firestarter diff --git a/lisp/ravi-init-function.el b/lisp/ravi-init-function.el index d1c8230..612286c 100644 --- a/lisp/ravi-init-function.el +++ b/lisp/ravi-init-function.el @@ -75,5 +75,68 @@ and file 'filename' will be opened and cursor set on line 'linenumber'" (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 -- cgit v0.10.1 From 1a8b2d431567be8f047d8de23b0fe88eeb0ea6fb Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Wed, 29 Jul 2015 17:53:08 -0700 Subject: server-running-p requires server diff --git a/lisp/ravi-init-function.el b/lisp/ravi-init-function.el index 612286c..255602c 100644 --- a/lisp/ravi-init-function.el +++ b/lisp/ravi-init-function.el @@ -29,6 +29,7 @@ ;(setq enable-recursive-minibuffers t) ;; Use emacsclient from other programs +(require 'server) (unless (server-running-p) (server-start)) ;; Stolen from prelude -- cgit v0.10.1 From 384cd31646757fc93565f073080ce03096ce7131 Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Wed, 29 Jul 2015 17:54:13 -0700 Subject: Simplify config with magit 2.1.0 - no more hand-rolled git-svn - whitespace toggling is built in - skip auto-revert modes for now, will revisit later diff --git a/lisp/ravi-init-vc.el b/lisp/ravi-init-vc.el index 11e3143..0c7ace1 100644 --- a/lisp/ravi-init-vc.el +++ b/lisp/ravi-init-vc.el @@ -27,130 +27,46 @@ ;; Git (use-package magit :bind (("" . magit-status) + ("C-x v B" . magit-blame) ("C-x v F" . magit-file-log)) - :init - (progn - (setq magit-last-seen-setup-instructions "1.4.0")) :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) + magit-completing-read-function (if ravi/use-helm-instead-of-ido + 'helm-completing-read-with-cands-in-buffer + 'magit-ido-completing-read)) (setq magit-restore-window-configuration t) - (diminish 'magit-auto-revert-mode) - - (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) - + :config (add-hook 'magit-mode-hook 'magit-svn-mode) + :ensure t) ) - :ensure t - ) + :ensure t) (use-package git-gutter :config (progn (use-package git-gutter-fringe - :ensure t - ) + :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 - ) + :ensure t) (use-package gitconfig-mode - :ensure t - ) + :ensure t) (use-package git-messenger - :ensure t :bind ("C-x v p" . git-messenger:popup-message) - ) + :ensure t) (use-package git-timemachine - :ensure t :bind ("C-x v t" . git-timemachine) - ) -(use-package magit-blame - :bind (("C-x v B" . magit-blame-mode))) + :ensure t) +(use-package vc-git + :bind ("C-x v f" . vc-git-grep)) ;; Stolen almost entirely from Fuco (Matus Goljer) (use-package ediff -- cgit v0.10.1 From 011a01ac7643d779b5023eb861a1e6c45b8f8478 Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Wed, 29 Jul 2015 21:38:54 -0700 Subject: Navigate easier diff --git a/lisp/ravi-init-org.el b/lisp/ravi-init-org.el index 814add2..523f564 100644 --- a/lisp/ravi-init-org.el +++ b/lisp/ravi-init-org.el @@ -53,6 +53,7 @@ org-gnus org-id org-info))) + (setq org-use-speed-commands t) ) ) -- cgit v0.10.1 From 97327f381ca9291bfb297dd1c1eff952b34f41dd Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Wed, 29 Jul 2015 22:00:11 -0700 Subject: Use which-key in preference to guide-key diff --git a/lisp/ravi-init-appearance.el b/lisp/ravi-init-appearance.el index ed58b57..35d872f 100644 --- a/lisp/ravi-init-appearance.el +++ b/lisp/ravi-init-appearance.el @@ -300,13 +300,21 @@ Delete all whitespace on a successive key press." ) ) :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 - :init + :config (progn (popwin-mode 1) (push '("*Pp Eval Output*" :height 15) popwin:special-display-config)) diff --git a/lisp/ravi-init-dired.el b/lisp/ravi-init-dired.el index 0c8fab2..a82ba6c 100644 --- a/lisp/ravi-init-dired.el +++ b/lisp/ravi-init-dired.el @@ -141,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/lisp/ravi-init-function.el b/lisp/ravi-init-function.el index 255602c..673031a 100644 --- a/lisp/ravi-init-function.el +++ b/lisp/ravi-init-function.el @@ -73,7 +73,8 @@ and file 'filename' will be opened and cursor set on line 'linenumber'" ("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")) + ;; (add-to-list 'guide-key/guide-key-sequence "C-x t") + ) (ravi/setup-toggle-launcher-map) ;; Start something going on saving a file -- cgit v0.10.1 From fc6e8c75dea423fb24923b2a32113a766c1c3247 Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Wed, 29 Jul 2015 22:13:44 -0700 Subject: Electric operators on python mode May eventually extend this to other modes. diff --git a/lisp/ravi-init-python.el b/lisp/ravi-init-python.el index 7c433ea..70234c9 100644 --- a/lisp/ravi-init-python.el +++ b/lisp/ravi-init-python.el @@ -178,6 +178,13 @@ (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) ) ) -- cgit v0.10.1 From dd509349d6e9ef94120d8531922995e17e92314f Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Wed, 29 Jul 2015 22:32:33 -0700 Subject: Use proper helm function to replace completing-read diff --git a/lisp/ravi-init-vc.el b/lisp/ravi-init-vc.el index 0c7ace1..a28a75a 100644 --- a/lisp/ravi-init-vc.el +++ b/lisp/ravi-init-vc.el @@ -35,7 +35,7 @@ magit-process-popup-time 10 magit-diff-refine-hunk t magit-completing-read-function (if ravi/use-helm-instead-of-ido - 'helm-completing-read-with-cands-in-buffer + 'helm--completing-read-default 'magit-ido-completing-read)) (setq magit-restore-window-configuration t) -- cgit v0.10.1 From e66510180f38fd7b7f212c7585d3b5ea220739a4 Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Wed, 26 Aug 2015 09:28:18 -0700 Subject: Manage word navigation diff --git a/lisp/ravi-init-appearance.el b/lisp/ravi-init-appearance.el index 35d872f..80c4d8a 100644 --- a/lisp/ravi-init-appearance.el +++ b/lisp/ravi-init-appearance.el @@ -123,6 +123,24 @@ Delete all whitespace on a successive key press." :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) -- cgit v0.10.1 From ffe50580fb2b64d90c9cac7ec0c82b9fd4c73685 Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Wed, 26 Aug 2015 09:28:43 -0700 Subject: Do not let company-quickhelp steal a global key On the home row too! diff --git a/lisp/ravi-init-insertion.el b/lisp/ravi-init-insertion.el index e36cc94..5cbcef8 100644 --- a/lisp/ravi-init-insertion.el +++ b/lisp/ravi-init-insertion.el @@ -109,7 +109,11 @@ (use-package company-quickhelp :config - (company-quickhelp-mode 1) + (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 -- cgit v0.10.1 From 9b78d27a15c5e6e6180194d7bd61786e45e47bce Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Sun, 30 Aug 2015 22:16:47 -0700 Subject: Remove ropemacs due to disuse diff --git a/lisp/ravi-init-python.el b/lisp/ravi-init-python.el index 70234c9..ba37dc6 100644 --- a/lisp/ravi-init-python.el +++ b/lisp/ravi-init-python.el @@ -82,49 +82,6 @@ :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 -- cgit v0.10.1 From bb9af4ac22ad1016971d21589cd9ac16242f9773 Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Sun, 30 Aug 2015 22:17:12 -0700 Subject: Succumb to muscle memory of control keys diff --git a/lisp/ravi-init-insertion.el b/lisp/ravi-init-insertion.el index 5cbcef8..e75c414 100644 --- a/lisp/ravi-init-insertion.el +++ b/lisp/ravi-init-insertion.el @@ -89,6 +89,16 @@ (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 -- cgit v0.10.1 From 72503695fdbc002c294965ff37d82daa33f9e1eb Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Sun, 30 Aug 2015 22:17:32 -0700 Subject: Pre-populate searches diff --git a/lisp/ravi-init-helm.el b/lisp/ravi-init-helm.el index 72d9b0a..40e32af 100644 --- a/lisp/ravi-init-helm.el +++ b/lisp/ravi-init-helm.el @@ -73,6 +73,9 @@ :ensure t) (use-package helm-ag + :config + (progn + (setq helm-ag-insert-at-point 'symbol)) :ensure t) (use-package helm-dash -- cgit v0.10.1 From 2e6e06642d668f6fd667d95bd43c3d8e81823943 Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Sun, 30 Aug 2015 22:17:52 -0700 Subject: Sometimes the dispatch list does come in handy How can we make it display the dispatch alist as help? diff --git a/lisp/ravi-init-appearance.el b/lisp/ravi-init-appearance.el index 80c4d8a..af0d411 100644 --- a/lisp/ravi-init-appearance.el +++ b/lisp/ravi-init-appearance.el @@ -351,7 +351,8 @@ Delete all whitespace on a successive key press." :ensure t) (use-package ace-window - :bind (("M-o" . 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) @@ -370,6 +371,12 @@ Delete all whitespace on a successive key press." (?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))) + (when (package-installed-p 'hydra) (defhydra hydra-window-size (:color red) "Windows size" -- cgit v0.10.1 From 0156bb35d17d7d0b9c7228a14e755f7bdd5058a8 Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Mon, 31 Aug 2015 22:15:38 -0700 Subject: ace-window gets confused when tooltips are present diff --git a/lisp/ravi-init-appearance.el b/lisp/ravi-init-appearance.el index af0d411..eb5d441 100644 --- a/lisp/ravi-init-appearance.el +++ b/lisp/ravi-init-appearance.el @@ -377,6 +377,11 @@ Delete all whitespace on a successive key press." (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" -- cgit v0.10.1 From 01661ece4c9e20cd85527e77c76ce747d1330ca6 Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Mon, 31 Aug 2015 22:16:04 -0700 Subject: Please remove tooltips after a while, please diff --git a/lisp/ravi-init-python.el b/lisp/ravi-init-python.el index ba37dc6..7993092 100644 --- a/lisp/ravi-init-python.el +++ b/lisp/ravi-init-python.el @@ -103,6 +103,21 @@ 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) ; needs auto-complete (add-hook 'hack-local-variables-hook 'ravi/jedi-setup nil t)) -- cgit v0.10.1 From c70bd0d2ae138e313f50015c976c760c0cef32c7 Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Mon, 31 Aug 2015 22:29:20 -0700 Subject: Update to newest version of mu diff --git a/site-lisp/mu b/site-lisp/mu index 33804f6..7981845 160000 --- a/site-lisp/mu +++ b/site-lisp/mu @@ -1 +1 @@ -Subproject commit 33804f63d852dc222050c9e606059138d5e4557a +Subproject commit 7981845daad7318a214162ac5580a29edd0d1e78 -- cgit v0.10.1 From 6f4fd3ca64e5a2a4c3a8be55781040b5621f25e9 Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Thu, 17 Sep 2015 10:16:19 -0700 Subject: Attach files more easily in mu diff --git a/lisp/ravi-init-mu.el b/lisp/ravi-init-mu.el index de87132..bd2f13e 100644 --- a/lisp/ravi-init-mu.el +++ b/lisp/ravi-init-mu.el @@ -172,6 +172,7 @@ (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 @@ -189,6 +190,13 @@ (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) ) ) -- cgit v0.10.1 From d13d45410530798918d33fef19b7f9f9b66c2ef2 Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Thu, 17 Sep 2015 10:16:37 -0700 Subject: Potential use for modes without repls diff --git a/lisp/ravi-init-repl.el b/lisp/ravi-init-repl.el index 5ff6b52..3191bb3 100644 --- a/lisp/ravi-init-repl.el +++ b/lisp/ravi-init-repl.el @@ -56,9 +56,15 @@ (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 "" 'rtog/toggle-repl repl-toggle-mode-map) + (bind-key "" 'ravi/repl-toggle-or-compile-dwim repl-toggle-mode-map) ) :diminish repl-toggle-mode :ensure t) -- cgit v0.10.1 From b14ed970bba7387343eee4d552717303b848f964 Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Fri, 23 Oct 2015 10:52:07 -0700 Subject: Add desktop notifications for email diff --git a/lisp/ravi-init-mu.el b/lisp/ravi-init-mu.el index bd2f13e..bd068e7 100644 --- a/lisp/ravi-init-mu.el +++ b/lisp/ravi-init-mu.el @@ -167,6 +167,14 @@ ;;:config (mu4e-maildirs-extension) ; does not work with mu now :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) -- cgit v0.10.1 From 91ed923de8e3d9342d4d180b7f33bbe3dc99e11a Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Fri, 23 Oct 2015 10:52:29 -0700 Subject: Fix maildir data with correct path diff --git a/lisp/ravi-init-mu.el b/lisp/ravi-init-mu.el index bd068e7..2f21a0b 100644 --- a/lisp/ravi-init-mu.el +++ b/lisp/ravi-init-mu.el @@ -164,9 +164,13 @@ ;; Show summary of all folders (use-package mu4e-maildirs-extension - ;;:config (mu4e-maildirs-extension) ; does not work with mu now - :ensure t - ) + :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 -- cgit v0.10.1 From 26b63eff549019e0daaf5257c1c1bbd83da4cc39 Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Fri, 23 Oct 2015 10:57:04 -0700 Subject: Add pdf-tools submodule diff --git a/.gitmodules b/.gitmodules index b6f9968..8de3a75 100644 --- a/.gitmodules +++ b/.gitmodules @@ -19,3 +19,6 @@ [submodule "site-lisp/keyadvice"] path = site-lisp/keyadvice url = https://github.com/Fuco1/keyadvice.el.git +[submodule "site-lisp/pdf-tools"] + path = site-lisp/pdf-tools + url = https://github.com/politza/pdf-tools.git diff --git a/site-lisp/pdf-tools b/site-lisp/pdf-tools new file mode 160000 index 0000000..787762d --- /dev/null +++ b/site-lisp/pdf-tools @@ -0,0 +1 @@ +Subproject commit 787762d3ad86fcba2ce81889f56968dc8b475d97 -- cgit v0.10.1 From 74c319ef12dd3130f6afc17abc59404b59d601d1 Mon Sep 17 00:00:00 2001 From: Ravi R Kiran Date: Fri, 23 Oct 2015 11:32:00 -0700 Subject: Add pdf-tools as a nicer replacement for doc-view 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/lisp/ravi-init-appearance.el b/lisp/ravi-init-appearance.el index eb5d441..fe81dcb 100644 --- a/lisp/ravi-init-appearance.el +++ b/lisp/ravi-init-appearance.el @@ -416,5 +416,13 @@ Delete all whitespace on a successive key press." (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 -- cgit v0.10.1