view src/intervals.h @ 4872:628cbf7e7005

(comint-after-partial-file-name-command): Renamed from comint-after-partial-pathname-command. (comint-match-partial-file-name, comint-after-partial-file-name): Renamed from comint-match-partial-pathname, etc. (comint-last-output-start): New variable to record where most recent process output started from. (comint-mode): Initialise it. (comint-output-filter): Set it. (comint-previous-matching-input-string): Moved to comint-previous-matching-input-position. (comint-previous-matching-input-string): Use it. (comint-search-arg, comint-search-start, comint-previous-input-string): New subroutines. (comint-previous-input, comint-next-input, comint-previous-matching-input, comint-next-matching-input, comint-previous-matching-input-from-input, comint-next-matching-input-from-input): Use them. (comint-mode-map): Added signal menu-bar. Moved comint-backward/forward-matching-input to output menu-bar, since they move within the buffer rather than do input. (comint-send-input, comint-after-pmark-p, comint-kill-input, comint-proc-query): Removed serialisation of obtaining the process mark's marker-position. Commented out comint-load-hooks. (comint-dynamic-simple-complete): New subroutine. (comint-dynamic-complete-filename-command): New variable. (comint-after-partial-pathname-command): New variable. (comint-after-partial-pathname): New subroutine. (comint-dynamic-complete): Use them. (comint-mode): Make them local. Renamed comint-dynamic-complete-command to comint-dynamic-complete-command-command for consistency. Renamed comint-file-name-addsuffix/autolist/recexact to comint-completion-addsuffix/autolist/recexact for consistency. (comint-replace-by-expanded-history): Check if input ring size is not big enough for relative reference. (comint-read-input-ring, comint-input-ring-file-name): From shell.el. (shell-write-input-ring): New subroutine. (comint-file-name-prefix): New variable. (comint-directory): New inline subroutine. (comint-dynamic-complete-filename, comint-dynamic-complete-variable, comint-dynamic-list-filename-completions): Use it. (comint-dynamic-complete-filename, comint-dynamic-complete-variable, comint-dynamic-list-filename-completions): Make sure local completion-ignore-case is nil. (comint-next-prompt, comint-previous-prompt): Use paragraph-start and paragraph motion commands rather than re-search-forward and re-search-backward commands. (comint-dynamic-list-input-ring, comint-previous-matching-input-string): Use ring-empty-p rather than zerop and ring-length. (comint-input-ignoredups): New variable. (comint-send-input, shell-read-input-ring): Use it. (comint-mode): Make comint-input-ignoredups local. Doc fix. (comint-scroll-to-bottom-on-input): New variable. (comint-scroll-to-bottom-on-output): New variable. (comint-scroll-show-maximum-output): New variable. (comint-output-filter-hook): New variable, defaults to comint-postoutput-scroll-to-bottom. (comint-output-filter): Renamed from comint-filter for consistency. Now calls comint-output-filter-hook. (comint-preinput-scroll-to-bottom): New subroutine. (comint-postoutput-scroll-to-bottom): New subroutine. (comint-show-maximum-output): New command. (comint-copy-old-input): New command. (comint-send-input): Run comint-output-filter-hook if necessary as a kludge to prevent messy redisplays. (comint-mode-map): Added comint-show-maximum-output to C-c C-e and menu-bar output, and comint-copy-old-input to C-c C-i and menu-bar input. (comint-mode): Make local variables comint-scroll-to-bottom-on-input, before-change-function, comint-scroll-to-bottom-on-output, comint-scroll-show-maximum-output, and comint-output-filter-hook. (comint-version): Deleted--no need for separate version. (comint-input-ring-index): Make this a permanent local. (comint-mode): Don't alter comint-input-ring-index or comint-input-ring if already set meaningfully. (comint-mode-map): Added keys M-R/S for comint-previous/next-matching-input-from-input and to completion menu-bar. Added comint-forward/backward-matching-input and comint-previous/next-matching-input to completion menu-bar. (comint-mode): Doc fix for functionality. (comint-exec-1): Uses setenv. (comint-update-env): Removed. (comint-input-ring-size): Incremented to 32, as with command history. (comint-dynamic-list-input-ring): Check for zero length ring. Use ring length, not ring size, when generating list. Use buffer " *Input History*". (comint-previous-matching-input-string): Check for zero-length ring. Check last item in case at end of cycle and it's a match. (comint-searching-input-ring): New subroutine. (comint-regexp-arg): New subroutine. (comint-previous-matching-input-from-input): New command. (comint-next-matching-input-from-input): New command. (comint-replace-by-expanded-history): Fix for matching inside quotes. Fix to allow argument subrange specifiers. Fix to identify and reject absolute input number references. (comint-within-quotes): New subroutine. (comint-how-many-region): New subroutine. (comint-args): New subroutine. (comint-delim-arg): New subroutine. (comint-arguments): New subroutine. (comint-delimiter-argument-list): New variable. (comint-send-input): Inserts input arguments into ring separated by single spaces. (comint-filter): Checks the buffer's process to make sure it's still there. Otherwise, set-buffer will fail. (comint-backward-matching-input): New command. (comint-forward-matching-input): New command. (comint-next-prompt, comint-previous-prompt): Error if reach beg/end of buffer. (comint-dynamic-complete): Fix for absolute input number references. (comint-dynamic-complete-filename): Changed listings function to comint-dynamic-list-filename-completions. Uses file-directory-p rather than string-match to test for directories. (comint-dynamic-list-completions): Changed to list the list of completions supplied as the function argument. Use buffer " *Completions*". (comint-match-partial-pathname): New subroutine. (comint-dynamic-complete-variable): New command. (comint-dynamic-list-filename-completions): New function. (comint-previous-input): Don't use replace-match; just insert before deleting. (comint-magic-space): Use self-insert command. (comint-history-file-name): New variable. (comint-mode): Initialize comint-input-ring before running comint-mode-hook. (comint-input-autoexpand): New variable. (comint-dynamic-complete-command): New variable. (comint-get-current-command): New variable. (comint-read-input-ring): New function. (comint-send-input): Handle history expansion. (comint-input-sentinel): Doc fix. (comint-mode-map): Added key binding for C-c C-h. Added menu bars for completion, input and output. (comint-dynamic-list-input-ring): New function. (comint-previous-input-string): New subroutine. (comint-previous-input): Use it. (comint-previous-matching-input-string): New subroutine. (comint-previous-matching-input): Use it. (comint-replace-by-expanded-history): New command. (comint-magic-space): New command. (comint-replace-by-expanded-filename): Now replaces expanded match for a filename, and then calls filename completion comint-dynamic-complete-filename to do file name completion. (comint-kill-output): Don't kill prompt. (comint-show-output): Don't move point if it's visible where it is, and if point is moved, put it after prompt. (comint-dynamic-complete): Totally new definition. (comint-dynamic-complete-filename): New name for old function comint-dynamic-complete, completes files and lists candidates, souped up for configurability. (comint-dynamic-complete-variable): New command. (comint-file-name-autolist): New variable. (comint-file-name-addsuffix): New variable, (comint-file-name-recexact): New variable.
author Richard M. Stallman <rms@gnu.org>
date Fri, 22 Oct 1993 02:57:36 +0000
parents c11d710e0403
children 39f0a30bb163
line wrap: on
line source

