;;; gw-utils --- some utility macros ;; Author: Paul Du Bois <dubois@geoworks.com> ;; Maintainer: dubois@infinite-machine.com ;; $Id: //depot/tools/lisp/gw-utils.el#2 $ ;;; Code: ;;; XXX: only works for Windows NT right now 'cuz I'm too lazy to ;;; look up what Windows95 sets system-type to. (defmacro if-win32 (true &rest false) "Evaluate TRUE clause if we're running under Windows 95 or NT. Otherwise do the FALSE clause. Should have the exact same semantics/syntax as IF, if I wrote it correctly." (` (if (eq system-type 'windows-nt) (, true) (,@ false)))) (defmacro if-not-win32 (true &rest false) "Evaluate TRUE clause if we're not running under Windows 95 or NT. Otherwise do the FALSE clause. Should have the exact same semantics/syntax as IF, if I wrote it correctly." (` (if (not (eq system-type 'windows-nt)) (, true) (,@ false)))) ;; Make the macros indent similarly to "if" (mapcar '(lambda (sym) (put sym 'lisp-indent-function 1)) '(if-not-win32 if-win32)) (defmacro foreach (var args &rest body) (` (mapcar '(lambda ((, var)) (,@ body)) (, args)))) (put 'foreach 'lisp-indent-function 2) (defun filter (predicate list) "Return list containing only those elements of LIST which match PREDICATE" (let (new-list) (while list (if (apply predicate (list (car list))) (setq new-list (cons (car list) new-list))) (setq list (cdr list))) (nreverse new-list))) (defun join (separator list) "Use SEPARATOR to join the strings in LIST together." (mapconcat 'identity list separator)) ;; macro that makes it easy to set up commands (defmacro clambda (&rest body) `(lambda () (interactive) ,@body)) (defun add-auto-mode (regexp mode) "Ensure that files matching REGEXP start in mode MODE. Does nothing if REGEXP is already registered in auto-mode-alist." (interactive "sRegexp: \nCMode: ") (or (assoc regexp auto-mode-alist) (setq auto-mode-alist (cons (cons regexp mode) auto-mode-alist)))) (defun remove-auto-mode (mode) "Removes all regexps that start MODE from auto-mode-alist. MODE may also be a list of modes." (interactive "CMode: ") (cond ((symbolp mode) (setq mode (list mode))) ((listp mode) nil) (t (error "%s is not a list or mode symbol"))) (setq auto-mode-alist (apply 'append (mapcar '(lambda (p) (if (memq (cdr p) mode) nil (list p))) auto-mode-alist)))) ;; ---- standard c/c++ stuff (setq c-style-variables-are-local-p t) (defconst im-c-style '((c-basic-offset . 4) (c-hanging-comment-ender-p . nil) (indent-tabs-mode . nil) (c-offsets-alist . ((substatement-open . 0) (inline-open . 0) (label . 0) (access-label . -) (arglist-cont . 0) (case-label . 0) (statement-case-open . +) (statement-case-intro . +)))) "Infinite Machine standard C and C++ style") (eval-after-load "cc-mode" '(progn (c-add-style "IM-c" im-c-style))) (defun im-set-style() (c-set-style "IM-c")) (add-hook 'c-mode-hook 'im-set-style) (add-hook 'c++-mode-hook 'im-set-style) (provide 'gw-utils)
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#2 | 302 | paul_dubois |
Remove dependency on gw-utils.el A batch of small bug fixes, mostly dealing with depots that aren't named "depot" |
||
#1 | 301 | paul_dubois | Initial checkpoint of p4.el |