Updated emacs-d and added Remtrail command to vimrc

This commit is contained in:
hellerve
2015-06-15 16:10:45 +02:00
parent d6da2b169d
commit 23636108a1
64 changed files with 3571 additions and 21 deletions

91
.emacs.d/ohai/ohai-lib.el Normal file
View File

@@ -0,0 +1,91 @@
;;; -*- lexical-binding: t -*-
;;; ohai-lib.el --- Utility functions for use elsewhere.
;; Copyright (C) 2015 Bodil Stokke
;; Author: Bodil Stokke <bodil@bodil.org>
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;;; Code:
(require 'ohai-package)
;; Ensure the New Standard Library is installed and always available.
;; f.el - files and paths https://github.com/rejeep/f.el
;; s.el - strings https://github.com/magnars/s.el
;; dash.el - lists https://github.com/magnars/dash.el
(package-require 'f)
(require 'f)
(package-require 's)
(require 's)
(package-require 'dash)
(require 'dash)
(defun ohai/font-lock-replace-symbol (mode reg sym)
"Given a major mode `mode', replace the regular expression `reg' with
the symbol `sym' when rendering."
(font-lock-add-keywords
mode `((,reg
(0 (progn (compose-region (match-beginning 1) (match-end 1)
,sym 'decompose-region)))))))
(defun ohai/exec (command)
"Run a shell command and return its output as a string, whitespace trimmed."
(s-trim (shell-command-to-string command)))
(defun ohai/is-exec (command)
"Returns true if `command' is an executable on the system search path."
(f-executable? (s-trim (shell-command-to-string (s-concat "which " command)))))
(defun ohai/resolve-exec (command)
"If `command' is an executable on the system search path, return its absolute path.
Otherwise, return nil."
(-let [path (s-trim (shell-command-to-string (s-concat "which " command)))]
(when (f-executable? path) path)))
(defun ohai/exec-if-exec (command args)
"If `command' satisfies `ohai/is-exec', run it with `args' and return its
output as per `ohai/exec'. Otherwise, return nil."
(when (ohai/is-exec command) (ohai/exec (s-concat command " " args))))
(defun ohai/getent (user)
"Get the /etc/passwd entry for the user `user' as a list of strings,
or nil if there is no such user. Empty fields will be represented as nil,
as opposed to empty strings."
(-let [ent (ohai/exec (s-concat "getent passwd " user))]
(when (not (s-blank? ent))
(-map (lambda (i) (if (s-blank? i) nil i))
(s-split ":" ent)))))
(defun ohai/user-full-name ()
"Guess the user's full name. Returns nil if no likely name could be found."
(or (ohai/exec-if-exec "git" "config --get user.name")
(elt (ohai/getent (getenv "USER")) 4)))
(defun ohai/user-email ()
"Guess the user's email address. Returns nil if none could be found."
(or (ohai/exec-if-exec "git" "config --get user.email")
(getenv "EMAIL")))
(provide 'ohai-lib)
;;; ohai-lib.el ends here

View File

@@ -0,0 +1,66 @@
;;; -*- lexical-binding: t -*-
;;; ohai-module-index.el --- The index of available Ohai Emacs modules.
;; Copyright (C) 2015 Bodil Stokke
;; Author: Bodil Stokke <bodil@bodil.org>
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;;; Code:
(setq
ohai/available-modules
'((ohai-appearance "how Emacs looks" :recommended)
(ohai-fonts "adjust font size on the fly" :recommended)
(ohai-general "basic editor settings" :recommended)
(ohai-splash "enhance your scratch buffer" :recommended)
(ohai-ido "improved file selector etc" :recommended)
(ohai-navigation "moving around better" :recommended)
(ohai-editing "editing improvements (multiple cursors etc)" :recommended)
(ohai-complete "auto completion" :recommended)
(ohai-snippets "snippet management" :recommended)
(ohai-codestyle "code formatting, whitespace management" :recommended)
(ohai-dired "enhanced file manager" :recommended)
(ohai-project "manage projects with Projectile" :recommended)
(ohai-flycheck "run linters automatically with Flycheck" :recommended)
(ohai-git "Git tools" :recommended)
(ohai-orgmode "your personal everything manager" :recommended)
(ohai-swiper "improved incremental search" :recommended)
(ohai-help "ways to get more help" :recommended)
(ohai-elisp "Emacs Lisp" :recommended)
(ohai-helm "advanced selection and narrowing" :optional)
(ohai-html "HTML, CSS and friends" :optional)
(ohai-markdown "Markdown support" :optional)
(ohai-javascript "JavaScript language support" :optional)
(ohai-purescript "PureScript language support" :optional)
(ohai-clojure "Clojure language support" :optional)
(ohai-erlang "Erlang language support" :optional)
(ohai-elixir "Elixir language support" :optional)
(ohai-haskell "Haskell language support" :optional)))
(require 'cl)
(defcustom ohai/modules (mapcar #'car
(remove-if-not
(lambda (i) (equal :recommended (caddr i)))
ohai/available-modules))
"Your choice of Ohai Emacs modules.")
(defun ohai/load-modules ()
(interactive)
(dolist (module ohai/modules) (require module))
(run-hooks 'ohai/modules-loaded-hook))
(provide 'ohai-module-index)
;;; ohai-module-index.el ends here

View File

@@ -0,0 +1,95 @@
;;; -*- lexical-binding: t -*-
;;; ohai-module-selector.el --- Interface for choosing Ohai Emacs modules.
;; Copyright (C) 2015 Bodil Stokke
;; Author: Bodil Stokke <bodil@bodil.org>
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;;; Code:
(require 'ohai-lib)
(require 'widget)
(require 'cus-edit)
(defun ohai/select-modules ()
"Select the modules Ohai Emacs should load on startup."
(interactive)
(switch-to-buffer "*Ohai Emacs Modules*")
(kill-all-local-variables)
(-let [inhibit-read-only t] (erase-buffer))
(remove-overlays)
(setq-local selected-modules ohai/modules)
(-let ((save-settings
(lambda (&rest ignore)
(interactive)
(customize-save-variable 'ohai/modules selected-modules)
(package-refresh-contents)
(ohai/load-modules)
(kill-buffer))))
(widget-insert (propertize "Ohai Emacs Modules" 'face 'custom-group-tag))
(widget-insert "\n")
(widget-insert "
This menu allows you to select feature modules for your Ohai Emacs.
Navigate between checkboxes using <tab> and S-<tab>, or use the cursor
keys to move around. Hit <return> to toggle checkboxes, or to press the
buttons. When you're done, press the `Save' or `Cancel' buttons, or just
save the buffer (C-x C-s).
You can also use your mouse, but you must resist the urge to do this.
An Emacs Master does not use mice.
")
(widget-insert "\n ")
(widget-create 'push-button
:tag "Save"
:notify save-settings)
(widget-insert " ")
(widget-create 'push-button :tag "Cancel"
:notify (lambda (&rest ignore) (kill-buffer)))
(widget-insert "\n\n ")
(apply 'widget-create 'checklist
:indent 2
:greedy t
:value selected-modules
:notify (lambda (this &rest ignore)
(setq-local selected-modules (widget-value this)))
(-map (lambda (mod)
(-let [(sym desc) mod]
`(item :tag ,(s-concat (s-pad-right 24 " " (symbol-name sym)))
:doc ,desc
:value ,sym
:format "%t %d")))
ohai/available-modules))
(widget-insert "\n")
(use-local-map (copy-keymap widget-keymap))
(local-set-key (kbd "C-x C-s") save-settings)
(widget-setup)
(widget-forward 1)))
(provide 'ohai-module-selector)
;;; ohai-module-selector.el ends here

View File

@@ -0,0 +1,65 @@
;;; -*- lexical-binding: t -*-
;;; ohai-package.el --- Package system configuration.
;; Copyright (C) 2015 Bodil Stokke
;; Author: Bodil Stokke <bodil@bodil.org>
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;;; Code:
;; `(online?)` is a function that tries to detect whether you are online.
;; We want to refresh our package list on Emacs start if we are.
(require 'cl)
(defun online? ()
(if (and (functionp 'network-interface-list)
(network-interface-list))
(some (lambda (iface) (unless (equal "lo" (car iface))
(member 'up (first (last (network-interface-info
(car iface)))))))
(network-interface-list))
t))
;; Emacs comes with a package manager for installing more features.
;; The default package repository doesn't contain much, so we tell it
;; to use a few more: MELPA and Marmalade.
(setq package-user-dir (concat dotfiles-dir "elpa"))
(require 'package)
(dolist (source '(("melpa" . "http://melpa.org/packages/")
("marmalade" . "http://marmalade-repo.org/packages/")))
(add-to-list 'package-archives source t))
;; To get the package manager going, we invoke its initialise function.
(package-initialize)
;; If we're online, we attempt to fetch the package directories if
;; we don't have a local copy already. This lets us start installing
;; packages right away from a clean install.
(when (online?)
(unless package-archive-contents (package-refresh-contents)))
;; We're going to try to declare the packages each feature needs as we
;; define it. To do this, we define a function `(package-require)`
;; which will fetch and install a package from the repositories if it
;; isn't already installed. Eg. to ensure the hypothetical package
;; `ponies` is installed, you'd call `(package-require 'ponies)`.
(defun package-require (pkg)
"Install a package only if it's not already installed."
(when (not (package-installed-p pkg))
(package-install pkg)))
(provide 'ohai-package)

View File

@@ -0,0 +1,68 @@
;;; -*- lexical-binding: t -*-
;;; ohai-personal-taste.el --- Ohai Emacs preferences.
;; Copyright (C) 2015 Bodil Stokke
;; Author: Bodil Stokke <bodil@bodil.org>
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;;; Code:
(defgroup ohai-emacs nil
"Your personal taste in Ohai Emacs."
:prefix "ohai-personal-taste/")
(defcustom ohai-personal-taste/run-wizard t
"Should we run the Ohai Emacs startup wizard on the next startup?"
:group 'ohai-emacs
:type '(choice (const :tag "Yes" t)
(const :tag "No" nil)))
(defcustom ohai-personal-taste/window-state 'normal
"Should Emacs maximise its frame on startup, or leave it alone?"
:group 'ohai-emacs
:type '(choice (const :tag "Normal" normal)
(const :tag "Maximise" maximised)))
(defcustom ohai-personal-taste/style 'light
"Light or dark colour scheme?"
:group 'ohai-emacs
:type '(choice (const :tag "Light" light)
(const :tag "Dark" dark)))
(defcustom ohai-personal-taste/splash nil
"What sort of image to load into the initial scratch buffer."
:group 'ohai-emacs
:type '(choice (const :tag "Emergency Puppy" emergency-puppy)
(const :tag "Daily Otter" daily-otter)
(const :tag "Nothing" nil)))
(defcustom ohai-personal-taste/paredit nil
"Do you want Paredit in Emacs Lisp buffers?"
:group 'ohai-emacs
:type '(choice (const :tag "Yes, please" t)
(const :tag "I'm not ready for that" nil)))
(defcustom ohai-personal-taste/training-wheels nil
"Would you prefer an Emacs experience without the clutter of the menu bar,
toolbar and scrollbar?"
:group 'ohai-emacs
:type '(choice (const :tag "Yes, please" t)
(const :tag "I'm not ready for that" nil)))
(provide 'ohai-personal-taste)
;;; ohai-personal-taste.el ends here

View File

@@ -0,0 +1,119 @@
;;; -*- lexical-binding: t -*-
;;; ohai-startup-wizard.el --- Ask questions and configure on first run.
;; Copyright (C) 2015 Bodil Stokke
;; Author: Bodil Stokke <bodil@bodil.org>
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;;; Code:
(require 'ohai-personal-taste)
(defun ohai-startup-wizard/get-window-state ()
(x-popup-dialog
t '("Normal or maximised window?"
("Normal" . normal)
("Maximised" . maximised))))
(defun ohai-startup-wizard/get-style ()
(x-popup-dialog
t '("Light or dark background?"
("Light" . light)
("Dark" . dark))))
(defun ohai-startup-wizard/get-splash ()
(x-popup-dialog
t '("What is your favourite animal?
We will put it on your splash screen for you, a fresh picture
every day, because your Emacs loves you.
This won't work if you're running Emacs in a terminal. Sorry.
Don't do that unless you really have to."
("Puppies" . emergency-puppy)
("The noble otter" . daily-otter)
("I hate animals" . nil))))
(defun ohai-startup-wizard/get-paredit ()
(x-popup-dialog
t '("Do you want to enable Paredit style editing for
the Emacs Lisp mode?
This will add a slight learning curve to your Elisp
journey, but trust me, it will be worth it."
("OK, let's paredit" . t)
("Not right now" . nil))))
(defun ohai-startup-wizard/get-training-wheels ()
(x-popup-dialog
t '("Would you like to get rid of the toolbar,
menu bar and scrollbar?
This is how adult emacsen roll, but you
might want to get comfortable with being
emacs before you assume your final form.
This is OK too; no pressure yet."
("I'm ready" . nil)
("Wait, I'm scared" . t))))
(defun ohai-startup-wizard ()
(interactive)
(x-popup-dialog
t '("Welcome to the Church of Emacs, my child!
This is the first time you've run it, so let's
start off by asking you some basic questions
about how you like to emacs.
If you change your mind about any of these
decisions, you can re-run this wizard with
`M-x ohai-startup-wizard` (that is Alt+X
ohai-startup-wizard <enter> to non-native
speakers)."
("I am ready to emacs" . t)) t)
(customize-save-variable
'ohai-personal-taste/window-state
(ohai-startup-wizard/get-window-state))
(customize-save-variable
'ohai-personal-taste/style
(ohai-startup-wizard/get-style))
(customize-save-variable
'ohai-personal-taste/splash
(ohai-startup-wizard/get-splash))
(customize-save-variable
'ohai-personal-taste/paredit
(ohai-startup-wizard/get-paredit))
(customize-save-variable
'ohai-personal-taste/training-wheels
(ohai-startup-wizard/get-training-wheels))
(customize-save-variable 'ohai-personal-taste/run-wizard nil)
(setq ohai/wizard-did-run t)
(ohai/select-modules))
(when ohai-personal-taste/run-wizard
(ohai-startup-wizard))
(provide 'ohai-startup-wizard)

View File

@@ -0,0 +1,35 @@
;;; -*- lexical-binding: t -*-
;;; ohai-test.el --- Test environment for ohai-emacs.
;; Copyright (C) 2015 Bodil Stokke
;; Author: Bodil Stokke <bodil@bodil.org>
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;;; Code:
;; Should be run from the repo with HOME=`pwd`.
(load-file "$HOME/ohai/ohai-module-index.el")
(setq ohai-personal-taste/paredit t
ohai-personal-taste/run-wizard nil
ohai/modules (mapcar #'car ohai/available-modules))
(load-file "$HOME/init.el")
(kill-emacs 0)
;;; ohai-test.el ends here

View File

@@ -0,0 +1,37 @@
;;; -*- lexical-binding: t -*-
;;; ohai-update.el --- Update your ohai-emacs installation.
;; Copyright (C) 2015 Bodil Stokke
;; Author: Bodil Stokke <bodil@bodil.org>
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
;; Hello world!
;;; Code:
(defun ohai/update ()
(interactive)
(let ((default-directory dotfiles-dir)
(buf (get-buffer-create "*ohai-emacs update*")))
(switch-to-buffer-other-window buf)
(shell-command "git pull --ff-only --stat" buf)
(end-of-buffer)
(insert "\nRun `M-x ohai/select-modules' to review and install new modules.\n")
(local-set-key (kbd "q") 'quit-window)))
(provide 'ohai-update)
;;; ohai-update.el ends here