el/dot-emacs.el (mdw-examine-fill-prefixes): Rewrite to be iterative.
[profile] / el / dot-emacs.el
index 5968944..5bde809 100644 (file)
@@ -100,11 +100,11 @@ This may be at the expense of cool features.")
                     (replace-match with t))))
            (with-temp-buffer
              (insert-file-contents "~/.mdw.conf")
-             (replace  "^[ \t]*\\(#.*\\|\\)\n" "")
+             (replace  "^[ \t]*\\(#.*\\)?\n" "")
              (replace (concat "^[ \t]*"
                               "\\([-a-zA-Z0-9_.]*\\)"
                               "[ \t]*=[ \t]*"
-                              "\\(.*[^ \t\n]\\|\\)"
+                              "\\(.*[^ \t\n]\\)?"
                               "[ \t]**\\(\n\\|$\\)")
                       "(\\1 . \"\\2\")\n")
              (car (read-from-string
@@ -588,6 +588,9 @@ Even if an existing window in some random frame looks tempting."
 Pretend they don't exist.  They might be on other display devices."
   (ad-set-arg 2 nil))
 
+(setq even-window-sizes nil
+      even-window-heights nil)
+
 ;; Rename buffers along with files.
 
 (defvar mdw-inhibit-rename-buffer nil
@@ -1224,17 +1227,6 @@ This is mainly useful in `auto-fill-mode'.")
          (funcall tabfun (point-min) (point-max))
          (setq s (buffer-substring (point-min) (1- (point-max)))))))))
 
-(defun mdw-examine-fill-prefixes (l)
-  "Given a list of dynamic fill prefixes, pick one which matches
-context and return the static fill prefix to use.  Point must be
-at the start of a line, and match data must be saved."
-  (cond ((not l) nil)
-       ((looking-at (car (car l)))
-        (mdw-maybe-tabify (apply #'concat
-                                 (mapcar #'mdw-do-prefix-match
-                                         (cdr (car l))))))
-       (t (mdw-examine-fill-prefixes (cdr l)))))
-
 (defun mdw-maybe-car (p)
   "If P is a pair, return (car P), otherwise just return P."
   (if (consp p) (car p) p))
@@ -1258,6 +1250,22 @@ See `mdw-fill-prefix' for details."
        ((eq (car m) 'eval) (eval (cdr m)))
        (t "")))
 
+(defun mdw-examine-fill-prefixes (l)
+  "Given a list of dynamic fill prefixes, pick one which matches
+context and return the static fill prefix to use.  Point must be
+at the start of a line, and match data must be saved."
+  (let ((prefix nil))
+    (while (cond ((null l) nil)
+                ((looking-at (caar l))
+                 (setq prefix
+                         (mdw-maybe-tabify
+                          (apply #'concat
+                                 (mapcar #'mdw-do-prefix-match
+                                         (cdr (car l))))))
+                 nil))
+      (setq l (cdr l)))
+    prefix))
+
 (defun mdw-choose-dynamic-fill-prefix ()
   "Work out the dynamic fill prefix based on the variable `mdw-fill-prefix'."
   (cond ((and fill-prefix (not (string= fill-prefix ""))) fill-prefix)
@@ -1330,6 +1338,7 @@ case."
   (setq comment-column 40)
   (auto-fill-mode 1)
   (setq fill-column mdw-text-width)
+  (flyspell-prog-mode)
   (and (fboundp 'gtags-mode)
        (gtags-mode))
   (if (fboundp 'hs-minor-mode)
@@ -1661,6 +1670,10 @@ doesn't match any of the regular expressions in
 (mdw-define-face gnus-cite-11
   (t :foreground "grey"))
 
+(mdw-define-face gnus-emphasis-underline
+  (((type tty)) :underline t)
+  (t :slant italic))
+
 (mdw-define-face diff-header
   (t nil))
 (mdw-define-face diff-index
@@ -2001,12 +2014,11 @@ set."
         (func (intern (concat "mdw-define-c-style/" name-string))))
     `(progn
        (setq ,var
-            ',(if (null parent)
-                  assocs
-                (let ((parent-list (symbol-value
-                                    (intern (concat "mdw-c-style/"
-                                                    (symbol-name parent))))))
-                  (mdw-merge-style-alists assocs parent-list))))
+            ,(if (null parent)
+                 `',assocs
+               (let ((parent-list (intern (concat "mdw-c-style/"
+                                                  (symbol-name parent)))))
+                 `(mdw-merge-style-alists ',assocs ,parent-list))))
        (defun ,func () (c-add-style ,name-string ,var))
        (and (featurep 'cc-mode) (,func))
        (add-hook 'mdw-define-c-styles-hook ',func)
@@ -2036,15 +2048,17 @@ set."
                   (statement-cont . +)
                   (statement-case-intro . +)))
 
-(mdw-define-c-style mdw-trustonic-c (mdw-c)
+(mdw-define-c-style mdw-trustonic-basic-c (mdw-c)
   (c-basic-offset . 4)
   (comment-column . 0)
   (c-indent-comment-alist (anchored-comment . (column . 0))
                          (end-block . (space . 1))
                          (cpp-end-block . (space . 1))
                          (other . (space . 1)))
-  (c-offsets-alist (arglist-cont-nonempty . mdw-c-indent-arglist-nested)
-                  (access-label . -2)))
+  (c-offsets-alist (access-label . -2)))
+
+(mdw-define-c-style mdw-trustonic-c (mdw-trustonic-basic-c)
+  (c-offsets-alist (arglist-cont-nonempty . mdw-c-indent-arglist-nested)))
 
 (defun mdw-set-default-c-style (modes style)
   "Update the default CC Mode style for MODES to be STYLE.
@@ -2223,7 +2237,7 @@ name, as a symbol."
           ;; Fontify include files as strings.
           (list (concat "^[ \t]*\\#[ \t]*"
                         "\\(include\\|import\\)"
-                        "[ \t]*\\(<[^>]+\\(>\\|\\)\\)")
+                        "[ \t]*\\(<[^>]+>?\\)")
                 '(2 font-lock-string-face))
 
           ;; Preprocessor directives are `references'?.
@@ -2317,7 +2331,7 @@ name, as a symbol."
 
 ;; Make indentation nice.
 
-(mdw-define-c-style mdw-java
+(mdw-define-c-style mdw-java ()
   (c-basic-offset . 2)
   (c-backslash-column . 72)
   (c-offsets-alist (substatement-open . 0)
@@ -2379,8 +2393,8 @@ name, as a symbol."
           ;; 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]+\\|\\)\\)"
+                        "[0-9]+\\(\\.[0-9]*\\)?"
+                        "\\([eE][-+]?[0-9]+\\)?\\)"
                         "[lLfFdD]?")
                 '(0 mdw-number-face))
 
@@ -2438,8 +2452,8 @@ name, as a symbol."
           ;; 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]+\\|\\)\\)"
+                        "[0-9]+\\(\\.[0-9]*\\)?"
+                        "\\([eE][-+]?[0-9]+\\)?\\)"
                         "[lLfFdD]?")
                 '(0 mdw-number-face))
 
@@ -2496,8 +2510,8 @@ name, as a symbol."
           ;; As usual, not quite right.
           (list (concat "\\_<\\("
                         "0\\([xX][0-9a-fA-F]+\\|[0-7]+\\)\\|"
-                        "[0-9]+\\(\\.[0-9]*\\|\\)"
-                        "\\([eE]\\([-+]\\|\\)[0-9]+\\|\\)\\)"
+                        "[0-9]+\\(\\.[0-9]*\\)?"
+                        "\\([eE][-+]?[0-9]+\\)?\\)"
                         "[lLfFdD]?")
                 '(0 mdw-number-face))
 
@@ -2529,7 +2543,7 @@ name, as a symbol."
 
 ;; Make indentation nice.
 
-(mdw-define-c-style mdw-csharp
+(mdw-define-c-style mdw-csharp ()
   (c-basic-offset . 2)
   (c-backslash-column . 72)
   (c-offsets-alist (substatement-open . 0)
@@ -2583,8 +2597,8 @@ name, as a symbol."
           ;; 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]+\\|\\)\\)"
+                        "[0-9]+\\(\\.[0-9]*\\)?"
+                        "\\([eE][-+]?[0-9]+\\)?\\)"
                         "[lLfFdD]?")
                 '(0 mdw-number-face))
 
@@ -2775,8 +2789,8 @@ name, as a symbol."
           ;; 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]+\\|\\)\\)")
+                        "[0-9]+\\(\\.[0-9]*\\)?"
+                        "\\([eE][-+]?[0-9]+\\)?\\)")
                 '(0 mdw-number-face))
 
           ;; And anything else is punctuation.