/* Definitions and global variables for intervals.
   Copyright (C) 1993 Free Software Foundation, Inc.

This file is part of GNU Emacs.

GNU Emacs is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 1, or (at your option)
any later version.

GNU Emacs 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 General Public License for more details.

You should have received a copy of the GNU General Public License
along with GNU Emacs; see the file COPYING.  If not, write to
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */

#ifdef USE_TEXT_PROPERTIES
#ifndef NORMAL_FACE
#include "dispextern.h"
#endif

#define NULL_INTERVAL 0
#define INTERVAL_DEFAULT NULL_INTERVAL

/* These are macros for dealing with the interval tree. */

/* Size of the structure used to represent an interval */
#define INTERVAL_SIZE (sizeof (struct interval))

/* Size of a pointer to an interval structure */
#define INTERVAL_PTR_SIZE (sizeof (struct interval *))

/* True if an interval pointer is null, or is a Lisp_Buffer or
   Lisp_String pointer (meaning it points to the owner of this
   interval tree.) */
#define NULL_INTERVAL_P(i) ((i) == NULL_INTERVAL ||                    \
			    XTYPE ((Lisp_Object)(i)) == Lisp_Buffer || \
			    XTYPE ((Lisp_Object)(i)) == Lisp_String)

/* True if this interval has no right child. */
#define NULL_RIGHT_CHILD(i) (NULL_INTERVAL_P((i)->right))

