el/dot-emacs.el: Add a bunch of search shortcuts for `w3m'.
[profile] / el / dot-emacs.el
index 2f61f96..dc5529d 100644 (file)
@@ -229,6 +229,21 @@ Evil key bindings are defined in `mdw-evil-keymap-keys'."
        (dolist (key replacements)
          (define-key keymap key binding))))))
 
+(eval-after-load "org"
+  '(progn
+     (push '("strayman"
+            "\\documentclass{strayman}
+\\usepackage[utf8]{inputenc}
+\\usepackage[palatino, helvetica, courier, maths=cmr]{mdwfonts}
+\\usepackage[T1]{fontenc}
+\\usepackage{graphicx, tikz, mdwtab, mdwmath, crypto, longtable}"
+            ("\\section{%s}" . "\\section*{%s}")
+            ("\\subsection{%s}" . "\\subsection*{%s}")
+            ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
+            ("\\paragraph{%s}" . "\\paragraph*{%s}")
+            ("\\subparagraph{%s}" . "\\subparagraph*{%s}"))
+          org-export-latex-classes)))
+
 ;;;--------------------------------------------------------------------------
 ;;; Mail and news hacking.
 
@@ -486,6 +501,42 @@ CHECK is fboundp, and returning the correponding FUNC."
          (setq answer func)))
     answer))
 
+(eval-after-load "w3m-search"
+  '(progn
+     (dolist
+        (item
+         '(("g" "Google" "http://www.google.co.uk/search?q=%s")
+           ("gd" "Google Directory"
+            "http://www.google.com/search?cat=gwd/Top&q=%s")
+           ("gg" "Google Groups" "http://groups.google.com/groups?q=%s")
+           ("ward" "Ward's wiki" "http://c2.com/cgi/wiki?%s")
+           ("gi" "Images" "http://images.google.com/images?q=%s")
+           ("rfc" "RFC"
+            "http://metalzone.distorted.org.uk/ftp/pub/mirrors/rfc/rfc%s.txt.gz")
+           ("wp" "Wikipedia"
+            "http://en.wikipedia.org/wiki/Special:Search?go=Go&search=%s")
+           ("imdb" "IMDb" "http://www.imdb.com/Find?%s")
+           ("nc-wiki" "nCipher wiki"
+            "http://wiki.ncipher.com/wiki/bin/view/Devel/?topic=%s")
+           ("map" "Google maps" "http://maps.google.co.uk/maps?q=%s&hl=en")
+           ("lp" "Launchpad bug by number"
+            "https://bugs.launchpad.net/bugs/%s")
+           ("lppkg" "Launchpad bugs by package"
+            "https://bugs.launchpad.net/%s")
+           ("msdn" "MSDN"
+            "http://social.msdn.microsoft.com/Search/en-GB/?query=%s&ac=8")
+           ("debbug" "Debian bug by number"
+            "http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=%s")
+           ("debbugpkg" "Debian bugs by package"
+            "http://bugs.debian.org/cgi-bin/pkgreport.cgi?pkg=%s")
+           ("ljlogin" "LJ login" "http://www.livejournal.com/login.bml")))
+       (add-to-list 'w3m-search-engine-alist
+                   (list (cadr item) (caddr item) nil))
+       (add-to-list 'w3m-uri-replace-alist
+                   (list (concat "\\`" (car item) ":")
+                         'w3m-search-uri-replace
+                         (cadr item))))))
+
 ;;;--------------------------------------------------------------------------
 ;;; Paragraph filling.
 
@@ -630,6 +681,7 @@ case."
   (and (fboundp 'gtags-mode)
        (gtags-mode))
   (outline-minor-mode t)
+  (hs-minor-mode t)
   (mdw-set-font))
 
 (eval-after-load 'gtags
@@ -807,11 +859,6 @@ doesn't match any of the regular expressions in
 
 ;; Make C indentation nice.
 
-(eval-after-load "cc-mode"
-  '(progn
-     (define-key c-mode-map "*" nil)
-     (define-key c-mode-map "/" nil)))
-
 (defun mdw-c-lineup-arglist (langelem)
   "Hack for DWIMmery in c-lineup-arglist."
   (if (save-excursion
@@ -850,6 +897,15 @@ doesn't match any of the regular expressions in
                  (statement-case-intro . +)))
               t))
 
+(defvar mdw-c-comment-fill-prefix
+  `((,(concat "\\([ \t]*/?\\)"
+             "\\(\*\\|//]\\)"
+             "\\([ \t]*\\)"
+             "\\([A-Za-z]+:[ \t]*\\)?"
+             mdw-hanging-indents)
+     (pad . 1) (match . 2) (pad . 3) (pad . 4) (pad . 5)))
+  "Fill prefix matching C comments (both kinds).")
+
 (defun mdw-fontify-c-and-c++ ()
 
   ;; Fiddle with some syntax codes.
@@ -862,12 +918,7 @@ doesn't match any of the regular expressions in
   (setq c-hanging-comment-ender-p nil)
   (setq c-backslash-column 72)
   (setq c-label-minimum-indentation 0)
-  (setq mdw-fill-prefix
-       `((,(concat "\\([ \t]*/?\\)"
-                   "\\([\*/][ \t]*\\)"
-                   "\\([A-Za-z]+:[ \t]*\\)?"
-                   mdw-hanging-indents)
-          (pad . 1) (match . 2) (pad . 3) (pad . 4))))
+  (setq mdw-fill-prefix mdw-c-comment-fill-prefix)
 
   ;; Now define things to be fontified.
   (make-local-variable 'font-lock-keywords)
@@ -1036,12 +1087,7 @@ doesn't match any of the regular expressions in
   (setq c-backslash-column 72)
   (setq comment-start "/* ")
   (setq comment-end " */")
-  (setq mdw-fill-prefix
-       `((,(concat "\\([ \t]*/?\\)"
-                   "\\([\*/][ \t]*\\)"
-                   "\\([A-Za-z]+:[ \t]*\\)?"
-                   mdw-hanging-indents)
-          (pad . 1) (match . 2) (pad . 3) (pad . 4))))
+  (setq mdw-fill-prefix mdw-c-comment-fill-prefix)
 
   ;; Now define things to be fontified.
   (make-local-variable 'font-lock-keywords)
@@ -1095,14 +1141,7 @@ doesn't match any of the regular expressions in
   (mdw-java-style)
   (setq c-hanging-comment-ender-p nil)
   (setq c-backslash-column 72)
-  (setq comment-start "/* ")
-  (setq comment-end " */")
-  (setq mdw-fill-prefix
-       `((,(concat "\\([ \t]*/?\\)"
-                   "\\([\*/][ \t]*\\)"
-                   "\\([A-Za-z]+:[ \t]*\\)?"
-                   mdw-hanging-indents)
-          (pad . 1) (match . 2) (pad . 3) (pad . 4))))
+  (setq mdw-fill-prefix mdw-c-comment-fill-prefix)
 
   ;; Now define things to be fontified.
   (make-local-variable 'font-lock-keywords)
@@ -1164,14 +1203,7 @@ doesn't match any of the regular expressions in
   (mdw-csharp-style)
   (setq c-hanging-comment-ender-p nil)
   (setq c-backslash-column 72)
-  (setq comment-start "/* ")
-  (setq comment-end " */")
-  (setq mdw-fill-prefix
-       `((,(concat "\\([ \t]*/?\\)"
-                   "\\([\*/][ \t]*\\)"
-                   "\\([A-Za-z]+:[ \t]*\\)?"
-                   mdw-hanging-indents)
-          (pad . 1) (match . 2) (pad . 3) (pad . 4))))
+  (setq mdw-fill-prefix mdw-c-comment-fill-prefix)
 
   ;; Now define things to be fontified.
   (make-local-variable 'font-lock-keywords)
@@ -1214,13 +1246,8 @@ doesn't match any of the regular expressions in
           (list "\\(\\s.\\|\\s(\\|\\s)\\|\\s\\\\|\\s/\\)"
                 '(0 mdw-punct-face))))))
 
-(defun csharp-mode ()
-  (interactive)
-  (java-mode)
-  (setq major-mode 'csharp-mode)
-  (setq mode-name "C#")
-  (mdw-fontify-csharp)
-  (run-hooks 'csharp-mode-hook))
+(define-derived-mode csharp-mode java-mode "C#"
+  "Major mode for editing C# code.")
 
 ;;;--------------------------------------------------------------------------
 ;;; Awk programming configuration.
@@ -1345,37 +1372,48 @@ strip numbers instead."
 ;;;--------------------------------------------------------------------------
 ;;; Python programming style.
 
-;; Define Python fontification style.
-
-(defun mdw-fontify-python ()
+(defun mdw-fontify-pythonic (keywords)
 
   ;; Miscellaneous fiddling.
   (mdw-standard-fill-prefix "\\([ \t]*#+[ \t]*\\)")
 
   ;; Now define fontification things.
   (make-local-variable 'font-lock-keywords)
-  (let ((python-keywords
-        (mdw-regexps "and" "as" "assert" "break" "class" "continue" "def"
-                     "del" "elif" "else" "except" "exec" "finally" "for"
-                     "from" "global" "if" "import" "in" "is" "lambda"
-                     "not" "or" "pass" "print" "raise" "return" "try"
-                     "while" "with" "yield")))
-    (setq font-lock-keywords
-         (list
+  (setq font-lock-keywords
+       (list
 
-          ;; Set up the keywords defined above.
-          (list (concat "\\<\\(" python-keywords "\\)\\>")
-                '(0 font-lock-keyword-face))
+        ;; Set up the keywords defined above.
+        (list (concat "\\<\\(" keywords "\\)\\>")
+              '(0 font-lock-keyword-face))
 
-          ;; At least numbers are simpler than C.
-          (list (concat "\\<0\\([xX][0-9a-fA-F_]+\\|[0-7_]+\\)\\|"
-                        "\\<[0-9][0-9_]*\\(\\.[0-9_]*\\|\\)"
-                        "\\([eE]\\([-+]\\|\\)[0-9_]+\\|[lL]\\|\\)")
-                '(0 mdw-number-face))
+        ;; At least numbers are simpler than C.
+        (list (concat "\\<0\\([xX][0-9a-fA-F_]+\\|[0-7_]+\\)\\|"
+                      "\\<[0-9][0-9_]*\\(\\.[0-9_]*\\|\\)"
+                      "\\([eE]\\([-+]\\|\\)[0-9_]+\\|[lL]\\|\\)")
+              '(0 mdw-number-face))
 
-          ;; And anything else is punctuation.
-          (list "\\(\\s.\\|\\s(\\|\\s)\\|\\s\\\\|\\s/\\)"
-                '(0 mdw-punct-face))))))
+        ;; And anything else is punctuation.
+        (list "\\(\\s.\\|\\s(\\|\\s)\\|\\s\\\\|\\s/\\)"
+              '(0 mdw-punct-face)))))
+
+;; Define Python fontification styles.
+
+(defun mdw-fontify-python ()
+  (mdw-fontify-pythonic
+   (mdw-regexps "and" "as" "assert" "break" "class" "continue" "def"
+               "del" "elif" "else" "except" "exec" "finally" "for"
+               "from" "global" "if" "import" "in" "is" "lambda"
+               "not" "or" "pass" "print" "raise" "return" "try"
+               "while" "with" "yield")))
+
+(defun mdw-fontify-pyrex ()
+  (mdw-fontify-pythonic
+   (mdw-regexps "and" "as" "assert" "break" "cdef" "class" "continue"
+               "ctypedef" "def" "del" "elif" "else" "except" "exec"
+               "extern" "finally" "for" "from" "global" "if"
+               "import" "in" "is" "lambda" "not" "or" "pass" "print"
+               "raise" "return" "struct" "try" "while" "with"
+               "yield")))
 
 ;;;--------------------------------------------------------------------------
 ;;; Icon programming style.
@@ -2146,7 +2184,7 @@ strip numbers instead."
   (auto-fill-mode 1))
 
 ;;;--------------------------------------------------------------------------
-;;; Outline mode.
+;;; Outline and hide/show modes.
 
 (defun mdw-outline-collapse-all ()
   "Completely collapse everything in the entire buffer."
@@ -2157,6 +2195,8 @@ strip numbers instead."
       (hide-subtree)
       (forward-line))))
 
+(setq hs-hide-comments-when-hiding-all nil)
+
 ;;;--------------------------------------------------------------------------
 ;;; Shell mode.