Adding the command-line option --noread to treat any name
on the command line as a new file. Patch by Hans Alves. git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4754 35c25a1d-7b9e-4130-9fde-d3aeb78583b8master
parent
d19be5aafa
commit
db7064b8e6
|
@ -1,3 +1,11 @@
|
||||||
|
2014-04-08 Hans Alves <fonsvandeachterburen@gmail.com>
|
||||||
|
* nano.h, files.c, nano.c: Adding the command-line option --noread
|
||||||
|
to treat any name on the command line as a new file. This allows
|
||||||
|
nano to write to named pipes -- it will start with a blank buffer,
|
||||||
|
and will write to the pipe when the user saves the file. This way
|
||||||
|
nano can be used as an editor in combination with for instance gpg
|
||||||
|
without having to write sensitive data to disk first.
|
||||||
|
|
||||||
2014-04-08 David Lawrence Ramsey <pooka109@gmail.com>
|
2014-04-08 David Lawrence Ramsey <pooka109@gmail.com>
|
||||||
* src/*.c: More editing of comment blocks and trimming of blank lines.
|
* src/*.c: More editing of comment blocks and trimming of blank lines.
|
||||||
|
|
||||||
|
|
|
@ -328,10 +328,10 @@ void open_buffer(const char *filename, bool undoable)
|
||||||
if (new_buffer)
|
if (new_buffer)
|
||||||
make_new_buffer();
|
make_new_buffer();
|
||||||
|
|
||||||
/* If the filename isn't blank, open the file. Otherwise, treat it
|
/* If the filename isn't blank, and we are not in NOREAD_MODE,
|
||||||
* as a new file. */
|
* open the file. Otherwise, treat it as a new file. */
|
||||||
rc = (filename[0] != '\0') ? open_file(filename, new_buffer, &f) :
|
rc = (filename[0] != '\0' && !ISSET(NOREAD_MODE)) ?
|
||||||
-2;
|
open_file(filename, new_buffer, &f) : -2;
|
||||||
|
|
||||||
/* If we have a file, and we're loading into a new buffer, update
|
/* If we have a file, and we're loading into a new buffer, update
|
||||||
* the filename. */
|
* the filename. */
|
||||||
|
|
|
@ -916,6 +916,7 @@ void usage(void)
|
||||||
#ifndef DISABLE_MOUSE
|
#ifndef DISABLE_MOUSE
|
||||||
print_opt("-m", "--mouse", N_("Enable the use of the mouse"));
|
print_opt("-m", "--mouse", N_("Enable the use of the mouse"));
|
||||||
#endif
|
#endif
|
||||||
|
print_opt("-n", "--noread", N_("Do not read the file (only write it)"));
|
||||||
#ifndef DISABLE_OPERATINGDIR
|
#ifndef DISABLE_OPERATINGDIR
|
||||||
print_opt(_("-o <dir>"), _("--operatingdir=<dir>"),
|
print_opt(_("-o <dir>"), _("--operatingdir=<dir>"),
|
||||||
N_("Set operating directory"));
|
N_("Set operating directory"));
|
||||||
|
@ -2121,6 +2122,7 @@ int main(int argc, char **argv)
|
||||||
#ifndef DISABLE_MOUSE
|
#ifndef DISABLE_MOUSE
|
||||||
{"mouse", 0, NULL, 'm'},
|
{"mouse", 0, NULL, 'm'},
|
||||||
#endif
|
#endif
|
||||||
|
{"noread", 0, NULL, 'n'},
|
||||||
#ifndef DISABLE_OPERATINGDIR
|
#ifndef DISABLE_OPERATINGDIR
|
||||||
{"operatingdir", 1, NULL, 'o'},
|
{"operatingdir", 1, NULL, 'o'},
|
||||||
#endif
|
#endif
|
||||||
|
@ -2193,11 +2195,11 @@ int main(int argc, char **argv)
|
||||||
while ((optchr =
|
while ((optchr =
|
||||||
#ifdef HAVE_GETOPT_LONG
|
#ifdef HAVE_GETOPT_LONG
|
||||||
getopt_long(argc, argv,
|
getopt_long(argc, argv,
|
||||||
"h?ABC:DEFGHIKLNOPQ:RST:UVWY:abcdefgijklmo:pqr:s:tuvwxz$",
|
"h?ABC:DEFGHIKLNOPQ:RST:UVWY:abcdefgijklmno:pqr:s:tuvwxz$",
|
||||||
long_options, NULL)
|
long_options, NULL)
|
||||||
#else
|
#else
|
||||||
getopt(argc, argv,
|
getopt(argc, argv,
|
||||||
"h?ABC:DEFGHIKLNOPQ:RST:UVWY:abcdefgijklmo:pqr:s:tuvwxz$")
|
"h?ABC:DEFGHIKLNOPQ:RST:UVWY:abcdefgijklmno:pqr:s:tuvwxz$")
|
||||||
#endif
|
#endif
|
||||||
) != -1) {
|
) != -1) {
|
||||||
switch (optchr) {
|
switch (optchr) {
|
||||||
|
@ -2325,6 +2327,9 @@ int main(int argc, char **argv)
|
||||||
SET(USE_MOUSE);
|
SET(USE_MOUSE);
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
case 'n':
|
||||||
|
SET(NOREAD_MODE);
|
||||||
|
break;
|
||||||
#ifndef DISABLE_OPERATINGDIR
|
#ifndef DISABLE_OPERATINGDIR
|
||||||
case 'o':
|
case 'o':
|
||||||
operating_dir = mallocstrcpy(operating_dir, optarg);
|
operating_dir = mallocstrcpy(operating_dir, optarg);
|
||||||
|
|
|
@ -532,7 +532,8 @@ enum
|
||||||
UNDOABLE,
|
UNDOABLE,
|
||||||
SOFTWRAP,
|
SOFTWRAP,
|
||||||
POS_HISTORY,
|
POS_HISTORY,
|
||||||
LOCKING
|
LOCKING,
|
||||||
|
NOREAD_MODE
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Flags for the menus in which a given function should be present. */
|
/* Flags for the menus in which a given function should be present. */
|
||||||
|
|
Loading…
Reference in New Issue