/* True if this interval has no left child. */
#define NULL_LEFT_CHILD(i) (NULL_INTERVAL_P((i)->left))

/* True if this interval has no parent. */
#define NULL_PARENT(i) (NULL_INTERVAL_P((i)->parent))

/* True if this interval is the left child of some other interval. */
#define AM_LEFT_CHILD(i) (! NULL_INTERVAL_P ((i)->parent) \
			  && (i)->parent->left == (i))

/* True if this interval is the right ehild of some other interval. */
#define AM_RIGHT_CHILD(i) (! NULL_INTERVAL_P ((i)->parent) \
			   && (i)->parent->right == (i))

/* True if this interval has no children. */
#define LEAF_INTERVAL_P(i) ((i)->left == NULL_INTERVAL \
			    && (i)->right == NULL_INTERVAL)

/* True if this interval has no parent and is therefore the root. */
#define ROOT_INTERVAL_P(i) (NULL_PARENT (i))

/* True if this interval is the only interval in the interval tree. */
#define ONLY_INTERVAL_P(i) (ROOT_INTERVAL_P((i)) && LEAF_INTERVAL_P ((i)))

/* True if this interval has both left and right children. */
#define BOTH_KIDS_P(i) ((i)->left != NULL_INTERVAL     \
			&& (i)->right != NULL_INTERVAL)

/* The total size of all text represented by this interval and all its
   children in the tree.   This is zero if the interval is null. */
#define TOTAL_LENGTH(i) ((i) == NULL_INTERVAL ? 0 : (i)->total_length)

/* The size of text represented by this interval alone. */
#define LENGTH(i) ((i) == NULL_INTERVAL ? 0 : (TOTAL_LENGTH ((i))          \
					       - TOTAL_LENGTH ((i)->right) \
					       - TOTAL_LENGTH ((i)->left)))

/* The absolute index of the last character belonging to I.  Note that
   the position cache i->position must be valid for this to work. */
#define INTERVAL_LAST_POS(i) ((i)->position + LENGTH ((i)) - 1)

/* The total size of the left subtree of this interval. */
#define LEFT_TOTAL_LENGTH(i) ((i)->left ? (i)->left->total_length : 0)

/* The total size of the right subtree of this interval. */
#define RIGHT_TOTAL_LENGTH(i) ((i)->right ? (i)->right->total_length : 0)


/* These macros are for dealing with the interval properties. */

/* True if this is a default interval, which is the same as being null
   or having no properties. */
#define DEFAULT_INTERVAL_P(i) (NULL_INTERVAL_P (i) || EQ ((i)->plist, Qnil))

/* Reset this interval to its vanilla, or no-property state. */
#define RESET_INTERVAL(i) { \
			      (i)->total_length = (i)->position = 0;    \
			      (i)->left = (i)->right = NULL_INTERVAL;   \
			      (i)->parent = NULL_INTERVAL;              \
			      (i)->write_protect = 0;                   \
			      (i)->visible = 0;                         \
			      (i)->front_sticky = (i)->rear_sticky = 0; \
			      (i)->plist = Qnil;         \
			  }

/* Copy the cached property values of interval FROM to interval TO. */
#define COPY_INTERVAL_CACHE(from,to) \
{ \
  (to)->write_protect = (from)->write_protect; \
  (to)->visible = (from)->visible;             \
  (to)->front_sticky = (from)->front_sticky;   \
  (to)->rear_sticky = (from)->rear_sticky;     \
}

/* Copy only the set bits of FROM's cache. */
#define MERGE_INTERVAL_CACHE(from,to) \
{ \
  if ((from)->write_protect) (to)->write_protect = 1; \
  if ((from)->visible) (to)->visible = 1;             \
  if ((from)->front_sticky) (to)->front_sticky = 1;   \
  if ((from)->rear_sticky) (to)->rear_sticky = 1;     \
}

/* Macro determining whether the properties of an interval being
   inserted should be merged with the properties of the text where
   they are being inserted. */
