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

📄 buffer.c

📁 早期freebsd实现
💻 C
📖 第 1 页 / 共 3 页
字号:
{  register int i;  CHECK_NUMBER_COERCE_MARKER (*b, 0);  CHECK_NUMBER_COERCE_MARKER (*e, 1);  if (XINT (*b) > XINT (*e))    {      i = XFASTINT (*b);	/* This is legit even if *b is < 0 */      *b = *e;      XFASTINT (*e) = i;	/* because this is all we do with i.  */    }  if (!(BEGV <= XINT (*b) && XINT (*b) <= XINT (*e)        && XINT (*e) <= ZV))    args_out_of_range (*b, *e);}Lisp_Objectlist_buffers_1 (files)     Lisp_Object files;{  register Lisp_Object tail, tem, buf;  Lisp_Object col1, col2, col3, minspace;  register struct buffer *old = current_buffer, *b;  int desired_point = 0;  XFASTINT (col1) = 19;  XFASTINT (col2) = 25;  XFASTINT (col3) = 40;  XFASTINT (minspace) = 1;  Fset_buffer (Vstandard_output);  tail = intern ("Buffer-menu-mode");  if (!EQ (tail, current_buffer->major_mode)      && (tem = Ffboundp (tail), !NULL (tem)))    call0 (tail);  Fbuffer_flush_undo (Vstandard_output);  current_buffer->read_only = Qnil;  write_string ("\ MR Buffer         Size  Mode           File\n\ -- ------         ----  ----           ----\n", -1);  for (tail = Vbuffer_alist; !NULL (tail); tail = Fcdr (tail))    {      buf = Fcdr (Fcar (tail));      b = XBUFFER (buf);      /* Don't mention the minibuffers. */      if (XSTRING (b->name)->data[0] == ' ')	continue;      /* Optionally don't mention buffers that lack files. */      if (!NULL (files) && NULL (b->filename))	continue;      /* Identify the current buffer. */      if (b == old)	desired_point = point;      write_string (b == old ? "." : " ", -1);      /* Identify modified buffers */      write_string (BUF_MODIFF (b) > b->save_modified ? "*" : " ", -1);      write_string (NULL (b->read_only) ? "  " : "% ", -1);      Fprinc (b->name, Qnil);      Findent_to (col1, make_number (2));      XFASTINT (tem) = BUF_Z (b) - BUF_BEG (b);      Fprin1 (tem, Qnil);      Findent_to (col2, minspace);      Fprinc (b->mode_name, Qnil);      Findent_to (col3, minspace);      if (!NULL (b->filename))	Fprinc (b->filename, Qnil);      write_string ("\n", -1);    }  current_buffer->read_only = Qt;  set_buffer_internal (old);/* Foo.  This doesn't work since temp_output_buffer_show sets point to 1  if (desired_point)    BUF_PT (XBUFFER (Vstandard_output)) = desired_point; */  return Qnil;}DEFUN ("list-buffers", Flist_buffers, Slist_buffers, 0, 1, "P",  "Display a list of names of existing buffers.\n\Inserts it in buffer *Buffer List* and displays that.\n\Note that buffers with names starting with spaces are omitted.\n\Non-null optional arg FILES-ONLY means mention only file buffers.\n\\n\The M column contains a * for buffers that are modified.\n\The R column contains a % for buffers that are read-only.")  (files)     Lisp_Object files;{  internal_with_output_to_temp_buffer ("*Buffer List*",				       list_buffers_1, files);  return Qnil;}DEFUN ("kill-all-local-variables", Fkill_all_local_variables, Skill_all_local_variables,  0, 0, 0,  "Eliminate all the buffer-local variable values of the current buffer.\n\This buffer will then see the default values of all variables.")  (){  register Lisp_Object alist, sym, tem;  for (alist = current_buffer->local_var_alist; !NULL (alist); alist = XCONS (alist)->cdr)    {      sym = XCONS (XCONS (alist)->car)->car;      /* Need not do anything if some other buffer's binding is now encached.  */      tem = XCONS (XCONS (XSYMBOL (sym)->value)->cdr)->car;      if (XBUFFER (tem) == current_buffer)	{	  /* Symbol is set up for this buffer's old local value.	     Set it up for the current buffer with the default value.  */	  tem = XCONS (XCONS (XSYMBOL (sym)->value)->cdr)->cdr;	  XCONS (tem)->car = tem;	  XCONS (XCONS (XSYMBOL (sym)->value)->cdr)->car = Fcurrent_buffer ();	  store_symval_forwarding (sym, XCONS (XSYMBOL (sym)->value)->car,				   XCONS (tem)->cdr);	}    }  reset_buffer_local_variables (current_buffer);  return Qnil;}extern Lisp_Object Vprin1_to_string_buffer;	/* in print.c */init_buffer_once (){  register Lisp_Object tem;  /* Make sure all markable slots in buffer_defaults     are initialized reasonably, so mark_buffer won't choke.  */  reset_buffer (&buffer_defaults);  reset_buffer (&buffer_local_symbols);  XSET (Vbuffer_defaults, Lisp_Buffer, &buffer_defaults);  XSET (Vbuffer_local_symbols, Lisp_Buffer, &buffer_local_symbols);  /* Set up the default values of various buffer slots.  */  /* Must do these before making the first buffer! */  /* real setup is done in loaddefs.el */  buffer_defaults.mode_line_format = build_string ("%-");  buffer_defaults.abbrev_mode = Qnil;  buffer_defaults.overwrite_mode = Qnil;  buffer_defaults.case_fold_search = Qt;  buffer_defaults.auto_fill_hook = Qnil;  buffer_defaults.selective_display = Qnil;  buffer_defaults.selective_display_ellipses = Qt;  buffer_defaults.abbrev_table = Qnil;  buffer_defaults.undo_list = Qnil;  XFASTINT (buffer_defaults.tab_width) = 8;  buffer_defaults.truncate_lines = Qnil;  buffer_defaults.ctl_arrow = Qt;  XFASTINT (buffer_defaults.fill_column) = 70;  XFASTINT (buffer_defaults.left_margin) = 0;  /* Assign the local-flags to the slots that have default values.     The local flag is a bit that is used in the buffer     to say that it has its own local value for the slot.     The local flag bits are in the local_var_flags slot of the buffer.  */  /* Nothing can work if this isn't true */  if (sizeof (int) != sizeof (Lisp_Object)) abort ();  /* 0 means not a lisp var, -1 means always local, else mask */  bzero (&buffer_local_flags, sizeof buffer_local_flags);  XFASTINT (buffer_local_flags.filename) = -1;  XFASTINT (buffer_local_flags.directory) = -1;  XFASTINT (buffer_local_flags.backed_up) = -1;  XFASTINT (buffer_local_flags.save_length) = -1;  XFASTINT (buffer_local_flags.auto_save_file_name) = -1;  XFASTINT (buffer_local_flags.read_only) = -1;  XFASTINT (buffer_local_flags.major_mode) = -1;  XFASTINT (buffer_local_flags.mode_name) = -1;  XFASTINT (buffer_local_flags.undo_list) = -1;  XFASTINT (buffer_local_flags.mode_line_format) = 1;  XFASTINT (buffer_local_flags.abbrev_mode) = 2;  XFASTINT (buffer_local_flags.overwrite_mode) = 4;  XFASTINT (buffer_local_flags.case_fold_search) = 8;  XFASTINT (buffer_local_flags.auto_fill_hook) = 0x10;  XFASTINT (buffer_local_flags.selective_display) = 0x20;  XFASTINT (buffer_local_flags.selective_display_ellipses) = 0x40;  XFASTINT (buffer_local_flags.tab_width) = 0x80;  XFASTINT (buffer_local_flags.truncate_lines) = 0x100;  XFASTINT (buffer_local_flags.ctl_arrow) = 0x200;  XFASTINT (buffer_local_flags.fill_column) = 0x400;  XFASTINT (buffer_local_flags.left_margin) = 0x800;  XFASTINT (buffer_local_flags.abbrev_table) = 0x1000;  XFASTINT (buffer_local_flags.syntax_table) = 0x2000;  Vbuffer_alist = Qnil;  current_buffer = 0;  all_buffers = 0;  QSFundamental = build_string ("Fundamental");  Qfundamental_mode = intern ("fundamental-mode");  buffer_defaults.major_mode = Qfundamental_mode;  Qmode_class = intern ("mode-class");  Vprin1_to_string_buffer = Fget_buffer_create (build_string (" prin1"));  /* super-magic invisible buffer */  Vbuffer_alist = Qnil;  tem = Fset_buffer (Fget_buffer_create (build_string ("*scratch*")));  /* Want no undo records for *scratch*     until after Emacs is dumped */  Fbuffer_flush_undo (tem);}init_buffer (){  char buf[MAXPATHLEN+1];  Fset_buffer (Fget_buffer_create (build_string ("*scratch*")));  if (getwd (buf) == 0)    fatal ("`getwd' failed: %s.\n", buf);#ifndef VMS  /* Maybe this should really use some standard subroutine     whose definition is filename syntax dependent.  */  if (buf[strlen (buf) - 1] != '/')    strcat (buf, "/");#endif /* not VMS */  current_buffer->directory = build_string (buf);}/* initialize the buffer routines */syms_of_buffer (){  staticpro (&Vbuffer_defaults);  staticpro (&Vbuffer_local_symbols);  staticpro (&Qfundamental_mode);  staticpro (&Qmode_class);  staticpro (&QSFundamental);  staticpro (&Vbuffer_alist);/*staticpro (&Qlisp_mode);  Qlisp_mode = intern ("lisp-mode");*/  /* All these use DEFVAR_LISP_NOPRO because the slots in     buffer_defaults will all be marked via Vbuffer_defaults.  */  DEFVAR_LISP_NOPRO ("default-mode-line-format",	      &buffer_defaults.mode_line_format,    "Default mode-line-format for buffers that do not override it.\n\This is the same as (default-value 'mode-line-format).");  DEFVAR_LISP_NOPRO ("default-abbrev-mode",	      &buffer_defaults.abbrev_mode,    "Default abbrev-mode for buffers that do not override it.\n\This is the same as (default-value 'abbrev-mode).");  DEFVAR_LISP_NOPRO ("default-ctl-arrow",	      &buffer_defaults.ctl_arrow,    "Default ctl-arrow for buffers that do not override it.\n\This is the same as (default-value 'ctl-arrow).");  DEFVAR_LISP_NOPRO ("default-truncate-lines",	      &buffer_defaults.truncate_lines,    "Default truncate-lines for buffers that do not override it.\n\This is the same as (default-value 'truncate-lines).");  DEFVAR_LISP_NOPRO ("default-fill-column",	      &buffer_defaults.fill_column,    "Default fill-column for buffers that do not override it.\n\This is the same as (default-value 'fill-column).");  DEFVAR_LISP_NOPRO ("default-left-margin",	      &buffer_defaults.left_margin,    "Default left-margin for buffers that do not override it.\n\This is the same as (default-value 'left-margin).");  DEFVAR_LISP_NOPRO ("default-tab-width",	      &buffer_defaults.tab_width,    "Default tab-width for buffers that do not override it.\n\This is the same as (default-value 'tab-width).");  DEFVAR_LISP_NOPRO ("default-case-fold-search",	      &buffer_defaults.case_fold_search,    "Default case-fold-search for buffers that do not override it.\n\This is the same as (default-value 'case-fold-search).");  DEFVAR_PER_BUFFER ("mode-line-format", &current_buffer->mode_line_format, 0);/* This doc string is too long for cpp; cpp dies.  DEFVAR_PER_BUFFER ("mode-line-format", &current_buffer->mode_line_format,    "Template for displaying mode line for current buffer.\n\Each buffer has its own value of this variable.\n\Value may be a string, a symbol or a list or cons cell.\n\For a symbol, its value is used (but it is ignored if t or nil).\n\ A string appearing directly as the value of a symbol is processed verbatim\n\ in that the %-constructs below are not recognized.\n\For a list whose car is a symbol, the symbol's value is taken,\n\ and if that is non-nil, the cadr of the list is processed recursively.\n\ Otherwise, the caddr of the list (if there is one) is processed.\n\For a list whose car is a string or list, each element is processed\n\ recursively and the results are effectively concatenated.\n\For a list whose car is an integer, the cdr of the list is processed\n\  and padded (if the number is positive) or truncated (if negative)\n\  to the width specified by that number.\n\A string is printed verbatim in the mode line except for %-constructs:\n\  (%-constructs are allowed when the string is the entire mode-line-format\n\   or when it is found in a cons-cell or a list)\n\  %b -- print buffer name.      %f -- print visited file name.\n\  %* -- print *, % or hyphen.   %m -- print value of mode-name (obsolete).\n\  %s -- print process status.   %M -- print value of global-mode-string. (obs)\n\  %p -- print percent of buffer above top of window, or top, bot or all.\n\  %n -- print Narrow if appropriate.\n\  %[ -- print one [ for each recursive editing level.  %] similar.\n\  %% -- print %.   %- -- print infinitely many dashes.\n\Decimal digits after the % specify field width to which to pad.");*/  DEFVAR_LISP_NOPRO ("default-major-mode", &buffer_defaults.major_mode,    "*Major mode for new buffers.  Defaults to fundamental-mode.\n\nil here means use current buffer's major mode.");  DEFVAR_PER_BUFFER ("major-mode", &current_buffer->major_mode,    "Symbol for current buffer's major mode.");  DEFVAR_PER_BUFFER ("abbrev-mode", &current_buffer->abbrev_mode,    "Non-nil turns on automatic expansion of abbrevs when inserted.\n\Automatically becomes local when set in any fashion.");  DEFVAR_PER_BUFFER ("case-fold-search", &current_buffer->case_fold_search,    "*Non-nil if searches should ignore case.\n\Automatically becomes local when set in any fashion.");  DEFVAR_PER_BUFFER ("mode-name", &current_buffer->mode_name,    "Pretty name of current buffer's major mode (a string).");  DEFVAR_PER_BUFFER ("fill-column", &current_buffer->fill_column,    "*Column beyond which automatic line-wrapping should happen.\n\Automatically becomes local when set in any fashion.");  DEFVAR_PER_BUFFER ("left-margin", &current_buffer->left_margin,    "*Column for the default indent-line-function to indent to.\n\Linefeed indents to this column in Fundamental mode.\n\Automatically becomes local when set in any fashion.");  DEFVAR_PER_BUFFER ("tab-width", &current_buffer->tab_width,    "*Distance between tab stops (for display of tab characters), in columns.\n\Automatically becomes local when set in any fashion.");  DEFVAR_PER_BUFFER ("ctl-arrow", &current_buffer->ctl_arrow,    "*Non-nil means display control chars with uparrow.\n\Nil means use backslash and octal digits.\n\Automatically becomes local when set in any fashion.");  DEFVAR_PER_BUFFER ("truncate-lines", &current_buffer->truncate_lines,    "*Non-nil means do not display continuation lines;\n\give each line of text one screen line.\n\Automatically becomes local when set in any fashion.\n\\n\Note that this is overridden by the variable\n\truncate-partial-width-windows if that variable is non-nil\n\and this buffer is not full-screen width.");  DEFVAR_PER_BUFFER ("default-directory", &current_buffer->directory,    "Name of default directory of current buffer.  Should end with slash.");  DEFVAR_PER_BUFFER ("auto-fill-hook", &current_buffer->auto_fill_hook,    "Function called (if non-nil) after self-inserting a space at column beyond fill-column");  DEFVAR_PER_BUFFER ("buffer-file-name", &current_buffer->filename,    "Name of file visited in current buffer, or nil if not visiting a file.");  DEFVAR_PER_BUFFER ("buffer-auto-save-file-name",		    &current_buffer->auto_save_file_name,    "Name of file for auto-saving current buffer,\n\or nil if buffer should not be auto-saved.");  DEFVAR_PER_BUFFER ("buffer-read-only", &current_buffer->read_only,    "Non-nil if this buffer is read-only.");  DEFVAR_PER_BUFFER ("buffer-backed-up", &current_buffer->backed_up,    "Non-nil if this buffer's file has been backed up.\n\Backing up is done before the first time the file is saved.");  DEFVAR_PER_BUFFER ("buffer-saved-size", &current_buffer->save_length,    "Length of current buffer when last read in, saved or auto-saved.\n\0 initially.");  DEFVAR_PER_BUFFER ("selective-display", &current_buffer->selective_display,    "t enables selective display:\n\ after a ^M, all the rest of the line is invisible.\n\ ^M's in the file are written into files as newlines.\n\Integer n as value means display only lines\n\ that start with less than n columns of space.\n\Automatically becomes local when set in any fashion.");  DEFVAR_PER_BUFFER ("selective-display-ellipses",		    &current_buffer->selective_display_ellipses,    "t means display ... on previous line when a line is invisible.\n\Automatically becomes local when set in any fashion.");  DEFVAR_PER_BUFFER ("overwrite-mode", &current_buffer->overwrite_mode,    "Non-nil if self-insertion should replace existing text.\n\Automatically becomes local when set in any fashion.");  DEFVAR_PER_BUFFER ("buffer-undo-list", &current_buffer->undo_list,    "List of undo entries in current buffer.");/*DEFVAR_LISP ("debug-check-symbol", &Vcheck_symbol,    "Don't ask.");*/  defsubr (&Sbuffer_list);  defsubr (&Sget_buffer);  defsubr (&Sget_file_buffer);  defsubr (&Sget_buffer_create);  defsubr (&Sgenerate_new_buffer);  defsubr (&Sbuffer_name);/*defsubr (&Sbuffer_number);*/  defsubr (&Sbuffer_file_name);  defsubr (&Sbuffer_local_variables);  defsubr (&Sbuffer_modified_p);  defsubr (&Sset_buffer_modified_p);  defsubr (&Srename_buffer);  defsubr (&Sother_buffer);  defsubr (&Sbuffer_flush_undo);  defsubr (&Sbuffer_enable_undo);  defsubr (&Skill_buffer);  defsubr (&Serase_buffer);  defsubr (&Sswitch_to_buffer);  defsubr (&Spop_to_buffer);  defsubr (&Scurrent_buffer);  defsubr (&Sset_buffer);  defsubr (&Sbarf_if_buffer_read_only);  defsubr (&Sbury_buffer);  defsubr (&Slist_buffers);  defsubr (&Skill_all_local_variables);}keys_of_buffer (){  ndefkey (Vctl_x_map, 'b', "switch-to-buffer");  ndefkey (Vctl_x_map, 'k', "kill-buffer");  ndefkey (Vctl_x_map, Ctl ('B'), "list-buffers");}

⌨️ 快捷键说明

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