Home My Page Projects Code Snippets Project Openings SML/NJ
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files

SCM Repository

[smlnj] View of /sml/trunk/sml-mode/sml-util.el
ViewVC logotype

View of /sml/trunk/sml-mode/sml-util.el

Parent Directory Parent Directory | Revision Log Revision Log

Revision 319 - (download) (annotate)
Mon Jun 7 22:47:00 1999 UTC (22 years, 2 months ago) by monnier
File size: 2432 byte(s)
First seemingly acceptable new code.
;;; sml-util.el

(defconst rcsid-sml-util "@(#)$Name$:$Id$")

;; Copyright (C) 1999-1999  Stefan Monnier <monnier@cs.yale.edu>
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, write to the Free Software
;; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

(require 'cl)
(require 'sml-compat)


(defmacro concatq (&rest ss)
  "Concatenate all the arguments and make the result a string.
As opposed to `concat', `concatq' does not evaluate its arguments
and is hence executed at macro-expansion-time."
  (apply 'concat ss))

(defun flatten (ls &optional acc)
  (if (null ls) acc
    (let ((rest (flatten (cdr ls) acc))
	  (head (car ls)))
      (if (listp head)
	  (flatten head rest)
	(cons head rest)))))

(defun custom-create-map (m bs args)
  (unless (keymapp m)
    (setq bs (append m bs))
    (setq m (make-sparse-keymap)))
  (dolist (b bs)
    (let ((key (car b))
	  (binding (cdr b)))
       ((symbolp key)
	(substitute-key-definition key binding m global-map))
       ((not (lookup-key m key))
	(define-key m key binding)))))
  (while args
    (let ((key (first args))
	  (val (second args)))
       ((eq key :inherit)
	 ((keymapp val) (set-keymap-parent m val))
	 (t (set-keymap-parents m val))))
       (t (error "Uknown argument %s in defmap" key))))
    (setq args (cddr args))))

(defmacro defmap (m bs doc &rest args)
     (defvar ,m (make-sparse-keymap) ,doc)
     (custom-create-map ,m ,bs ,(cons 'list args))))

(defmacro defsyntax (st css doc &rest args)
  `(defvar ,st
     (let ((st (make-syntax-table ,(cadr (memq :copy args)))))
       (dolist (cs ,css)
	 (let ((char (car cs))
	       (syntax (cdr cs)))
	   (if (sequencep char)
	       (mapcar* (lambda (c) (modify-syntax-entry c syntax st))
	     (modify-syntax-entry char syntax st))))

(provide 'sml-util)

ViewVC Help
Powered by ViewVC 1.0.0