Skip to content
This repository has been archived by the owner on Mar 15, 2024. It is now read-only.

Commit

Permalink
Breaking Build. Actually evaluating the Emacs Lisp loaded more proper…
Browse files Browse the repository at this point in the history
…ly, will take a bit to settle down
  • Loading branch information
Hakan Raberg committed Sep 6, 2012
1 parent 7497be8 commit 5cf9716
Show file tree
Hide file tree
Showing 8 changed files with 109 additions and 69 deletions.
16 changes: 13 additions & 3 deletions src/deuce/emacs/data.clj
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
for example, (type-of 1) returns `integer'."
(type object))

(declare symbol-function)

(defun indirect-function (object &optional noerror)
"Return the function at the end of OBJECT's function chain.
If OBJECT is not a symbol, just return it. Otherwise, follow all
Expand All @@ -48,7 +50,7 @@
Optional arg NOERROR non-nil means to return nil instead of signaling.
Signal a cyclic-function-indirection error if there is a loop in the
function chain of symbols."
)
(symbol-function object))

(defun symbol-name (symbol)
"Return SYMBOL's name, a string."
Expand Down Expand Up @@ -79,13 +81,15 @@
"Return t if NUMBER is zero."
(zero? number))

(declare symbol-value)

(defun indirect-variable (object)
"Return the variable at the end of OBJECT's variable chain.
If OBJECT is a symbol, follow all variable indirections and return the final
variable. If OBJECT is not a symbol, just return it.
Signal a cyclic-variable-indirection error if there is a loop in the
variable chain of symbols."
)
(symbol-value object))

(defun symbol-value (symbol)
"Return SYMBOL's value. Error if that is void."
Expand Down Expand Up @@ -408,7 +412,13 @@
The optional third argument DOCSTRING specifies the documentation string
for SYMBOL; if it is omitted or nil, SYMBOL uses the documentation string
determined by DEFINITION."
(el/defvar-helper* symbol definition docstring))
(println symbol definition)
(el/defvar-helper* 'deuce.emacs symbol
(if (symbol? definition)
@(ns-resolve 'deuce.emacs definition)
definition)
docstring)
definition)

(defun setplist (symbol newplist)
"Set SYMBOL's property list to NEWPLIST, and return NEWPLIST."
Expand Down
8 changes: 5 additions & 3 deletions src/deuce/emacs/emacs.clj
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
(ns
deuce.emacs.emacs
(use [deuce.emacs-lisp :only (defun defvar)])
(require [clojure.core :as c])
(require [clojure.core :as c]
[deuce.emacs-lisp.globals :as globals])
(import [java.io File])
(:refer-clojure :exclude []))

Expand Down Expand Up @@ -45,7 +46,7 @@
(defvar system-configuration-options nil
"String containing the configuration options Emacs was built with.")

(defvar command-line-args nil
(defvar command-line-args ["deuce"]
"Args passed by shell to Emacs, as a list of strings.
Many arguments are deleted from the list as they are processed.")

Expand Down Expand Up @@ -140,7 +141,8 @@
The value of `kill-emacs-hook', if not void,
is a list of functions (of no args),
all of which are called before Emacs is actually killed."
)
(doall (map #(%) globals/kill-emacs-hook))
(System/exit 0))

(defun dump-emacs (filename symfile)
"Dump current state of Emacs into executable file FILENAME.
Expand Down
4 changes: 3 additions & 1 deletion src/deuce/emacs/eval.clj
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,9 @@
itself an alias. If NEW-ALIAS is bound, and BASE-VARIABLE is not,
then the value of BASE-VARIABLE is set to that of NEW-ALIAS.
The return value is BASE-VARIABLE."
)
(el/defvar-helper* 'deuce.emacs-lisp.globals new-alias
@(ns-resolve 'deuce.emacs-lisp.globals base-variable) docstring)
base-variable)

(defun run-hook-with-args-until-success (hook &rest args)
"Run HOOK with the specified arguments ARGS.
Expand Down
11 changes: 7 additions & 4 deletions src/deuce/emacs/fns.clj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
deuce.emacs.fns
(use [deuce.emacs-lisp :only (defun defvar)])
(require [clojure.core :as c]
[clojure.string :as s])
[clojure.string :as s]
[deuce.emacs.data :as data])
(import [deuce.emacs_lisp DottedPair]
[java.nio CharBuffer]
[java.nio.charset Charset]
Expand Down Expand Up @@ -258,7 +259,9 @@
(defun eql (obj1 obj2)
"Return t if the two args are the same Lisp object.
Floating-point numbers of equal value are `eql', but they may not be `eq'."
(identical? obj1 obj2))
(if (and (float? obj1) (float obj2))
(== obj1 obj2)
(identical? obj1 obj2)))

(defun plist-get (plist prop)
"Extract a value from a property list.
Expand Down Expand Up @@ -539,12 +542,12 @@
(defun memq (elt list)
"Return non-nil if ELT is an element of LIST. Comparison done with `eq'.
The value is actually the tail of LIST whose car is ELT."
)
(drop-while #(not (data/eq elt %)) list))

(defun memql (elt list)
"Return non-nil if ELT is an element of LIST. Comparison done with `eql'.
The value is actually the tail of LIST whose car is ELT."
)
(drop-while #(not (eql elt %)) list))

(defun gethash (key table &optional dflt)
"Look up KEY in TABLE and return its associated value.
Expand Down
50 changes: 25 additions & 25 deletions src/deuce/emacs/keymap.clj
Original file line number Diff line number Diff line change
Expand Up @@ -49,23 +49,23 @@
which binds the character CHAR to DEFINITION, or (SYMBOL . DEFINITION),
which binds the function key or mouse event SYMBOL to DEFINITION.
Initially the alist is nil.
The optional arg STRING supplies a menu name for the keymap
in case you use it as a menu with `x-popup-menu'."
)
(list 'keymap))

(defun define-key (keymap key def)
"In KEYMAP, define key sequence KEY as DEF.
KEYMAP is a keymap.
KEY is a string or a vector of symbols and characters, representing a
sequence of keystrokes and events. Non-ASCII characters with codes
above 127 (such as ISO Latin-1) can be represented by vectors.
Two types of vector have special meanings:
[remap COMMAND] remaps any key binding for COMMAND.
[t] creates a default definition, which applies to any event with no
other definition in KEYMAP.
DEF is anything that can be a key's definition:
nil (means key is undefined in this keymap),
a command (a Lisp function suitable for interactive calling),
Expand All @@ -79,7 +79,7 @@
or a cons (MAP . CHAR), meaning use definition of CHAR in keymap MAP,
or an extended menu item definition.
(See info node `(elisp)Extended Menu Items'.)
If KEYMAP is a sparse keymap with a binding for KEY, the existing
binding is altered. If there is no binding for KEY, the new pair
binding KEY to DEF is added at the front of KEYMAP."
Expand Down Expand Up @@ -112,35 +112,35 @@
If KEYMAP is nil, search all the currently active keymaps, except
for `overriding-local-map' (which is ignored).
If KEYMAP is a list of keymaps, search only those keymaps.
If optional 3rd arg FIRSTONLY is non-nil, return the first key sequence found,
rather than a list of all possible key sequences.
If FIRSTONLY is the symbol `non-ascii', return the first binding found,
no matter what it is.
If FIRSTONLY has another non-nil value, prefer bindings
that use the modifier key specified in `where-is-preferred-modifier'
(or their meta variants) and entirely reject menu bindings.
If optional 4th arg NOINDIRECT is non-nil, don't follow indirections
to other keymaps or slots. This makes it possible to search for an
indirect definition itself.
The optional 5th arg NO-REMAP alters how command remapping is handled:
- If another command OTHER-COMMAND is remapped to DEFINITION, normally
search for the bindings of OTHER-COMMAND and include them in the
returned list. But if NO-REMAP is non-nil, include the vector
[remap OTHER-COMMAND] in the returned list instead, without
searching for those other bindings.
- If DEFINITION is remapped to OTHER-COMMAND, normally return the
bindings for OTHER-COMMAND. But if NO-REMAP is non-nil, return the
bindings for DEFINITION instead, ignoring its remapping."
)

(defun keymapp (object)
"Return t if OBJECT is a keymap.
A keymap is a list (keymap . ALIST),
or a symbol whose function definition is itself a keymap.
ALIST elements look like (CHAR . DEFN) or (SYMBOL . DEFN);
Expand Down Expand Up @@ -168,22 +168,22 @@
"Return the binding for command KEY in current keymaps.
KEY is a string or vector, a sequence of keystrokes.
The binding is probably a symbol with a function definition.
Normally, `key-binding' ignores bindings for t, which act as default
bindings, used when nothing else in the keymap applies; this makes it
usable as a general function for probing keymaps. However, if the
optional second argument ACCEPT-DEFAULT is non-nil, `key-binding' does
recognize the default bindings, just as `read-key-sequence' does.
Like the normal command loop, `key-binding' will remap the command
resulting from looking up KEY by looking up the command in the
current keymaps. However, if the optional third argument NO-REMAP
is non-nil, `key-binding' returns the unmapped command.
If KEY is a key sequence initiated with the mouse, the used keymaps
will depend on the clicked mouse position with regard to the buffer
and possible local keymaps on strings.
If the optional argument POSITION is non-nil, it specifies a mouse
position as returned by `event-start' and `event-end', and the lookup
occurs in the keymaps associated with it instead of KEY. It can also
Expand All @@ -195,7 +195,7 @@
"Call FUNCTION once for each event binding in KEYMAP.
FUNCTION is called with two arguments: the event that is bound, and
the definition it is bound to. The event may be a character range.
If KEYMAP has a parent, the parent's bindings are included as well.
This works recursively: if the parent has itself a parent, then the
grandparent's bindings are also included and so on."
Expand Down Expand Up @@ -230,7 +230,7 @@
\"command undefined\". ALIST is an assoc-list which holds bindings for
function keys, mouse events, and any other things that appear in the
input stream. Initially, ALIST is nil.
The optional arg STRING supplies a menu name for the keymap
in case you use it as a menu with `x-popup-menu'."
)
Expand Down Expand Up @@ -258,13 +258,13 @@
"In keymap KEYMAP, look up key sequence KEY. Return the definition.
A value of nil means undefined. See doc of `define-key'
for kinds of definitions.
A number as value means KEY is \"too long\";
that is, characters or symbols in it except for the last one
fail to be a valid sequence of prefix characters in KEYMAP.
The number is how many characters at the front of KEY
it takes to reach a non-prefix key.
Normally, `lookup-key' ignores bindings for t, which act as default
bindings, used when nothing else in the keymap applies; this makes it
usable as a general function for probing keymaps. However, if the
Expand All @@ -276,7 +276,7 @@
"Return a pretty description of key-sequence KEYS.
Optional arg PREFIX is the sequence of keys leading up to KEYS.
For example, [?C-x ?l] is converted into the string \"C-x l\".
The `kbd' macro is an approximate inverse of this."
)

Expand All @@ -296,7 +296,7 @@
"Return the binding for command KEYS in current local keymap only.
KEYS is a string or vector, a sequence of keystrokes.
The binding is probably a symbol with a function definition.
If optional argument ACCEPT-DEFAULT is non-nil, recognize default
bindings; see the description of `lookup-key' for more details about this."
)
Expand All @@ -323,7 +323,7 @@
The binding is probably a symbol with a function definition.
This function's return values are the same as those of `lookup-key'
(which see).
If optional argument ACCEPT-DEFAULT is non-nil, recognize default
bindings; see the description of `lookup-key' for more details about this."
)
Expand All @@ -335,14 +335,14 @@
(defun command-remapping (command &optional position keymaps)
"Return the remapping for command COMMAND.
Returns nil if COMMAND is not remapped (or not a symbol).
If the optional argument POSITION is non-nil, it specifies a mouse
position as returned by `event-start' and `event-end', and the
remapping occurs in the keymaps associated with it. It can also be a
number or marker, in which case the keymap properties at the specified
buffer position instead of point are used. The KEYMAPS argument is
ignored if POSITION is non-nil.
If the optional argument KEYMAPS is non-nil, it should be a list of
keymaps to search for command remapping. Otherwise, search for the
remapping in all currently active keymaps."
Expand All @@ -357,7 +357,7 @@
non-prefix, all subsequent bindings will be omitted, since they would
be ignored. Similarly, the list doesn't include non-prefix bindings
that come after prefix bindings.
If optional argument ACCEPT-DEFAULT is non-nil, recognize default
bindings; see the description of `lookup-key' for more details about this."
)
Expand Down
Loading

0 comments on commit 5cf9716

Please sign in to comment.