+;;; @ Basic lisp subroutines.
+;;;
+
+(defmacro lambda (&rest cdr)
+ "Return a lambda expression.
+A call of the form (lambda ARGS DOCSTRING INTERACTIVE BODY) is
+self-quoting; the result of evaluating the lambda expression is the
+expression itself. The lambda expression may then be treated as a
+function, i.e., stored as the function value of a symbol, passed to
+funcall or mapcar, etc.
+
+ARGS should take the same form as an argument list for a `defun'.
+DOCSTRING is an optional documentation string.
+ If present, it should describe how to call the function.
+ But documentation strings are usually not useful in nameless functions.
+INTERACTIVE should be a call to the function `interactive', which see.
+It may also be omitted.
+BODY should be a list of lisp expressions."
+ ;; Note that this definition should not use backquotes; subr.el should not
+ ;; depend on backquote.el.
+ (list 'function (cons 'lambda cdr)))
+
+(defun force-mode-line-update (&optional all)
+ "Force the mode-line of the current buffer to be redisplayed.
+With optional non-nil ALL, force redisplay of all mode-lines."
+ (if all (save-excursion (set-buffer (other-buffer))))
+ (set-buffer-modified-p (buffer-modified-p)))
+
+(defalias 'set-match-data 'store-match-data)
+
+(defvar save-match-data-internal)
+
+;; We use save-match-data-internal as the local variable because
+;; that works ok in practice (people should not use that variable elsewhere).
+(defmacro save-match-data (&rest body)
+ "Execute the BODY forms, restoring the global value of the match data."
+ (` (let ((save-match-data-internal (match-data)))
+ (unwind-protect (progn (,@ body))
+ (set-match-data save-match-data-internal)))))
+
+
+;;; @ Basic editing commands.
+;;;
+
+;; 18.55 does not have these variables.
+(defvar buffer-undo-list nil
+ "List of undo entries in current buffer.
+APEL provides this as dummy for a compatibility.")
+
+(defvar auto-fill-function nil
+ "Function called (if non-nil) to perform auto-fill.
+APEL provides this as dummy for a compatibility.")
+
+(defvar unread-command-event nil
+ "APEL provides this as dummy for a compatibility.")
+(defvar unread-command-events nil
+ "List of events to be read as the command input.
+APEL provides this as dummy for a compatibility.")
+
+;; (defvar minibuffer-setup-hook nil
+;; "Normal hook run just after entry to minibuffer.")
+;; (defvar minibuffer-exit-hook nil
+;; "Normal hook run just after exit from minibuffer.")
+
+(defvar minor-mode-map-alist nil
+ "Alist of keymaps to use for minor modes.
+APEL provides this as dummy for a compatibility.")
+
+(defalias 'insert-and-inherit 'insert)
+(defalias 'insert-before-markers-and-inherit 'insert-before-markers)
+(defalias 'number-to-string 'int-to-string)
+
+(defun generate-new-buffer-name (name &optional ignore)
+ "Return a string that is the name of no existing buffer based on NAME.
+If there is no live buffer named NAME, then return NAME.
+Otherwise modify name by appending `<NUMBER>', incrementing NUMBER
+until an unused name is found, and then return that name.
+Optional second argument IGNORE specifies a name that is okay to use
+\(if it is in the sequence to be tried\)
+even if a buffer with that name exists."
+ (if (get-buffer name)
+ (let ((n 2) new)
+ (while (get-buffer (setq new (format "%s<%d>" name n)))
+ (setq n (1+ n)))
+ new)
+ name))
+
+(or (fboundp 'si:mark)
+ (fset 'si:mark (symbol-function 'mark)))
+(defun mark (&optional force)
+ (si:mark))
+
+(defun window-minibuffer-p (&optional window)
+"Return non-nil if WINDOW is a minibuffer window."
+ (eq (or window (selected-window)) (minibuffer-window)))
+
+(defun window-live-p (object)
+ "Returns t if OBJECT is a window which is currently visible."
+ (and (windowp object)
+ (or (eq object (minibuffer-window))
+ (eq object (get-buffer-window (window-buffer object))))))
+
+;; Add optinal argument `hist'
+(or (fboundp 'si:read-from-minibuffer)
+ (progn
+ (fset 'si:read-from-minibuffer (symbol-function 'read-from-minibuffer))
+ (defun read-from-minibuffer (prompt &optional
+ initial-contents keymap read hist)
+
+ "Read a string from the minibuffer, prompting with string PROMPT.
+If optional second arg INITIAL-CONTENTS is non-nil, it is a string
+to be inserted into the minibuffer before reading input.
+If INITIAL-CONTENTS is (STRING . POSITION), the initial input
+is STRING, but point is placed at position POSITION in the minibuffer.
+Third arg KEYMAP is a keymap to use whilst reading;
+if omitted or nil, the default is `minibuffer-local-map'.
+If fourth arg READ is non-nil, then interpret the result as a lisp object
+and return that object:
+in other words, do `(car (read-from-string INPUT-STRING))'
+Fifth arg HIST is ignored in this implementation."
+ (si:read-from-minibuffer prompt initial-contents keymap read))))
+
+;; Add optional argument `frame'.
+(or (fboundp 'si:get-buffer-window)
+ (progn
+ (fset 'si:get-buffer-window (symbol-function 'get-buffer-window))
+ (defun get-buffer-window (buffer &optional frame)
+ "Return a window currently displaying BUFFER, or nil if none.
+Optional argument FRAME is ignored in this implementation."
+ (si:get-buffer-window buffer))))
+
+(defun walk-windows (proc &optional minibuf all-frames)
+ "Cycle through all visible windows, calling PROC for each one.
+PROC is called with a window as argument.
+
+Optional second arg MINIBUF t means count the minibuffer window even
+if not active. MINIBUF nil or omitted means count the minibuffer iff
+it is active. MINIBUF neither t nor nil means not to count the
+minibuffer even if it is active.
+Optional third argument ALL-FRAMES is ignored in this implementation."
+ (if (window-minibuffer-p (selected-window))
+ (setq minibuf t))
+ (let* ((walk-windows-start (selected-window))
+ (walk-windows-current walk-windows-start))
+ (unwind-protect
+ (while (progn
+ (setq walk-windows-current
+ (next-window walk-windows-current minibuf))
+ (funcall proc walk-windows-current)
+ (not (eq walk-windows-current walk-windows-start))))
+ (select-window walk-windows-start))))
+
+(defun buffer-disable-undo (&optional buffer)
+ "Make BUFFER stop keeping undo information.
+No argument or nil as argument means do this for the current buffer."
+ (buffer-flush-undo (or buffer (current-buffer))))
+
+
+;;; @@ Frame (Emacs 18 cannot make frame)
+;;;
+;; The following four are frequently used for manipulating the current frame.
+;; frame.el has `screen-width', `screen-height', `set-screen-width' and
+;; `set-screen-height' for backward compatibility and declare them as obsolete.
+(defun frame-width (&optional frame)
+ "Return number of columns available for display on FRAME.
+If FRAME is omitted, describe the currently selected frame."
+ (screen-width))
+
+(defun frame-height (&optional frame)
+ "Return number of lines available for display on FRAME.
+If FRAME is omitted, describe the currently selected frame."
+ (screen-height))
+
+(defun set-frame-width (frame cols &optional pretend)
+ "Specify that the frame FRAME has COLS columns.
+Optional third arg non-nil means that redisplay should use COLS columns
+but that the idea of the actual width of the frame should not be changed."
+ (set-screen-width cols pretend))
+
+(defun set-frame-height (frame lines &optional pretend)
+ "Specify that the frame FRAME has LINES lines.
+Optional third arg non-nil means that redisplay should use LINES lines
+but that the idea of the actual height of the frame should not be changed."
+ (set-screen-height lines pretend))
+
+;;; @@ Environment variables.
+;;;
+
+(autoload 'setenv "env"
+ "Set the value of the environment variable named VARIABLE to VALUE.
+VARIABLE should be a string. VALUE is optional; if not provided or is
+`nil', the environment variable VARIABLE will be removed.
+This function works by modifying `process-environment'."
+ t)