@@ -2874,7 +2888,7 @@ name, as a symbol."
 
 ;; Make Awk indentation nice.
 
-(mdw-define-c-style mdw-awk
+(mdw-define-c-style mdw-awk ()
   (c-basic-offset . 2)
   (c-offsets-alist (substatement-open . 0)
                   (c-backslash-column . 72)
@@ -2916,8 +2930,8 @@ name, as a symbol."
           ;; 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]+\\|\\)\\)"
+                        "[0-9]+\\(\\.[0-9]*\\)?"
+                        "\\([eE][-+]?[0-9]+\\)?\\)"
                         "[uUlL]*")
                 '(0 mdw-number-face))
 
@@ -2983,8 +2997,8 @@ name, as a symbol."
 
           ;; 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_]+\\|\\)")
+                        "\\<[0-9][0-9_]*\\(\\.[0-9_]*\\)?"
+                        "\\([eE][-+]?[0-9_]+\\)?")
                 '(0 mdw-number-face))
 
           ;; And anything else is punctuation.
@@ -3035,8 +3049,8 @@ strip numbers instead."
 
         ;; At least numbers are simpler than C.
         (list (concat "\\_<0\\([xX][0-9a-fA-F]+\\|[oO]?[0-7]+\\|[bB][01]+\\)\\|"
-                      "\\_<[0-9][0-9]*\\(\\.[0-9]*\\|\\)"
-                      "\\([eE]\\([-+]\\|\\)[0-9]+\\|[lL]\\|\\)")
+                      "\\_<[0-9][0-9]*\\(\\.[0-9]*\\)?"
+                      "\\([eE][-+]?[0-9]+\\|[lL]\\)?")
               '(0 mdw-number-face))
 
         ;; And anything else is punctuation.
