Permalink
Browse files

misc reorg and tweaks

  • Loading branch information...
1 parent 252bd61 commit 9f2f20ce60fcf5ad0aca021adccd599c33d05c04 @tavisrudd committed Jul 1, 2010
Showing with 38 additions and 26 deletions.
  1. +31 −0 dss-codenav-helpers.el
  2. +7 −26 dss-javascript.el
@@ -106,6 +106,32 @@ Do nothing if not in string."
(interactive)
(dss/out-sexp 1 1))
+(defun dss/indent-sexp ()
+ "http://mihai.bazon.net/projects/editing-javascript-with-emacs-js2-mode
+ can be used from any coding major mode"
+ (interactive)
+ (save-restriction
+ (save-excursion
+ (widen)
+ (let* ((inhibit-point-motion-hooks t)
+ (parse-status (syntax-ppss (point)))
+ (beg (nth 1 parse-status))
+ (end-marker (make-marker))
+ (end (progn (goto-char beg) (forward-list) (point)))
+ (ovl (make-overlay beg end)))
+ (set-marker end-marker end)
+ (overlay-put ovl 'face 'highlight)
+ (goto-char beg)
+ (while (< (point) (marker-position end-marker))
+ ;; don't reindent blank lines so we don't set the "buffer
+ ;; modified" property for nothing
+ (beginning-of-line)
+ (unless (looking-at "\\s-*$")
+ (indent-according-to-mode))
+ (forward-line))
+ (run-with-timer 0.5 nil (lambda(ovl)
+ (delete-overlay ovl)) ovl)))))
+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun dss/electric-pair ()
"If at end of line, insert character pair without surrounding spaces.
@@ -235,5 +261,10 @@ Comes from http://github.com/technomancy/emacs-starter-kit/blob/master/starter-k
(dss/column-marker-1 -1)
(hl-line-mode t))
+(defun dss/local-line-jump (n)
+ (interactive "nLine: ")
+ ;(message (format "%d" (+ n (* (/ (line-number-at-pos) 100) 100))))
+ (goto-line (+ n (* (/ (line-number-at-pos) 100) 100))))
+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(provide 'dss-codenav-helpers)
View
@@ -1,6 +1,10 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Yegge's js2-mode with better indentation support
+(require 'dss-codenav-helpers)
+
+(add-to-list 'load-path (concat dss-vendor-dir "js2-mode"))
+
(autoload 'js2-mode "js2-mode" nil t)
(defun dss/js2-indent-function ()
@@ -35,37 +39,13 @@
(indent-line-to indentation)
(when (> offset 0) (forward-char offset)))))
-(defun dss/indent-sexp ()
- "http://mihai.bazon.net/projects/editing-javascript-with-emacs-js2-mode
- can be used from any coding major mode"
- (interactive)
- (save-restriction
- (save-excursion
- (widen)
- (let* ((inhibit-point-motion-hooks t)
- (parse-status (syntax-ppss (point)))
- (beg (nth 1 parse-status))
- (end-marker (make-marker))
- (end (progn (goto-char beg) (forward-list) (point)))
- (ovl (make-overlay beg end)))
- (set-marker end-marker end)
- (overlay-put ovl 'face 'highlight)
- (goto-char beg)
- (while (< (point) (marker-position end-marker))
- ;; don't reindent blank lines so we don't set the "buffer
- ;; modified" property for nothing
- (beginning-of-line)
- (unless (looking-at "\\s-*$")
- (indent-according-to-mode))
- (forward-line))
- (run-with-timer 0.5 nil (lambda(ovl)
- (delete-overlay ovl)) ovl)))))
+
(defun dss/js2-mode-hook ()
(require 'espresso)
(setq espresso-indent-level 4
indent-tabs-mode nil
c-basic-offset 4)
- (c-toggle-auto-state 0)
+ (c-toggle-auto-newline 0)
(c-toggle-hungry-state 1)
(set (make-local-variable 'indent-line-function) 'dss/js2-indent-function)
(define-key js2-mode-map [(meta control "|")] 'cperl-lineup)
@@ -85,6 +65,7 @@
(add-hook 'js2-mode-hook 'dss/js2-mode-hook)
(add-hook 'js2-mode-hook 'dss/install-whitespace-cleanup-hook)
+(add-hook 'js2-mode-hook '(lambda () (linum-mode t)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; alternately espresso-mode instead of js2-mode

0 comments on commit 9f2f20c

Please sign in to comment.