Skip to content

Commit

Permalink
Better config layout
Browse files Browse the repository at this point in the history
Greatly inspired by Bodil's amazing ohai-emacs
  • Loading branch information
julienXX committed Mar 29, 2015
1 parent 010e0e3 commit 2090e53
Show file tree
Hide file tree
Showing 18 changed files with 765 additions and 255 deletions.
42 changes: 0 additions & 42 deletions custom/haskell.el

This file was deleted.

59 changes: 15 additions & 44 deletions init.el
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,6 @@

(setq make-backup-files nil)
(setq auto-save-default nil)
(setq-default tab-width 2)
(setq-default indent-tabs-mode nil)
(setq inhibit-startup-message t)

(fset 'yes-or-no-p 'y-or-n-p)

(delete-selection-mode t)
(scroll-bar-mode -1)
(tool-bar-mode -1)
(blink-cursor-mode t)
(show-paren-mode t)
(column-number-mode t)
(set-fringe-style -1)
(tooltip-mode -1)
(setq ring-bell-function (lambda () (message "*beep*")))

;; initial frame size
(add-to-list 'default-frame-alist '(left . 0))
(add-to-list 'default-frame-alist '(top . 0))
(add-to-list 'default-frame-alist '(height . 40))
(add-to-list 'default-frame-alist '(width . 130))

