+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>
* src/*.c: More editing of comment blocks and trimming of blank lines.
if (new_buffer)
make_new_buffer();
- /* If the filename isn't blank, open the file. Otherwise, treat it
- * as a new file. */
- rc = (filename[0] != '\0') ? open_file(filename, new_buffer, &f) :
- -2;
+ /* If the filename isn't blank, and we are not in NOREAD_MODE,
+ * open the file. Otherwise, treat it as a new file. */
+ rc = (filename[0] != '\0' && !ISSET(NOREAD_MODE)) ?
+ open_file(filename, new_buffer, &f) : -2;
/* If we have a file, and we're loading into a new buffer, update
* the filename. */
#ifndef DISABLE_MOUSE
print_opt("-m", "--mouse", N_("Enable the use of the mouse"));
#endif
+ print_opt("-n", "--noread", N_("Do not read the file (only write it)"));
#ifndef DISABLE_OPERATINGDIR
print_opt(_("-o <dir>"), _("--operatingdir=<dir>"),
N_("Set operating directory"));
#ifndef DISABLE_MOUSE
{"mouse", 0, NULL, 'm'},
#endif
+ {"noread", 0, NULL, 'n'},
#ifndef DISABLE_OPERATINGDIR
{"operatingdir", 1, NULL, 'o'},
#endif
while ((optchr =
#ifdef HAVE_GETOPT_LONG
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)
#else
getopt(argc, argv,
- "h?ABC:DEFGHIKLNOPQ:RST:UVWY:abcdefgijklmo:pqr:s:tuvwxz$")
+ "h?ABC:DEFGHIKLNOPQ:RST:UVWY:abcdefgijklmno:pqr:s:tuvwxz$")
#endif
) != -1) {
switch (optchr) {
SET(USE_MOUSE);
break;
#endif
+ case 'n':
+ SET(NOREAD_MODE);
+ break;
#ifndef DISABLE_OPERATINGDIR
case 'o':
operating_dir = mallocstrcpy(operating_dir, optarg);
UNDOABLE,
SOFTWRAP,
POS_HISTORY,
- LOCKING
+ LOCKING,
+ NOREAD_MODE
};
/* Flags for the menus in which a given function should be present. */