LW Editor Functions not in Manual

πŸ“€: Symbol has exported from EDITOR package;
❎: Definition is not contained in Editor source code;

Movement

Regular

(point-before point) & (point-after point)

Move the POINT 1 character before / after. Like a shorthand of character-offset N=1 or -1 but slightly faster.

❎(move-to-column point column &optional (line (point-bigline point)))

Move the POINT to the COLUMN of its current regular line.

(move-point-to-offset point offset)

Move the POINT to the OFFSET position of current buffer. Similar with (setf point-position), but must be called with the buffer locked.

❎(FIND-PREVIOUS-CHARACTER POINT CHAR) & (FIND-NEXT-CHARACTER POINT CHAR)

Search character CHAR before / after the POINT. Return non-NIL and move the POINT to the position of that character if found, return NIL otherwise.

The value succesfully returned is a POINT, but it probably is not the same point with POINT and can be invalid, so do not use it.

Pixelwise

(cursorpos-to-point px y window &optional point)

Giving X position in pixels, Y in line-number, relative with WINDOW, return a nearest point of the position. If POINT is a valid editor point, move the POINT to that position instead of return a new point.

Must be called with both window and buffer locked. See Locking Window.

❎(point-to-cursorpos point window)

Return 5 values: The horizontal character offset and vertical character offset of the POINT, relative with the visible area of WINDOW; The character at that point; The editor face at that point; The position of that point at its buffer (= how many characters before it).

❎(point-to-xy-pixels window point)

Return the horizontal and vertical position of POINT in pixels, relative with the visible area of WINDOW, as 2 values.

Some source are inside searchcom.lisp of the Editor source code.

Use get-search-pattern (or new-search-pattern) and find-pattern to search through buffer programmatically.

(GET-SEARCH-PATTERN STRING DIRECTION &OPTIONAL USER-GIVEN)

Make a new search-pattern using STRING and DIRECTION. DIRECTION can be :forward, :forward-regexp, :backward, :backward-regexp. If DIRECTION is :forward-regexp or :backward-regexp, treat STRING as a LW regular expression and search with the expression. If DIRECTION is not indicate a RegEXP, search string in the way specified by default-search-kind Editor variable (:string-insensitive by default).

Calling new-search-pattern under the hood.

❎(NEW-SEARCH-PATTERN KIND DIRECTION PATTERN &OPTIONAL RESULT-SEARCH-PATTERN)

Return a newly constructed search-pattern.

KIND can be one of :string-sensitive, :string-insensitive and :string-regexp;

DIRECTION can be one of :forward and :backward;

PATTERN can be a string.

❎(FIND-PATTERN POINT SEARCH-PATTERN &OPTIONAL LIMIT)

Find the SEARCH-PATTERN 1 time, starting at POINT. LIMIT should be a point if provided.

If success, POINT will be moved to the beginning (lower position, no matter which direction) of the match, and return the length of the match (a number). Unless NIL and the POINT will not be moved.

(FIND-REGEXP-PATTERN POINT PATTERN FORWARDP TEXT-END &OPTIONAL TEXT-START)

Find regex pattern starting at POINT.

PATTERN must be a LW precompiled regular-expression

TEXT-END should be a point, indicating the search limit.

This function must be called inside a lock. It can be more efficient than find-pattern if you're reusing the precompiled regex.

The two functions use the same function to handle Regex search under the hood: find-regexp-pattern-from-line and underlying search-for-regexp. *search-pattern-experts* seems contain handlers for find-pattern.

Insertion & Deletion

Window

Locking Window

It seems that only 2 functions for window locking are reserved:

❎(lock-window-and-call func window)

Lock WINDOW and call FUNC. FUNC is called with one argument that's the WINDOW itself.

(call-with-window-and-buffer-locked window timeout function arg)

Lock WINDOW, and lock BUFFER as for modification, then call FUNCTION with ARG. The FUNCTION will receive 3 arguments: WINDOW, BUFFER and ARG.

Text Property

The text property of the buffer are constructed by a continuous sequence of text-property-regions, splitted by text-property-point. See the notes at the head of text-properties.lisp of the Editor source code.

The text-property content is a plist that can hold any keys and values. the 'editor::face property is used to implement face facility of LW Editor.

πŸ“€Interface Functions

They're same with Emacs's corresponding functions. Notes that all points are editor:point.

If modification is non-NIL, the change (of-course include the change of text properties) of the function made will be recorded into buffer's undo history using record-text-property-undo.

When modifying the value of a property using functions like put-text-property and alter-text-property, make sure you are giving them a fresh-new object, but not the original object modified, e.g. modified list using nconc or delete.

That's because these functions will merge the text-property-regions automatically, by comparing if two value objects are same using EQ (inside the same-properties-p function). Thus if you give a original object modified, the region of your modification may expand to its neighbours.

Text Property Region

Functions related with text-property-region.

See text-properties.lisp of Editor source code for more details.

(region-text-property region prop &optional default)

Retrieve the underlying text-property-region-plist of a region.

This is the only function to retrieve text-property-region-plist, since LW has shaked its accessor. To set the plist, use the interface functions above.

(region-text-property-or-default region prop)

Same with region-text-property, but take the *default-text-properties* count as the default-default.

(ensure-text-property-region start end)

Giving editor:points START and END, Return a text-property-region starting at START and ending at or before END. Second value indicates if it exactly ends at END. The third values can be :before, :after or :both, indicating whether the region has been chopped at its two sides.

If START is inside a text-property-region, the region will be chopped to be started at START; If the region is longer than END, chop the region to make it end at END;
If the region is shorter than END, return the early-ended region with second value NIL.

Buffer String

Just like Emacs's buffer-string.

(make-buffer-string &key %string properties)

Make a buffer string. Properties is a list of (start end plist) representing the text-property-region relative with the %string(constructed by bounded-text-properties-in function).

Example:

(editor::make-buffer-string 
  :%string "test"
  :properties `((0 4 (editor:face ,editor::*highlight-face*))))

(insert-buffer-string point buffer-string)

Insert buffer-string to POINT.

(points-to-buffer-string start end)

Retrieve a buffer-string between START and END. Same with Emacs's buffer-substring.

Must be called inside buffer or START point locked.

(concatenate-buffer-strings buffer-string1 buffer-string2)

Concatenate two buffer-strings.

Overlays

Much performant than Emacs's overlay, although lacking (= need hacking) for some functions.

Interface Functions

They're basically same with Emacs's corresponding functions.

Overlay Properties

Properties can be put into overlays using overlay-put, and retrieved using overlay-get.

All Property Names Are Symbols Inside the EDITOR Package (May Not Exported).

Hooks

(Probably most of) Global hooks are defined with docstrings inside the init-editor.lisp of the Editor source code. All of them are worked. Use add-global-hook to add hook object. Hook object can be a function or fbounded symbol. Symbol is recommended as it's easy to be removed using remove-global-hook.

Buffer-local hooks: