Lugaru's Epsilon
Programmer's
Editor 14.04

Context:
Epsilon User's Manual and Reference
   Primitives and EEL Subroutines
      Input Primitives
         . . .
         Window Events
         Completion Subroutines
            Completion Internals
            Listing Commands & Buffers & Files
         Other Input Functions
         . . .

Previous   Up    Next
Completion Internals  Primitives and EEL Subroutines   Other Input Functions


Epsilon User's Manual and Reference > Primitives and EEL Subroutines > Input Primitives > Completion Subroutines >

Listing Commands & Buffers & Files

int name_match(char *prefix, int start)

Several primitives help to perform completion. The name_match( ) primitive takes a command prefix such as "nex" and a number. It finds the next command or other name table entry that begins with the supplied prefix, returning its name table index. If its numeric argument is nonzero, it starts at the beginning of the name table. Otherwise it continues from the name table index returned on the previous call. It returns zero when there are no more matching names. When comparing names, case doesn't count and "-" is the same as "_".

char *buf_match(char *pattern, int flags)
char *do_file_match(char *pattern, int flags)
char *low_file_match(char *pattern, int flags)
#define STARTMATCH      1
#define EXACTONLY       2
#define FM_NO_DIRS      (0x10)
#define FM_ONLY_DIRS    (0x20)
#define FM_FOLD         (0x200)
char *file_match(char *pattern, int flags)

The buf_match( ) and file_match( ) primitives may be used to find buffer or file names matching a pattern, similar to name_match( ). Instead of returning a command index, they return the actual matching buffer or file names, respectively, and return a null pointer when there are no more matches. The values returned by file_match( ) are only valid until the next call to this function. Copy the name if you want to preserve it.

The buf_match( ) primitive returns one of a series of buffer names that match a pattern. The pattern is of the sort that fpatmatch( ) accepts: * matches any number of characters, ? matches a single character, [a-z] represents a character class, and | separates alternatives. The STARTMATCH flag tells it to examine the pattern and return the first match; omitting the flag makes it return the next match of the current pattern. The EXACTONLY flag tells it to return only exact matches of the pattern; otherwise it returns buffer names that start with a match of the pattern (as if it ended in *). The FM_FOLD flag tells it to ignore case when comparing buffer names against the pattern; by default buffer names are case-sensitive (but see the preserve-filename-case variable).

The file_match( ) primitive returns one of a series of file names that match a pattern. You can use this primitive to expand file name patterns such as a*.c. See Extended file patterns for details on Epsilon's syntax for file patterns. The STARTMATCH flag tells it to examine the pattern and return the first match; omitting the flag makes it return the next match of the current pattern. The EXACTONLY flag tells it to return only exact matches of the pattern; otherwise it returns file names that start with a match of the pattern. Use the FM_NO_DIRS flags if you want to skip over directories when looking for files that match, or FM_ONLY_DIRS to retrieve only directory names.

Instead of directly calling the file_match( ) primitive, you may want to call one of the subroutines do_file_match( ) or low_file_match( ). They both take the same arguments as file_match( ) and return the same values. But they also handle URL file patterns like scp://host/*.c (unless the file-pattern-rules variable includes the FPAT_PERMIT_NO_URLS bit). Additionally, do_file_match( ) removes any " double-quote characters from the pattern before using it.

short abort_file_matching = 0;
#define ABORT_IGNORE  0   /* ignore abort key & continue */
#define ABORT_JUMP    -1  /* jump via check_abort() */
#define ABORT_ERROR   -2  /* return ABORT_ERROR as error code */

By default, the file_match( ) and do_dired( ) primitives ignore the abort key. (See Dired Subroutines for information on do_dired( ).) To permit aborting a long file match, set the primitive variable abort_file_matching using save_var to tell Epsilon what to do when the user presses the abort key. If you set abort_file_matching to ABORT_ERROR and the user presses the abort key, this function will return a failure code and set errno to EREADABORT. Set the variable to ABORT_JUMP if you want Epsilon to abort your function by calling the check_abort( ) primitive. (See Control Flow.) By default, the variable is zero, and Epsilon ignores the abort key until the primitive finishes.



Previous   Up    Next
Completion Internals  Primitives and EEL Subroutines   Other Input Functions


Lugaru Epsilon Programmer's Editor 14.04 manual. Copyright (C) 1984, 2021 by Lugaru Software Ltd. All rights reserved.