Working emacs prelude with ox-twbs
This commit is contained in:
@@ -1 +0,0 @@
|
||||
../.dotfiles/emacs/.emacs.d/core
|
||||
178
emacs/.emacs.d/core/prelude-core.el
Normal file
178
emacs/.emacs.d/core/prelude-core.el
Normal file
@@ -0,0 +1,178 @@
|
||||
;;; prelude-core.el --- Emacs Prelude: Core Prelude functions.
|
||||
;;
|
||||
;; Copyright © 2011-2017 Bozhidar Batsov
|
||||
;;
|
||||
;; Author: Bozhidar Batsov <bozhidar@batsov.com>
|
||||
;; URL: https://github.com/bbatsov/prelude
|
||||
;; Version: 1.0.0
|
||||
;; Keywords: convenience
|
||||
|
||||
;; This file is not part of GNU Emacs.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; Here are the definitions of most of the functions added by Prelude.
|
||||
|
||||
;;; 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:
|
||||
|
||||
(require 'thingatpt)
|
||||
(require 'dash)
|
||||
(require 'ov)
|
||||
|
||||
(defun prelude-buffer-mode (buffer-or-name)
|
||||
"Retrieve the `major-mode' of BUFFER-OR-NAME."
|
||||
(with-current-buffer buffer-or-name
|
||||
major-mode))
|
||||
|
||||
(defun prelude-search (query-url prompt)
|
||||
"Open the search url constructed with the QUERY-URL.
|
||||
PROMPT sets the `read-string prompt."
|
||||
(browse-url
|
||||
(concat query-url
|
||||
(url-hexify-string
|
||||
(if mark-active
|
||||
(buffer-substring (region-beginning) (region-end))
|
||||
(read-string prompt))))))
|
||||
|
||||
(defmacro prelude-install-search-engine (search-engine-name search-engine-url search-engine-prompt)
|
||||
"Given some information regarding a search engine, install the interactive command to search through them"
|
||||
`(defun ,(intern (format "prelude-%s" search-engine-name)) ()
|
||||
,(format "Search %s with a query or region if any." search-engine-name)
|
||||
(interactive)
|
||||
(prelude-search ,search-engine-url ,search-engine-prompt)))
|
||||
|
||||
(prelude-install-search-engine "google" "http://www.google.com/search?q=" "Google: ")
|
||||
(prelude-install-search-engine "youtube" "http://www.youtube.com/results?search_query=" "Search YouTube: ")
|
||||
(prelude-install-search-engine "github" "https://github.com/search?q=" "Search GitHub: ")
|
||||
(prelude-install-search-engine "duckduckgo" "https://duckduckgo.com/?t=lm&q=" "Search DuckDuckGo: ")
|
||||
|
||||
(defun prelude-todo-ov-evaporate (_ov _after _beg _end &optional _length)
|
||||
(let ((inhibit-modification-hooks t))
|
||||
(if _after (ov-reset _ov))))
|
||||
|
||||
(defun prelude-annotate-todo ()
|
||||
"Put fringe marker on TODO: lines in the current buffer."
|
||||
(interactive)
|
||||
(ov-set (format "[[:space:]]*%s+[[:space:]]*TODO:" comment-start)
|
||||
'before-string
|
||||
(propertize (format "A")
|
||||
'display '(left-fringe right-triangle))
|
||||
'modification-hooks '(prelude-todo-ov-evaporate)))
|
||||
|
||||
(defun prelude-recompile-init ()
|
||||
"Byte-compile all your dotfiles again."
|
||||
(interactive)
|
||||
(byte-recompile-directory prelude-dir 0))
|
||||
|
||||
(defvar prelude-tips
|
||||
'("Press <C-c o> to open a file with external program."
|
||||
"Press <C-c p f> to navigate a project's files with ido."
|
||||
"Press <s-r> to open a recently visited file."
|
||||
"Press <C-c p s g> to run grep on a project."
|
||||
"Press <C-c p p> to switch between projects."
|
||||
"Press <C-=> to expand the selected region."
|
||||
"Press <C-c g> to search in Google."
|
||||
"Press <C-c G> to search in GitHub."
|
||||
"Press <C-c y> to search in YouTube."
|
||||
"Press <C-c U> to search in DuckDuckGo."
|
||||
"Press <C-c r> to rename the current buffer and the file it's visiting if any."
|
||||
"Press <C-c t> to open a terminal in Emacs."
|
||||
"Press <C-c k> to kill all the buffers, but the active one."
|
||||
"Press <C-x g> to run magit-status."
|
||||
"Press <C-c D> to delete the current file and buffer."
|
||||
"Press <C-c s> to swap two windows."
|
||||
"Press <S-RET> or <M-o> to open a line beneath the current one."
|
||||
"Press <s-o> to open a line above the current one."
|
||||
"Press <C-c C-z> in a Elisp buffer to launch an interactive Elisp shell."
|
||||
"Press <C-Backspace> to kill a line backwards."
|
||||
"Press <C-S-Backspace> or <s-k> to kill the whole line."
|
||||
"Press <s-j> or <C-^> to join lines."
|
||||
"Press <s-.> or <C-c j> to jump to the start of a word in any visible window."
|
||||
"Press <f11> to toggle fullscreen mode."
|
||||
"Press <f12> to toggle the menu bar."
|
||||
"Explore the Tools->Prelude menu to find out about some of Prelude extensions to Emacs."
|
||||
"Access the official Emacs manual by pressing <C-h r>."
|
||||
"Visit the EmacsWiki at http://emacswiki.org to find out even more about Emacs."))
|
||||
|
||||
(defun prelude-tip-of-the-day ()
|
||||
"Display a random entry from `prelude-tips'."
|
||||
(interactive)
|
||||
(when (and prelude-tips (not (window-minibuffer-p)))
|
||||
;; pick a new random seed
|
||||
(random t)
|
||||
(message
|
||||
(concat "Prelude tip: " (nth (random (length prelude-tips)) prelude-tips)))))
|
||||
|
||||
(defun prelude-eval-after-init (form)
|
||||
"Add `(lambda () FORM)' to `after-init-hook'.
|
||||
|
||||
If Emacs has already finished initialization, also eval FORM immediately."
|
||||
(let ((func (list 'lambda nil form)))
|
||||
(add-hook 'after-init-hook func)
|
||||
(when after-init-time
|
||||
(eval form))))
|
||||
|
||||
(require 'epl)
|
||||
|
||||
(defun prelude-update ()
|
||||
"Update Prelude to its latest version."
|
||||
(interactive)
|
||||
(when (y-or-n-p "Do you want to update Prelude? ")
|
||||
(message "Updating installed packages...")
|
||||
(epl-upgrade)
|
||||
(message "Updating Prelude...")
|
||||
(cd prelude-dir)
|
||||
(shell-command "git pull")
|
||||
(prelude-recompile-init)
|
||||
(message "Update finished. Restart Emacs to complete the process.")))
|
||||
|
||||
(defun prelude-update-packages (&optional arg)
|
||||
"Update Prelude's packages.
|
||||
This includes package installed via `prelude-require-package'.
|
||||
|
||||
With a prefix ARG updates all installed packages."
|
||||
(interactive "P")
|
||||
(when (y-or-n-p "Do you want to update Prelude's packages? ")
|
||||
(if arg
|
||||
(epl-upgrade)
|
||||
(epl-upgrade (-filter (lambda (p) (memq (epl-package-name p) prelude-packages))
|
||||
(epl-installed-packages))))
|
||||
(message "Update finished. Restart Emacs to complete the process.")))
|
||||
|
||||
;;; Emacs in OSX already has fullscreen support
|
||||
;;; Emacs has a similar built-in command in 24.4
|
||||
(defun prelude-fullscreen ()
|
||||
"Make Emacs window fullscreen.
|
||||
|
||||
This follows freedesktop standards, should work in X servers."
|
||||
(interactive)
|
||||
(if (eq window-system 'x)
|
||||
(x-send-client-message nil 0 nil "_NET_WM_STATE" 32
|
||||
'(2 "_NET_WM_STATE_FULLSCREEN" 0))
|
||||
(error "Only X server is supported")))
|
||||
|
||||
(defun prelude-wrap-with (s)
|
||||
"Create a wrapper function for smartparens using S."
|
||||
`(lambda (&optional arg)
|
||||
(interactive "P")
|
||||
(sp-wrap-with-pair ,s)))
|
||||
|
||||
(provide 'prelude-core)
|
||||
;;; prelude-core.el ends here
|
||||
103
emacs/.emacs.d/core/prelude-custom.el
Normal file
103
emacs/.emacs.d/core/prelude-custom.el
Normal file
@@ -0,0 +1,103 @@
|
||||
;;; prelude-custom.el --- Emacs Prelude: Prelude's customizable variables.
|
||||
;;
|
||||
;; Copyright © 2011-2017 Bozhidar Batsov
|
||||
;;
|
||||
;; Author: Bozhidar Batsov <bozhidar@batsov.com>
|
||||
;; URL: https://github.com/bbatsov/prelude
|
||||
;; 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:
|
||||
|
||||
;; customize
|
||||
(defgroup prelude nil
|
||||
"Emacs Prelude configuration."
|
||||
:prefix "prelude-"
|
||||
:group 'convenience)
|
||||
|
||||
(defcustom prelude-auto-save t
|
||||
"Non-nil values enable Prelude's auto save."
|
||||
:type 'boolean
|
||||
:group 'prelude)
|
||||
|
||||
(defcustom prelude-guru t
|
||||
"Non-nil values enable `guru-mode'."
|
||||
:type 'boolean
|
||||
:group 'prelude)
|
||||
|
||||
(defcustom prelude-whitespace t
|
||||
"Non-nil values enable Prelude's whitespace visualization."
|
||||
:type 'boolean
|
||||
:group 'prelude)
|
||||
|
||||
(defcustom prelude-clean-whitespace-on-save t
|
||||
"Cleanup whitespace from file before it's saved.
|
||||
Will only occur if `prelude-whitespace' is also enabled."
|
||||
:type 'boolean
|
||||
:group 'prelude)
|
||||
|
||||
(defcustom prelude-flyspell t
|
||||
"Non-nil values enable Prelude's flyspell support."
|
||||
:type 'boolean
|
||||
:group 'prelude)
|
||||
|
||||
(defcustom prelude-user-init-file (expand-file-name "personal/"
|
||||
user-emacs-directory)
|
||||
"Path to your personal customization file.
|
||||
Prelude recommends you only put personal customizations in the
|
||||
personal folder. This variable allows you to specify a specific
|
||||
folder as the one that should be visited when running
|
||||
`crux-find-user-init-file'. This can be easily set to the desired buffer
|
||||
in lisp by putting `(setq prelude-user-init-file load-file-name)'
|
||||
in the desired elisp file."
|
||||
:type 'string
|
||||
:group 'prelude)
|
||||
|
||||
(defcustom prelude-indent-sensitive-modes
|
||||
'(conf-mode coffee-mode haml-mode python-mode slim-mode yaml-mode)
|
||||
"Modes for which auto-indenting is suppressed."
|
||||
:type 'list
|
||||
:group 'prelude)
|
||||
|
||||
(defcustom prelude-yank-indent-modes '(LaTeX-mode TeX-mode)
|
||||
"Modes in which to indent regions that are yanked (or yank-popped).
|
||||
Only modes that don't derive from `prog-mode' should be listed here."
|
||||
:type 'list
|
||||
:group 'prelude)
|
||||
|
||||
(defcustom prelude-yank-indent-threshold 1000
|
||||
"Threshold (# chars) over which indentation does not automatically occur."
|
||||
:type 'number
|
||||
:group 'prelude)
|
||||
|
||||
(defcustom prelude-theme 'zenburn
|
||||
"The default color theme, change this in your /personal/preload config."
|
||||
:type 'symbol
|
||||
:group 'prelude)
|
||||
|
||||
(provide 'prelude-custom)
|
||||
|
||||
;;; prelude-custom.el ends here
|
||||
440
emacs/.emacs.d/core/prelude-editor.el
Normal file
440
emacs/.emacs.d/core/prelude-editor.el
Normal file
@@ -0,0 +1,440 @@
|
||||
;;; prelude-editor.el --- Emacs Prelude: enhanced core editing experience.
|
||||
;;
|
||||
;; Copyright © 2011-2017 Bozhidar Batsov
|
||||
;;
|
||||
;; Author: Bozhidar Batsov <bozhidar@batsov.com>
|
||||
;; URL: https://github.com/bbatsov/prelude
|
||||
;; 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:
|
||||
|
||||
;; 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
|
||||
|
||||
;; Newline at end of file
|
||||
(setq require-final-newline t)
|
||||
|
||||
;; 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)))
|
||||
|
||||
;; autosave the undo-tree history
|
||||
(setq undo-tree-history-directory-alist
|
||||
`((".*" . ,temporary-file-directory)))
|
||||
(setq undo-tree-auto-save-history t)
|
||||
|
||||
;; 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))
|
||||
|
||||
;; smart tab behavior - indent or complete
|
||||
(setq tab-always-indent 'complete)
|
||||
|
||||
;; smart pairing for all
|
||||
(require 'smartparens-config)
|
||||
(setq sp-base-key-bindings 'paredit)
|
||||
(setq sp-autoskip-closing-pair 'always)
|
||||
(setq sp-hybrid-kill-entire-symbol nil)
|
||||
(sp-use-paredit-bindings)
|
||||
|
||||
(show-smartparens-global-mode +1)
|
||||
|
||||
(define-key prog-mode-map (kbd "M-(") (prelude-wrap-with "("))
|
||||
;; FIXME: pick terminal friendly binding
|
||||
;; (define-key prog-mode-map (kbd "M-[") (prelude-wrap-with "["))
|
||||
(define-key prog-mode-map (kbd "M-\"") (prelude-wrap-with "\""))
|
||||
|
||||
;; disable annoying blink-matching-paren
|
||||
(setq blink-matching-paren nil)
|
||||
|
||||
;; diminish keeps the modeline tidy
|
||||
(require 'diminish)
|
||||
|
||||
;; 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
|
||||
|
||||
;; saveplace remembers your location in a file when saving files
|
||||
(setq save-place-file (expand-file-name "saveplace" prelude-savefile-dir))
|
||||
;; activate it for all buffers
|
||||
(if (< emacs-major-version 25)
|
||||
(progn (require 'saveplace)
|
||||
(setq-default save-place t))
|
||||
(save-place-mode 1))
|
||||
|
||||
;; savehist keeps track of some history
|
||||
(require 'savehist)
|
||||
(setq savehist-additional-variables
|
||||
;; search entries
|
||||
'(search-ring regexp-search-ring)
|
||||
;; save every minute
|
||||
savehist-autosave-interval 60
|
||||
;; keep the home clean
|
||||
savehist-file (expand-file-name "savehist" prelude-savefile-dir))
|
||||
(savehist-mode +1)
|
||||
|
||||
;; save recent files
|
||||
(require 'recentf)
|
||||
(setq recentf-save-file (expand-file-name "recentf" prelude-savefile-dir)
|
||||
recentf-max-saved-items 500
|
||||
recentf-max-menu-items 15
|
||||
;; disable recentf-cleanup on Emacs start, because it can cause
|
||||
;; problems with remote files
|
||||
recentf-auto-cleanup 'never)
|
||||
|
||||
(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))))
|
||||
(-any-p (lambda (dir)
|
||||
(string-prefix-p dir file-dir))
|
||||
(mapcar 'file-truename (list prelude-savefile-dir package-user-dir)))))
|
||||
|
||||
(add-to-list 'recentf-exclude 'prelude-recentf-exclude-p)
|
||||
|
||||
(recentf-mode +1)
|
||||
|
||||
;; use shift + arrow keys to switch between visible buffers
|
||||
(require 'windmove)
|
||||
(windmove-default-keybindings)
|
||||
|
||||
;; automatically save buffers associated with files on buffer switch
|
||||
;; and on windows switch
|
||||
(defun prelude-auto-save-command ()
|
||||
"Save the current buffer if `prelude-auto-save' is not nil."
|
||||
(when (and prelude-auto-save
|
||||
buffer-file-name
|
||||
(buffer-modified-p (current-buffer))
|
||||
(file-writable-p buffer-file-name))
|
||||
(save-buffer)))
|
||||
|
||||
(defmacro advise-commands (advice-name commands class &rest body)
|
||||
"Apply advice named ADVICE-NAME to multiple COMMANDS.
|
||||
|
||||
The body of the advice is in BODY."
|
||||
`(progn
|
||||
,@(mapcar (lambda (command)
|
||||
`(defadvice ,command (,class ,(intern (concat (symbol-name command) "-" advice-name)) activate)
|
||||
,@body))
|
||||
commands)))
|
||||
|
||||
;; advise all window switching functions
|
||||
(advise-commands "auto-save"
|
||||
(switch-to-buffer other-window windmove-up windmove-down windmove-left windmove-right)
|
||||
before
|
||||
(prelude-auto-save-command))
|
||||
|
||||
(add-hook 'mouse-leave-buffer-hook 'prelude-auto-save-command)
|
||||
|
||||
(when (version<= "24.4" emacs-version)
|
||||
(add-hook 'focus-out-hook 'prelude-auto-save-command))
|
||||
|
||||
(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)))
|
||||
(when (and mode (consp mode))
|
||||
(setq mode (car mode)))
|
||||
(with-current-buffer buffer (if mode (funcall mode)))))
|
||||
|
||||
;; highlight the current line
|
||||
(global-hl-line-mode +1)
|
||||
|
||||
(require 'volatile-highlights)
|
||||
(volatile-highlights-mode t)
|
||||
(diminish 'volatile-highlights-mode)
|
||||
|
||||
;; note - this should be after volatile-highlights is required
|
||||
;; add the ability to cut the current line, without marking it
|
||||
(require 'rect)
|
||||
(crux-with-region-or-line kill-region)
|
||||
|
||||
;; 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)
|
||||
|
||||
;; flyspell-mode does spell-checking on the fly as you type
|
||||
(require 'flyspell)
|
||||
(setq ispell-program-name "aspell" ; use aspell instead of ispell
|
||||
ispell-extra-args '("--sug-mode=ultra"))
|
||||
|
||||
(defun prelude-enable-flyspell ()
|
||||
"Enable command `flyspell-mode' if `prelude-flyspell' is not nil."
|
||||
(when (and prelude-flyspell (executable-find ispell-program-name))
|
||||
(flyspell-mode +1)))
|
||||
|
||||
(defun prelude-cleanup-maybe ()
|
||||
"Invoke `whitespace-cleanup' if `prelude-clean-whitespace-on-save' is not nil."
|
||||
(when prelude-clean-whitespace-on-save
|
||||
(whitespace-cleanup)))
|
||||
|
||||
(defun prelude-enable-whitespace ()
|
||||
"Enable `whitespace-mode' if `prelude-whitespace' is not nil."
|
||||
(when prelude-whitespace
|
||||
;; keep the whitespace decent all the time (in this buffer)
|
||||
(add-hook 'before-save-hook 'prelude-cleanup-maybe nil t)
|
||||
(whitespace-mode +1)))
|
||||
|
||||
(add-hook 'text-mode-hook 'prelude-enable-flyspell)
|
||||
(add-hook 'text-mode-hook 'prelude-enable-whitespace)
|
||||
|
||||
;; enable narrowing commands
|
||||
(put 'narrow-to-region 'disabled nil)
|
||||
(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)
|
||||
|
||||
;; enable erase-buffer command
|
||||
(put 'erase-buffer 'disabled nil)
|
||||
|
||||
(require 'expand-region)
|
||||
|
||||
;; bookmarks
|
||||
(require 'bookmark)
|
||||
(setq bookmark-default-file (expand-file-name "bookmarks" prelude-savefile-dir)
|
||||
bookmark-save-flag 1)
|
||||
|
||||
;; projectile is a project management mode
|
||||
(require 'projectile)
|
||||
(setq projectile-cache-file (expand-file-name "projectile.cache" prelude-savefile-dir))
|
||||
(projectile-global-mode t)
|
||||
|
||||
;; avy allows us to effectively navigate to visible things
|
||||
(require 'avy)
|
||||
(setq avy-background t)
|
||||
(setq avy-style 'at-full)
|
||||
|
||||
;; anzu-mode enhances isearch & query-replace by showing total matches and current match position
|
||||
(require 'anzu)
|
||||
(diminish 'anzu-mode)
|
||||
(global-anzu-mode)
|
||||
|
||||
(global-set-key (kbd "M-%") 'anzu-query-replace)
|
||||
(global-set-key (kbd "C-M-%") 'anzu-query-replace-regexp)
|
||||
|
||||
;; dired - reuse current buffer by pressing 'a'
|
||||
(put 'dired-find-alternate-file 'disabled nil)
|
||||
|
||||
;; 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)
|
||||
|
||||
;; enable some really cool extensions like C-x C-j(dired-jump)
|
||||
(require 'dired-x)
|
||||
|
||||
;; ediff - don't start another frame
|
||||
(require 'ediff)
|
||||
(setq ediff-window-setup-function 'ediff-setup-windows-plain)
|
||||
|
||||
;; clean up obsolete buffers automatically
|
||||
(require 'midnight)
|
||||
|
||||
;; smarter kill-ring navigation
|
||||
(require 'browse-kill-ring)
|
||||
(browse-kill-ring-default-keybindings)
|
||||
(global-set-key (kbd "s-y") 'browse-kill-ring)
|
||||
|
||||
(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)))))
|
||||
|
||||
(require 'tabify)
|
||||
(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)
|
||||
|
||||
;; 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."
|
||||
(if (<= (- end beg) prelude-yank-indent-threshold)
|
||||
(indent-region beg end nil)))
|
||||
|
||||
(advise-commands "indent" (yank yank-pop) after
|
||||
"If current mode is one of `prelude-yank-indent-modes',
|
||||
indent yanked text (with prefix arg don't indent)."
|
||||
(if (and (not (ad-get-arg 0))
|
||||
(not (member major-mode prelude-indent-sensitive-modes))
|
||||
(or (derived-mode-p 'prog-mode)
|
||||
(member major-mode prelude-yank-indent-modes)))
|
||||
(let ((transient-mark-mode nil))
|
||||
(yank-advised-indent-function (region-beginning) (region-end)))))
|
||||
|
||||
;; abbrev config
|
||||
(add-hook 'text-mode-hook 'abbrev-mode)
|
||||
|
||||
;; make a shell script executable automatically on save
|
||||
(add-hook 'after-save-hook
|
||||
'executable-make-buffer-file-executable-if-script-p)
|
||||
|
||||
;; .zsh file is shell script too
|
||||
(add-to-list 'auto-mode-alist '("\\.zsh\\'" . shell-script-mode))
|
||||
|
||||
;; whitespace-mode config
|
||||
(require 'whitespace)
|
||||
(setq whitespace-line-column 80) ;; limit line length
|
||||
(setq whitespace-style '(face tabs empty trailing lines-tail))
|
||||
|
||||
;; saner regex syntax
|
||||
(require 're-builder)
|
||||
(setq reb-re-syntax 'string)
|
||||
|
||||
(require 'eshell)
|
||||
(setq eshell-directory-name (expand-file-name "eshell" prelude-savefile-dir))
|
||||
|
||||
(setq semanticdb-default-save-directory
|
||||
(expand-file-name "semanticdb" prelude-savefile-dir))
|
||||
|
||||
;; 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
|
||||
; starting the new one
|
||||
compilation-scroll-output 'first-error ; Automatically scroll to first
|
||||
; error
|
||||
)
|
||||
|
||||
;; Colorize output of Compilation Mode, see
|
||||
;; http://stackoverflow.com/a/3072831/355252
|
||||
(require 'ansi-color)
|
||||
(add-hook 'compilation-filter-hook #'prelude-colorize-compilation-buffer)
|
||||
|
||||
;; enable Prelude's keybindings
|
||||
(prelude-global-mode t)
|
||||
|
||||
;; sensible undo
|
||||
(global-undo-tree-mode)
|
||||
(diminish 'undo-tree-mode)
|
||||
|
||||
;; enable winner-mode to manage window configurations
|
||||
(winner-mode +1)
|
||||
|
||||
;; diff-hl
|
||||
(global-diff-hl-mode +1)
|
||||
(add-hook 'dired-mode-hook 'diff-hl-dired-mode)
|
||||
(add-hook 'magit-post-refresh-hook 'diff-hl-magit-post-refresh)
|
||||
|
||||
;; easy-kill
|
||||
(global-set-key [remap kill-ring-save] 'easy-kill)
|
||||
(global-set-key [remap mark-sexp] 'easy-mark)
|
||||
|
||||
;; operate-on-number
|
||||
(require 'operate-on-number)
|
||||
(require 'smartrep)
|
||||
|
||||
(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)
|
||||
("\\" . 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)
|
||||
("'" . operate-on-number-at-point)))
|
||||
|
||||
(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)))
|
||||
|
||||
;; use settings from .editorconfig file when present
|
||||
(require 'editorconfig)
|
||||
(editorconfig-mode 1)
|
||||
|
||||
(provide 'prelude-editor)
|
||||
|
||||
;;; prelude-editor.el ends here
|
||||
116
emacs/.emacs.d/core/prelude-global-keybindings.el
Normal file
116
emacs/.emacs.d/core/prelude-global-keybindings.el
Normal file
@@ -0,0 +1,116 @@
|
||||
;;; prelude-global-keybindings.el --- Emacs Prelude: some useful keybindings.
|
||||
;;
|
||||
;; Copyright © 2011-2017 Bozhidar Batsov
|
||||
;;
|
||||
;; Author: Bozhidar Batsov <bozhidar@batsov.com>
|
||||
;; URL: https://github.com/bbatsov/prelude
|
||||
;; Version: 1.0.0
|
||||
;; Keywords: convenience
|
||||
|
||||
;; This file is not part of GNU Emacs.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; Lots of useful keybindings.
|
||||
|
||||
;;; 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:
|
||||
|
||||
;; Align your code in a pretty way.
|
||||
(global-set-key (kbd "C-x \\") 'align-regexp)
|
||||
|
||||
;; Font size
|
||||
(global-set-key (kbd "C-+") 'text-scale-increase)
|
||||
(global-set-key (kbd "C--") 'text-scale-decrease)
|
||||
|
||||
;; Window switching. (C-x o goes to the next window)
|
||||
(global-set-key (kbd "C-x O") (lambda ()
|
||||
(interactive)
|
||||
(other-window -1))) ;; back one
|
||||
|
||||
;; Indentation help
|
||||
(global-set-key (kbd "C-^") 'crux-top-join-line)
|
||||
;; Start proced in a similar manner to dired
|
||||
(unless (eq system-type 'darwin)
|
||||
(global-set-key (kbd "C-x p") 'proced))
|
||||
|
||||
;; Start eshell or switch to it if it's active.
|
||||
(global-set-key (kbd "C-x m") 'eshell)
|
||||
|
||||
;; Start a new eshell even if one is active.
|
||||
(global-set-key (kbd "C-x M") (lambda () (interactive) (eshell t)))
|
||||
|
||||
;; Start a regular shell if you prefer that.
|
||||
(global-set-key (kbd "C-x M-m") 'shell)
|
||||
|
||||
;; If you want to be able to M-x without meta
|
||||
(global-set-key (kbd "C-x C-m") 'smex)
|
||||
|
||||
;; A complementary binding to the apropos-command (C-h a)
|
||||
(define-key 'help-command "A" 'apropos)
|
||||
|
||||
;; A quick major mode help with discover-my-major
|
||||
(define-key 'help-command (kbd "C-m") 'discover-my-major)
|
||||
|
||||
(define-key 'help-command (kbd "C-f") 'find-function)
|
||||
(define-key 'help-command (kbd "C-k") 'find-function-on-key)
|
||||
(define-key 'help-command (kbd "C-v") 'find-variable)
|
||||
(define-key 'help-command (kbd "C-l") 'find-library)
|
||||
|
||||
(define-key 'help-command (kbd "C-i") 'info-display-manual)
|
||||
|
||||
;; replace zap-to-char functionality with the more powerful zop-to-char
|
||||
(global-set-key (kbd "M-z") 'zop-up-to-char)
|
||||
(global-set-key (kbd "M-Z") 'zop-to-char)
|
||||
|
||||
;; kill lines backward
|
||||
(global-set-key (kbd "C-<backspace>") (lambda ()
|
||||
(interactive)
|
||||
(kill-line 0)
|
||||
(indent-according-to-mode)))
|
||||
|
||||
(global-set-key [remap kill-whole-line] 'crux-kill-whole-line)
|
||||
|
||||
;; Activate occur easily inside isearch
|
||||
(define-key isearch-mode-map (kbd "C-o") 'isearch-occur)
|
||||
|
||||
;; use hippie-expand instead of dabbrev
|
||||
(global-set-key (kbd "M-/") 'hippie-expand)
|
||||
|
||||
;; replace buffer-menu with ibuffer
|
||||
(global-set-key (kbd "C-x C-b") 'ibuffer)
|
||||
|
||||
(unless (fboundp 'toggle-frame-fullscreen)
|
||||
(global-set-key (kbd "<f11>") 'prelude-fullscreen))
|
||||
|
||||
;; toggle menu-bar visibility
|
||||
(global-set-key (kbd "<f12>") 'menu-bar-mode)
|
||||
|
||||
(global-set-key (kbd "C-x g") 'magit-status)
|
||||
(global-set-key (kbd "C-x M-g") 'magit-dispatch-popup)
|
||||
|
||||
(global-set-key (kbd "C-=") 'er/expand-region)
|
||||
|
||||
(global-set-key (kbd "C-c j") 'avy-goto-word-or-subword-1)
|
||||
(global-set-key (kbd "s-.") 'avy-goto-word-or-subword-1)
|
||||
(global-set-key (kbd "s-w") 'ace-window)
|
||||
|
||||
(provide 'prelude-global-keybindings)
|
||||
|
||||
;;; prelude-global-keybindings.el ends here
|
||||
149
emacs/.emacs.d/core/prelude-mode.el
Normal file
149
emacs/.emacs.d/core/prelude-mode.el
Normal file
@@ -0,0 +1,149 @@
|
||||
;;; prelude-mode.el --- Emacs Prelude: minor mode
|
||||
;;
|
||||
;; Copyright © 2011-2017 Bozhidar Batsov
|
||||
;;
|
||||
;; Author: Bozhidar Batsov <bozhidar@batsov.com>
|
||||
;; URL: https://github.com/bbatsov/prelude
|
||||
;; Version: 1.0.0
|
||||
;; Keywords: convenience
|
||||
|
||||
;; This file is not part of GNU Emacs.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; A minor mode defining a local keymap, plus a menu.
|
||||
|
||||
;;; 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:
|
||||
(require 'easymenu)
|
||||
(require 'imenu-anywhere)
|
||||
(require 'crux)
|
||||
|
||||
(defvar prelude-mode-map
|
||||
(let ((map (make-sparse-keymap)))
|
||||
(define-key map (kbd "C-c o") 'crux-open-with)
|
||||
(define-key map (kbd "C-c g") 'prelude-google)
|
||||
(define-key map (kbd "C-c G") 'prelude-github)
|
||||
(define-key map (kbd "C-c y") 'prelude-youtube)
|
||||
(define-key map (kbd "C-c U") 'prelude-duckduckgo)
|
||||
;; mimic popular IDEs binding, note that it doesn't work in a terminal session
|
||||
(define-key map (kbd "C-a") 'crux-move-beginning-of-line)
|
||||
(define-key map [(shift return)] 'crux-smart-open-line)
|
||||
(define-key map (kbd "M-o") 'crux-smart-open-line)
|
||||
(define-key map [(control shift return)] 'crux-smart-open-line-above)
|
||||
(define-key map [(control shift up)] 'move-text-up)
|
||||
(define-key map [(control shift down)] 'move-text-down)
|
||||
(define-key map [(meta shift up)] 'move-text-up)
|
||||
(define-key map [(meta shift down)] 'move-text-down)
|
||||
(define-key map (kbd "C-c n") 'crux-cleanup-buffer-or-region)
|
||||
(define-key map (kbd "C-c f") 'crux-recentf-ido-find-file)
|
||||
(define-key map (kbd "C-M-z") 'crux-indent-defun)
|
||||
(define-key map (kbd "C-c u") 'crux-view-url)
|
||||
(define-key map (kbd "C-c e") 'crux-eval-and-replace)
|
||||
(define-key map (kbd "C-c s") 'crux-swap-windows)
|
||||
(define-key map (kbd "C-c D") 'crux-delete-file-and-buffer)
|
||||
(define-key map (kbd "C-c d") 'crux-duplicate-current-line-or-region)
|
||||
(define-key map (kbd "C-c M-d") 'crux-duplicate-and-comment-current-line-or-region)
|
||||
(define-key map (kbd "C-c r") 'crux-rename-buffer-and-file)
|
||||
(define-key map (kbd "C-c t") 'crux-visit-term-buffer)
|
||||
(define-key map (kbd "C-c k") 'crux-kill-other-buffers)
|
||||
(define-key map (kbd "C-c TAB") 'crux-indent-rigidly-and-copy-to-clipboard)
|
||||
(define-key map (kbd "C-c I") 'crux-find-user-init-file)
|
||||
(define-key map (kbd "C-c S") 'crux-find-shell-init-file)
|
||||
(define-key map (kbd "C-c i") 'imenu-anywhere)
|
||||
;; extra prefix for projectile
|
||||
(define-key map (kbd "s-p") 'projectile-command-map)
|
||||
;; make some use of the Super key
|
||||
(define-key map (kbd "s-g") 'god-local-mode)
|
||||
(define-key map (kbd "s-r") 'crux-recentf-ido-find-file)
|
||||
(define-key map (kbd "s-j") 'crux-top-join-line)
|
||||
(define-key map (kbd "s-k") 'crux-kill-whole-line)
|
||||
(define-key map (kbd "s-m m") 'magit-status)
|
||||
(define-key map (kbd "s-m l") 'magit-log)
|
||||
(define-key map (kbd "s-m f") 'magit-log-buffer-file)
|
||||
(define-key map (kbd "s-m b") 'magit-blame)
|
||||
(define-key map (kbd "s-o") 'crux-smart-open-line-above)
|
||||
|
||||
map)
|
||||
"Keymap for Prelude mode.")
|
||||
|
||||
(defun prelude-mode-add-menu ()
|
||||
"Add a menu entry for `prelude-mode' under Tools."
|
||||
(easy-menu-add-item nil '("Tools")
|
||||
'("Prelude"
|
||||
("Files"
|
||||
["Open with..." crux-open-with]
|
||||
["Delete file and buffer" crux-delete-file-and-buffer]
|
||||
["Rename buffer and file" crux-rename-buffer-and-file])
|
||||
|
||||
("Buffers"
|
||||
["Clean up buffer or region" crux-cleanup-buffer-or-region]
|
||||
["Kill other buffers" crux-kill-other-buffers])
|
||||
|
||||
("Editing"
|
||||
["Insert empty line" prelude-insert-empty-line]
|
||||
["Move line up" prelude-move-line-up]
|
||||
["Move line down" prelude-move-line-down]
|
||||
["Duplicate line or region" prelude-duplicate-current-line-or-region]
|
||||
["Indent rigidly and copy to clipboard" crux-indent-rigidly-and-copy-to-clipboard]
|
||||
["Insert date" crux-insert-date]
|
||||
["Eval and replace" crux-eval-and-replace]
|
||||
)
|
||||
|
||||
("Windows"
|
||||
["Swap windows" crux-swap-windows])
|
||||
|
||||
("General"
|
||||
["Visit term buffer" crux-visit-term-buffer]
|
||||
["Search in Google" prelude-google]
|
||||
["View URL" crux-view-url]))
|
||||
"Search Files (Grep)...")
|
||||
|
||||
(easy-menu-add-item nil '("Tools") '("--") "Search Files (Grep)..."))
|
||||
|
||||
(defun prelude-mode-remove-menu ()
|
||||
"Remove `prelude-mode' menu entry."
|
||||
(easy-menu-remove-item nil '("Tools") "Prelude")
|
||||
(easy-menu-remove-item nil '("Tools") "--"))
|
||||
|
||||
;; define minor mode
|
||||
(define-minor-mode prelude-mode
|
||||
"Minor mode to consolidate Emacs Prelude extensions.
|
||||
|
||||
\\{prelude-mode-map}"
|
||||
:lighter " Pre"
|
||||
:keymap prelude-mode-map
|
||||
(if prelude-mode
|
||||
;; on start
|
||||
(prelude-mode-add-menu)
|
||||
;; on stop
|
||||
(prelude-mode-remove-menu)))
|
||||
|
||||
(define-globalized-minor-mode prelude-global-mode prelude-mode prelude-on)
|
||||
|
||||
(defun prelude-on ()
|
||||
"Turn on `prelude-mode'."
|
||||
(prelude-mode +1))
|
||||
|
||||
(defun prelude-off ()
|
||||
"Turn off `prelude-mode'."
|
||||
(prelude-mode -1))
|
||||
|
||||
(provide 'prelude-mode)
|
||||
;;; prelude-mode.el ends here
|
||||
75
emacs/.emacs.d/core/prelude-osx.el
Normal file
75
emacs/.emacs.d/core/prelude-osx.el
Normal file
@@ -0,0 +1,75 @@
|
||||
;;; prelude-osx.el --- Emacs Prelude: OSX specific settings.
|
||||
;;
|
||||
;; Copyright © 2011-2017 Bozhidar Batsov
|
||||
;;
|
||||
;; Author: Bozhidar Batsov <bozhidar@batsov.com>
|
||||
;; URL: https://github.com/bbatsov/prelude
|
||||
;; Version: 1.0.0
|
||||
;; Keywords: convenience
|
||||
|
||||
;; This file is not part of GNU Emacs.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; Some OSX specific stuff.
|
||||
|
||||
;;; 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:
|
||||
|
||||
;; On OS X Emacs doesn't use the shell PATH if it's not started from
|
||||
;; the shell. Let's fix that:
|
||||
(prelude-require-packages '(exec-path-from-shell vkill))
|
||||
|
||||
(require 'exec-path-from-shell)
|
||||
(exec-path-from-shell-initialize)
|
||||
|
||||
;; It's all in the Meta
|
||||
(setq ns-function-modifier 'hyper)
|
||||
|
||||
;; proced-mode doesn't work on OS X so we use vkill instead
|
||||
(autoload 'vkill "vkill" nil t)
|
||||
(global-set-key (kbd "C-x p") 'vkill)
|
||||
|
||||
(defun prelude-swap-meta-and-super ()
|
||||
"Swap the mapping of Meta and Super.
|
||||
Very useful for people using their Mac with a
|
||||
Windows external keyboard from time to time."
|
||||
(interactive)
|
||||
(if (eq mac-command-modifier 'super)
|
||||
(progn
|
||||
(setq mac-command-modifier 'meta)
|
||||
(setq mac-option-modifier 'super)
|
||||
(message "Command is now bound to META and Option is bound to SUPER."))
|
||||
(progn
|
||||
(setq mac-command-modifier 'super)
|
||||
(setq mac-option-modifier 'meta)
|
||||
(message "Command is now bound to SUPER and Option is bound to META."))))
|
||||
|
||||
(define-key prelude-mode-map (kbd "C-c w") 'prelude-swap-meta-and-super)
|
||||
(define-key prelude-mode-map (kbd "s-/") 'hippie-expand)
|
||||
|
||||
(menu-bar-mode +1)
|
||||
|
||||
;; Enable emoji, and stop the UI from freezing when trying to display them.
|
||||
(if (fboundp 'set-fontset-font)
|
||||
(set-fontset-font t 'unicode "Apple Color Emoji" nil 'prepend))
|
||||
|
||||
|
||||
(provide 'prelude-osx)
|
||||
;;; prelude-osx.el ends here
|
||||
217
emacs/.emacs.d/core/prelude-packages.el
Normal file
217
emacs/.emacs.d/core/prelude-packages.el
Normal file
@@ -0,0 +1,217 @@
|
||||
;;; prelude-packages.el --- Emacs Prelude: default package selection.
|
||||
;;
|
||||
;; Copyright © 2011-2017 Bozhidar Batsov
|
||||
;;
|
||||
;; Author: Bozhidar Batsov <bozhidar@batsov.com>
|
||||
;; URL: https://github.com/bbatsov/prelude
|
||||
;; Version: 1.0.0
|
||||
;; Keywords: convenience
|
||||
|
||||
;; This file is not part of GNU Emacs.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; Takes care of the automatic installation of all the packages required by
|
||||
;; Emacs Prelude.
|
||||
|
||||
;;; 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:
|
||||
(require 'cl)
|
||||
(require 'package)
|
||||
|
||||
;; accessing a package repo over https on Windows is a no go, so we
|
||||
;; fallback to http there
|
||||
(if (eq system-type 'windows-nt)
|
||||
(add-to-list 'package-archives
|
||||
'("melpa" . "http://melpa.org/packages/") t)
|
||||
(add-to-list 'package-archives
|
||||
'("melpa" . "https://melpa.org/packages/") t))
|
||||
|
||||
;; load the pinned packages
|
||||
(let ((prelude-pinned-packages-file (expand-file-name "prelude-pinned-packages.el" prelude-dir)))
|
||||
(if (file-exists-p prelude-pinned-packages-file)
|
||||
(load prelude-pinned-packages-file)))
|
||||
|
||||
;; set package-user-dir to be relative to Prelude install path
|
||||
(setq package-user-dir (expand-file-name "elpa" prelude-dir))
|
||||
(package-initialize)
|
||||
|
||||
(defvar prelude-packages
|
||||
'(ace-window
|
||||
avy
|
||||
anzu
|
||||
beacon
|
||||
browse-kill-ring
|
||||
crux
|
||||
dash
|
||||
discover-my-major
|
||||
diff-hl
|
||||
diminish
|
||||
easy-kill
|
||||
editorconfig
|
||||
epl
|
||||
expand-region
|
||||
flycheck
|
||||
gist
|
||||
git-timemachine
|
||||
gitconfig-mode
|
||||
gitignore-mode
|
||||
god-mode
|
||||
grizzl
|
||||
guru-mode
|
||||
imenu-anywhere
|
||||
ov
|
||||
projectile
|
||||
magit
|
||||
move-text
|
||||
operate-on-number
|
||||
smart-mode-line
|
||||
smartparens
|
||||
smartrep
|
||||
undo-tree
|
||||
volatile-highlights
|
||||
which-key
|
||||
zenburn-theme
|
||||
zop-to-char)
|
||||
"A list of packages to ensure are installed at launch.")
|
||||
|
||||
(defun prelude-packages-installed-p ()
|
||||
"Check if all packages in `prelude-packages' are installed."
|
||||
(every #'package-installed-p prelude-packages))
|
||||
|
||||
(defun prelude-require-package (package)
|
||||
"Install PACKAGE unless already installed."
|
||||
(unless (memq package prelude-packages)
|
||||
(add-to-list 'prelude-packages package))
|
||||
(unless (package-installed-p package)
|
||||
(package-install package)))
|
||||
|
||||
(defun prelude-require-packages (packages)
|
||||
"Ensure PACKAGES are installed.
|
||||
Missing packages are installed automatically."
|
||||
(mapc #'prelude-require-package packages))
|
||||
|
||||
(define-obsolete-function-alias 'prelude-ensure-module-deps 'prelude-require-packages)
|
||||
|
||||
(defun prelude-install-packages ()
|
||||
"Install all packages listed in `prelude-packages'."
|
||||
(unless (prelude-packages-installed-p)
|
||||
;; check for new packages (package versions)
|
||||
(message "%s" "Emacs Prelude is now refreshing its package database...")
|
||||
(package-refresh-contents)
|
||||
(message "%s" " done.")
|
||||
;; install the missing packages
|
||||
(prelude-require-packages prelude-packages)))
|
||||
|
||||
;; run package installation
|
||||
(prelude-install-packages)
|
||||
|
||||
(defun prelude-list-foreign-packages ()
|
||||
"Browse third-party packages not bundled with Prelude.
|
||||
|
||||
Behaves similarly to `package-list-packages', but shows only the packages that
|
||||
are installed and are not in `prelude-packages'. Useful for
|
||||
removing unwanted packages."
|
||||
(interactive)
|
||||
(package-show-package-list
|
||||
(set-difference package-activated-list prelude-packages)))
|
||||
|
||||
(defmacro prelude-auto-install (extension package mode)
|
||||
"When file with EXTENSION is opened triggers auto-install of PACKAGE.
|
||||
PACKAGE is installed only if not already present. The file is opened in MODE."
|
||||
`(add-to-list 'auto-mode-alist
|
||||
`(,extension . (lambda ()
|
||||
(unless (package-installed-p ',package)
|
||||
(package-install ',package))
|
||||
(,mode)))))
|
||||
|
||||
(defvar prelude-auto-install-alist
|
||||
'(("\\.clj\\'" clojure-mode clojure-mode)
|
||||
("\\.cmake\\'" cmake-mode cmake-mode)
|
||||
("CMakeLists\\.txt\\'" cmake-mode cmake-mode)
|
||||
("\\.coffee\\'" coffee-mode coffee-mode)
|
||||
("\\.css\\'" css-mode css-mode)
|
||||
("\\.csv\\'" csv-mode csv-mode)
|
||||
("Cask" cask-mode cask-mode)
|
||||
("\\.d\\'" d-mode d-mode)
|
||||
("\\.dart\\'" dart-mode dart-mode)
|
||||
("\\.elm\\'" elm-mode elm-mode)
|
||||
("\\.ex\\'" elixir-mode elixir-mode)
|
||||
("\\.exs\\'" elixir-mode elixir-mode)
|
||||
("\\.elixir\\'" elixir-mode elixir-mode)
|
||||
("\\.erl\\'" erlang erlang-mode)
|
||||
("\\.feature\\'" feature-mode feature-mode)
|
||||
("\\.go\\'" go-mode go-mode)
|
||||
("\\.groovy\\'" groovy-mode groovy-mode)
|
||||
("\\.haml\\'" haml-mode haml-mode)
|
||||
("\\.hs\\'" haskell-mode haskell-mode)
|
||||
("\\.json\\'" json-mode json-mode)
|
||||
("\\.kt\\'" kotlin-mode kotlin-mode)
|
||||
("\\.kv\\'" kivy-mode kivy-mode)
|
||||
("\\.latex\\'" auctex LaTeX-mode)
|
||||
("\\.less\\'" less-css-mode less-css-mode)
|
||||
("\\.lua\\'" lua-mode lua-mode)
|
||||
("\\.markdown\\'" markdown-mode markdown-mode)
|
||||
("\\.md\\'" markdown-mode markdown-mode)
|
||||
("\\.ml\\'" tuareg tuareg-mode)
|
||||
("\\.pp\\'" puppet-mode puppet-mode)
|
||||
("\\.php\\'" php-mode php-mode)
|
||||
("\\.proto\\'" protobuf-mode protobuf-mode)
|
||||
("\\.pyd\\'" cython-mode cython-mode)
|
||||
("\\.pyi\\'" cython-mode cython-mode)
|
||||
("\\.pyx\\'" cython-mode cython-mode)
|
||||
("PKGBUILD\\'" pkgbuild-mode pkgbuild-mode)
|
||||
("\\.rs\\'" rust-mode rust-mode)
|
||||
("\\.sass\\'" sass-mode sass-mode)
|
||||
("\\.scala\\'" scala-mode scala-mode)
|
||||
("\\.scss\\'" scss-mode scss-mode)
|
||||
("\\.slim\\'" slim-mode slim-mode)
|
||||
("\\.styl\\'" stylus-mode stylus-mode)
|
||||
("\\.swift\\'" swift-mode swift-mode)
|
||||
("\\.textile\\'" textile-mode textile-mode)
|
||||
("\\.thrift\\'" thrift thrift-mode)
|
||||
("\\.yml\\'" yaml-mode yaml-mode)
|
||||
("\\.yaml\\'" yaml-mode yaml-mode)
|
||||
("Dockerfile\\'" dockerfile-mode dockerfile-mode)))
|
||||
|
||||
;; markdown-mode doesn't have autoloads for the auto-mode-alist
|
||||
;; so we add them manually if it's already installed
|
||||
(when (package-installed-p 'markdown-mode)
|
||||
(add-to-list 'auto-mode-alist '("\\.markdown\\'" . gfm-mode))
|
||||
(add-to-list 'auto-mode-alist '("\\.md\\'" . gfm-mode)))
|
||||
|
||||
(when (package-installed-p 'pkgbuild-mode)
|
||||
(add-to-list 'auto-mode-alist '("PKGBUILD\\'" . pkgbuild-mode)))
|
||||
|
||||
;; build auto-install mappings
|
||||
(mapc
|
||||
(lambda (entry)
|
||||
(let ((extension (car entry))
|
||||
(package (cadr entry))
|
||||
(mode (cadr (cdr entry))))
|
||||
(unless (package-installed-p package)
|
||||
(prelude-auto-install extension package mode))))
|
||||
prelude-auto-install-alist)
|
||||
|
||||
(provide 'prelude-packages)
|
||||
;; Local Variables:
|
||||
;; byte-compile-warnings: (not cl-functions)
|
||||
;; End:
|
||||
|
||||
;;; prelude-packages.el ends here
|
||||
92
emacs/.emacs.d/core/prelude-ui.el
Normal file
92
emacs/.emacs.d/core/prelude-ui.el
Normal file
@@ -0,0 +1,92 @@
|
||||
;;; prelude-ui.el --- Emacs Prelude: UI optimizations and tweaks.
|
||||
;;
|
||||
;; Copyright © 2011-2017 Bozhidar Batsov
|
||||
;;
|
||||
;; Author: Bozhidar Batsov <bozhidar@batsov.com>
|
||||
;; URL: https://github.com/bbatsov/prelude
|
||||
;; Version: 1.0.0
|
||||
;; Keywords: convenience
|
||||
|
||||
;; This file is not part of GNU Emacs.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; We dispense with most of the point and click UI, reduce the startup noise,
|
||||
;; configure smooth scolling and a nice theme that's easy on the eyes (zenburn).
|
||||
|
||||
;;; 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:
|
||||
|
||||
;; the toolbar is just a waste of valuable screen estate
|
||||
;; in a tty tool-bar-mode does not properly auto-load, and is
|
||||
;; already disabled anyway
|
||||
(when (fboundp 'tool-bar-mode)
|
||||
(tool-bar-mode -1))
|
||||
|
||||
(menu-bar-mode -1)
|
||||
|
||||
;; the blinking cursor is nothing, but an annoyance
|
||||
(blink-cursor-mode -1)
|
||||
|
||||
;; disable the annoying bell ring
|
||||
(setq ring-bell-function 'ignore)
|
||||
|
||||
;; disable startup screen
|
||||
(setq inhibit-startup-screen t)
|
||||
|
||||
;; nice scrolling
|
||||
(setq scroll-margin 0
|
||||
scroll-conservatively 100000
|
||||
scroll-preserve-screen-position 1)
|
||||
|
||||
;; mode line settings
|
||||
(line-number-mode t)
|
||||
(column-number-mode t)
|
||||
(size-indication-mode t)
|
||||
|
||||
;; enable y/n answers
|
||||
(fset 'yes-or-no-p 'y-or-n-p)
|
||||
|
||||
;; more useful frame title, that show either a file or a
|
||||
;; buffer name (if the buffer isn't visiting a file)
|
||||
(setq frame-title-format
|
||||
'("" invocation-name " Prelude - " (:eval (if (buffer-file-name)
|
||||
(abbreviate-file-name (buffer-file-name))
|
||||
"%b"))))
|
||||
|
||||
;; use zenburn as the default theme
|
||||
(when prelude-theme
|
||||
(load-theme prelude-theme t))
|
||||
|
||||
(require 'smart-mode-line)
|
||||
(setq sml/no-confirm-load-theme t)
|
||||
;; delegate theming to the currently active theme
|
||||
(setq sml/theme nil)
|
||||
(add-hook 'after-init-hook #'sml/setup)
|
||||
|
||||
;; show the cursor when moving after big movements in the window
|
||||
(require 'beacon)
|
||||
(beacon-mode +1)
|
||||
|
||||
;; show available keybindings after you start typing
|
||||
(require 'which-key)
|
||||
(which-key-mode +1)
|
||||
|
||||
(provide 'prelude-ui)
|
||||
;;; prelude-ui.el ends here
|
||||
Reference in New Issue
Block a user