Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
chalmagean committed Apr 6, 2015
1 parent 527de47 commit 7d6a2ca
Show file tree
Hide file tree
Showing 8 changed files with 189 additions and 10,509 deletions.
206 changes: 73 additions & 133 deletions init.el

Large diffs are not rendered by default.

14 changes: 10 additions & 4 deletions my-dired.el
@@ -1,6 +1,7 @@
;; I want this for dired-jump
(require 'dired-x)

;; I usually want to see just the file names
(require 'dired-details)
(dired-details-install)

Expand All @@ -19,7 +20,7 @@
(setq dired-omit-files "^\\..*$\\|^\\.\\.$")
(setq dired-omit-mode t)


;; List directories first
(defun sof/dired-sort ()
"Dired sort hook to list directories first."
(save-excursion
Expand All @@ -33,6 +34,14 @@

(add-hook 'dired-after-readin-hook 'sof/dired-sort)

;; Automatically create missing directories when creating new files
(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)

;; Use ls from emacs
(when (eq system-type 'darwin)
(require 'ls-lisp)
Expand All @@ -56,9 +65,6 @@
(define-key dired-mode-map
(vector 'remap 'end-of-buffer) 'dired-jump-to-bottom)

;; Move files between split panes
(setq dired-dwim-target t)

;; C-a is nicer in dired if it moves back to start of files
(defun dired-back-to-start-of-files ()
(interactive)
Expand Down
59 changes: 54 additions & 5 deletions my-functions.el
@@ -1,9 +1,58 @@
(defun isearch-exit-other-end (rbeg rend)
"Exit isearch, but at the other end of the search string.
This is useful when followed by an immediate kill."
(defun my-goto-match-beginning ()
(when (and isearch-forward isearch-other-end)
(goto-char isearch-other-end)))
(add-hook 'isearch-mode-end-hook 'my-goto-match-beginning)
(defadvice isearch-exit (after my-goto-match-beginning activate)
"Go to beginning of match."
(when (and isearch-forward isearch-other-end)
(goto-char isearch-other-end)))

;; Search back/forth for the symbol at point
;; See http://www.emacswiki.org/emacs/SearchAtPoint
(defun isearch-yank-symbol ()
"*Put symbol at current point into search string."
(interactive)
(let ((sym (symbol-at-point)))
(if sym
(progn
(setq isearch-regexp t
isearch-string (concat "\\_<" (regexp-quote (symbol-name sym)) "\\_>")
isearch-message (mapconcat 'isearch-text-char-description isearch-string "")
isearch-yank-flag t))
(ding)))
(isearch-search-and-update))

(define-key isearch-mode-map "\C-w" 'isearch-yank-symbol)

;; http://www.emacswiki.org/emacs/ZapToISearch
(defun zap-to-isearch (rbeg rend)
"Kill the region between the mark and the closest portion of
the isearch match string. The behaviour is meant to be analogous
to zap-to-char; let's call it zap-to-isearch. The deleted region
does not include the isearch word. This is meant to be bound only
in isearch mode. The point of this function is that oftentimes
you want to delete some portion of text, one end of which happens
to be an active isearch word. The observation to make is that if
you use isearch a lot to move the cursor around (as you should,
it is much more efficient than using the arrows), it happens a
lot that you could just delete the active region between the mark
and the point, not include the isearch word."
(interactive "r")
(isearch-exit)
(goto-char isearch-other-end))
(when (not mark-active)
(error "Mark is not active"))
(let* ((isearch-bounds (list isearch-other-end (point)))
(ismin (apply 'min isearch-bounds))
(ismax (apply 'max isearch-bounds))
)
(if (< (mark) ismin)
(kill-region (mark) ismin)
(if (> (mark) ismax)
(kill-region ismax (mark))
(error "Internal error in isearch kill function.")))
(isearch-exit)
))

(define-key isearch-mode-map [(meta z)] 'zap-to-isearch)

(defun find-tag-at-point ()
"Runs find-tag with the word at point as the argument"
Expand Down
22 changes: 12 additions & 10 deletions my-ido.el
@@ -1,21 +1,23 @@
;; Ido
(require 'ido) ;; loading a newer version which fixes flex matching
(require 'ido-vertical-mode)
(require 'ido)
(ido-mode 1)

;; Display results vertically
(require 'ido-vertical-mode)
(ido-vertical-mode)

(setq ido-enable-prefix nil
ido-enable-flex-matching t
ido-case-fold nil
ido-auto-merge-work-directories-length -1
ido-create-new-buffer 'always
ido-use-filename-at-point nil
ido-max-prospects 10)

;; disable ido faces to see flx highlights.
(setq ido-use-faces nil)
ido-case-fold t ;; ignore case
ido-auto-merge-work-directories-length -1 ;; disable auto-merge (it's confusing)
ido-create-new-buffer 'always ;; create new files easily
ido-use-filename-at-point nil ;; don't try to be smart about what I want
)

;; I like visual matching (colors)
(setq ido-use-faces t)

;; Ido buffer intuitive navigation
(add-hook 'ido-setup-hook '(lambda ()
(define-key ido-completion-map "\C-h" 'ido-delete-backward-updir)
(define-key ido-completion-map "\C-n" 'ido-next-match)
Expand Down
16 changes: 2 additions & 14 deletions my-magit.el
Expand Up @@ -4,22 +4,10 @@
(set-face-foreground 'diff-context "#666666")
(set-face-foreground 'diff-added "#00cc33")
(set-face-foreground 'diff-removed "#ff0000")
(setq magit-server-window-for-commit nil)
(setq magit-emacsclient-executable "/usr/local/bin/emacsclient")

;; Enable a right limit of 70 chars for git logs
(add-hook 'magit-log-edit-mode-hook 'turn-on-auto-fill)

;; full screen magit-status
(defadvice magit-status (around magit-fullscreen activate)
(window-configuration-to-register :magit-fullscreen)
ad-do-it
(delete-other-windows))

(defun magit-quit-session ()
"Restores the previous window configuration and kills the magit buffer"
(interactive)
(kill-buffer)
(jump-to-register :magit-fullscreen))

(define-key magit-status-mode-map (kbd "q") 'magit-quit-session)

(provide 'my-magit)
73 changes: 38 additions & 35 deletions my-ruby.el
@@ -1,3 +1,4 @@
;; Files with the following extensions should open in ruby-mode
(add-to-list 'auto-mode-alist '("\\.rb$" . ruby-mode))
(add-to-list 'auto-mode-alist '("\\.rake$" . ruby-mode))
(add-to-list 'auto-mode-alist '("Rakefile$" . ruby-mode))
Expand All @@ -7,63 +8,65 @@

(require 'ruby-mode)
(require 'inf-ruby)
(setq ruby-deep-indent-paren nil)

;; When folding, take these delimiters into consideration
(add-to-list 'hs-special-modes-alist
'(ruby-mode
"\\(class\\|def\\|do\\|if\\)" "\\(end\\)" "#"
(lambda (arg) (ruby-end-of-block)) nil))

;; RVM support
(require 'rvm)
(rvm-use-default)

;; Cucumber
(require 'feature-mode)
(setq feature-use-rvm t) ;; Tell cucumber to use RVM
(setq feature-cucumber-command "cucumber {options} {feature}")
;; .feature files should open in feature-mode
(add-to-list 'auto-mode-alist '("\.feature$" . feature-mode))

;; Rspec
(require 'rspec-mode)
;; I want rspec instead of rake spec
(setq rspec-use-rake-when-possible nil)
;; Scroll to the first test failure
(setq compilation-scroll-output 'first-error)

;; Projectile mode
(require 'projectile)
(projectile-global-mode)
(setq projectile-completion-system 'grizzl)
(require 'persp-projectile)
(persp-mode)
(define-key projectile-mode-map (kbd "s-s") 'projectile-persp-switch-project)
(helm-projectile-on)

;; Populate the `magit-repo-dirs` variable with the .git projects you
;; visited so that when you hit C-u M-x git-status you can choose to
;; open one of those repos
(eval-after-load "projectile"
'(progn (setq magit-repo-dirs (mapcar (lambda (dir)
(substring dir 0 -1))
(remove-if-not (lambda (project)
(file-directory-p (concat project "/.git/")))
(projectile-relevant-known-projects)))

magit-repo-dirs-depth 1)))

(require 'robe)

(defadvice inf-ruby-console-auto (before activate-rvm-for-robe activate)
(rvm-activate-corresponding-ruby))

;; Make _ parts of the "word"
(modify-syntax-entry ?_ "w" ruby-mode-syntax-table)
;; Prevent emacs from adding the encoding line at the top of the file
(setq ruby-insert-encoding-magic-comment nil)

;; Functions to help with refactoring
(require 'ruby-refactor)
(add-hook 'ruby-mode-hook 'ruby-refactor-mode-launch)
;; Easily toggle ruby's hash syntax
(require 'ruby-hash-syntax)
;; Ruby rdoc helpers mostly
(require 'ruby-additional)
(require 'ruby-block)
(ruby-block-mode t)
;; Helpers to deal with strings and symbols
(require 'ruby-tools)
;; Support for YARD
(require 'yard-mode)
(add-hook 'ruby-mode-hook 'yard-mode)
;; Support for running rspec tests
(require 'rspec-mode)
(require 'eldoc)
(require 'rubocop)

;; Bind YARI to C-h R
(require 'yari)
(define-key 'help-command "R" 'yari)

;; Turn on eldoc in ruby files to display info about the
;; method or variable at point
(add-hook 'ruby-mode-hook 'eldoc-mode)
;; Switch the compilation buffer mode with C-x C-q (useful
;; when interacting with a debugger)
(add-hook 'after-init-hook 'inf-ruby-switch-setup)
(add-hook 'ruby-mode-hook 'yard-mode)
(add-hook 'ruby-mode-hook 'ruby-refactor-mode-launch)
(add-hook 'ruby-mode-hook 'robe-mode)

(add-hook 'ruby-mode-hook
(lambda ()
(hs-minor-mode 1) ;; Enables folding
(modify-syntax-entry ?: "."))) ;; Adds ":" to the word definition

;; Start projectile-rails
(add-hook 'projectile-mode-hook 'projectile-rails-on)

0 comments on commit 7d6a2ca

Please sign in to comment.