Navigation

Operators and Keywords

Function List:

C++ API

edit.m File Reference


Functions

 if (nargin==2) switch(toupper(file)) case"EDITOR"FUNCTION.EDITOR
case HOME if (!isempty(state)&&state(1)=="~") state
case MODE if (strcmp(state,"sync")||strcmp(state,"async")) FUNCTION.MODE
else error ('expected"edit MODE sync|async"')
endif case EDITINPLACE if (ischar(state)) if(strcmpi(state
 elseif (strcmpi(state,"false")) state
case GET if (isfield(FUNCTION, toupper(state))) ret
endif otherwise error ("expected \"edit EDITOR|HOME|AUTHOR|EMAIL|LICENSE|MODE val\"")
endswitch return endif if (nargin< 1) if(exist(FUNCTION.HOME
else system (sprintf(FUNCTION.EDITOR,""),[], FUNCTION.MODE)
endif switch (exist(file)) case
 error ("unable to edit a built-in or compiled function")
 if (idx==0) filelist
 if (isempty(regexp(file,"\\.m$"))) filelist
endif if (isempty(regexp(file,"\\.cc$"))) filelist
endif endif if (!strcmp(file,"@")&&index(file, filesep)) numfiles
 if (!isempty(filetoedit)) fileandpath
endif endfor if (!isempty(fileandpath)) if(FUNCTION.EDITINPLACE) system(sprintf(FUNCTION.EDITOR
endif endfor cstrcat ("\"", fileandpath,"\""))
 if (status==0) error(msg)
endif else fclose (fid)
endif system (sprintf(FUNCTION.EDITOR, cstrcat("\"", fileandpath,"\"")),[], FUNCTION.MODE)
 switch (ext) case
endswitch if (isempty(FUNCTION.EMAIL)) host
 if (isempty(host)&&ispc()) host
endif if (isempty(host))[status
 if (!isempty(host)) host
 switch (uclicense) case"GPL"head
 if (isempty(head)) comment
endif if (any(exists==[2, 103])) code
 if (isempty(ret)) ret
 if (!isempty(ret)) ret
 if (!isstruct(ent)) ret
endif elseif (long_form) ret
 if (!isempty(pos)) ret
!edit editor none!edit home
none!edit author none!edit
email none!edit license none 
!edit ("editinplace",!s.editinplace)%!if(s.mode(1)
 !edit ("home", s.home)
 !edit ("author", s.author)
 !edit ("email", s.email)
 !edit ("license", s.license)
 !edit ("editinplace", s.editinplace)
 !edit ("mode", s.mode)
 !assert (edit("get","editor"), s.editor)
 !assert (edit("get","home"), s.home)
 !assert (edit("get","author"), s.author)
 !assert (edit("get","email"), s.email)
 !assert (edit("get","license"), s.license)
 !assert (edit("get","editinplace"), s.editinplace)
 !assert (edit("get","mode"), s.mode)

Variables

function ret
 mlock
endif FUNCTION HOME = state
case AUTHOR FUNCTION AUTHOR = state
case EMAIL FUNCTION EMAIL = state
case LICENSE FUNCTION LICENSE = state
endif case EDITINPLACE true state = true
endif endif FUNCTION EDITINPLACE = state
endswitch return endif dir
endif return
endswitch filelist = {file}
 idx = rindex (file, ".")
for n
endfor endif fileandpath = ""
 break
endif endfor FUNCTION MODE
else fid = fopen (fileandpath, "r+t")
 name = file(1:idx-1)
 ext = file(idx+1:end)
endif host = system ("uname -n")
endif endif now = localtime (time)
 revs = cstrcat ("Created: ", strftime ("%Y-%m-%d", now))
 copyright = cstrcat (strftime ("Copyright (C) %Y ", now), FUNCTION.AUTHOR)
 author = cstrcat ("Author: ", FUNCTION.AUTHOR, " ", FUNCTION.EMAIL)
 uclicense = toupper (FUNCTION.LICENSE)
 tail = cstrcat (author, "\n", revs)
case BSD head
endswitch exists = exist (name)
else comment = cstrcat ("/*\n", head, "\n\n", tail, "\n\n*/\n\n")
else code = " "
endif body
 text = cstrcat (comment, body)
 pos = strfind (ret, ",")
endif endfunction!test!s editor = edit ("get", "editor")
!s home = edit ("get", "home")
!s email = edit ("get", "email")
!s license = edit ("get", "license")
!s editinplace = edit ("get", "editinplace")
!s mode = edit ("get", "mode")

Function Documentation

!assert ( edit("get","mode")  ,
s.  mode 
)

!assert ( edit("get","editinplace")  ,
s.  editinplace 
)

!assert ( edit("get","license")  ,
s.  license 
)

!assert ( edit("get","email")  ,
s.  email 
)

!assert ( edit("get","author")  ,
s.  author 
)

!assert ( edit("get","home")  ,
s.  home 
)

!assert ( edit("get","editor")  ,
s.  editor 
)

!edit ( "mode"  ,
s.  mode 
)

!edit ( "editinplace"  ,
s.  editinplace 
)

!edit ( "license"  ,
s.  license 
)

!edit ( "email"  ,
s.  email 
)

!edit ( "author"  ,
s.  author 
)

!edit ( "home"  ,
s.  home 
)

! edit editor none ! edit home none ! edit author none ! edit email none ! edit license none !edit ( "editinplace"  ,
!s.  editinplace 
)

endif endfor cstrcat ( "\""  ,
fileandpath  ,
"\""   
)

endif elseif ( long_form   ) 

elseif ( strcmpi(state,"false")   ) 

error ( "unable to edit a built-in or compiled function  ) 

endif otherwise error ( "expected \"edit EDITOR|HOME|AUTHOR|EMAIL|LICENSE|MODE val\""   ) 

else error ( 'expected"edit MODE sync|async"'   ) 

endif else fclose ( fid   ) 

if ( isemptypos  ) 

if ( isstructent  ) 

if ( isemptyret  ) 

if ( isempty(ret  ) 

endif if ( any(exists==[2, 103])   ) 

if ( isempty(head  ) 

if ( isemptyhost  ) 

endif if ( isempty(host  ) 

if ( isempty(host)&&ispc()   ) 

endswitch if ( isempty(FUNCTION.EMAIL  ) 

if ( status  = =0  ) 

endif endfor if ( isemptyfileandpath  ) 

if ( isemptyfiletoedit  ) 

endif endif if ( strcmpfile,"@")&&index(file, filesep  ) 

endif if ( isempty(regexp(file,"\\.cc$"))   ) 

if ( isempty(regexp(file,"\\.m$"))   ) 

if ( idx  = =0  ) 

endswitch return endif if (  ) 

case GET if ( isfield(FUNCTION, toupper(state))   ) 

endif case EDITINPLACE if ( ischar(state  ) 

case MODE if ( strcmp(state,"sync")||strcmp(state,"async")   ) 

case HOME if ( isemptystate)&&state(1 = ="~"  ) 

if ( nargin  = =2  ) 

switch ( uclicense   ) 

switch ( ext   ) 

endif switch ( exist(file  ) 

otherwise system ( sprintf(FUNCTION.EDITOR, cstrcat("\"", fileandpath,"\""))  ,
FUNCTION.  MODE 
)

else system ( sprintf(FUNCTION.EDITOR,"")  ,
FUNCTION.  MODE 
)


Variable Documentation

s author = cstrcat ("Author: ", FUNCTION.AUTHOR, " ", FUNCTION.EMAIL)

case AUTHOR FUNCTION AUTHOR = state

Initial value:

 cstrcat ("#include <octave/oct.h>\n\n",
                     "DEFUN_DLD(", name, ",args,nargout,\"\\\n",
                     name, "\\n\\\n\")\n{\n",
                     "  octave_value_list retval;\n",
                     "  int nargin = args.length();\n\n",
                     code, "\n  return retval;\n}\n")

break

else code = " "

else comment = cstrcat ("/*\n", head, "\n\n", tail, "\n\n*/\n\n")

copyright = cstrcat (strftime ("Copyright (C) %Y ", now), FUNCTION.AUTHOR)

Initial value:

= 7 && (isunix () || ! ispc ()))
      system (cstrcat ("cd \"", FUNCTION.HOME, "\" ; ",
                      sprintf (FUNCTION.EDITOR, "")),
              [], FUNCTION.MODE)

! s editinplace = edit ("get", "editinplace")

endif endfunction !test ! s editor = edit ("get", "editor")

! s email = edit ("get", "email")

else FUNCTION EMAIL = state

endswitch exists = exist (name)

ext = file(idx+1:end)

endswitch fid = fopen (fileandpath, "r+t")

otherwise head

Initial value:

 cstrcat (copyright, "\n\n", "\
This program is free software; redistribution and use in source and\n\
binary forms, with or without modification, are permitted provided that\n\
the following conditions are met:\n\
\n\
   1.Redistributions of source code must retain the above copyright\n\
     notice, this list of conditions and the following disclaimer.\n\
   2.Redistributions in binary form must reproduce the above copyright\n\
     notice, this list of conditions and the following disclaimer in the\n\
     documentation and/or other materials provided with the distribution.\n\
\n\
THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND\n\
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n\
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n\
ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n\
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n\
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n\
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n\
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n\
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n\
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n\
SUCH DAMAGE.\
")

! s home = edit ("get", "home")

endif FUNCTION HOME = state

endif host = system ("uname -n")

idx = rindex (file, ".")

! s license = edit ("get", "license")

case LICENSE FUNCTION LICENSE = state

mlock

! s mode = edit ("get", "mode")

endif endfor FUNCTION MODE

for n

Initial value:

 1:numfiles
      filelist{n+numfiles} = cat (2, "@", filelist{n})

name = file(1:idx-1)

endif endif now = localtime (time)

pos = strfind (ret, ",")

Initial value:

 edit (file, state)



  persistent FUNCTION = struct ("EDITOR", cstrcat (EDITOR (), " %s"),
                                "HOME", fullfile (default_home, "octave"),
                                "AUTHOR", default_user(1),
                                "EMAIL",  [],
                                "LICENSE",  "GPL",
                                "MODE", "sync",
                                "EDITINPLACE", false)

return

revs = cstrcat ("Created: ", strftime ("%Y-%m-%d", now))

st state = true

tail = cstrcat (author, "\n", revs)

endif text = cstrcat (comment, body)