dot/emacs, el/dot-emacs.el: Javascript support
[profile] / el / dot-emacs.el
index 3372556..82ff4b3 100644 (file)
@@ -285,6 +285,11 @@ Evil key bindings are defined in `mdw-evil-keymap-keys'."
             ("\\subparagraph{%s}" . "\\subparagraph*{%s}"))
           org-export-latex-classes)))
 
+(setq org-export-docbook-xslt-proc-command "xsltproc --output %o %s %i"
+      org-export-docbook-xsl-fo-proc-command "fop %i.safe %o"
+      org-export-docbook-xslt-stylesheet
+      "/usr/share/xml/docbook/stylesheet/docbook-xsl/fo/docbook.xsl")
+
 ;;;--------------------------------------------------------------------------
 ;;; Mail and news hacking.
 
@@ -358,6 +363,9 @@ so that it can be used for convenient filtering."
          (setenv "REAL_MOVEMAIL" try))
       (setq path (cdr path)))))
 
+(eval-after-load "erc"
+    '(load "~/.ercrc.el"))
+
 ;;;--------------------------------------------------------------------------
 ;;; Utility functions.
 
@@ -982,6 +990,13 @@ doesn't match any of the regular expressions in
 (mdw-define-face whizzy-error-face
   (t :background "darkred"))
 
+;; Ellipses used to indicate hidden text (and similar).
+(mdw-define-face mdw-ellipsis-face
+  (((type tty)) :foreground "blue") (t :foreground "grey60"))
+(let ((dot (make-glyph-code ?. 'mdw-ellipsis-face)))
+  (set-display-table-slot standard-display-table 4
+                         (vector dot dot dot)))
+
 ;;;--------------------------------------------------------------------------
 ;;; C programming configuration.
 
@@ -1026,13 +1041,14 @@ doesn't match any of the regular expressions in
                  (arglist-cont-nonempty . mdw-c-lineup-arglist)
                  (topmost-intro . mdw-c-indent-extern-mumble)
                  (cpp-define-intro . 0)
+                 (knr-argdecl . 0)
                  (inextern-lang . [0])
                  (label . 0)
                  (case-label . +)
                  (access-label . -)
                  (inclass . +)
                  (inline-open . ++)
-                 (statement-cont . 0)
+                 (statement-cont . +)
                  (statement-case-intro . +)))
               t))
 
@@ -1325,6 +1341,66 @@ doesn't match any of the regular expressions in
   (mdw-post-config-mode-hack))
 
 ;;;--------------------------------------------------------------------------
+;;; Javascript programming configuration.
+
+(defun mdw-javascript-style ()
+  (setq js-indent-level 2)
+  (setq js-expr-indent-offset 0))
+
+(defun mdw-fontify-javascript ()
+
+  ;; Other stuff.
+  (mdw-javascript-style)
+  (setq js-auto-indent-flag t)
+
+  ;; Now define things to be fontified.
+  (make-local-variable 'font-lock-keywords)
+  (let ((javascript-keywords
+        (mdw-regexps "abstract" "boolean" "break" "byte" "case" "catch"
+                     "char" "class" "const" "continue" "debugger" "default"
+                     "delete" "do" "double" "else" "enum" "export" "extends"
+                     "final" "finally" "float" "for" "function" "goto" "if"
+                     "implements" "import" "in" "instanceof" "int"
+                     "interface" "let" "long" "native" "new" "package"
+                     "private" "protected" "public" "return" "short"
+                     "static" "super" "switch" "synchronized" "throw"
+                     "throws" "transient" "try" "typeof" "var" "void"
+                     "volatile" "while" "with" "yield"
+
+                     "boolean" "byte" "char" "double" "float" "int" "long"
+                     "short" "void"))
+       (javascript-constants
+        (mdw-regexps "false" "null" "undefined" "Infinity" "NaN" "true"
+                     "arguments" "this")))
+
+    (setq font-lock-keywords
+         (list
+
+          ;; Handle the keywords defined above.
+          (list (concat "\\<\\(" javascript-keywords "\\)\\>")
+                '(0 font-lock-keyword-face))
+
+          ;; Handle the predefined constants defined above.
+          (list (concat "\\<\\(" javascript-constants "\\)\\>")
+                '(0 font-lock-variable-name-face))
+
+          ;; Handle numbers too.
+          ;;
+          ;; The following isn't quite right, but it's close enough.
+          (list (concat "\\<\\("
+                        "0\\([xX][0-9a-fA-F]+\\|[0-7]+\\)\\|"
+                        "[0-9]+\\(\\.[0-9]*\\|\\)"
+                        "\\([eE]\\([-+]\\|\\)[0-9]+\\|\\)\\)"
+                        "[lLfFdD]?")
+                '(0 mdw-number-face))
+
+          ;; And anything else is punctuation.
+          (list "\\(\\s.\\|\\s(\\|\\s)\\|\\s\\\\|\\s/\\)"
+                '(0 mdw-punct-face)))))
+
+  (mdw-post-config-mode-hack))
+
+;;;--------------------------------------------------------------------------
 ;;; C# programming configuration.
 
 ;; Make indentation nice.
@@ -1515,11 +1591,11 @@ doesn't match any of the regular expressions in
   ;; Now define fontification things.
   (make-local-variable 'font-lock-keywords)
   (let ((perl-keywords
-        (mdw-regexps "and" "cmp" "continue" "do" "else" "elsif" "eq"
-                     "for" "foreach" "ge" "gt" "goto" "if"
+        (mdw-regexps "and" "break" "cmp" "continue" "do" "else" "elsif" "eq"
+                     "for" "foreach" "ge" "given" "gt" "goto" "if"
                      "last" "le" "lt" "local" "my" "ne" "next" "or"
-                     "package" "redo" "require" "return" "sub"
-                     "undef" "unless" "until" "use" "while")))
+                     "our" "package" "redo" "require" "return" "sub"
+                     "undef" "unless" "until" "use" "when" "while")))
 
     (setq font-lock-keywords
          (list
@@ -1940,8 +2016,7 @@ strip numbers instead."
 ;;;--------------------------------------------------------------------------
 ;;; Erlang configuration.
 
-(setq erlang-electric-commannds
-      '(erlang-electric-newline erlang-electric-semicolon))
+(setq erlang-electric-commands nil)
 
 (defun mdw-fontify-erlang ()
 
@@ -2136,13 +2211,21 @@ strip numbers instead."
            (save-match-data
              (replace-regexp-in-string "\\..*$" "" (system-name)))
            " "
-           (eshell/pwd)
+           (let* ((pwd (eshell/pwd)) (npwd (length pwd))
+                  (home (expand-file-name "~")) (nhome (length home)))
+             (if (and (>= npwd nhome)
+                      (or (= nhome npwd)
+                          (= (elt pwd nhome) ?/))
+                      (string= (substring pwd 0 nhome) home))
+                 (concat "~" (substring pwd (length home)))
+               pwd))
            right)))
 (setq eshell-prompt-function 'mdw-eshell-prompt)
 (setq eshell-prompt-regexp "^\\[[^]>]+\\(\\]\\|>>?\\)")
 
-(defalias 'eshell/e 'find-file)
-(defalias 'eshell/w3m 'w3m-goto-url)
+(defun eshell/e (file) (find-file file) nil)
+(defun eshell/ee (file) (find-file-other-window file) nil)
+(defun eshell/w3m (url) (w3m-goto-url url) nil)
 
 (mdw-define-face eshell-prompt (t :weight bold))
 (mdw-define-face eshell-ls-archive (t :weight bold :foreground "red"))
@@ -2466,6 +2549,20 @@ strip numbers instead."
      (define-key term-raw-map [M-left] 'term-send-meta-left)
      (define-key term-raw-map [?\e ?\M-O ?D] 'term-send-meta-left)))
 
+(defadvice term-exec (before program-args-list compile activate)
+  "If the PROGRAM argument is a list, interpret it as (PROGRAM . SWITCHES).
+This allows you to pass a list of arguments through `ansi-term'."
+  (let ((program (ad-get-arg 2)))
+    (if (listp program)
+       (progn
+         (ad-set-arg 2 (car program))
+         (ad-set-arg 4 (cdr program))))))
+
+(defun ssh (host)
+  "Open a terminal containing an ssh session to the HOST."
+  (interactive "sHost: ")
+  (ansi-term (list "ssh" host) (format "ssh@%s" host)))
+
 ;;;--------------------------------------------------------------------------
 ;;; Inferior Emacs Lisp.