Permalink
Browse files

Major additions to beef up Emacs and JavaScript editing abilities. Do…

…cumented most modes added in emacs.el, yasnippet still needs some work to get strapped and loaded and not interfer with auto-complete-mode. There's additional tweaking needed in this respect.
  • Loading branch information...
jweaver committed Aug 26, 2012
1 parent 791a292 commit e7475f85f73ae1c72317fb644c073f3024c84fdf
Showing with 131 additions and 0 deletions.
  1. +21 −0 .gitmodules
  2. +1 −0 auto-complete
  3. +1 −0 emacs-flymake-cursor
  4. +103 −0 emacs.el
  5. +1 −0 fuzzy-el
  6. +1 −0 js-comint
  7. +1 −0 lintnode
  8. +1 −0 popup-el
  9. +1 −0 yasnippet
View
@@ -19,3 +19,24 @@
[submodule "emacs-jabber"]
path = emacs-jabber
url = git://emacs-jabber.git.sourceforge.net/gitroot/emacs-jabber/emacs-jabber
+[submodule "auto-complete"]
+ path = auto-complete
+ url = git://github.com/m2ym/auto-complete.git
+[submodule "yasnippet"]
+ path = yasnippet
+ url = git://github.com/capitaomorte/yasnippet.git
+[submodule "lintnode"]
+ path = lintnode
+ url = git://github.com/davidmiller/lintnode.git
+[submodule "emacs-flymake-cursor"]
+ path = emacs-flymake-cursor
+ url = https://github.com/illusori/emacs-flymake-cursor
+[submodule "js-comint"]
+ path = js-comint
+ url = git://github.com/emacsmirror/js-comint.git
+[submodule "popup-el"]
+ path = popup-el
+ url = git://github.com/m2ym/popup-el.git
+[submodule "fuzzy-el"]
+ path = fuzzy-el
+ url = git://github.com/m2ym/fuzzy-el.git
Submodule auto-complete added at 40ceea
Submodule emacs-flymake-cursor added at 5cac50
View
103 emacs.el
@@ -62,6 +62,14 @@ This one changes the cursor color on each blink. Define colors in `blink-cursor-
(add-to-list 'load-path (construct-path (file-name-directory (or (buffer-file-name) load-file-name)) "ace-jump-mode"))
(add-to-list 'load-path (construct-path (file-name-directory (or (buffer-file-name) load-file-name)) "Mew"))
(add-to-list 'load-path (construct-path (file-name-directory (or (buffer-file-name) load-file-name)) "emacs-jabber"))
+(add-to-list 'load-path (construct-path (file-name-directory (or (buffer-file-name) load-file-name)) "popup-el"))
+(add-to-list 'load-path (construct-path (file-name-directory (or (buffer-file-name) load-file-name)) "fuzzy-el"))
+(add-to-list 'load-path (construct-path (file-name-directory (or (buffer-file-name) load-file-name)) "auto-complete"))
+(add-to-list 'load-path (construct-path (file-name-directory (or (buffer-file-name) load-file-name)) "yasnippet"))
+(add-to-list 'load-path (construct-path (file-name-directory (or (buffer-file-name) load-file-name)) "lintnode"))
+(add-to-list 'load-path (construct-path (file-name-directory (or (buffer-file-name) load-file-name)) "emacs-flymake-cursor"))
+(add-to-list 'load-path (construct-path (file-name-directory (or (buffer-file-name) load-file-name)) "js-comint"))
+
(setq backup-directory-alist `(("." . ,(construct-path "~" "emacsbackup"))))
@@ -102,6 +110,100 @@ This one changes the cursor color on each blink. Define colors in `blink-cursor-
(require 'todotxt)
+
+;; HUGE list of addons incoming... the next section of require modes are aimed at beefing up JavaScript editing capability
+;; within emacs. Most of these are hooked into js-mode when that mode is activated. The List:
+;; js-comint - Used to have a REPL when javascript coding. Useful for non-DOM, algorithmic JavaScript.
+;; flymake-jslint - allows for syntax and lint checking. This required some hand-editing of existing C-source file in
+;; jslint, so be careful. See the URL link below for more information.
+;; flymake-cursor - allows for flymake notifications to appear in the mini-buffer.
+;; auto-complete-config - enables auto completion for all JavaScript variable names as well as syntax words.
+;; yasnippet - for template auto completion, things like 'forin' auto complete on TAB.
+;; hs-minor-mode - for code folding. C-c C-f (Fold the code block), C-c C-o (Open the code block).
+;;
+;; Key command chart:
+;; C-c C-n - Jumps to next flymake error.
+;; C-c C-p - Jumps to previous flymake error.
+;; C-c C-f - Folds the current code block, where cursor is at. If inside a Function, folds the function.
+;; C-c C-o - Opens the current code block if Folded. Inside a folded function, then it opens/expands it.
+(require 'js-comint)
+;; Use nodejs as repl
+(setq inferior-js-program-command "node")
+(setq inferior-js-mode-hook
+ (lambda ()
+ (ansi-color-for-comint-mode-on)
+ (add-to-list 'comint-preoutput-filter-functions
+ (lambda (output)
+ (replace-regexp-in-string ".*1G\.\.\..*5G" "..." (replace-regexp-in-string ".*1G.*3G" ">" output))))))
+
+
+;; Setup flymake, note we have to edit the output of jslint due to error reporting
+;; on multiple lines. See: http://lapin-bleu.net/riviera/?p=191
+;; This is due to reporter.js in /usr/local/lib/node_modules/jslint/lib. line breaking code needs to be removed in this file.
+(require 'flymake-jslint)
+
+(when (load "flymake" t)
+ (defun flymake-jslint-init ()
+ (let* ((temp-file (flymake-init-create-temp-buffer-copy
+ 'flymake-create-temp-inplace))
+ (local-file (file-relative-name
+ temp-file
+ (file-name-directory buffer-file-name))))
+ (list "jslint" (list local-file))))
+
+ (setq flymake-err-line-patterns
+ (cons '("Error: \\([[:digit:]]+\\):\\([[:digit:]]+\\):\\(.*\\)$"
+ nil 1 2 3)
+ flymake-err-line-patterns))
+ (add-to-list 'flymake-allowed-file-name-masks
+ '("\\.js\\'" flymake-jslint-init))
+ (require 'flymake-cursor)
+)
+(add-hook 'js-mode-hook
+ (lambda ()
+ (flymake-mode 1)
+ (define-key js-mode-map "\C-c\C-n" 'flymake-goto-next-error)))
+(add-hook 'js-mode-hook
+ (lambda ()
+ (flymake-mode 1)
+ (define-key js-mode-map "\C-c\C-p" 'flymake-goto-prev-error)))
+
+(setq temporary-file-directory "~/.emacs.d/tmp/")
+
+
+(require 'auto-complete-config)
+(add-to-list 'ac-dictionary-directories (construct-path (file-name-directory (or (buffer-file-name) load-file-name)) "auto-complete/dict"))
+;; Use auto-complete dictionaries by default
+(setq-default ac-sources (add-to-list 'ac-sources 'ac-source-dictionary))
+(global-auto-complete-mode t)
+;; Start auto-complete after 2 characters
+(setq ac-auto-start 2)
+(setq ac-ignore-case nil)
+
+
+(require 'yasnippet)
+(yas/global-mode 1)
+(yas/initialize)
+;; Load the snippet files themselves
+;;(yas/load-directory (construct-path (file-name-directory (or (buffer-file-name) load-file-name)) "yasnippet/snippets"))
+;; Required for the snippets to appear in auto-complete
+(add-to-list 'ac-sources 'ac-source-yasnippet)
+
+;; Set up code folding for javascript, aka hs-minor-mode
+(add-hook 'js-mode-hook
+ (lambda ()
+ ;; Scan the file for nested code blocks
+ (imenu-add-menubar-index)
+ ;; Activate the folding mode
+ (hs-minor-mode t)))
+(add-hook 'js-mode-hook
+ (lambda ()
+ (define-key js-mode-map "\C-c\C-f" 'hs-hide-block)))
+(add-hook 'js-mode-hook
+ (lambda ()
+ (define-key js-mode-map "\C-c\C-o" 'hs-show-block)))
+
+
(require 'mew)
;; Both these functions are completely optional
@@ -142,6 +244,7 @@ This one changes the cursor color on each blink. Define colors in `blink-cursor-
(setq mew-prog-mime-decode (concat mew-dir "/bin/mewdecode"))
(setq mew-prog-est-update (concat mew-dir "/bin/mewest"))
+
(recentf-mode t)
(setq recentf-auto-cleanup 'never)
Submodule fuzzy-el added at b47d80
Submodule js-comint added at 18bc6d
Submodule lintnode added at 187398
Submodule popup-el added at 6862a4
Submodule yasnippet added at b38e17

0 comments on commit e7475f8

Please sign in to comment.