Public Vars

Back

char (clj)

(source)

function

(char x)
Coerce to char

Examples

hraberg/deuce
(ns deuce.emacs.chartab
  (:use [deuce.emacs-lisp :only (defun defvar)])
  (:require [clojure.core :as c]
            [deuce.emacs.alloc :as alloc]
            [deuce.emacs.data :as data]
            [deuce.emacs.fns :as fns])
  (:import [deuce.emacs.data CharTable]
           [java.util Arrays])
  (:refer-clojure :exclude []))

(defvar char-code-property-alist nil
  "Alist of character property name vs char-table containing property values.
  Internal use only.")

(defun char-table-parent (char-table)
  "Return the parent char-table of CHAR-TABLE.
  The value is either nil or another char-table.
  If CHAR-TABLE holds nil for a given character,
  then the actual applicable value is inherited from the parent char-table
  (or from its parents, if necessary)."
  @(.parent ^CharTable char-table))

(defun set-char-table-parent (char-table parent)
  "Set the parent char-table of CHAR-TABLE to PARENT.
  Return PARENT.  PARENT must be either nil or another char-table."
  (reset! (.parent ^CharTable char-table) parent))

(defun map-char-table (function char-table)
  "Call FUNCTION for each character in CHAR-TABLE that has non-nil value.
  FUNCTION is called with two arguments--a key and a value.
  The key is a character code or a cons of character codes specifying a
  range of characters that have the same value."
  )

(defun char-table-extra-slot (char-table n)
  "Return the value of CHAR-TABLE's extra-slot number N."
  (aget ^objects (.extras ^CharTable char-table) n))

(defun char-table-subtype (char-table)
  "Return the subtype of char-table CHAR-TABLE.  The value is a symbol."
  (.purpose ^CharTable char-table))

(defun set-char-table-range (char-table range value)
  "Set the value in CHAR-TABLE for a range of characters RANGE to VALUE.
  RANGE should be t (for all characters), nil (for the default value),
  a cons of character codes (for characters in the range),
  or a character code.  Return VALUE."
  (let [[start end] (if (data/consp range)
                      [(int (data/car range)) (int (data/cdr range))]
                      [0 (count (.contents ^CharTable  char-table))])]
    (Arrays/fill ^objects (.contents ^CharTable char-table) (int start) (int end)
                 (if (nil? range) (.defalt ^CharTable char-table) value)))
  value)

(defun get-unicode-property-internal (char-table ch)
  "Return an element of CHAR-TABLE for character CH.
  CHAR-TABLE must be what returned by `unicode-property-table-internal'."
  )

(defun set-char-table-extra-slot (char-table n value)
  "Set CHAR-TABLE's extra-slot number N to VALUE."
  (aset ^objects (.extras ^CharTable char-table) n value))

(defun unicode-property-table-internal (prop)
  "Return a char-table for Unicode character property PROP.
  Use `get-unicode-property-internal' and
  `put-unicode-property-internal' instead of `aref' and `aset' to get
  and put an element value."
  )

(def ^:private char-table-size 4194303)

(defun make-char-table (purpose &optional init)
  "Return a newly created char-table, with purpose PURPOSE.
  Each element is initialized to INIT, which defaults to nil.

  PURPOSE should be a symbol.  If it has a `char-table-extra-slots'
  property, the property's value should be an integer between 0 and 10
  that specifies how many extra slots the char-table has.  Otherwise,
  the char-table has no extra slot."
  (CharTable. init (atom nil) purpose
              (alloc/make-vector char-table-size init)
              (when-let [extras (fns/get purpose 'char-table-extra-slots)]
                (alloc/make-vector extras init))))

(defun set-char-table-default (char-table ch value)
  "This function is obsolete since 23.1;
  generic characters no longer exist.

(defun char-table-range (char-table range)
  "Return the value in CHAR-TABLE for a range of characters RANGE.
  RANGE should be nil (for the default value),
  a cons of character codes (for characters in the range), or a character code."
  )

(defun optimize-char-table (char-table &optional test)
  "Optimize CHAR-TABLE.
  TEST is the comparison function used to decide whether two entries are
  equivalent and can be merged.  It defaults to `equal'."
  nil)

(defun put-unicode-property-internal (char-table ch value)
  "Set an element of CHAR-TABLE for character CH to VALUE.
  CHAR-TABLE must be what returned by `unicode-property-table-internal'."
  )
hraberg/deuce
(ns deuce.emacs.print
  (:use [deuce.emacs-lisp :only (defun defvar)])
  (:require [clojure.core :as c]
            [clojure.string :as s]
            [deuce.emacs.buffer :as buffer]
            [deuce.emacs.data :as data]
            [deuce.emacs.editfns :as editfns]
            [deuce.emacs.fns :as fns])
  (:refer-clojure :exclude [print]))

(defvar print-charset-text-property nil
  "A flag to control printing of `charset' text property on printing a string.
  The value must be nil, t, or `default'.

  If the value is nil, don't print the text property `charset'.

  If the value is t, always print the text property `charset'.

  If the value is `default', print the text property `charset' only when
  the value is different from what is guessed in the current charset
  priorities.")

(defvar print-escape-multibyte nil
  "Non-nil means print multibyte characters in strings as \\xXXXX.
  (XXXX is the hex representation of the character code.)
  This affects only `prin1'.")

(defvar standard-output nil
  "Output stream `print' uses by default for outputting a character.
  This may be any function of one argument.
  It may also be a buffer (output is inserted before point)
  or a marker (output is inserted and the marker is advanced)
  or the symbol t (output appears in the echo area).")

(defvar float-output-format nil
  "The format descriptor string used to print floats.
  This is a %-spec like those accepted by `printf' in C,
  but with some restrictions.  It must start with the two characters `%.'.
  After that comes an integer precision specification,
  and then a letter which controls the format.
  The letters allowed are `e', `f' and `g'.
  Use `e' for exponential notation \"DIG.DIGITSeEXPT\"
  Use `f' for decimal point notation \"DIGITS.DIGITS\".
  Use `g' to choose the shorter of those two formats for the number at hand.
  The precision in any of these cases is the number of digits following
  the decimal point.  With `f', a precision of 0 means to omit the
  decimal point.  0 is not allowed with `e' or `g'.

(defvar print-escape-nonascii nil
  "Non-nil means print unibyte non-ASCII chars in strings as \\OOO.
  (OOO is the octal representation of the character code.)
  Only single-byte characters are affected, and only in `prin1'.
  When the output goes in a multibyte buffer, this feature is
  enabled regardless of the value of the variable.")

(defun print (object &optional printcharfun)
  "Output the printed representation of OBJECT, with newlines around it.
  Quoting characters are printed when needed to make output that `read'
  can handle, whenever this is possible.  For complex objects, the behavior
  is controlled by `print-level' and `print-length', which see.

     - a buffer, in which case output is inserted into that buffer at point;
     - a marker, in which case output is inserted at marker's position;
     - a function, in which case that function is called once for each
       character of OBJECT's printed representation;
     - a symbol, in which case that symbol's function definition is called; or
     - t, in which case the output is displayed in the echo area.

(defun terpri (&optional printcharfun)
  "Output a newline to stream PRINTCHARFUN.
  If PRINTCHARFUN is omitted or nil, the value of `standard-output' is used."
  (println)
  true)

(defun prin1-to-string (object &optional noescape)
  "Return a string containing the printed representation of OBJECT.
  OBJECT can be any Lisp object.  This function outputs quoting characters
  when necessary to make output that `read' can handle, whenever possible,
  unless the optional second argument NOESCAPE is non-nil.  For complex objects,
  the behavior is controlled by `print-level' and `print-length', which see.

(defun prin1 (object &optional printcharfun)
  "Output the printed representation of OBJECT, any Lisp object.
  Quoting characters are printed when needed to make output that `read'
  can handle, whenever this is possible.  For complex objects, the behavior
  is controlled by `print-level' and `print-length', which see.

     - a buffer, in which case output is inserted into that buffer at point;
     - a marker, in which case output is inserted at marker's position;
     - a function, in which case that function is called once for each
       character of OBJECT's printed representation;
     - a symbol, in which case that symbol's function definition is called; or
     - t, in which case the output is displayed in the echo area.

  If PRINTCHARFUN is omitted, the value of `standard-output' (which see)
  is used instead."
  (let [printcharfun (or printcharfun (data/symbol-value 'standard-output))
        s (prin1-to-string object)]
    (condp some [printcharfun]
      #{nil true} (editfns/message s)
      data/bufferp (binding [buffer/*current-buffer* printcharfun]
                     (editfns/insert s)))))

(defun external-debugging-output (character)
  "Write CHARACTER to stderr.
  You can call print while debugging emacs, and pass it this function
  to make it write to the debugging output."
  )

(defun princ (object &optional printcharfun)
  "Output the printed representation of OBJECT, any Lisp object.
  No quoting characters are used; no delimiters are printed around
  the contents of strings.

     - a buffer, in which case output is inserted into that buffer at point;
     - a marker, in which case output is inserted at marker's position;
     - a function, in which case that function is called once for each
       character of OBJECT's printed representation;
     - a symbol, in which case that symbol's function definition is called; or
     - t, in which case the output is displayed in the echo area.

(defun write-char (character &optional printcharfun)
  "Output character CHARACTER to stream PRINTCHARFUN.
  PRINTCHARFUN defaults to the value of `standard-output' (which see)."
  )
hraberg/deuce
(ns deuce.emacs.composite
  (:use [deuce.emacs-lisp :only (defun defvar)])
  (:require [clojure.core :as c])
  (:refer-clojure :exclude []))

(defvar compose-chars-after-function nil
  "Function to adjust composition of buffer text.

  The default value is the function `compose-chars-after'.")

(defvar auto-composition-function nil
  "Function to call to compose characters automatically.
  This function is called from the display routine with four arguments:
  FROM, TO, WINDOW, and STRING.

  If STRING is nil, the function must compose characters in the region
  between FROM and TO in the current buffer.

  Otherwise, STRING is a string, and FROM and TO are indices into the
  string.  In this case, the function must compose characters in the
  string.")

(defvar composition-function-table nil
  "Char-table of functions for automatic character composition.
  For each character that has to be composed automatically with
  preceding and/or following characters, this char-table contains
  a function to call to compose that character.

  PATTERN is a regular expression which C and the surrounding
  characters must match.

  PREV-CHARS is a non-negative integer (less than 4) specifying how many
  characters before C to check the matching with PATTERN.  If it is 0,
  PATTERN must match C and the following characters.  If it is 1,
  PATTERN must match a character before C and the following characters.

  If PREV-CHARS is 0, PATTERN can be nil, which means that the
  single character C should be composed.

  FUNC is a function to return a glyph-string representing a
  composition of the characters that match PATTERN.  It is
  called with one argument GSTRING.

  GSTRING is a template of a glyph-string to return.  It is already
  filled with a proper header for the characters to compose, and
  glyphs corresponding to those characters one by one.  The
  function must return a new glyph-string with the same header as
  GSTRING, or modify GSTRING itself and return it.

(defun composition-get-gstring (from to font-object string)
  "Return a glyph-string for characters between FROM and TO.
  If the glyph string is for graphic display, FONT-OBJECT must be
  a font-object to use for those characters.
  Otherwise (for terminal display), FONT-OBJECT must be a terminal ID, a
  frame, or nil for the selected frame's terminal device.

  If the optional 4th argument STRING is not nil, it is a string
  containing the target characters between indices FROM and TO.

  A glyph-string is a vector containing information about how to display
  a specific character sequence.  The format is:
     [HEADER ID GLYPH ...]

  HEADER is a vector of this form:
      [FONT-OBJECT CHAR ...]
  where
      FONT-OBJECT is a font-object for all glyphs in the glyph-string,
      or the terminal coding system of the specified terminal.
      CHARs are characters to be composed by GLYPHs.

  GLYPH is a vector whose elements have this form:
      [ FROM-IDX TO-IDX C CODE WIDTH LBEARING RBEARING ASCENT DESCENT
        [ [X-OFF Y-OFF WADJUST] | nil] ]
  where
      FROM-IDX and TO-IDX are used internally and should not be touched.
      C is the character of the glyph.
      CODE is the glyph-code of C in FONT-OBJECT.
      WIDTH thru DESCENT are the metrics (in pixels) of the glyph.
      X-OFF and Y-OFF are offsets to the base position for the glyph.
      WADJUST is the adjustment to the normal width of the glyph.
typedclojure/typedclojure
(ns ^:no-doc typed.ann.clojure
  "Type annotations for the base Clojure distribution."
  #?(:cljs (:require-macros [typed.ann-macros.clojure :as macros]))
  (:require [clojure.core :as cc]
            [typed.clojure :as t]
            #?(:clj [typed.ann-macros.clojure :as macros])
            #?(:clj typed.ann.clojure.jvm) ;; jvm annotations
            #?(:clj clojure.core.typed))
  #?(:clj
     (:import (clojure.lang PersistentHashSet PersistentList
                            APersistentMap #_IPersistentCollection
                            #_ITransientSet
                            IRef)
              (java.util Comparator Collection))))

cc/prefer-method [t/Multi t/Any t/Any :-> t/Any]
#?@(:cljs [] :default [
cc/print-simple [t/Any java.io.Writer :-> nil]
cc/char-escape-string (t/Map Character t/Str)
cc/char-name-string (t/Map Character t/Str)
cc/primitives-classnames (t/Map Class t/Str)
cc/namespace-munge [(t/U t/Sym t/Namespace) :-> t/Str]
;cc/find-protocol-impl ['{:on-interface Class
;                                   :impls ?}]

cc/string? (t/Pred t/Str)
cc/char? #?(:clj (t/Pred Character)
            :cljs [t/Any :-> t/Bool :filters {:then (is t/Str 0)}])

;coercions
#?@(:cljs [] :default [
cc/bigdec [(t/U t/Str t/Num) :-> BigDecimal]
cc/bigint [(t/U t/Str t/Num) :-> clojure.lang.BigInt]
cc/biginteger [(t/U t/Str t/Num) :-> java.math.BigInteger]
])
cc/boolean [t/Any :-> t/Bool]
cc/parse-boolean [t/Str :-> (t/Option t/Bool)]
cc/byte [(t/U Character t/Num) :-> Byte]
#?@(:cljs [
cc/char [(t/U t/Str t/Num) :-> t/Str]
] :default [
cc/char [(t/U Character t/Num) :-> Character]
])
cc/double [t/Num :-> #?(:cljs t/Num :default Double)]
cc/parse-double [t/Str :-> (t/Option #?(:cljs t/Num :default Double))]

;array ctors
#?@(:cljs [] :default [
cc/boolean-array (t/IFn [(t/U t/Num (t/Seqable t/Bool)) :-> (Array boolean)]
                        [t/Num (t/U t/Bool (t/Seqable t/Bool)) :-> (Array boolean)])
cc/byte-array (t/IFn [(t/U t/Num (t/Seqable Byte)) :-> (Array byte)]
                     [t/Num (t/U Byte (t/Seqable Byte)) :-> (Array byte)])
cc/char-array (t/IFn [(t/U t/Num (t/Seqable Character)) :-> (Array char)]
                     [t/Num (t/U t/Num (t/Seqable Character)) :-> (Array char)])
cc/short-array (t/IFn [(t/U t/Num (t/Seqable Short)) :-> (Array short)]
                      [t/Num (t/U Short (t/Seqable Short)) :-> (Array short)])
cc/int-array (t/IFn [(t/U t/Num (t/Seqable t/Num)) :-> (Array int)]
                    [t/Num (t/U t/Num (t/Seqable t/Num)) :-> (Array int)])
cc/double-array (t/IFn [(t/U t/Num (t/Seqable t/Num)) :-> (Array double)]
                       [t/Num (t/U t/Num (t/Seqable t/Num)) :-> (Array double)])
])

;cast to java array
;; TODO rethink input and output types. eg.,
;;      cc/booleans [(ReadyOnlyArray boolean) :-> (t/U nil (Array boolean))]
;; TODO objects??
;;      cc/objects [(ReadyOnlyArray Object) :-> (t/U nil (ReadyOnlyArray Object))]
;;                                  
;; TODO propagate to Numbers/booleans etc
;cc/booleans [t/Any :-> (t/U nil (Array boolean))]
;cc/bytes [t/Any :-> (t/U nil (Array byte))]
;cc/chars [t/Any :-> (t/U nil (Array char))]
;cc/shorts [t/Any :-> (t/U nil (Array short))]
;cc/ints [t/Any :-> (t/U nil (Array int))]
;cc/longs [t/Any :-> (t/U nil (Array long))]
;cc/floats [t/Any :-> (t/U nil (Array float))]
;cc/doubles [t/Any :-> (t/U nil (Array double))]
gga/janus
(ns janus.test.regex-unify-test
  [:require [clojure.core.logic :as logic]]
  [:use [janus.regex-unify]
   [midje.sweet]])

(fact
  (make-char-set \a \b) => [\a \b])

(facts
  (logic/run 1 [q] (charo q \a true)) => '(\a)
  (logic/run 1 [q] (charo q \a false)) => '(_.0))