;; Free up the option key for special characters
(setq ns-alternate-modifier 'none)
Expand All @@ -38,12 +17,6 @@
(setq auto-save-file-name-transforms
`((".*" ,temporary-file-directory t)))

;; aesthetics
(setq ns-use-srgb-colorspace t)
(set-default-font
"-*-Source Code Pro-normal-normal-normal-*-14-*-*-*-m-0-iso10646-1")
(setq linum-format " %3d ")

;; stop opening a new frame (window) for each file
(setq ns-pop-up-frames nil)

Expand All @@ -63,17 +36,11 @@
(setq auto-revert-verbose nil)

;; load customizations
(add-to-list 'load-path "~/.emacs.d/custom")
(add-to-list 'load-path "~/.emacs.d/modules")
(add-to-list 'load-path (expand-file-name "~/.emacs.d/vendor"))

(add-to-list 'custom-theme-load-path "~/.emacs.d/themes/")

;; Set Frame title with file path
(setq frame-title-format
'((:eval (if (buffer-file-name)
(abbreviate-file-name (buffer-file-name))
"%b"))))

;; Add external projects to load path
(dolist (project (directory-files "~/.emacs.d/vendor" t "\\w+"))
(when (file-directory-p project)
Expand All @@ -84,16 +51,20 @@
(require 'pallet)
(pallet-mode t)

(load "packages")
(load "functions")
(load "modes")
(load "haskell")
(load "hooks")
(load "mappings")
(load "orgmode")
(load "mode-line")

(eval-after-load 'magit '(require 'setup-magit))
(load "jxx-libs")
(load "jxx-editing")
(load "jxx-appearance")
(load "jxx-packages")
(load "jxx-functions")
(load "jxx-modes")
(load "jxx-mappings")
(load "jxx-hooks")
(load "jxx-ruby")
(load "jxx-haskell")
(load "jxx-orgmode")
(load "jxx-mode-line")

(eval-after-load 'magit '(require 'jxx-magit))

;; Shell variables on OSX
(when (memq window-system '(mac ns))
Expand Down
60 changes: 60 additions & 0 deletions modules/jxx-appearance.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
;;; -*- lexical-binding: t -*-
;;; jxx-appearance.el --- Emacs look

;; Copyright (C) 2015 Julien Blanchard

;; Author: Julien Blanchard <julien@sideburns.eu>

;; 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:

;;; Code:

(setq-default tab-width 2)
(setq-default indent-tabs-mode nil)
(setq inhibit-startup-message t)

(fset 'yes-or-no-p 'y-or-n-p)

(delete-selection-mode t)
(scroll-bar-mode -1)
(tool-bar-mode -1)
(blink-cursor-mode t)
(show-paren-mode t)
(column-number-mode t)
(set-fringe-style -1)
(tooltip-mode -1)
(setq ring-bell-function (lambda () (message "*beep*")))

;; initial frame size
(add-to-list 'default-frame-alist '(left . 0))
(add-to-list 'default-frame-alist '(top . 0))
(add-to-list 'default-frame-alist '(height . 40))
(add-to-list 'default-frame-alist '(width . 130))

(setq ns-use-srgb-colorspace t)
(set-default-font
"-*-Source Code Pro-normal-normal-normal-*-14-*-*-*-m-0-iso10646-1")
(setq linum-format " %3d ")

;; Set Frame title with file path
(setq frame-title-format
'((:eval (if (buffer-file-name)
(abbreviate-file-name (buffer-file-name))
"%b"))))


(provide 'jxx-appearance)
;;; jxx-appearance.el ends here
133 changes: 51 additions & 82 deletions custom/functions.el → modules/jxx-editing.el
Original file line number Diff line number Diff line change
@@ -1,6 +1,52 @@
(defun switch-to-previous-buffer ()
(interactive)
(switch-to-buffer (other-buffer (current-buffer) 1)))
;;; -*- lexical-binding: t -*-
;;; jxx-editing.el --- Editing functions

;; Copyright (C) 2015 Julien Blanchard

;; Author: Julien Blanchard <julien@sideburns.eu>

;; 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:

;;; Code:

;;; multiple-cursors
(require 'multiple-cursors)
(global-set-key (kbd "C-S-c C-S-c") 'mc/edit-lines)
(global-set-key (kbd "C->") 'mc/mark-next-like-this)
(global-set-key (kbd "C-<") 'mc/mark-previous-like-this)
(global-set-key (kbd "C-c C-<") 'mc/mark-all-like-this)

;; Save point position between sessions
(require 'saveplace)
(setq-default save-place t)
(setq save-place-file (expand-file-name ".places" user-emacs-directory))

;; Expand region
(require 'expand-region)
(global-set-key (kbd "C-=") 'er/expand-region)

;; Wrap region
(require 'wrap-region)
(wrap-region-global-mode)

;; Hit C-c <tab> to auto-indent the entire buffer you're in.
(defun indent-buffer ()
(interactive)
(indent-region (point-min) (point-max)))
(global-set-key (kbd "C-c <tab>") 'indent-buffer)

(defun duplicate-line (arg)
"Duplicate current line, leaving point in lower line."
Expand Down Expand Up @@ -94,25 +140,6 @@ Ignores CHAR at point."
(backward-char direction))
(point)))))

(defun ruby-open-spec-other-buffer ()
(interactive)
(when (featurep 'rspec-mode)
(let ((source-buffer (current-buffer))
(other-buffer (progn
(rspec-toggle-spec-and-target)
(current-buffer))))
(switch-to-buffer source-buffer)
(pop-to-buffer other-buffer))))

(defun revert-all-buffers ()
"Refreshes all open buffers from their respective files."
(interactive)
(dolist (buf (buffer-list))
(with-current-buffer buf
(when (and (buffer-file-name) (not (buffer-modified-p)))
(revert-buffer t t t) )))
(message "Refreshed open files.") )

(defun move-line-down ()
(interactive)
(let ((col (current-column)))
Expand Down Expand Up @@ -155,64 +182,6 @@ Ignores CHAR at point."
(set-window-start w2 s1)
(setq i (1+ i)))))))

(defun jxx-markdown-preview ()
(interactive)
(save-buffer)
(call-process "open" nil nil nil "-a" "Marked.app" (buffer-file-name)))

(defun jxx-show-ruby-tags ()
(interactive)
(occur "^\\s-*\\\(class \\\|module \\\|def \\\|[^:]include \\\|private\\b\\\|protected\\b\\\)"))

(define-key ruby-mode-map (kbd "C-c t") 'jxx-show-ruby-tags)

(defun rename-file-and-buffer ()
"Rename the current buffer and file it is visiting."
(interactive)
(let ((filename (buffer-file-name)))
(if (not (and filename (file-exists-p filename)))
(message "Buffer is not visiting a file!")
(let ((new-name (read-file-name "New name: " filename)))
(cond
((vc-backend filename) (vc-rename-file filename new-name))
(t
(rename-file filename new-name t)
(set-visited-file-name new-name t t)))))))

(global-set-key (kbd "C-c r") 'rename-file-and-buffer)

(defun delete-file-and-buffer ()
"Kill the current buffer and deletes the file it is visiting."
(interactive)
(let ((filename (buffer-file-name)))
(when filename
(if (vc-backend filename)
(vc-delete-file filename)
(progn
(delete-file filename)
(message "Deleted file %s" filename)
(kill-buffer))))))

(define-key isearch-mode-map (kbd "C-d")
'fc/isearch-yank-symbol)
(defun fc/isearch-yank-symbol ()
"Yank the symbol at point into the isearch minibuffer.
C-w does something similar in isearch, but it only looks for
the rest of the word. I want to look for the whole string. And
symbol, not word, as I need this for programming the most."
(interactive)
(isearch-yank-string
(save-excursion
(when (and (not isearch-forward)
isearch-other-end)
(goto-char isearch-other-end))
(thing-at-point 'symbol))))

(defun my-create-non-existent-directory ()
(let ((parent-directory (file-name-directory buffer-file-name)))
(when (and (not (file-exists-p parent-directory))
(y-or-n-p (format "Directory `%s' does not exist! Create it?" parent-directory)))
(make-directory parent-directory t))))

(add-to-list 'find-file-not-found-functions #'my-create-non-existent-directory)
(provide 'jxx-editing)
;;; jxx-editing.el ends here
Loading

0 comments on commit 2090e53

Please sign in to comment.