2011-10-08 23:05:06 +03:00
|
|
|
;;; prelude-editor.el --- Emacs Prelude: enhanced core editing experience.
|
|
|
|
;;
|
2018-05-06 09:21:24 +03:00
|
|
|
;; Copyright © 2011-2018 Bozhidar Batsov
|
2011-10-08 23:05:06 +03:00
|
|
|
;;
|
2012-04-17 17:35:21 +03:00
|
|
|
;; Author: Bozhidar Batsov <bozhidar@batsov.com>
|
2013-03-07 09:57:33 +02:00
|
|
|
;; URL: https://github.com/bbatsov/prelude
|
2011-10-08 23:05:06 +03:00
|
|
|
;; Version: 1.0.0
|
|
|
|
;; Keywords: convenience
|
|
|
|
|
|
|
|
;; This file is not part of GNU Emacs.
|
|
|
|
|
|
|
|
;;; Commentary:
|
|
|
|
|
|
|
|
;; Refinements of the core editing experience in Emacs.
|
|
|
|
|
|
|
|
;;; License:
|
|
|
|
|
|
|
|
;; 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 GNU Emacs; see the file COPYING. If not, write to the
|
|
|
|
;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
|
|
;; Boston, MA 02110-1301, USA.
|
|
|
|
|
|
|
|
;;; Code:
|
|
|
|
|
2012-02-27 21:49:00 +02:00
|
|
|
;; Death to the tabs! However, tabs historically indent to the next
|
|
|
|
;; 8-character offset; specifying anything else will cause *mass*
|
|
|
|
;; confusion, as it will change the appearance of every existing file.
|
|
|
|
;; In some cases (python), even worse -- it will change the semantics
|
|
|
|
;; (meaning) of the program.
|
|
|
|
;;
|
|
|
|
;; Emacs modes typically provide a standard means to change the
|
|
|
|
;; indentation width -- eg. c-basic-offset: use that to adjust your
|
|
|
|
;; personal indentation width, while maintaining the style (and
|
|
|
|
;; meaning) of any files you load.
|
|
|
|
(setq-default indent-tabs-mode nil) ;; don't use tabs to indent
|
|
|
|
(setq-default tab-width 8) ;; but maintain correct appearance
|
2011-10-07 23:25:37 +03:00
|
|
|
|
2014-05-26 19:05:29 +03:00
|
|
|
;; Newline at end of file
|
|
|
|
(setq require-final-newline t)
|
|
|
|
|
2011-10-07 23:25:37 +03:00
|
|
|
;; delete the selection with a keypress
|
|
|
|
(delete-selection-mode t)
|
|
|
|
|
|
|
|
;; store all backup and autosave files in the tmp dir
|
|
|
|
(setq backup-directory-alist
|
|
|
|
`((".*" . ,temporary-file-directory)))
|
|
|
|
(setq auto-save-file-name-transforms
|
|
|
|
`((".*" ,temporary-file-directory t)))
|
|
|
|
|
2014-12-30 19:19:42 +02:00
|
|
|
;; autosave the undo-tree history
|
|
|
|
(setq undo-tree-history-directory-alist
|
|
|
|
`((".*" . ,temporary-file-directory)))
|
|
|
|
(setq undo-tree-auto-save-history t)
|
|
|
|
|
2011-10-07 23:25:37 +03:00
|
|
|
;; revert buffers automatically when underlying files are changed externally
|
|
|
|
(global-auto-revert-mode t)
|
|
|
|
|
|
|
|
;; hippie expand is dabbrev expand on steroids
|
|
|
|
(setq hippie-expand-try-functions-list '(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
|
|
|
|
try-expand-list
|
|
|
|
try-expand-line
|
|
|
|
try-complete-lisp-symbol-partially
|
|
|
|
try-complete-lisp-symbol))
|
|
|
|
|
2013-12-07 09:40:05 +02:00
|
|
|
;; smart tab behavior - indent or complete
|
|
|
|
(setq tab-always-indent 'complete)
|
|
|
|
|
2012-04-26 19:07:46 +03:00
|
|
|
;; smart pairing for all
|
2013-06-29 11:09:16 +03:00
|
|
|
(require 'smartparens-config)
|
2013-07-11 11:38:49 +03:00
|
|
|
(setq sp-base-key-bindings 'paredit)
|
2013-08-06 22:51:10 +03:00
|
|
|
(setq sp-autoskip-closing-pair 'always)
|
2013-09-26 12:31:00 +03:00
|
|
|
(setq sp-hybrid-kill-entire-symbol nil)
|
2013-08-22 14:58:19 +03:00
|
|
|
(sp-use-paredit-bindings)
|
2011-10-09 00:24:41 +03:00
|
|
|
|
2013-10-04 12:43:32 +03:00
|
|
|
(show-smartparens-global-mode +1)
|
|
|
|
|
2013-12-07 09:14:44 +02:00
|
|
|
(define-key prog-mode-map (kbd "M-(") (prelude-wrap-with "("))
|
2013-12-07 08:45:05 +02:00
|
|
|
;; FIXME: pick terminal friendly binding
|
2013-12-07 09:14:44 +02:00
|
|
|
;; (define-key prog-mode-map (kbd "M-[") (prelude-wrap-with "["))
|
|
|
|
(define-key prog-mode-map (kbd "M-\"") (prelude-wrap-with "\""))
|
2013-10-17 19:20:28 +03:00
|
|
|
|
2013-10-07 18:13:04 +03:00
|
|
|
;; disable annoying blink-matching-paren
|
|
|
|
(setq blink-matching-paren nil)
|
|
|
|
|
2013-03-12 21:56:21 +02:00
|
|
|
;; diminish keeps the modeline tidy
|
|
|
|
(require 'diminish)
|
|
|
|
|
2011-10-07 23:25:37 +03:00
|
|
|
;; meaningful names for buffers with the same name
|
|
|
|
(require 'uniquify)
|
|
|
|
(setq uniquify-buffer-name-style 'forward)
|
|
|
|
(setq uniquify-separator "/")
|
|
|
|
(setq uniquify-after-kill-buffer-p t) ; rename after killing uniquified
|
|
|
|
(setq uniquify-ignore-buffers-re "^\\*") ; don't muck with special buffers
|
|
|
|
|
2011-10-22 23:50:40 +03:00
|
|
|
;; saveplace remembers your location in a file when saving files
|
2012-10-21 18:16:40 +03:00
|
|
|
(setq save-place-file (expand-file-name "saveplace" prelude-savefile-dir))
|
2011-10-22 23:50:40 +03:00
|
|
|
;; activate it for all buffers
|
2016-10-26 09:36:17 +03:00
|
|
|
(if (< emacs-major-version 25)
|
|
|
|
(progn (require 'saveplace)
|
|
|
|
(setq-default save-place t))
|
|
|
|
(save-place-mode 1))
|
2011-10-22 23:50:40 +03:00
|
|
|
|
|
|
|
;; savehist keeps track of some history
|
2013-03-12 21:56:21 +02:00
|
|
|
(require 'savehist)
|
2011-10-22 23:50:40 +03:00
|
|
|
(setq savehist-additional-variables
|
|
|
|
;; search entries
|
2014-09-09 20:18:20 +03:00
|
|
|
'(search-ring regexp-search-ring)
|
2011-10-22 23:50:40 +03:00
|
|
|
;; save every minute
|
|
|
|
savehist-autosave-interval 60
|
|
|
|
;; keep the home clean
|
2012-10-21 18:16:40 +03:00
|
|
|
savehist-file (expand-file-name "savehist" prelude-savefile-dir))
|
2013-03-12 21:56:21 +02:00
|
|
|
(savehist-mode +1)
|
2011-10-07 23:25:37 +03:00
|
|
|
|
|
|
|
;; save recent files
|
2013-03-12 21:56:21 +02:00
|
|
|
(require 'recentf)
|
2012-10-21 18:16:40 +03:00
|
|
|
(setq recentf-save-file (expand-file-name "recentf" prelude-savefile-dir)
|
2013-07-15 11:56:25 +03:00
|
|
|
recentf-max-saved-items 500
|
2014-05-25 14:02:48 +03:00
|
|
|
recentf-max-menu-items 15
|
|
|
|
;; disable recentf-cleanup on Emacs start, because it can cause
|
|
|
|
;; problems with remote files
|
|
|
|
recentf-auto-cleanup 'never)
|
2014-04-30 12:46:32 +03:00
|
|
|
|
|
|
|
(defun prelude-recentf-exclude-p (file)
|
|
|
|
"A predicate to decide whether to exclude FILE from recentf."
|
|
|
|
(let ((file-dir (file-truename (file-name-directory file))))
|
2018-05-08 22:54:42 +03:00
|
|
|
(cl-some (lambda (dir)
|
|
|
|
(string-prefix-p dir file-dir))
|
|
|
|
(mapcar 'file-truename (list prelude-savefile-dir package-user-dir)))))
|
2014-04-30 12:46:32 +03:00
|
|
|
|
|
|
|
(add-to-list 'recentf-exclude 'prelude-recentf-exclude-p)
|
2014-05-25 14:02:48 +03:00
|
|
|
|
2013-03-12 21:56:21 +02:00
|
|
|
(recentf-mode +1)
|
2011-10-07 23:25:37 +03:00
|
|
|
|
|
|
|
;; use shift + arrow keys to switch between visible buffers
|
|
|
|
(require 'windmove)
|
2012-04-23 12:11:44 +03:00
|
|
|
(windmove-default-keybindings)
|
2011-10-07 23:25:37 +03:00
|
|
|
|
2012-03-07 11:51:57 +02:00
|
|
|
;; automatically save buffers associated with files on buffer switch
|
|
|
|
;; and on windows switch
|
2012-12-08 20:59:59 +02:00
|
|
|
(defun prelude-auto-save-command ()
|
2013-04-28 16:37:09 +03:00
|
|
|
"Save the current buffer if `prelude-auto-save' is not nil."
|
2012-12-08 20:59:59 +02:00
|
|
|
(when (and prelude-auto-save
|
|
|
|
buffer-file-name
|
2013-05-08 13:52:20 +03:00
|
|
|
(buffer-modified-p (current-buffer))
|
|
|
|
(file-writable-p buffer-file-name))
|
2012-12-08 20:59:59 +02:00
|
|
|
(save-buffer)))
|
|
|
|
|
2014-06-25 05:17:37 +03:00
|
|
|
(defmacro advise-commands (advice-name commands class &rest body)
|
2013-07-17 15:28:30 +03:00
|
|
|
"Apply advice named ADVICE-NAME to multiple COMMANDS.
|
|
|
|
|
|
|
|
The body of the advice is in BODY."
|
|
|
|
`(progn
|
|
|
|
,@(mapcar (lambda (command)
|
2014-06-25 05:17:37 +03:00
|
|
|
`(defadvice ,command (,class ,(intern (concat (symbol-name command) "-" advice-name)) activate)
|
2013-07-17 15:28:30 +03:00
|
|
|
,@body))
|
|
|
|
commands)))
|
|
|
|
|
|
|
|
;; advise all window switching functions
|
|
|
|
(advise-commands "auto-save"
|
|
|
|
(switch-to-buffer other-window windmove-up windmove-down windmove-left windmove-right)
|
2014-06-25 05:17:37 +03:00
|
|
|
before
|
2013-07-17 15:28:30 +03:00
|
|
|
(prelude-auto-save-command))
|
2012-12-08 20:59:59 +02:00
|
|
|
|
|
|
|
(add-hook 'mouse-leave-buffer-hook 'prelude-auto-save-command)
|
2012-03-07 11:51:57 +02:00
|
|
|
|
2014-04-14 17:54:13 +03:00
|
|
|
(when (version<= "24.4" emacs-version)
|
2014-07-14 18:54:49 +03:00
|
|
|
(add-hook 'focus-out-hook 'prelude-auto-save-command))
|
2014-04-14 17:54:13 +03:00
|
|
|
|
2014-07-01 15:47:15 +03:00
|
|
|
(defadvice set-buffer-major-mode (after set-major-mode activate compile)
|
|
|
|
"Set buffer major mode according to `auto-mode-alist'."
|
|
|
|
(let* ((name (buffer-name buffer))
|
|
|
|
(mode (assoc-default name auto-mode-alist 'string-match)))
|
2016-02-13 05:10:03 +02:00
|
|
|
(when (and mode (consp mode))
|
|
|
|
(setq mode (car mode)))
|
2014-07-01 15:47:15 +03:00
|
|
|
(with-current-buffer buffer (if mode (funcall mode)))))
|
|
|
|
|
2011-11-08 16:43:19 +02:00
|
|
|
;; highlight the current line
|
|
|
|
(global-hl-line-mode +1)
|
|
|
|
|
2012-02-15 22:02:14 +02:00
|
|
|
(require 'volatile-highlights)
|
|
|
|
(volatile-highlights-mode t)
|
2013-03-06 21:43:59 +02:00
|
|
|
(diminish 'volatile-highlights-mode)
|
2012-02-15 22:02:14 +02:00
|
|
|
|
2014-12-22 08:23:12 +02:00
|
|
|
;; note - this should be after volatile-highlights is required
|
|
|
|
;; add the ability to cut the current line, without marking it
|
2015-09-10 11:29:57 +03:00
|
|
|
(require 'rect)
|
2016-09-25 07:58:06 +03:00
|
|
|
(crux-with-region-or-line kill-region)
|
2014-12-22 08:23:12 +02:00
|
|
|
|
2011-10-07 23:25:37 +03:00
|
|
|
;; tramp, for sudo access
|
|
|
|
(require 'tramp)
|
|
|
|
;; keep in mind known issues with zsh - see emacs wiki
|
|
|
|
(setq tramp-default-method "ssh")
|
|
|
|
|
|
|
|
(set-default 'imenu-auto-rescan t)
|
|
|
|
|
2011-10-22 23:50:40 +03:00
|
|
|
;; flyspell-mode does spell-checking on the fly as you type
|
2013-03-12 21:56:21 +02:00
|
|
|
(require 'flyspell)
|
2011-10-07 23:25:37 +03:00
|
|
|
(setq ispell-program-name "aspell" ; use aspell instead of ispell
|
|
|
|
ispell-extra-args '("--sug-mode=ultra"))
|
|
|
|
|
2012-12-09 11:36:21 +02:00
|
|
|
(defun prelude-enable-flyspell ()
|
2013-04-28 16:37:09 +03:00
|
|
|
"Enable command `flyspell-mode' if `prelude-flyspell' is not nil."
|
2012-12-09 11:36:21 +02:00
|
|
|
(when (and prelude-flyspell (executable-find ispell-program-name))
|
|
|
|
(flyspell-mode +1)))
|
|
|
|
|
2013-03-26 00:35:00 +02:00
|
|
|
(defun prelude-cleanup-maybe ()
|
2013-04-28 16:37:09 +03:00
|
|
|
"Invoke `whitespace-cleanup' if `prelude-clean-whitespace-on-save' is not nil."
|
2013-03-28 17:22:33 +02:00
|
|
|
(when prelude-clean-whitespace-on-save
|
|
|
|
(whitespace-cleanup)))
|
2013-03-26 00:35:00 +02:00
|
|
|
|
2013-01-05 10:38:12 +02:00
|
|
|
(defun prelude-enable-whitespace ()
|
2013-04-28 16:37:09 +03:00
|
|
|
"Enable `whitespace-mode' if `prelude-whitespace' is not nil."
|
2013-01-05 10:38:12 +02:00
|
|
|
(when prelude-whitespace
|
|
|
|
;; keep the whitespace decent all the time (in this buffer)
|
2013-03-26 00:35:00 +02:00
|
|
|
(add-hook 'before-save-hook 'prelude-cleanup-maybe nil t)
|
2013-01-05 10:38:12 +02:00
|
|
|
(whitespace-mode +1)))
|
|
|
|
|
2012-12-09 11:36:21 +02:00
|
|
|
(add-hook 'text-mode-hook 'prelude-enable-flyspell)
|
2013-01-05 10:38:12 +02:00
|
|
|
(add-hook 'text-mode-hook 'prelude-enable-whitespace)
|
2011-10-08 23:05:06 +03:00
|
|
|
|
2012-02-23 18:22:18 +02:00
|
|
|
;; enable narrowing commands
|
2011-10-07 23:25:37 +03:00
|
|
|
(put 'narrow-to-region 'disabled nil)
|
2012-02-23 18:22:18 +02:00
|
|
|
(put 'narrow-to-page 'disabled nil)
|
|
|
|
(put 'narrow-to-defun 'disabled nil)
|
|
|
|
|
|
|
|
;; enabled change region case commands
|
|
|
|
(put 'upcase-region 'disabled nil)
|
|
|
|
(put 'downcase-region 'disabled nil)
|
2011-10-07 23:25:37 +03:00
|
|
|
|
2013-05-04 10:27:32 +03:00
|
|
|
;; enable erase-buffer command
|
|
|
|
(put 'erase-buffer 'disabled nil)
|
|
|
|
|
2011-12-05 16:30:05 +02:00
|
|
|
(require 'expand-region)
|
|
|
|
|
2011-10-07 23:25:37 +03:00
|
|
|
;; bookmarks
|
2013-03-12 21:56:21 +02:00
|
|
|
(require 'bookmark)
|
2012-10-21 18:16:40 +03:00
|
|
|
(setq bookmark-default-file (expand-file-name "bookmarks" prelude-savefile-dir)
|
2011-10-08 23:05:06 +03:00
|
|
|
bookmark-save-flag 1)
|
|
|
|
|
2011-10-10 12:27:17 +03:00
|
|
|
;; projectile is a project management mode
|
|
|
|
(require 'projectile)
|
2012-10-21 18:16:40 +03:00
|
|
|
(setq projectile-cache-file (expand-file-name "projectile.cache" prelude-savefile-dir))
|
2011-10-10 12:27:17 +03:00
|
|
|
(projectile-global-mode t)
|
2012-04-12 14:54:25 +03:00
|
|
|
|
2015-05-09 13:02:43 +03:00
|
|
|
;; avy allows us to effectively navigate to visible things
|
2015-05-11 12:44:30 +03:00
|
|
|
(require 'avy)
|
2015-05-09 13:02:43 +03:00
|
|
|
(setq avy-background t)
|
2015-05-11 12:44:30 +03:00
|
|
|
(setq avy-style 'at-full)
|
2015-05-09 13:02:43 +03:00
|
|
|
|
2014-08-28 18:40:43 +03:00
|
|
|
;; anzu-mode enhances isearch & query-replace by showing total matches and current match position
|
2013-09-27 15:07:40 +03:00
|
|
|
(require 'anzu)
|
|
|
|
(diminish 'anzu-mode)
|
|
|
|
(global-anzu-mode)
|
2013-09-27 12:35:04 +03:00
|
|
|
|
2014-08-28 18:40:43 +03:00
|
|
|
(global-set-key (kbd "M-%") 'anzu-query-replace)
|
|
|
|
(global-set-key (kbd "C-M-%") 'anzu-query-replace-regexp)
|
|
|
|
|
2011-11-10 10:37:39 +02:00
|
|
|
;; dired - reuse current buffer by pressing 'a'
|
|
|
|
(put 'dired-find-alternate-file 'disabled nil)
|
|
|
|
|
2013-04-30 23:39:54 +03:00
|
|
|
;; always delete and copy recursively
|
|
|
|
(setq dired-recursive-deletes 'always)
|
|
|
|
(setq dired-recursive-copies 'always)
|
|
|
|
|
|
|
|
;; if there is a dired buffer displayed in the next window, use its
|
|
|
|
;; current subdir, instead of the current subdir of this dired buffer
|
|
|
|
(setq dired-dwim-target t)
|
|
|
|
|
2013-04-13 18:36:47 +03:00
|
|
|
;; enable some really cool extensions like C-x C-j(dired-jump)
|
|
|
|
(require 'dired-x)
|
|
|
|
|
2011-12-07 13:47:27 +02:00
|
|
|
;; ediff - don't start another frame
|
2013-03-12 21:56:21 +02:00
|
|
|
(require 'ediff)
|
2011-12-07 13:47:27 +02:00
|
|
|
(setq ediff-window-setup-function 'ediff-setup-windows-plain)
|
|
|
|
|
2012-03-07 13:06:33 +02:00
|
|
|
;; clean up obsolete buffers automatically
|
|
|
|
(require 'midnight)
|
|
|
|
|
2013-12-11 11:50:32 +02:00
|
|
|
;; smarter kill-ring navigation
|
2013-12-14 11:06:53 +02:00
|
|
|
(require 'browse-kill-ring)
|
|
|
|
(browse-kill-ring-default-keybindings)
|
2013-12-11 11:50:32 +02:00
|
|
|
(global-set-key (kbd "s-y") 'browse-kill-ring)
|
|
|
|
|
2014-06-08 08:16:17 +03:00
|
|
|
(defadvice exchange-point-and-mark (before deactivate-mark activate compile)
|
|
|
|
"When called with no active region, do not activate mark."
|
|
|
|
(interactive
|
|
|
|
(list (not (region-active-p)))))
|
|
|
|
|
2015-03-13 05:26:20 +02:00
|
|
|
(require 'tabify)
|
2014-06-25 04:36:23 +03:00
|
|
|
(defmacro with-region-or-buffer (func)
|
|
|
|
"When called with no active region, call FUNC on current buffer."
|
|
|
|
`(defadvice ,func (before with-region-or-buffer activate compile)
|
|
|
|
(interactive
|
|
|
|
(if mark-active
|
|
|
|
(list (region-beginning) (region-end))
|
|
|
|
(list (point-min) (point-max))))))
|
|
|
|
|
|
|
|
(with-region-or-buffer indent-region)
|
|
|
|
(with-region-or-buffer untabify)
|
|
|
|
|
2012-03-07 13:06:33 +02:00
|
|
|
;; automatically indenting yanked text if in programming-modes
|
|
|
|
(defun yank-advised-indent-function (beg end)
|
|
|
|
"Do indentation, as long as the region isn't too large."
|
2014-06-25 05:03:15 +03:00
|
|
|
(if (<= (- end beg) prelude-yank-indent-threshold)
|
2012-03-07 13:06:33 +02:00
|
|
|
(indent-region beg end nil)))
|
|
|
|
|
2014-06-25 05:17:37 +03:00
|
|
|
(advise-commands "indent" (yank yank-pop) after
|
|
|
|
"If current mode is one of `prelude-yank-indent-modes',
|
2012-03-07 13:06:33 +02:00
|
|
|
indent yanked text (with prefix arg don't indent)."
|
|
|
|
(if (and (not (ad-get-arg 0))
|
2014-06-25 05:03:15 +03:00
|
|
|
(not (member major-mode prelude-indent-sensitive-modes))
|
2012-03-07 13:06:33 +02:00
|
|
|
(or (derived-mode-p 'prog-mode)
|
2014-06-25 05:03:15 +03:00
|
|
|
(member major-mode prelude-yank-indent-modes)))
|
2012-03-07 13:06:33 +02:00
|
|
|
(let ((transient-mark-mode nil))
|
2014-05-21 07:52:50 +03:00
|
|
|
(yank-advised-indent-function (region-beginning) (region-end)))))
|
2012-03-07 13:06:33 +02:00
|
|
|
|
|
|
|
;; abbrev config
|
2012-10-05 19:35:39 +03:00
|
|
|
(add-hook 'text-mode-hook 'abbrev-mode)
|
2012-03-07 13:06:33 +02:00
|
|
|
|
|
|
|
;; make a shell script executable automatically on save
|
|
|
|
(add-hook 'after-save-hook
|
|
|
|
'executable-make-buffer-file-executable-if-script-p)
|
|
|
|
|
2013-05-17 19:24:56 +03:00
|
|
|
;; .zsh file is shell script too
|
|
|
|
(add-to-list 'auto-mode-alist '("\\.zsh\\'" . shell-script-mode))
|
|
|
|
|
2012-12-23 11:24:55 +02:00
|
|
|
;; whitespace-mode config
|
2013-03-12 21:56:21 +02:00
|
|
|
(require 'whitespace)
|
2012-12-23 11:24:55 +02:00
|
|
|
(setq whitespace-line-column 80) ;; limit line length
|
|
|
|
(setq whitespace-style '(face tabs empty trailing lines-tail))
|
|
|
|
|
2012-03-07 13:06:33 +02:00
|
|
|
;; saner regex syntax
|
|
|
|
(require 're-builder)
|
|
|
|
(setq reb-re-syntax 'string)
|
|
|
|
|
2012-06-15 18:54:12 +03:00
|
|
|
(require 'eshell)
|
2012-10-21 18:16:40 +03:00
|
|
|
(setq eshell-directory-name (expand-file-name "eshell" prelude-savefile-dir))
|
2012-06-15 18:54:12 +03:00
|
|
|
|
2012-09-18 23:54:41 +03:00
|
|
|
(setq semanticdb-default-save-directory
|
2012-10-21 18:16:40 +03:00
|
|
|
(expand-file-name "semanticdb" prelude-savefile-dir))
|
2012-06-15 18:54:12 +03:00
|
|
|
|
2014-04-19 10:29:14 +03:00
|
|
|
;; Compilation from Emacs
|
|
|
|
(defun prelude-colorize-compilation-buffer ()
|
|
|
|
"Colorize a compilation mode buffer."
|
|
|
|
(interactive)
|
|
|
|
;; we don't want to mess with child modes such as grep-mode, ack, ag, etc
|
|
|
|
(when (eq major-mode 'compilation-mode)
|
|
|
|
(let ((inhibit-read-only t))
|
|
|
|
(ansi-color-apply-on-region (point-min) (point-max)))))
|
|
|
|
|
|
|
|
(require 'compile)
|
|
|
|
(setq compilation-ask-about-save nil ; Just save before compiling
|
|
|
|
compilation-always-kill t ; Just kill old compile processes before
|
2014-05-21 07:52:50 +03:00
|
|
|
; starting the new one
|
2014-04-19 10:29:14 +03:00
|
|
|
compilation-scroll-output 'first-error ; Automatically scroll to first
|
2014-05-21 07:52:50 +03:00
|
|
|
; error
|
2014-04-19 10:29:14 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
;; Colorize output of Compilation Mode, see
|
|
|
|
;; http://stackoverflow.com/a/3072831/355252
|
|
|
|
(require 'ansi-color)
|
|
|
|
(add-hook 'compilation-filter-hook #'prelude-colorize-compilation-buffer)
|
|
|
|
|
2012-02-23 18:02:34 +02:00
|
|
|
;; enable Prelude's keybindings
|
|
|
|
(prelude-global-mode t)
|
|
|
|
|
2013-02-07 00:34:02 +02:00
|
|
|
;; sensible undo
|
|
|
|
(global-undo-tree-mode)
|
2013-03-06 21:43:59 +02:00
|
|
|
(diminish 'undo-tree-mode)
|
2013-02-07 00:34:02 +02:00
|
|
|
|
2013-01-01 21:38:50 +02:00
|
|
|
;; enable winner-mode to manage window configurations
|
|
|
|
(winner-mode +1)
|
|
|
|
|
2014-04-14 17:40:34 +03:00
|
|
|
;; diff-hl
|
|
|
|
(global-diff-hl-mode +1)
|
|
|
|
(add-hook 'dired-mode-hook 'diff-hl-dired-mode)
|
2016-04-06 20:01:29 +03:00
|
|
|
(add-hook 'magit-post-refresh-hook 'diff-hl-magit-post-refresh)
|
2014-04-14 17:40:34 +03:00
|
|
|
|
2014-04-12 17:47:06 +03:00
|
|
|
;; easy-kill
|
|
|
|
(global-set-key [remap kill-ring-save] 'easy-kill)
|
|
|
|
(global-set-key [remap mark-sexp] 'easy-mark)
|
|
|
|
|
2014-05-29 07:04:44 +03:00
|
|
|
;; operate-on-number
|
2014-05-21 07:52:50 +03:00
|
|
|
(require 'operate-on-number)
|
2015-02-22 20:25:34 +02:00
|
|
|
(require 'smartrep)
|
|
|
|
|
2014-05-21 07:52:50 +03:00
|
|
|
(smartrep-define-key global-map "C-c ."
|
|
|
|
'(("+" . apply-operation-to-number-at-point)
|
|
|
|
("-" . apply-operation-to-number-at-point)
|
|
|
|
("*" . apply-operation-to-number-at-point)
|
|
|
|
("/" . apply-operation-to-number-at-point)
|
2014-05-29 07:04:44 +03:00
|
|
|
("\\" . apply-operation-to-number-at-point)
|
2014-05-21 07:52:50 +03:00
|
|
|
("^" . apply-operation-to-number-at-point)
|
|
|
|
("<" . apply-operation-to-number-at-point)
|
|
|
|
(">" . apply-operation-to-number-at-point)
|
2014-05-29 07:04:44 +03:00
|
|
|
("#" . apply-operation-to-number-at-point)
|
|
|
|
("%" . apply-operation-to-number-at-point)
|
2014-05-21 07:52:50 +03:00
|
|
|
("'" . operate-on-number-at-point)))
|
|
|
|
|
2014-10-26 13:44:24 +02:00
|
|
|
(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)))
|
|
|
|
|
2017-01-04 01:07:37 +02:00
|
|
|
;; use settings from .editorconfig file when present
|
|
|
|
(require 'editorconfig)
|
|
|
|
(editorconfig-mode 1)
|
|
|
|
|
2011-10-08 23:05:06 +03:00
|
|
|
(provide 'prelude-editor)
|
2011-10-07 23:25:37 +03:00
|
|
|
|
2011-10-08 23:05:06 +03:00
|
|
|
;;; prelude-editor.el ends here
|