@@ -3221,8 +3235,8 @@ strip numbers instead."
   (setq font-lock-keywords
        (list
         (list (concat "\\<0\\([xX][0-9a-fA-F_]+\\|[0-7_]+\\)\\|"
-                      "\\<[0-9][0-9_]*\\(\\.[0-9_]*\\|\\)"
-                      "\\([eE]\\([-+]\\|\\)[0-9_]+\\|\\)")
+                      "\\<[0-9][0-9_]*\\(\\.[0-9_]*\\)?"
+                      "\\([eE][-+]?[0-9_]+\\)?")
               '(0 mdw-number-face))
         (list "\\(\\s.\\|\\s(\\|\\s)\\|\\s\\\\|\\s/\\)"
               '(0 mdw-punct-face)))))
@@ -3467,12 +3481,12 @@ strip numbers instead."
                 '(0 font-lock-keyword-face))
 
           ;; At least numbers are simpler than C.
-          (list (concat "\\<\\(\\~\\|\\)"
-                           "\\(0\\(\\([wW]\\|\\)[xX][0-9a-fA-F]+\\|"
+          (list (concat "\\<\\~?"
+                           "\\(0\\([wW]?[xX][0-9a-fA-F]+\\|"
                                   "[wW][0-9]+\\)\\|"
-                               "\\([0-9]+\\(\\.[0-9]+\\|\\)"
-                                        "\\([eE]\\(\\~\\|\\)"
-                                               "[0-9]+\\|\\)\\)\\)")
+                               "\\([0-9]+\\(\\.[0-9]+\\)?"
+                                        "\\([eE]\\~?"
+                                               "[0-9]+\\)?\\)\\)")
                 '(0 mdw-number-face))
 
           ;; And anything else is punctuation.
@@ -3557,8 +3571,8 @@ strip numbers instead."
           (list "\\_<[A-Z]\\(\\sw+\\|\\s_+\\)*\\_>"
                 '(0 font-lock-variable-name-face))
           (list (concat "\\_<0\\([xX][0-9a-fA-F]+\\|[oO][0-7]+\\)\\|"
-                        "\\_<[0-9]+\\(\\.[0-9]*\\|\\)"
-                        "\\([eE]\\([-+]\\|\\)[0-9]+\\|\\)")
+                        "\\_<[0-9]+\\(\\.[0-9]*\\)?"
+                        "\\([eE][-+]?[0-9]+\\)?")
                 '(0 mdw-number-face))
           (list "\\(\\s.\\|\\s(\\|\\s)\\|\\s\\\\|\\s/\\)"
                 '(0 mdw-punct-face))))))
@@ -3595,7 +3609,7 @@ strip numbers instead."
                 '(0 font-lock-keyword-face))
           (list (concat "^-\\sw+\\>")
                 '(0 font-lock-keyword-face))
-          (list "\\<[0-9]+\\(\\|#[0-9a-zA-Z]+\\|[eE][+-]?[0-9]+\\)\\>"
+          (list "\\<[0-9]+\\(#[0-9a-zA-Z]+\\|[eE][+-]?[0-9]+\\)?\\>"
                 '(0 mdw-number-face))
           (list "\\(\\s.\\|\\s(\\|\\s)\\|\\s\\\\|\\s/\\)"
                 '(0 mdw-punct-face))))))
@@ -3627,7 +3641,7 @@ strip numbers instead."
               '(2 font-lock-variable-name-face))
 
         ;; Make sure we get comments properly.
-        (list "@c\\(\\|omment\\)\\( .*\\)?$"
+        (list "@c\\(omment\\)?\\( .*\\)?$"
               '(0 font-lock-comment-face))
 
         ;; Command names are keywords.
@@ -4065,7 +4079,7 @@ that character only to be normal punctuation.")
     (setq messages-mode-keywords
          (append (list (list (concat "^[ \t]*\\#[ \t]*"
                                      "\\(include\\|import\\)"
-                                     "[ \t]*\\(<[^>]+\\(>\\|\\)\\)")
+                                     "[ \t]*\\(<[^>]+\\(>\\)?\\)")
                              '(2 font-lock-string-face))
                        (list (concat "^\\([ \t]*#[ \t]*\\(\\("
                                      preprocessor-keywords
@@ -4111,7 +4125,7 @@ that character only to be normal punctuation.")
          (list
           (list (concat "^%\\s *\\(}\\|\\(" keywords "\\)\\>\\).*$")
                 '(0 font-lock-keyword-face))
-          (list "^%\\s *\\(#.*\\|\\)$"
+          (list "^%\\s *\\(#.*\\)?$"
                 '(0 font-lock-comment-face))
           (list "^%"
                 '(0 font-lock-keyword-face))
@@ -4295,8 +4309,8 @@ that character only to be normal punctuation.")
         (list "\\<[A-Z][a-zA-Z0-9]*\\>"
               '(0 font-lock-keyword-face))
         (list (concat "\\<0\\([xX][0-9a-fA-F_]+\\|[0-7_]+\\)\\|"
-                      "[0-9][0-9_]*\\(\\.[0-9_]*\\|\\)"
-                      "\\([eE]\\([-+]\\|\\)[0-9_]+\\|\\)")
+                      "[0-9][0-9_]*\\(\\.[0-9_]*\\)?"
+                      "\\([eE][-+]?[0-9_]+\\)?")
               '(0 mdw-number-face))
         (list "\\(\\s.\\|\\s(\\|\\s)\\|\\s\\\\|\\s/\\)"
               '(0 mdw-punct-face)))))
@@ -4536,15 +4550,16 @@ there is sadness."
     (around mdw-inhibit-noip (topic) compile activate)
   "Inhibit the `noip' preload hack when invoking `man'."
   (let* ((old-preload (getenv "LD_PRELOAD"))
-        (preloads (save-match-data (split-string old-preload ":")))
+        (preloads (and old-preload
+                       (save-match-data (split-string old-preload ":"))))
         (any nil)
         (filtered nil))
-    (while preloads
-      (let ((item (pop preloads)))
-       (if (save-match-data
-             (string-match  "\\(/\\|^\\)noip\.so\\(:\\|$\\)" item))
-           (setq any t)
-         (push item filtered))))
+    (save-match-data
+      (while preloads
+       (let ((item (pop preloads)))
+         (if (string-match  "\\(/\\|^\\)noip\.so\\(:\\|$\\)" item)
+             (setq any t)
+           (push item filtered)))))
     (if any
        (unwind-protect
            (progn