Common Lisp Package: COM.INFORMATIMAGO.COMMON-LISP.ED.ED

This package exports an implementation of the COMMON-LISP ED function following the user manual of ed(1). ed(1) in COMMON-LISP. Real men do it with magnets. ed is for girly men. This is a clone of the unix ed(1) editor written in pure Common-Lisp. Since Common-Lisp does not define any process management functions, all !command forms are taken as Lisp forms instead of sh(1) commands. These forms are executed within a (LAMBDA (*INPUT*) command) with the *INPUT* argument bound to a mutable list of inmutable input strings, one per line. The result of the returning form in command must be a list of string, the list of resulting lines to be inserted into the buffer or to be printed on the terminal. For the rest, the aim is to be 100% user-interface compatible with ed(1). Ed, man! !man ed: <http://www.gnu.org/fun/jokes/ed.msg.html> Can you imagine that some Common-Lisp implementations DON'T provide any editor (in conformity with the Common-Lisp specifications)? Not complete (waiting for a REGEXP package). But otherwise functional enough. License: AGPL3 Copyright Pascal J. Bourguignon 2003 - 2012 This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 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 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/>

README:

FUNCTION

Public

ED (&OPTIONAL X)

DO: Invokes the ed(1)-like editor. X: NIL, a pathname, a string, or a function name. The default is NIL.

Private