#define MERGE_INSERTIONS(i) 1

/* Macro determining if an invisible interval should be displayed
   as a special glyph, or not at all. */
#define DISPLAY_INVISIBLE_GLYPH(i) 0

/* Is this interval visible?  Replace later with cache access */
#define INTERVAL_VISIBLE_P(i) \
  (! NULL_INTERVAL_P (i) && NILP (textget ((i)->plist, Qinvisible)))

/* Is this interval writable?  Replace later with cache access */
#define INTERVAL_WRITABLE_P(i)					\
  (! NULL_INTERVAL_P (i)					\
   && (NILP (textget ((i)->plist, Qread_only))			\
       || ((CONSP (Vinhibit_read_only)				\
	    ? !NILP (Fmemq (textget ((i)->plist, Qread_only),	\
			    Vinhibit_read_only))		\
	    : !NILP (Vinhibit_read_only)))))			\

/* Macros to tell whether insertions before or after this interval
   should stick to it. */
/* Replace later with cache access */
/*#define FRONT_STICKY_P(i) ((i)->front_sticky != 0)
  #define END_STICKY_P(i) ((i)->rear_sticky != 0)*/
#define FRONT_STICKY_P(i) \
  (! NULL_INTERVAL_P (i) && ! NILP (textget ((i)->plist, Qfront_sticky)))
#define END_NONSTICKY_P(i) \
  (! NULL_INTERVAL_P (i) && ! NILP (textget ((i)->plist, Qrear_nonsticky)))


/* Declared in alloc.c */

extern INTERVAL make_interval ();

/* Declared in intervals.c */

extern Lisp_Object interval_balance_threshold;

extern INTERVAL create_root_interval ();
extern void copy_properties ();
extern int intervals_equal ();
extern void traverse_intervals ();
extern INTERVAL split_interval_right (), split_interval_left ();
extern INLINE INTERVAL find_interval ();
extern INTERVAL next_interval (), previous_interval ();
extern INTERVAL merge_interval_left (), merge_interval_right ();
extern void delete_interval ();
extern INLINE void offset_intervals ();
extern void graft_intervals_into_buffer ();
extern void set_point ();
extern INLINE void temp_set_point ();
extern void verify_interval_modification ();
extern INTERVAL balance_intervals ();
extern INLINE void copy_intervals_to_string ();
extern INTERVAL copy_intervals ();
extern Lisp_Object textget ();
extern Lisp_Object textget_direct ();
extern Lisp_Object get_local_map ();

/* Declared in textprop.c */

/* Types of hooks. */
extern Lisp_Object Qmouse_left;
extern Lisp_Object Qmouse_entered;
extern Lisp_Object Qpoint_left;
extern Lisp_Object Qpoint_entered;
extern Lisp_Object Qmodification_hooks;
extern Lisp_Object Qcategory;
extern Lisp_Object Qlocal_map;

/* Visual properties text (including strings) may have. */
extern Lisp_Object Qforeground, Qbackground, Qfont, Qunderline, Qstipple;
extern Lisp_Object Qinvisible, Qhidden, Qread_only;

extern Lisp_Object Vinhibit_point_motion_hooks;

/* Sticky properties */
extern Lisp_Object Qfront_sticky, Qrear_nonsticky;

extern Lisp_Object Ftext_properties_at ();
extern Lisp_Object Fnext_property_change (), Fprevious_property_change ();
extern Lisp_Object Fadd_text_properties (), Fset_text_properties ();
extern Lisp_Object Fremove_text_properties (), Ferase_text_properties ();
extern Lisp_Object Ftext_property_any (), Ftext_property_not_all ();
extern Lisp_Object copy_text_properties ();

extern void syms_of_textprop ();

#else  /* don't support text properties */

#define NULL_INTERVAL_P(i) 1
#define INTERVAL_SIZE 0
#define INTERVAL_PTR_SIZE 0

#define copy_intervals_to_string(string,buffer,position,length)
#define verify_interval_modification(buffer,start,end)
#define insert_interval_copy(source,position,end,sink,at)
#define graft_intervals_into_buffer(tree,position,bufferptr)
#define offset_intervals(buffer,position,length)
#define copy_intervals(tree,start,length)

#define syms_of_textprop()

#endif /* don't support text properties */