X-Git-Url: https://git.distorted.org.uk/~mdw/profile/blobdiff_plain/3260d9c4edcb845b7b441d42c294942957bee5ce..c36efcdc0b2d92b02fd7224d4fc53cf5a7cb74e3:/el/dot-emacs.el diff --git a/el/dot-emacs.el b/el/dot-emacs.el index 0ff628b..fc3c13f 100644 --- a/el/dot-emacs.el +++ b/el/dot-emacs.el @@ -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,37 @@ 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 + "If non-nil, `rename-file' won't rename the buffer visiting the file.") + +(defmacro mdw-advise-to-inhibit-rename-buffer (function) + "Advise FUNCTION to set `mdw-inhibit-rename-buffer' while it runs. + +This will prevent `rename-file' from renaming the buffer." + `(defadvice ,function (around mdw-inhibit-rename-buffer compile activate) + "Don't rename the buffer when renaming the underlying file." + (let ((mdw-inhibit-rename-buffer t)) + ad-do-it))) +(mdw-advise-to-inhibit-rename-buffer recode-file-name) +(mdw-advise-to-inhibit-rename-buffer set-visited-file-name) +(mdw-advise-to-inhibit-rename-buffer backup-buffer) + +(defadvice rename-file (after mdw-rename-buffers (from to &optional forcep) + compile activate) + "If a buffer is visiting the file, rename it to match the new name. + +Don't do this if `mdw-inhibit-rename-buffer' is non-nil." + (unless mdw-inhibit-rename-buffer + (let ((buffer (get-file-buffer from))) + (when buffer + (with-current-buffer buffer + (set-visited-file-name to nil t)))))) + ;;;-------------------------------------------------------------------------- ;;; Improved compilation machinery. @@ -1165,14 +1196,28 @@ If there's no fill prefix currently set (by the `fill-prefix' variable) and there's a match from one of the regexps here, it gets used to set the fill-prefix for the current operation. -The variable is a list of items of the form `REGEXP . PREFIX'; if -the REGEXP matches, the PREFIX is used to set the fill prefix. -It in turn is a list of things: +The variable is a list of items of the form `PATTERN . PREFIX'; if +the PATTERN matches, the PREFIX is used to set the fill prefix. - STRING -- insert a literal string - (match . N) -- insert the thing matched by bracketed subexpression N - (pad . N) -- a string of whitespace the same width as subexpression N - (expr . FORM) -- the result of evaluating FORM") +A PATTERN is one of the following. + + * STRING -- a regular expression, expected to match at point + * (eval . FORM) -- a Lisp form which must evaluate non-nil + * (if COND CONSEQ-PAT ALT-PAT) -- if COND evaluates non-nil, must match + CONSEQ-PAT; otherwise must match ALT-PAT + * (and PATTERN ...) -- must match all of the PATTERNs + * (or PATTERN ...) -- must match at least one PATTERN + * (not PATTERN) -- mustn't match (probably not useful) + +A PREFIX is a list of the following kinds of things: + + * STRING -- insert a literal string + * (match . N) -- insert the thing matched by bracketed subexpression N + * (pad . N) -- a string of whitespace the same width as subexpression N + * (expr . FORM) -- the result of evaluating FORM + +Information about `bracketed subexpressions' comes from the match data, +as modified during matching.") (make-variable-buffer-local 'mdw-fill-prefix) @@ -1196,16 +1241,41 @@ 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-fill-prefix-match-p (pat) + "Return non-nil if PAT matches at the current position." + (cond ((stringp pat) (looking-at pat)) + ((not (consp pat)) (error "Unknown pattern item `%S'" pat)) + ((eq (car pat) 'eval) (eval (cdr pat))) + ((eq (car pat) 'if) + (if (or (null (cdr pat)) + (null (cddr pat)) + (null (cdddr pat)) + (cddddr pat)) + (error "Invalid `if' pattern `%S'" pat)) + (mdw-fill-prefix-match-p (if (eval (cadr pat)) + (caddr pat) + (cadddr pat)))) + ((eq (car pat) 'and) + (let ((pats (cdr pat)) + (ok t)) + (while (and pats + (or (mdw-fill-prefix-match-p (car pats)) + (setq ok nil))) + (setq pats (cdr pats))) + ok)) + ((eq (car pat) 'or) + (let ((pats (cdr pat)) + (ok nil)) + (while (and pats + (or (not (mdw-fill-prefix-match-p (car pats))) + (progn (setq ok t) nil))) + (setq pats (cdr pats))) + ok)) + ((eq (car pat) 'not) + (if (or (null (cdr pat)) (cddr pat)) + (error "Invalid `not' pattern `%S'" pat)) + (not (mdw-fill-prefix-match-p (car pats)))) + (t (error "Unknown pattern form `%S'" pat)))) (defun mdw-maybe-car (p) "If P is a pair, return (car P), otherwise just return P." @@ -1230,6 +1300,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) + ((mdw-fill-prefix-match-p (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) @@ -1251,13 +1337,20 @@ case where there isn't a sensible static one." (let ((fill-prefix (mdw-choose-dynamic-fill-prefix))) (fill-paragraph nil))) +(defun mdw-point-within-string-p () + "Return non-nil if point is within a string." + (let ((state (syntax-ppss))) + (elt state 3))) + (defun mdw-standard-fill-prefix (rx &optional mat) "Set the dynamic fill prefix, handling standard hanging indents and stuff. This is just a short-cut for setting the thing by hand, and by design it doesn't cope with anything approximating a complicated case." (setq mdw-fill-prefix - `((,(concat rx mdw-hanging-indents) + `(((if (mdw-point-within-string-p) + ,(concat "\\(\\s-*\\)" mdw-hanging-indents) + ,(concat rx mdw-hanging-indents)) (match . 1) (pad . ,(or mat 2)))))) @@ -1291,10 +1384,18 @@ case." (set (make-local-variable 'mdw-do-misc-mode-hacking) t) (local-set-key [C-return] 'newline) (make-local-variable 'page-delimiter) - (setq page-delimiter "\f\\|^.*-\\{6\\}.*$") + (setq page-delimiter (concat "^" "\f" + "\\|" "^" + ".\\{0,4\\}" + "-\\{5\\}" + "\\(" " " ".*" " " "\\)?" + "-+" + ".\\{0,2\\}" + "$")) (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) @@ -1626,6 +1727,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 @@ -1939,50 +2044,47 @@ indentation anyway." (defvar mdw-define-c-styles-hook nil "Hook run when `cc-mode' starts up to define styles.") -(defmacro mdw-define-c-style (name &rest assocs) - "Define a C style, called NAME (a symbol), setting ASSOCs. +(defun mdw-merge-style-alists (first second) + (let ((output nil)) + (dolist (item first) + (let ((key (car item)) (value (cdr item))) + (if (string-suffix-p "-alist" (symbol-name key)) + (push (cons key + (mdw-merge-style-alists value + (cdr (assoc key second)))) + output) + (push item output)))) + (dolist (item second) + (unless (assoc (car item) first) + (push item output))) + (nreverse output))) + +(cl-defmacro mdw-define-c-style (name (&optional parent) &rest assocs) + "Define a C style, called NAME (a symbol) based on PARENT, setting ASSOCs. A function, named `mdw-define-c-style/NAME', is defined to actually install the style using `c-add-style', and added to the hook `mdw-define-c-styles-hook'. If CC Mode is already loaded, then the style is set." (declare (indent defun)) (let* ((name-string (symbol-name name)) + (var (intern (concat "mdw-c-style/" name-string))) (func (intern (concat "mdw-define-c-style/" name-string)))) `(progn - (defun ,func () (c-add-style ,name-string ',assocs)) + (setq ,var + ,(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)))) + (add-hook 'mdw-define-c-styles-hook ',func) + ',name))) (eval-after-load "cc-mode" '(run-hooks 'mdw-define-c-styles-hook)) -(mdw-define-c-style mdw-trustonic-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-class-key . "class") - (c-backslash-column . 0) - (c-auto-align-backslashes . nil) - (c-label-minimum-indentation . 0) - (c-offsets-alist (substatement-open . (add 0 c-indent-one-line-block)) - (defun-open . (add 0 c-indent-one-line-block)) - (arglist-cont-nonempty . mdw-c-indent-arglist-nested) - (topmost-intro . mdw-c-indent-extern-mumble) - (cpp-define-intro . 0) - (knr-argdecl . 0) - (inextern-lang . [0]) - (label . 0) - (case-label . +) - (access-label . -2) - (inclass . +) - (inline-open . ++) - (statement-cont . +) - (statement-case-intro . +))) - -(mdw-define-c-style mdw-c +(mdw-define-c-style mdw-c () (c-basic-offset . 2) (comment-column . 40) (c-class-key . "class") @@ -2003,6 +2105,18 @@ set." (statement-cont . +) (statement-case-intro . +))) +(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 (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. @@ -2180,7 +2294,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'?. @@ -2274,7 +2388,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) @@ -2336,8 +2450,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)) @@ -2395,8 +2509,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)) @@ -2453,8 +2567,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)) @@ -2486,7 +2600,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) @@ -2540,8 +2654,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)) @@ -2732,8 +2846,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. @@ -2831,7 +2945,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) @@ -2873,8 +2987,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)) @@ -2940,8 +3054,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. @@ -2992,8 +3106,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. @@ -3178,8 +3292,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))))) @@ -3424,12 +3538,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. @@ -3514,8 +3628,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)))))) @@ -3552,7 +3666,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)))))) @@ -3584,7 +3698,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. @@ -4022,7 +4136,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 @@ -4068,7 +4182,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)) @@ -4151,10 +4265,6 @@ that character only to be normal punctuation.") (make-local-variable 'lisp-indent-function) (setq lisp-indent-function 'common-lisp-indent-function)) -(setq-default lisp-simple-loop-indentation 2 - lisp-loop-keyword-indentation 6 - lisp-loop-forms-indentation 6) - (defmacro mdw-advise-hyperspec-lookup (func args) `(defadvice ,func (around mdw-browse-w3m ,args activate compile) (if (fboundp 'w3m) @@ -4194,8 +4304,93 @@ that character only to be normal punctuation.") (list "\\(\\s.\\|\\s(\\|\\s)\\|\\s\\\\|\\s/\\)" '(0 mdw-punct-face))))) +;; Special indentation. + +(defvar mdw-lisp-loop-default-indent 2) + +(setq lisp-simple-loop-indentation 0 + lisp-loop-keyword-indentation 0 + lisp-loop-forms-indentation 2 + lisp-lambda-list-keyword-parameter-alignment t) + +(defun mdw-indent-funcall (path state indent-point sexp-column normal-indent) + "Indent `funcall' more usefully. +Essentially, treat `funcall foo' as a function name, and align the arguments +to `foo'." + (and (null (cdr path)) + (save-excursion + (goto-char (cadr state)) + (forward-char 1) + (let ((start-line (line-number-at-pos))) + (and (condition-case nil (progn (forward-sexp 3) t) + (scan-error nil)) + (progn + (forward-sexp -1) + (and (= start-line (line-number-at-pos)) + (current-column)))))))) +(put 'funcall 'common-lisp-indent-function 'mdw-indent-funcall) + +(defadvice common-lisp-loop-part-indentation + (around mdw-fix-loop-indentation (indent-point state) activate compile) + "Improve `loop' indentation. +If the first subform is on the same line as the `loop' keyword, then +align the other subforms beneath it. Otherwise, indent them +`mdw-lisp-loop-default-indent' columns in from the opening parenthesis." + + (let* ((loop-indentation (save-excursion + (goto-char (elt state 1)) + (current-column)))) + + ;; Don't really care about this. + (when (and (eq lisp-indent-backquote-substitution-mode 'corrected)) + (save-excursion + (goto-char (elt state 1)) + (cl-incf loop-indentation + (cond ((eq (char-before) ?,) -1) + ((and (eq (char-before) ?@) + (progn (backward-char) + (eq (char-before) ?,))) + -2) + (t 0))))) + + ;; If the first loop item is on the same line as the `loop' itself then + ;; use that as the baseline. Otherwise advance by the default indent. + (goto-char (cadr state)) + (forward-char 1) + (let ((baseline-indent + (if (= (line-number-at-pos) + (if (condition-case nil (progn (forward-sexp 2) t) + (scan-error nil)) + (progn (forward-sexp -1) (line-number-at-pos)) + -1)) + (current-column) + (+ loop-indentation mdw-lisp-loop-default-indent)))) + + (goto-char indent-point) + (beginning-of-line) + + (setq ad-return-value + (list + (cond ((not (lisp-extended-loop-p (elt state 1))) + (+ baseline-indent lisp-simple-loop-indentation)) + ((looking-at "^\\s-*\\(:?\\sw+\\|;\\)") + (+ baseline-indent lisp-loop-keyword-indentation)) + (t + (+ baseline-indent lisp-loop-forms-indentation))) + + ;; Tell the caller that the next line needs recomputation, even + ;; though it doesn't start a sexp. + loop-indentation))))) + ;; SLIME setup. +(defvar mdw-friendly-name "[mdw]" + "How I want to be addressed.") +(defadvice slime-user-first-name + (around mdw-use-friendly-name compile activate) + (if mdw-friendly-name (setq ad-return-value mdw-friendly-name) + ad-do-it)) + (trap (if (not mdw-fast-startup) (progn @@ -4252,8 +4447,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))))) @@ -4493,15 +4688,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