Skip to content
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...
1 parent 791a292 commit e7475f85f73ae1c72317fb644c073f3024c84fdf @jweaver committed
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
21 .gitmodules
@@ -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
1 auto-complete
@@ -0,0 +1 @@
+Subproject commit 40ceeacbdd5efc5d6a6dc83716da83d8e27863d2
1 emacs-flymake-cursor
@@ -0,0 +1 @@
+Subproject commit 5cac5045398b1436ceb143d48961b50d38ae1396
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)
1 fuzzy-el
@@ -0,0 +1 @@
+Subproject commit b47d801d4e1ff67323eda4d602e78c31fbc5a08a
1 js-comint
@@ -0,0 +1 @@
+Subproject commit 18bc6d80d11b8e8fa79371b4ad90057aabde0c97
1 lintnode
@@ -0,0 +1 @@
+Subproject commit 187398f908a59e65f972c713fd83a20c284d70b8
1 popup-el
@@ -0,0 +1 @@
+Subproject commit 6862a4732a3f3eee25aba5bf2548228cd9cadcaf
1 yasnippet
@@ -0,0 +1 @@
+Subproject commit b38e171a0fe78800fd94ba066f30e5658a995b40

0 comments on commit e7475f8

Please sign in to comment.
Something went wrong with that request. Please try again.