80 columns formatting fixes.
[clon.git] / package.lisp
blobd799612f9df53232757011e65e0c76951c4a99ca
1 ;;; package.lisp --- Common Lisp Package definition
3 ;; Copyright (C) 2010, 2011 Didier Verna
5 ;; Author: Didier Verna <didier@lrde.epita.fr>
6 ;; Maintainer: Didier Verna <didier@lrde.epita.fr>
8 ;; This file is part of Clon.
10 ;; Clon is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License version 3,
12 ;; as published by the Free Software Foundation.
14 ;; Clon is distributed in the hope that it will be useful,
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ;; GNU General Public License for more details.
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with this program; if not, write to the Free Software
21 ;; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 ;;; Commentary:
26 ;; Contents management by FCM version 0.1.
29 ;;; Code:
31 (in-package :cl-user)
33 (defpackage :com.dvlsoft.clon
34 (:documentation "The Command-Line Options Nuker package.")
35 (:use :cl)
36 (:shadow :*readtable*)
37 (:import-from :com.dvlsoft.clon.asdf
38 :define-constant
39 :+release-major-level+
40 :+release-minor-level+
41 :+release-status+
42 :+release-status-level+
43 :+release-name+
44 :version)
45 (:export
46 ;; From com.dvlsoft.clon.asd:
47 :+release-major-level+
48 :+release-minor-level+
49 :+release-status+
50 :+release-status-level+
51 :+release-name+
52 :version
53 ;; From package.lisp:
54 :nickname-package
55 ;; From src/util.lisp:
56 :exit
57 :cmdline
58 :dump
59 ;; From src/text.lisp:
60 :make-text
61 ;; From src/options/flag.lisp:
62 :make-flag
63 ;; From src/options/switch.lisp:
64 :make-switch
65 ;; From src/options/stropt.lisp:
66 :make-stropt
67 ;; From src/options/lispobj.lisp:
68 :make-lispobj
69 ;; From src/options/path.lisp:
70 :make-path
71 ;; From src/options/enum.lisp:
72 :make-enum
73 ;; From src/options/xswitch.lisp:
74 :make-xswitch
75 ;; From src/group.lisp:
76 :make-group :defgroup
77 ;; From src/synopsis.lisp:
78 :*default-synopsis*
79 :make-synopsis :defsynopsis
80 ;; From src/context.lisp:
81 :*current-context*
82 :make-context
83 :with-context
84 :progname
85 :remainder
86 :getopt
87 :getopt-cmdline
88 :multiple-value-getopt-cmdline
89 :do-cmdline-options
90 :help))
93 (in-package :com.dvlsoft.clon)
96 ;; -------------------
97 ;; External utilities:
98 ;; -------------------
100 (defun nickname-package (&optional (nickname :clon))
101 "Add NICKNAME (:CLON by default) to the :COM.DVLSOFT.CLON package."
102 (rename-package :com.dvlsoft.clon
103 (package-name :com.dvlsoft.clon)
104 (adjoin nickname (package-nicknames :com.dvlsoft.clon)
105 :test #'string-equal)))
108 ;; -------------------
109 ;; Internal utilities:
110 ;; -------------------
112 (defvar *readtable* (copy-readtable)
113 "The Clon readtable.")
115 (defun tilde-reader (stream char)
116 "Read a series of ~\"strings\" to be concatenated together."
117 (declare (ignore char))
118 (apply #'concatenate 'string
119 (loop :for str := (read stream t nil t)
120 :then (progn (read-char stream t nil t)
121 (read stream t nil t))
122 :collect str
123 :while (eql (peek-char t stream nil nil t) #\~))))
125 (set-macro-character #\~ #'tilde-reader nil *readtable*)
127 ;; ECL and CLISP do not like to see undefined reader macros in expressions
128 ;; that belong to other compilers. For instance this will break:
129 ;; #+ccl (#_ccl-only-function)
130 ;; It seems to be a correct behavior (see *read-suppress* in CLHS), although
131 ;; other implementations like SBCL and CMUCL are more gentle. The solution I
132 ;; use is to define those reader macros to simply return nil.
133 #+(or ecl clisp)
134 (progn
136 (defun dummy-reader (stream subchar args)
137 "Return nil."
138 (declare (ignore stream subchar args))
139 nil)
141 (set-dispatch-macro-character #\# #\_ #'dummy-reader *readtable*)
142 (set-dispatch-macro-character #\# #\$ #'dummy-reader *readtable*))
144 (defmacro in-readtable (name)
145 "Set the current readtable to the value of NAME::*READTABLE*."
146 `(eval-when (:compile-toplevel :load-toplevel :execute)
147 (setf cl:*readtable* (symbol-value (find-symbol "*READTABLE*" ,name)))))
150 ;;; package.lisp ends here