BUFFER-COMMAND (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

BUFFER-CUT-LINES (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

BUFFER-GOT-ERROR (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

BUFFER-LAST-ERROR (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

BUFFER-LINE-CONS (BUFFER LINUM)

Return the cons cells where the line LINUM of the BUFFER is stored.

BUFFER-LINES (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

BUFFER-MARKS (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

BUFFER-MODIFIED (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

BUFFER-OLD-LINES (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

BUFFER-OLD-MARKS (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

BUFFER-PATH (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

BUFFER-PRINT (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

BUFFER-PROMPT-STRING (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

BUFFER-QUIT (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

BUFFER-SHOW-ERRORS (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

BUFFER-SHOW-PROMPT (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

CMD-EDIT-OR-READ (BUFFER ARG LINUM)

LINUM: NIL ==> Edit, NUMBERP ==> Read

DO-CUT (BUFFER FROM LAST)

RETURN: The list of cut lines.

FILE-OR-COMMAND-ARG (ARG)

--> :empty --> :path ; path ; exists (t/nil) --> :command ; command --> :command-append ; command --> :invalid ; error-message

SKIP-SPACES (COMMAND &OPTIONAL (START 0))

RETURN: The index of the next non white space character in command, starting from position, or nil if end of string.

Undocumented

ADDRESS->LINUM (BUFFER ADDRESS &OPTIONAL (MIN 1))

BUFFER-CLEAR-ERROR (BUFFER)

SETFBUFFER-COMMAND (NEW-VALUE INSTANCE)

BUFFER-CURRENT-LINUM (BUFFER)

SETFBUFFER-CURRENT-LINUM (NEW-LINUM BUFFER)

SETFBUFFER-CUT-LINES (NEW-VALUE INSTANCE)

BUFFER-ERASE (BUFFER)

BUFFER-FROM-STRING (TEXT)

BUFFER-GET-MARK (BUFFER CH)

SETFBUFFER-GOT-ERROR (NEW-VALUE INSTANCE)

SETFBUFFER-LAST-ERROR (NEW-VALUE INSTANCE)

BUFFER-LENGTH (BUFFER)

SETFBUFFER-LINES (NEW-VALUE INSTANCE)

SETFBUFFER-MARKS (NEW-VALUE INSTANCE)

SETFBUFFER-MODIFIED (NEW-VALUE INSTANCE)

BUFFER-NTH-LINE (BUFFER LINUM)

BUFFER-OFFSET-MARKS (BUFFER FROM OFFSET)

SETFBUFFER-OLD-LINES (NEW-VALUE INSTANCE)

SETFBUFFER-OLD-MARKS (NEW-VALUE INSTANCE)

BUFFER-P (OBJECT)

SETFBUFFER-PATH (NEW-VALUE INSTANCE)

SETFBUFFER-PRINT (NEW-VALUE INSTANCE)

SETFBUFFER-PROMPT-STRING (NEW-VALUE INSTANCE)

SETFBUFFER-QUIT (NEW-VALUE INSTANCE)

BUFFER-READ (PATH)

BUFFER-SAVE-UNDO (BUFFER)

BUFFER-SET-ERROR (BUFFER MESSAGE)

BUFFER-SET-MARK (BUFFER CH LINUM)

SETFBUFFER-SHOW-ERRORS (NEW-VALUE INSTANCE)

SETFBUFFER-SHOW-PROMPT (NEW-VALUE INSTANCE)

BUFFER-SWAP-UNDO (BUFFER)

CMD-APPEND (BUFFER FROM TO ARG)

CMD-APPEND-FILE (BUFFER FROM TO ARG)

CMD-CHANGE-LINES (BUFFER FROM TO ARG)

CMD-COMMENT (BUFFER FROM TO ARG)

CMD-COPY (BUFFER FROM TO ARG)

CMD-COPY-LINES (BUFFER FROM TO ARG)

CMD-DELETE-LINES (BUFFER FROM TO ARG)

CMD-EDIT-FILE (BUFFER FROM TO ARG)

CMD-EDIT-FILE-UNCONDITIONALLY (BUFFER FROM TO ARG)

CMD-EDIT-MATCHING (BUFFER FROM TO ARG)

CMD-EDIT-NOT-MATCHING (BUFFER FROM TO ARG)

CMD-INSERT (BUFFER FROM TO ARG)

CMD-JOIN-LINES (BUFFER FROM TO ARG)

CMD-MARK (BUFFER FROM TO ARG)

CMD-MOVE-LINES (BUFFER FROM TO ARG)

CMD-PASTE (BUFFER FROM TO ARG)

CMD-PRINT-LAST-ERROR (BUFFER FROM TO ARG)

CMD-PRINT-LINE-NUMBER (BUFFER FROM TO ARG)

CMD-PRINT-LINES (BUFFER FROM TO ARG)

CMD-PRINT-LINES-AND-NUMBERS (BUFFER FROM TO ARG)

CMD-PRINT-LINES-UNAMBIGUOUSLY (BUFFER FROM TO ARG)

CMD-QUIT (BUFFER FROM TO ARG)

CMD-QUIT-UNCONDITIONNALY (BUFFER FROM TO ARG)

CMD-READ-FILE (BUFFER FROM TO ARG)

CMD-SCROLL-LINES (BUFFER FROM TO ARG)

CMD-SET-DEFAULT-FILENAME (BUFFER FROM TO ARG)

CMD-SUBSHELL (BUFFER FROM TO ARG)

CMD-SUBSTITUTE (BUFFER FROM TO ARG)

CMD-TOGGLE-COMMAND-PROMPT (BUFFER FROM TO ARG)

CMD-TOGGLE-ERROR-EXPLANATIONS (BUFFER FROM TO ARG)

CMD-UNDO (BUFFER FROM TO ARG)

CMD-USER-EDIT-MATCHING (BUFFER FROM TO ARG)

CMD-USER-EDIT-NOT-MATCHING (BUFFER FROM TO ARG)

CMD-WRITE-FILE (BUFFER FROM TO ARG)

CMD-WRITE-FILE-QUIT (BUFFER FROM TO ARG)

CMD-WRITE-OR-APPEND (BUFFER FROM TO ARG MODE)

COPY-BUFFER (INSTANCE)

COPY-MARKS (MARKS)

DO-COMMAND (BUFFER &KEY (INPUT NIL) (OUTPUT PRINT))

DO-INSERT (BUFFER LINUM)

DO-PASTE (BUFFER LINUM NEW-LINES)

DO-PRINT-LINES (BUFFER CURR LAST FUNC)

DO-READ (BUFFER PATH LINUM)

DO-WRITE (BUFFER PATH MODE FROM LAST)

EDIT (BUFFER)

FILTER-COMMAND-OUTPUT (OUTPUT)

LIMIT (VALUE MIN MAX)

MAKE-BUFFER (&KEY ((PATH DUM6) NIL) ((LINES DUM7) '(0)) ((MARKS DUM8) 'NIL) ((OLD-LINES DUM9) '(0)) ((OLD-MARKS DUM10) 'NIL) ((CUT-LINES DUM11) 'NIL) ((SHOW-ERRORS DUM12) NIL) ((GOT-ERROR DUM13) NIL) ((LAST-ERROR DUM14) ) ((SHOW-PROMPT DUM15) NIL) ((PROMPT-STRING DUM16) ) ((COMMAND DUM17) NIL) ((MODIFIED DUM18) NIL) ((PRINT DUM19) NIL) ((QUIT DUM20) NIL))

PARSE-ADDRESS (COMMAND POSITION)

PARSE-AND-RUN-COMMAND (BUFFER COMMAND)

MACRO

Private

Undocumented

DBG (&BODY BODY)

TOGGLE (PLACE &ENVIRONMENT ENV)

UNLESS-MODIFIED (BUFFER &BODY BODY)

WITH-ADDRESSES ((BUFFER . ADDRESSES) &BODY BODY)

VARIABLE

Private

Undocumented

*COMMANDS*

*CURRENT-BUFFER*

*SHOW-DEBUG*

TEST-TEXT

CLASS

Private

Undocumented

BUFFER

CONSTANT

Private

Undocumented

+DEBUG+