⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 abbrev.c

📁 早期freebsd实现
💻 C
📖 第 1 页 / 共 2 页
字号:
  del_range (point, point + (p - buffer));  /* Now sym is the abbrev symbol. */  Vlast_abbrev = sym;  last_abbrev_point = point;  if (XTYPE (XSYMBOL (sym)->plist) == Lisp_Int)    XSETINT (XSYMBOL (sym)->plist,	     XINT (XSYMBOL (sym)->plist) + 1);	/* Increment use count */  expansion = XSYMBOL (sym)->value;  insert (XSTRING (expansion)->data, XSTRING (expansion)->size);  if (uccount && !lccount)    {      /* Abbrev was all caps */      /* If expansion is multiple words, normally capitalize each word */      /* This used to be if (!... && ... >= ...) Fcapitalize; else Fupcase	 but Megatest 68000 compiler can't handle that */      if (!abbrev_all_caps)	if (scan_words (point, -1) > scan_words (wordstart, 1))	  {	    upcase_initials_region (make_number (wordstart),				    make_number (point));	    goto caped;	  }      /* If expansion is one word, or if user says so, upcase it all. */      Fupcase_region (make_number (wordstart), make_number (point));    caped: ;    }  else if (uccount)    {      /* Abbrev included some caps.  Cap first initial of expansion */      idx = point;      SET_PT (wordstart);      Fcapitalize_word (make_number (1));      SET_PT (idx);    }  hook = XSYMBOL (sym)->function;  if (!NULL (hook))    call0 (hook);  return Qt;}DEFUN ("unexpand-abbrev", Funexpand_abbrev, Sunexpand_abbrev, 0, 0, "",  "Undo the expansion of the last abbrev that expanded.")  (){  int opoint = point;  int adjust = 0;  if (last_abbrev_point < BEGV      || last_abbrev_point >= ZV)    return Qnil;  SET_PT (last_abbrev_point);  if (XTYPE (Vlast_abbrev_text) == Lisp_String)    {      /* This isn't correct if Vlast_abbrev->function was used         to do the expansion */      Lisp_Object val;      XSET (val, Lisp_String, XSYMBOL (Vlast_abbrev)->value);      adjust = XSTRING (val)->size;      del_range (point, point + adjust);      insert (XSTRING (Vlast_abbrev_text)->data,	       XSTRING (Vlast_abbrev_text)->size);      adjust -= XSTRING (Vlast_abbrev_text)->size;      Vlast_abbrev_text = Qnil;    }  SET_PT (last_abbrev_point < opoint ? opoint - adjust : opoint);  return Qnil;}staticwrite_abbrev (sym, stream)     Lisp_Object sym, stream;{  Lisp_Object name;  if (NULL (XSYMBOL (sym)->value))    return;  insert ("    (", 5);  XSET (name, Lisp_String, XSYMBOL (sym)->name);  Fprin1 (name, stream);  insert (" ", 1);  Fprin1 (XSYMBOL (sym)->value, stream);  insert (" ", 1);  Fprin1 (XSYMBOL (sym)->function, stream);  insert (" ", 1);  Fprin1 (XSYMBOL (sym)->plist, stream);  insert (")\n", 2);}staticdescribe_abbrev (sym, stream)     Lisp_Object sym, stream;{  Lisp_Object one;  if (NULL (XSYMBOL (sym)->value))    return;  one = make_number (1);  Fprin1 (Fsymbol_name (sym), stream);  Findent_to (make_number (15), one);  Fprin1 (XSYMBOL (sym)->plist, stream);  Findent_to (make_number (20), one);  Fprin1 (XSYMBOL (sym)->value, stream);  if (!NULL (XSYMBOL (sym)->function))    {      Findent_to (make_number (45), one);      Fprin1 (XSYMBOL (sym)->function, stream);    }  Fterpri (stream);}DEFUN ("insert-abbrev-table-description",  Finsert_abbrev_table_description, Sinsert_abbrev_table_description,  2, 2, 0,  "Insert before point a description of abbrev table named NAME.\n\NAME is a symbol whose value is an abbrev table.\n\If 2nd arg READABLE is non-nil, a readable description is inserted.\n\Otherwise description is an expression,\n\a call to define-abbrev-table which would\n\define NAME exactly as it is currently defined.")  (name, readable)     Lisp_Object name, readable;{  Lisp_Object table;  Lisp_Object stream;  CHECK_SYMBOL (name, 0);  table = Fsymbol_value (name);  CHECK_VECTOR (table, 0);  XSET (stream, Lisp_Buffer, current_buffer);  if (!NULL (readable))    {      InsStr ("(");      Fprin1 (name, stream);      InsStr (")\n\n");      map_obarray (table, describe_abbrev, stream);      InsStr ("\n\n");    }  else    {      InsStr ("(define-abbrev-table '");      Fprin1 (name, stream);      InsStr (" '(\n");      map_obarray (table, write_abbrev, stream);      InsStr ("    ))\n\n");    }  return Qnil;}DEFUN ("define-abbrev-table", Fdefine_abbrev_table, Sdefine_abbrev_table,       2, 2, 0,  "Define TABNAME (a symbol) as an abbrev table name.\n\Define abbrevs in it according to DEFINITIONS, a list of elements\n\of the form (ABBREVNAME EXPANSION HOOK USECOUNT).")  (tabname, defns)     Lisp_Object tabname, defns;{  Lisp_Object name, exp, hook, count;  Lisp_Object table, elt;  CHECK_SYMBOL (tabname, 0);  table = Fboundp (tabname);  if (NULL (table) || (table = Fsymbol_value (tabname), NULL (table)))    {      table = Fmake_abbrev_table ();      Fset (tabname, table);      Vabbrev_table_name_list =	Fcons (tabname, Vabbrev_table_name_list);    }  CHECK_VECTOR (table, 0);  for (;!NULL (defns); defns = Fcdr (defns))    {      elt = Fcar (defns);      name = Fcar (elt);      elt = Fcdr (elt);      exp = Fcar (elt);      elt = Fcdr (elt);      hook = Fcar (elt);      elt = Fcdr (elt);      count = Fcar (elt);      Fdefine_abbrev (table, name, exp, hook, count);    }  return Qnil;}syms_of_abbrev (){  DEFVAR_LISP ("abbrev-table-name-list", &Vabbrev_table_name_list,    "List of symbols whose values are  abbrev tables.");  Vabbrev_table_name_list = Fcons (intern ("fundamental-mode-abbrev-table"),				   Fcons (intern ("global-abbrev-table"),					  Qnil));  DEFVAR_LISP ("global-abbrev-table", &Vglobal_abbrev_table,    "The abbrev table whose abbrevs affect all buffers.\n\Each buffer may also have a local abbrev table.\n\If it does, the local table overrides the global one\n\for any particular abbrev defined in both.");  Vglobal_abbrev_table = Fmake_abbrev_table ();  DEFVAR_LISP ("fundamental-mode-abbrev-table", &Vfundamental_mode_abbrev_table,    "The abbrev table of mode-specific abbrevs for Fundamental Mode.");  Vfundamental_mode_abbrev_table = Fmake_abbrev_table ();  current_buffer->abbrev_table = Vfundamental_mode_abbrev_table;  DEFVAR_LISP ("last-abbrev", &Vlast_abbrev,    "The abbrev-symbol of the last abbrev expanded.");  DEFVAR_LISP ("last-abbrev-text", &Vlast_abbrev_text,    "The exact text of the last abbrev expanded.\n\nil if the abbrev has already been unexpanded.");  DEFVAR_INT ("last-abbrev-location", &last_abbrev_point,    "The location of the last abbrev expanded.");  Vlast_abbrev = Qnil;  Vlast_abbrev_text = Qnil;  last_abbrev_point = 0;  DEFVAR_LISP ("abbrev-start-location", &Vabbrev_start_location,    "Buffer position for expand-abbrev to use as the start of the abbrev.\n\nil means use the word before point as the abbrev.\n\Set to nil each time expand-abbrev is called.");  Vabbrev_start_location = Qnil;  DEFVAR_LISP ("abbrev-start-location-buffer", &Vabbrev_start_location_buffer,    "Buffer that abbrev-start-location has been set for.\n\Trying to expand an abbrev in any other buffer clears abbrev-start-location.");  Vabbrev_start_location_buffer = Qnil;  DEFVAR_PER_BUFFER ("local-abbrev-table", &current_buffer->abbrev_table,    "Local (mode-specific) abbrev table of current buffer.");  DEFVAR_BOOL ("abbrevs-changed", &abbrevs_changed,    "Set non-nil by defining or altering any word abbrevs.");  abbrevs_changed = 0;  DEFVAR_BOOL ("abbrev-all-caps", &abbrev_all_caps,    "*Set non-nil means expand multi-word abbrevs all caps if abbrev was so.");  abbrev_all_caps = 0;  defsubr (&Smake_abbrev_table);  defsubr (&Sclear_abbrev_table);  defsubr (&Sdefine_abbrev);  defsubr (&Sdefine_global_abbrev);  defsubr (&Sdefine_mode_abbrev);  defsubr (&Sabbrev_expansion);  defsubr (&Sabbrev_symbol);  defsubr (&Sexpand_abbrev);  defsubr (&Sunexpand_abbrev);  defsubr (&Sinsert_abbrev_table_description);  defsubr (&Sdefine_abbrev_table);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -