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

📄 emacs.sgml

📁 OTP是开放电信平台的简称
💻 SGML
📖 第 1 页 / 共 5 页
字号:
  <ITEM><C>erlang-electric-newline-inhibit-list</C><BR><P>A list of electric commands.  The command<C>erlang-electric-newline</C> will do nothing when preceded by acommand in this list, and the variable<C>erlang-electric-newline-inhibit</C> is non-<C>nil</C>.</P>  <ITEM><C>erlang-electric-X-criteria</C><BR><P>There is one variable of this form for each electric command.  Thevariable is used to decide if the special action of an electriccommand should be used.  The variable contains a list of criteriafunctions that are called in the order they appear in the list.			</p><p>If a criteria function returns the atom <C>stop</C> the specialaction is not performed.If it returns a non-<C>nil</C> value the action is taken.If it returns <C>nil</C> the next function in the list is called.Should no function in the list returna non-<C>nil</C> value the special action will not be executed.Should the list contain the atom <C>t</C> the special action is performed(unless a previous function returned the atom <C>stop</C>).</P>  <ITEM><C>erlang-next-lines-empty-threshold</C> (default 2)<BR><P>Should the function <C>erlang-next-lines-empty-p</C> be part of acriteria list of an electric command (currently semicolon, comma, andarrow), this variable controls the number of blank lines required.</P></LIST></SECTION><SECTION><MARKER ID="unplug_elec"><TITLE> Unplugging the Electric Commands </TITLE><P>To disable all electric commands set the variable<C>erlang-electric-commands</C> to the empty list.  In short, place thefollowing line in your <C>~/.emacs</C> file:</P><CODE>(setq erlang-electric-commands '())</CODE></SECTION><SECTION><TITLE> Customizing the Electric Commands </TITLE><P>To activate all electric commands, including<C>erlang-electric-newline</C>, add the following line to your<C>~/.emacs</C> file:</P><CODE>(setq erlang-electric-commands t)</CODE></SECTION></SECTION><!-- CHAPTER --><SECTION><MARKER ID="func_cmds"><TITLE> Function and Clause Commands </TITLE><P>The Erlang editing mode has a set of commands that are aware of theErlang functions and function clauses.  The commands can be used tomove the point (cursor) to the end of, or to the beginning of Erlangfunctions, or to jump between functions.  The region can be placedaround a function. Function headers can be cloned (copied).</P><SECTION><TITLE> Movement Commands </TITLE><P>There is a set of commands that can be used to move the point tothe beginning or the end of an Erlang clause or function.  Thecommands are also designed for movement between Erlang functions andclauses.</P><LIST>  <ITEM><C> C-a M-a </C> (<C>erlang-beginning-of-function</C>)<BR><P>Move the point to the beginning of the current or preceding Erlangfunction.  With an argument skip backwards over this many Erlangfunctions.  Should the argument be negative the point is moved to thebeginning of a function below the current function.</P><P>This function returns <C>t</C> if a function was found, <C>nil</C>otherwise.</P>  <ITEM><C> M-C-a </C>  (<C>erlang-beginning-of-clause</C>)<BR><P>As above but move point to the beginning of the current or precedingErlang clause.</P><P>This function returns <c>t</c> if a clause was found, <C>nil</C> otherwise.</P>  <ITEM><C> C-a M-e </C> (<C>erlang-end-of-function</C>)<BR><P>Move to the end of the current or following Erlang function.  With anargument to it that many times.  Should the argument be negative moveto the end of a function above the current functions.</P>  <ITEM><C> M-C-e </C>  (<C>erlang-end-of-clause</C>)<BR><P>As above but move point to the end of the current or following Erlangclause.</P></LIST><P>When one of the movement commands is executed and the point is alreadyplaced at the beginning or end of a function or clause, the point ismoved to the previous/following function or clause.</P><P>When the point is above the first or below the last function in thebuffer, and an <c>erlang-beginning-of-</c>, or <c>erlang-end-of-</c>command is issued, the point is moved to the beginning or to the endof the buffer, respectively.<P><SECTION><TITLE> Development Tips </TITLE><P>The functions described above can be used both as user commands andcalled as functions in programs written in Emacs Lisp.</P><P><EM> Example: </EM></P><P>The sequence below will move the point to the beginning of the currentfunction even if the point should already be positioned at thebeginning of the function:</P><CODE>    (end-of-line)    (erlang-beginning-of-function)</CODE><P><EM> Example: </EM></P><P>To repeat over all the function in a buffer the following code can beused.  It will first move the point to the beginning of the buffer,then it will locate the first Erlang function.  Should the buffercontain no functions at all the call to<C>erlang-beginning-of-function</C> will return <C>nil</C> and hencethe loop will never be entered.</P><CODE>    (goto-char (point-min))    (erlang-end-of-function 1)    (let ((found-func (erlang-beginning-of-function 1)))       (while found-func         ;; Do something with this function.         ;; Go to the beginning of the next function.         (setq found-func (erlang-beginning-of-function -1))))</CODE></SECTION></SECTION><SECTION><TITLE>Region Commands</TITLE><LIST>  <ITEM><C> C-c M-h </C> (<C>erlang-mark-function</C>)<BR><P>Put the region around the current Erlang function.  The point isplaced in the beginning and the mark at the end of the function.</P>  <ITEM><C> M-C-h </C>  (<C>erlang-mark-clause</C>)<BR><P>Put the region around the current Erlang clause.  The point isplaced in the beginning and the mark at the end of the function.</P></LIST></SECTION><SECTION><TITLE>Function Header Commands</TITLE><LIST>  <ITEM><C> C-c C-j </C> (<C>erlang-generate-new-clause</C>)<BR><P>Create a new clause in the current Erlang function.  The point isplaced between the parentheses of the argument list.</P>  <ITEM><C> C-c C-y </C> (<C>erlang-clone-arguments</C>)<BR><P>Copy the function arguments of the preceding Erlang clause.  Thiscommand is useful when defining a new clause with almost the sameargument as the preceding.</P></LIST></SECTION><SECTION><TITLE>Limitations</TITLE><P>Several clauses are considered to be part of the same Erlang functionif they have the same name.  It is possible that in the future thearity of the function also will be checked.To avoid to perform a full parse of the entire buffer the functionsdescribed in the chapter only look at lines where the function startsin the first column.  This means that the commands does not workproperly if the source code contain non-standardized indentation.</SECTION></SECTION><!-- CHAPTER --><SECTION><TITLE>Skeletons</TITLE><P>A skeleton is a piece of pre-written code that can be inserted intothe buffer.  Erlang mode comes with a set of predefined skeletonsranging from simple <C>if</C> expressions to stand-alone applications.</P><P>The skeletons can be accessed either from the Erlang menu of fromcommands named <C>tempo-template-erlang-</C>X.</P><P>The skeletons is defined using the standard Emacs package "tempo".  Itis possible to define new skeletons for your favorite erlangconstructions.</P><SECTION><TITLE>Commands</TITLE><LIST>  <ITEM><C> C-c M-f </C> (<C>tempo-forward-mark</C>)  <ITEM><C> C-c M-b </C> (<C>tempo-backward-mark</C>)<P>In a skeleton certain positions are marked.  These two commandsmove the point between such positions.</P></LIST></SECTION><SECTION><TITLE>Predefined Skeletons</TITLE><LIST>  <ITEM>Simple skeletons: If, Case, Receive, Receive After, Receive Loop.  <ITEM>Header elements: Module, Author.<P>These commands inserts lines on the form <C>-module(</C>xxx<C>).</C> and<C>-author('my@home').</C>.  They can be used directly, but are also usedas part of the full headers described below:</P>  <ITEM>Full Headers: Small, Medium, and Large Headers<P>These commands generate three variants of file headers.</P></LIST><P>The following skeletons will complete almost ready-to-run modules.<LIST>  <ITEM>Small Server  <ITEM>application  <ITEM>Supervisor  <ITEM>Supervisor Bridge  <ITEM>gen_server  <ITEM>gen_event  <ITEM>gen_fsm</LIST></SECTION><SECTION><TITLE>Defining New Skeletons</TITLE><P>It is possible to define new Erlang skeletons.  The skeletons aredefined using the standard package "tempo".  The skeleton is describedusing the following variables:</P><LIST>  <ITEM><C>erlang-skel-</C>X  (Where X is the name of this skeleton.)<BR><P>Each skeleton is described by a variable.  It contains a list of Temporules.  See below for two examples of skeleton definitions.  See theTempo Reference Manual for a complete description of tempo rules.</P>  <ITEM><C>erlang-skel</C><BR><P>This variable describes all Erlang skeletons.  It is used to definethe skeletons and to add them to the Erlang menu.  The variable is alist where is each entry is either the empty list, representing avertical bar in the menu, or a list on the form:</P><CODE>   (Menu-name tempo-name erlang-skel-X)</CODE><P>The Menu-name is name to use in the menu.  A named function is createdfor each skeleton, it is <C>tempo-template-erlang-</C>tempo-name.Finally, <C>erlang-skel-</C>X is the name of the variable describing theskeleton.</P><P>The best time to change this variable is right after the Erlang modehas been loaded but before it has been activated.  See the "Example"section below.</P></LIST><SECTION><TITLE>Examples</TITLE><P>Below is two example on skeletons and one example on how to add anentry to the <C>erlang-skel</C> variable.  Please see the Temporeference manual for details about the format.</P><P><EM> Example 1: </EM></P><P>The "If" skeleton is defined by the following variable(slightly rearranged for pedagogical reasons):</P><CODE>(defvar erlang-skel-if  '((erlang-skel-skip-blank)   ;;  1    o                          ;;  2    >                          ;;  3    "if"                       ;;  4    n>                         ;;  5    p                          ;;  6    " ->"                      ;;  7    n>                         ;;  8    p                          ;;  9    "ok"                       ;; 10    n>                         ;; 11    "end"                      ;; 12    p))                        ;; 13</CODE><P>Each line describes an action to perform:</P><LIST>  <ITEM> 1:  This is a normal function call.  Here we skip over any spacecharacters after the point.  (If we do not they will end up after theskeleton.)  <ITEM> 2:  This means "Open Line", i.e. split the current line at thepoint, but leave the point on the end of the first line.  <ITEM> 3:  Indent Line.  This indents the current line.  <ITEM> 4:  Here we insert the string <C>if</C> into the buffer  <ITEM> 5, 8, 11:  Newline and indent.  <ITEM> 6, 9, 13: Mark these positions as special.  The point will beplaced at the position of the first <C>p</C>.  The point can later bemoved to the other by the <C>tempo-forward-mark</C> and<C>tempo-backward-mark</C> described above.  <ITEM> 7, 10, 12: These insert the strings "<C> -></C>","<C>ok</C>", and "<C>end</C>", respectively.</LIST><P><EM> Example 2: </EM></P><P>This example contains very few entries.  Basically, what it does is toinclude other skeletons in the correct place.</P><CODE>(defvar erlang-skel-small-header  '(o                                         ;; 1    (erlang-skel-include erlang-skel-module   ;; 2                         erlang-skel-author)    n                                         ;; 3    (erlang-skel-include erlang-skel-compile  ;; 4			 erlang-skel-export   ;; 5			 erlang-skel-vc)))    ;; 6</CODE><P>The lines performs the following actions:</P><LIST>  <ITEM> 1: "Open Line" (see example 1 above).  <ITEM> 2: Insert the skeletons <C>erlang-skel-module</C> and<C>erlang-skel-compile</C> into the buffer.  <ITEM> 3: Insert one empty line.  <ITEM> 4: Insert three more skeletons.</LIST><P>

⌨️ 快捷键说明

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