Compare commits

...

94 Commits
v5.8 ... v5.9

Author SHA1 Message Date
Benno Schulenberg
bec0cdcb54 po: update translations and regenerate POT file and PO files 2021-10-06 10:53:18 +02:00
Benno Schulenberg
ba9e5ac05d bump version numbers and add a news item for the 5.9 release 2021-10-06 10:04:22 +02:00
Benno Schulenberg
46b5f83601 tweaks: fold two lines into two others, for conciseness 2021-10-04 12:03:47 +02:00
Benno Schulenberg
6d5b16562f help: make the keystrokes ^W^Y and ^W^V work again
The keystrokes are not listed, but should work like
they do in a normal, editable buffer.

This fixes https://savannah.gnu.org/bugs/?61274.

Bug existed since version 4.0, commit bc98dbca.
2021-10-04 11:54:02 +02:00
Benno Schulenberg
508301a2ef browser: make the keystrokes ^W^Y and ^W^V work again
The functions to_first_file() and to_last_file() can get called from
do_statusbar_input(), which is called indirectly from do_prompt(),
and are expected to make the corresponding adjustment.

This fixes https://savannah.gnu.org/bugs/?61273.

Bug existed since version 5.0, commit 07c1ac90.
2021-10-04 11:38:30 +02:00
Benno Schulenberg
2f216281e7 syntax: yaml: allow slash and period in key names
Some Yaml files use path names and sometimes version numbers as keys,
even though / and . are not officially in the character set allowed
for key names (just like underscore is not), as far as I understand.

Also, do not colorize any backslash escapes as invalid
because some of them occur sometimes in value strings.

Also, colorize only the valid double-exclamation tags.
2021-10-03 15:38:43 +02:00
Benno Schulenberg
9459030d66 syntax: yaml: allow any character in tags except whitespace
This will colorize also invalid tags, but the rules are too complicated
to catch in a simple regex.

See https://yaml.org/spec/1.2.2/#691-node-tags.
2021-10-03 10:41:03 +02:00
Benno Schulenberg
f545735638 syntax: yaml: colorize the two known directives
See https://yaml.org/spec/1.2.2/#68-directives.

Also, recognize a Yaml file from a %YAML directive on the first line.
2021-10-03 10:14:04 +02:00
Hussam al-Homsi
bb8f40989f tweaks: change 'return ++var;' to 'return var + 1;'
This avoids an unused and misleading assignment that might make
someone think the incremented variable will be used again.

Signed-off-by: Hussam al-Homsi <sawuare@gmail.com>
2021-10-02 17:41:03 +02:00
Benno Schulenberg
675ad6386d syntax: yaml: colorize the question mark of complex mappings too
See https://yaml.org/spec/1.2.2/#22-structures, example 2.11.

Also make the dash more visible by bolding it.
2021-10-02 17:15:50 +02:00
Benno Schulenberg
6ce3487b65 syntax: yaml: colorize backslash-escaped characters as valid or invalid
See https://yaml.org/spec/1.2.2/#57-escaped-characters.

Also prevent an escaped double quote from breaking the coloring of
a string, and allow hyphens in an anchor.
2021-10-02 17:15:32 +02:00
Benno Schulenberg
bc7e7d847e docs: list the default color combo for 'spotlightcolor' in sample nanorc
The comment says that only 'errorcolor' and 'spotlightcolor' have
a default value.  Better list the default value for both of them.
2021-10-01 09:47:45 +02:00
Benno Schulenberg
71a73a1a10 syntax: yaml: allow double colon in key & do not colorize unspaced colon
Perl keys can contain a double colon.  And unspaced colons occur
quite regularly in values (URLs, IPv6 addresses, and the like)
and should not be colored as if they were an error.
2021-10-01 09:44:43 +02:00
Benno Schulenberg
c2790a8af3 syntax: yaml: new file -- coloring rules for YAML files
This fulfills https://bugs.debian.org/982091.
Requested-by: Otto Kekäläinen <otto@debian.org>

Signed-off-by: Benno Schulenberg <bensberg@telfort.nl>
2021-09-29 17:14:03 +02:00
Benno Schulenberg
fde86518ae tweaks: rename a function, to be more fitting
The file wasn't marked; a piece of text was marked, resulting in
a region, and it is this region that gets written out to a file.
2021-09-29 15:37:06 +02:00
Benno Schulenberg
61b3aa6626 tweaks: use five symbolic names, to make eight function calls clearer 2021-09-29 15:35:18 +02:00
Benno Schulenberg
6799bc69a6 tweaks: adjust three parameters -- two were mistaken, one superfluous
The calls of write_file() in do_spell() and do_formatter() write out
a temporary file -- such a file does not have an 'openfile' record,
so setting 'annotate' to TRUE was pointless.  Using the correct value
for this parameter allows dropping two conditions in write_file().

And when 'exiting' is TRUE and --save-on-exit is in effect, it is
slightly wasteful to stat() the written file and store the info in
its 'openfile' record as the buffer will be closed directly after.

So, now the only place where 'annotate' is TRUE is when writing out
the full buffer to a normally named file.
2021-09-29 15:04:22 +02:00
Benno Schulenberg
0c01227d86 tweaks: rename a parameter, to fit better what it is used for 2021-09-29 12:34:04 +02:00
Benno Schulenberg
c74fd81302 tweaks: rename a parameter and invert its logic
This makes more sense (an emergency file is not a temp file) and
avoids the constant negating.
2021-09-29 12:20:21 +02:00
Benno Schulenberg
4b30cfb8f8 tweaks: rename a variable, to be more visible and to match others 2021-09-29 11:56:45 +02:00
Benno Schulenberg
36b6416a7b tweaks: reshuffle some lines and adjust some indentation 2021-09-29 11:52:23 +02:00
Benno Schulenberg
e0334e861d shutdown: when dying, do not install/restore a handler for Ctrl+C
First, we don't want the writing of an emergency file to be interrupted
by the user.  But more important: the routine for restoring the handler
also disables SIGINT, which would leave the terminal with a non-working
Ctrl+C.

Saving an emergency file calls write_file() in a unique manner: with
thefile == NULL, fullbuffer == FALSE (even though the entire buffer
will be saved, of course) and tmp == TRUE (even though it is not a
temporary file, as it will persist after nano exits).  But in fact
we want the handler for Ctrl+C installed only for normal files, not
for temporary files and not for emergency files -- the user should
not be able to interrupt the writing of those.

This fixes https://savannah.gnu.org/bugs/?61237.

Bug existed since version 4.3, commit 8550c6bd.
2021-09-29 11:32:48 +02:00
Benno Schulenberg
b07fb5a811 files: exclude the call of fsync() from the tiny version
To avoid a spurious error message when the user chooses to write
the current buffer to a fifo.

Reported-by: André Kugland <kugland@gmail.com>
  https://lists.gnu.org/archive/html/nano-devel/2021-09/msg00031.html
2021-09-28 11:00:48 +02:00
Benno Schulenberg
9ab49658d7 files: prepending to a fifo makes no sense, so do not try that
Trying to prepend would hang nano until some other process writes
something to the fifo.

This fixes https://savannah.gnu.org/bugs/?61236.

Bug existed since before version 2.2.4.
2021-09-28 10:10:37 +02:00
Benno Schulenberg
bb3d367716 files: making a backup of a fifo makes no sense, so do not try that
This fixes https://savannah.gnu.org/bugs/?61235.

Bug existed since version 4.3, commit 1b2018e9,
since opening a fifo was made possible again.
2021-09-28 09:45:49 +02:00
Benno Schulenberg
26c0a7962e files: check for a fifo only when it is an existing file
To avoid referencing an uninitialized value.

Reported-by: André Kugland <kugland@gmail.com>
  https://lists.gnu.org/archive/html/nano-devel/2021-09/msg00031.html
2021-09-28 09:44:52 +02:00
Benno Schulenberg
a2b20a1915 files: do not call fsync() on a fifo, to avoid a spurious error message
This fixes https://savannah.gnu.org/bugs/?61234.

The original report was in:
  https://lists.gnu.org/archive/html/nano-devel/2021-09/msg00029.html
Reported-by: André Kugland <kugland@gmail.com>

Bug existed since version 5.0, commit a84cdaaa.
2021-09-27 17:23:49 +02:00
Benno Schulenberg
2087c20a83 tweaks: in comments, say "buffer" instead of "file" where appropriate 2021-09-27 16:37:03 +02:00
Benno Schulenberg
5512c63bdd copyright: update to the current year for significantly changed files 2021-09-24 11:01:41 +02:00
Benno Schulenberg
d31cf1da68 gnulib: update to its current upstream state 2021-09-21 16:52:04 +02:00
Benno Schulenberg
ce656cfca8 docs: improve the description of the spotlighting of a search match 2021-09-21 16:49:40 +02:00
Benno Schulenberg
46cdf8b745 startup: if TERM is unset, try falling back to VT220 instead of failing
Curses cannot function if not informed via TERM which type of terminal
is being used.  As many terminals are mostly compatible with a VT220,
falling back to "vt220" when TERM is unset has a good chance of giving
the user a usable nano, instead of simply failing.

(Falling back to "vt100" is not good as it contains padding delays.)

This partially addresses https://bugs.debian.org/991982.
2021-09-20 10:38:25 +02:00
Benno Schulenberg
fdc0b0ac24 tweaks: rename three variables, to follow the general scheme
Also rewrap a line, reshuffle two others, and remove two redundant
comments.
2021-09-20 10:08:56 +02:00
Benno Schulenberg
42b7dea14b docs: add some details to the bug-reporting paragraph in the README
And add a blank line at the end, to make EOF look better.
2021-09-19 12:03:12 +02:00
Benno Schulenberg
239c794503 feedback: use a smaller diamond to represent an anchor, to not overflow
In the terminal font that I use nowadays (that deals well with
combining characters), the normal diamond exceeded the boundaries
of a single cell and thus partly covered the first character of
the relevant line.
2021-09-19 12:03:12 +02:00
Benno Schulenberg
189960c467 cutting: copy anchors into the cutbuffer, so that undo can restore them
When a segment of text is extracted, copy any anchors that it has
into the cutbuffer, so that they get saved in the undo item, so that
an undo will put these anchors back on the lines where they were,
instead of leaving an inherited anchor at the top of the segment.

And when text is pasted, clear any anchors in it, so that they will
not travel nor multiply.

This fixes https://savannah.gnu.org/bugs/?61162.

Bug existed since version 5.0, since anchors were introduced.
2021-09-19 11:29:39 +02:00
Benno Schulenberg
04f8aa83ef tweaks: reshuffle a few lines, for esthetics and to elide an #ifdef 2021-09-17 10:06:21 +02:00
Benno Schulenberg
802a20b222 tweaks: rename a variable, to be more grammatical 2021-09-16 12:32:19 +02:00
Benno Schulenberg
88f7ec38f8 docs: spell "filename" as a single word, like in most other occurrences 2021-09-15 10:27:31 +02:00
Benno Schulenberg
baaff48547 syntax: nanorc: recognize also the template of the sample nanorc file 2021-09-15 10:00:41 +02:00
Benno Schulenberg
0010cd4443 tweaks: slightly reword or rewrap some comments in the sample nanorc 2021-09-15 09:55:14 +02:00
Benno Schulenberg
7d6ffd9e78 docs: don't use "light" after "bold", as the latter often implies "light"
On most terminals "bold" also makes the relevant text lighter (or just
makes it lighter, like on a Linux console).  Only some terminals allow
the user to switch this coupling of bold to light off.

Suggested-by: Hussam al-Homsi <sawuare@gmail.com>
2021-09-14 12:40:32 +02:00
Hussam al-Homsi
b8daf1fb0b docs: correct the default value of the errorcolor option
It should be "bold,white,red" instead of "brightwhite,red"
because "bright" is deprecated and not documented.

Signed-off-by: Hussam al-Homsi <sawuare@gmail.com>
Signed-off-by: Benno Schulenberg <bensberg@telfort.nl>
2021-09-14 12:03:04 +02:00
Benno Schulenberg
fe5f05f037 files: give the user time to absorb a warning about someone else editing
That is: pause a little to jolt the user, and then leave the message
on the status bar.

This fixes https://savannah.gnu.org/bugs/?61147.

Bug existed since version 4.8, commit 416386ed.
2021-09-12 10:43:07 +02:00
Benno Schulenberg
5cedb53c62 files: write a lock file also for a freshly saved buffer
This fixes https://savannah.gnu.org/bugs/?61146

Bug existed since version 2.3.2, since --locking was introduced,
and continued to exist since version 4.8 despite commit 497f126b
claiming to have fixed it.
2021-09-12 10:00:17 +02:00
Benno Schulenberg
650dc14e0f tweaks: rename a defined type, to fit within the general pattern
So that it can be colorized as a type by a general syntax rule.

(The name is now uglier than it was, but... alas.)
2021-09-11 18:05:03 +02:00
Benno Schulenberg
43ebabe05d docs: mention how to properly colorize all types in nano's source code 2021-09-11 17:50:11 +02:00
Benno Schulenberg
b6366411dc tweaks: reshuffle a few lines to avoid an #ifdef and unbalanced braces 2021-09-11 15:07:05 +02:00
Benno Schulenberg
914921887e tweaks: rename a variable, to make more sense 2021-09-11 11:09:56 +02:00
Benno Schulenberg
64a8f1930e history: emit a warning when file cannot be made private [coverity] 2021-09-08 09:15:41 +02:00
Benno Schulenberg
0ac2dfd920 docs: refer to the FAQ when <Alt+Up> does nothing on a Linux console 2021-09-04 12:29:31 +02:00
Benno Schulenberg
aa553ee5d6 docs: correct the descriptions of how to invoke the spell checker
The keystrokes to invoke it changed in version 5.0.
2021-08-30 17:09:41 +02:00
Benno Schulenberg
a8961c561f po: permit the Indonesian PO file to come back -- there was a big update 2021-08-27 12:37:26 +02:00
Benno Schulenberg
abce19b0e4 docs: improve the recipe in the FAQ for dealing with Alt+Up on a console 2021-08-25 11:53:27 +02:00
Benno Schulenberg
fc317660cb tweaks: harmonize the indentations in the FAQ somewhat 2021-08-25 11:28:45 +02:00
Benno Schulenberg
949fcde6f7 docs: indent the paragraphs in the FAQ that list commands to be typed
And use a monospaced font for them.
2021-08-25 11:27:26 +02:00
Benno Schulenberg
9f24b6ea65 po: delete the ancient PO files for Indonesian and Nynorsk
These files haven't been updated in more than fifteen years and their
number of translated strings has dropped to below twenty percent.

Also, prevent them from coming back when next syncing with the TP.
2021-08-24 10:23:06 +02:00
Benno Schulenberg
c6ba4ae89a docs: improve the descriptions of several bindable functions
Some functions behave differently when some lines or a region is marked.
2021-08-23 10:12:55 +02:00
Benno Schulenberg
dab3f95c71 tweaks: instead of "one" use "you", like in the rest of the man page 2021-08-23 10:04:01 +02:00
Benno Schulenberg
840ad5890f docs: move the notice in the main man page, to try and catch other eyes 2021-08-23 10:00:44 +02:00
Benno Schulenberg
ae61bab60b files: when there is a slash after the dot, then there is no extension
This fixes https://savannah.gnu.org/bugs/?61071.

Bug existed since commit f429ebe3 from three days ago.
2021-08-23 09:52:32 +02:00
Benno Schulenberg
d3a7f3abed tweaks: restore a quote that was accidentally deleted four months ago
Commit a69a8ce3 unintentionally removed the double quote that should
terminate the version string.
2021-08-23 09:39:12 +02:00
Benno Schulenberg
694cd9ddd4 build: ensure that mkstemps() is available by importing the gnulib module
The mkstemps() function is not part of the POSIX standard,
so there might be some platforms that don't have it.
2021-08-22 11:42:34 +02:00
Benno Schulenberg
47c8e627f4 build: help Haiku find the header files that define mkstemps()
The documentation (https://www.haiku-os.org/docs/api/libroot.html)
says that BSD extensions are enabled by default, but somehow this
does not seem to be the case on my system.  With _DEFAULT_SOURCE
defined, though, src/files.c now compiles fine.
2021-08-22 11:42:34 +02:00
Benno Schulenberg
f429ebe34d files: add the original file's suffix to the name of a temporary file
This allows 'aspell' to recognize a C file and thus
spell check only the comments and strings.

This fulfills https://savannah.gnu.org/bugs/?61056.
2021-08-22 11:41:19 +02:00
Benno Schulenberg
083bbae0e4 tweaks: rename a variable, away form an abbreviation 2021-08-20 10:35:56 +02:00
Benno Schulenberg
eaff5ec9e5 files: check the result of fdopen(), to avoid a possible crash
When safe_tempfile() returns a valid filename, it should also
return a valid open stream.

This fixes https://savannah.gnu.org/bugs/?61064.

Bug existed since version 1.3.8, commit 5e068c60.
2021-08-20 10:28:42 +02:00
Benno Schulenberg
51eb938fea tweaks: rewrap three lines, for esthetics 2021-08-20 10:14:21 +02:00
Benno Schulenberg
296c5a32c7 docs: replace a non-problem in the FAQ with something possibly useful
Opening a file whose name starts with a plus is not a problem at all.
Instead describe how to get the Alt+Up keystroke to scroll on a Linux
console (on Debian and friends).

This addresses https://savannah.gnu.org/bugs/?57294.
2021-08-18 11:54:54 +02:00
Hussam al-Homsi
ef6ccc47c8 syntax: perl, ruby: remove arbitrary highlighting of here documents
The rules assume that 'STOP' (for Perl) or EOT (for Ruby) is the
terminating string while it could be anything.  Also, the rules
don't take quotes nor backticks nor a tilde into account.

In short: these coloring rules are far too limited.

References:
  https://perldoc.perl.org/perlop#%3C%3CEOF
  https://docs.ruby-lang.org/en/3.0.0/doc/syntax/literals_rdoc.html#label-Here+Documents+-28heredocs-29

Signed-off-by: Hussam al-Homsi <sawuare@gmail.com>
2021-08-09 09:56:50 +02:00
Benno Schulenberg
eea2dfce48 tweaks: fix a typo 2021-07-31 20:48:10 +02:00
Benno Schulenberg
85682abbd5 docs: add a simulated "screenshot" of nano to the README
Suggested-by: Lars Wirzenius -- https://liw.fi/readme-review/
2021-07-21 10:15:07 +02:00
Benno Schulenberg
4005ee3284 docs: mention in the README which licenses cover nano's code and docs
Suggested-by: Lars Wirzenius -- https://liw.fi/readme-review/
2021-07-21 10:01:35 +02:00
Benno Schulenberg
9ead4c87a7 docs: add a paragraph at the start of the README about what nano is
Suggested-by: Lars Wirzenius -- https://liw.fi/readme-review/
2021-07-21 09:29:12 +02:00
Benno Schulenberg
1b5d9171f2 tweaks: try chmodding a dump file only when it was actually written 2021-07-14 10:38:02 +02:00
Benno Schulenberg
50543300d9 tweaks: reshuffle some code to elide a variable, and improve a comment 2021-07-14 10:36:15 +02:00
Benno Schulenberg
d9469b894f tweaks: remove a redundant feedback message
Any error message will already have been written to the terminal by
statusline().  Also, "Buffer not written to" looked too much like
"Buffer written to"; one had to look closely to see the difference.
2021-07-14 10:21:01 +02:00
Benno Schulenberg
6b9c24f7dd feedback: when not in curses mode, write error messages to the terminal
No errors ought to occur when not in curses mode, but when they *do*
occur, increase the chances that we can figure out what happened.
2021-07-14 10:16:31 +02:00
Benno Schulenberg
5954eeaff2 tweaks: reshuffle a fragment of code, to prepare for the next change 2021-07-14 10:08:32 +02:00
Benno Schulenberg
c84a769733 memory: free any allocated strings, also in the emergency code path 2021-07-14 10:06:04 +02:00
Benno Schulenberg
e3ef778756 files: when the buffer is nameless, include the PID in name of dump file
Make sure that when multiple nanos with nameless buffers die,
each of them tries saving those buffers to different files.

This addresses https://savannah.gnu.org/bugs/?60902.
Reported-by: Julian Rosen <julianrosen@gmail.com>
2021-07-14 10:02:44 +02:00
Benno Schulenberg
806e8e439f tweaks: reshuffle some lines to elide a variable
Having a local variable that gets assigned to just once looks rather
poor.  To me it makes more sense to have two separate exit points: one
for failure somewhere in the middle, and one for success at the end.
This way it is completely clear which value gets returned when.
2021-07-10 16:18:29 +02:00
Benno Schulenberg
30aaea2d04 tweaks: rename a variable and flip its logic, to avoid two negations
Plus, it makes more sense to start in the state "not saved" than in
the state "failed".
2021-07-10 15:56:38 +02:00
Benno Schulenberg
d0cb64650b usage: improve the description of the --positionlog option
And make the wording for the --historylog option similar.

This fixes https://savannah.gnu.org/bugs/?60868.

Bug existed since version 2.3.0, commit 8e2a9307, since the
saving and restoring of the cursor position was introduced.
2021-07-01 16:45:49 +02:00
Benno Schulenberg
0694255893 tweaks: adjust a description of 'showcursor', to match the other ones 2021-07-01 16:12:06 +02:00
Benno Schulenberg
5563c710d0 docs: improve the description of the 'tabstospaces' option
It never mentioned to how many spaces a tab would be converted.
2021-07-01 09:52:10 +02:00
Benno Schulenberg
177e4e5805 general: prevent die() from getting recursed into
When something that is called from die() calls die() again,
there is nothing we can do any more but give up.

This would have prevented the spiralling as
seen in https://savannah.gnu.org/bugs/?60853.
2021-06-30 15:54:21 +02:00
Benno Schulenberg
8d1a666dcf input: give up on the input stream only after millions of errors
This mitigates a problem seen sometimes among the Red Hat crash reports:
somehow wgetch() keeps returning ERR, as if it were in nodelay mode.
(I've seen this happen once after nano came out of suspension.)

Using a much larger error-count value gives the user a few seconds
to type something and hopefully get out of the error condition.
2021-06-29 14:31:22 +02:00
Benno Schulenberg
fc01c5a10e feedback: when not in curses mode, just skip displaying any message
Calling die() could trigger another call of emergency_save(), which
could fail and cause another call to statusline(), which would call
die() again...  Spiralling until stack space runs out.

This fixes https://savannah.gnu.org/bugs/?60853.

Bug existed since version 5.1, commit 7942dab0.

Original report was in https://bugzilla.redhat.com/1976410.
Reported-by: Souptik Dutta Roy <duttaroy.souptik@gmail.com>
2021-06-29 13:07:41 +02:00
Benno Schulenberg
896f174f94 syntax: rust: update the license to GPL3 or newer
With permission from the copyright holder:
    https://lists.gnu.org/archive/html/nano-devel/2021-06/msg00037.html

Signed-off-by: Benno Schulenberg <bensberg@telfort.nl>
2021-06-27 11:17:37 +02:00
David Michael
7b4a835df4 syntax: gentoo: remove some obsolete keywords and add some new ones
Removals:
  - All eblits were dropped from Gentoo years ago.
  - HDEPEND was never fully approved, superseded by BDEPEND.
  - Keywords 'dohard' and 'dosed' have been banned since EAPI 4:
    https://projects.gentoo.org/pms/5/pms.html#x1-130001r8
  - Several arches are dead.  For the currently supported list:
    https://gitweb.gentoo.org/repo/gentoo.git/tree/profiles/arch.list

Additions:
  - Two eapply functions replace the epatch functions, but epatch
    is still supported until EAPI 6 is banned.
  - Modern build systems (ninja and qmake5) have new functions.
  - EAPI 7 added more builtins: dostrip, get_libdir, ver_*
  - Highlight the cross-compiler boolean function.  (There are too
    many toolchain functions to add them all, but this one is very
    common and has a long name, so highlighting it is useful for
    catching typos early.)

The EAPI documentation:
    https://projects.gentoo.org/pms/8/pms.html#x1-590007

An extensive write-up on EAPI 7:
    https://mgorny.pl/articles/the-ultimate-guide-to-eapi-7.html

Signed-off-by: David Michael <fedora.dm0@gmail.com>
2021-06-25 16:37:32 +02:00
David Michael
ac85e16458 syntax: gentoo: highlight additional EAPI 7/8 variables
Add IDEPEND from EAPI 8, and also add more EAPI 7 roots so that all
of ROOT, EROOT, SYSROOT, ESYSROOT, and BROOT are supported.

Signed-off-by: David Michael <fedora.dm0@gmail.com>
2021-06-18 11:00:35 +02:00
Benno Schulenberg
45420968ee tweaks: correct two typos and a spello [codespell] 2021-06-17 10:55:23 +02:00
Benno Schulenberg
3c35538e8b tweaks: add Schiermonnikoog to the list of friendly islands
(The commit message is a joke, of course.  Instead, this commit just
removes some unneeded comments and corrects one bit of whitespace.)
2021-06-16 11:19:23 +02:00
76 changed files with 20054 additions and 22739 deletions

103
ChangeLog
View File

@@ -1,3 +1,106 @@
Changes between v5.8 and v5.9:
------------------------------
Benno Schulenberg (88):
browser: make the keystrokes ^W^Y and ^W^V work again
build: ensure that mkstemps() is available by importing the gnulib module
build: help Haiku find the header files that define mkstemps()
bump version numbers and add a news item for the 5.9 release
copyright: update to the current year for significantly changed files
cutting: copy anchors into the cutbuffer, so that undo can restore them
docs: add a paragraph at the start of the README about what nano is
docs: add a simulated "screenshot" of nano to the README
docs: add some details to the bug-reporting paragraph in the README
docs: correct the descriptions of how to invoke the spell checker
docs: don't use "light" after "bold", as the latter often implies "light"
docs: improve the description of the spotlighting of a search match
docs: improve the description of the 'tabstospaces' option
docs: improve the descriptions of several bindable functions
docs: improve the recipe in the FAQ for dealing with Alt+Up on a console
docs: indent the paragraphs in the FAQ that list commands to be typed
docs: list the default color combo for 'spotlightcolor' in sample nanorc
docs: mention how to properly colorize all types in nano's source code
docs: mention in the README which licenses cover nano's code and docs
docs: move the notice in the main man page, to try and catch other eyes
docs: refer to the FAQ when <Alt+Up> does nothing on a Linux console
docs: replace a non-problem in the FAQ with something possibly useful
docs: spell "filename" as a single word, like in most other occurrences
feedback: use a smaller diamond to represent an anchor, to not overflow
feedback: when not in curses mode, just skip displaying any message
feedback: when not in curses mode, write error messages to the terminal
files: add the original file's suffix to the name of a temporary file
files: check for a fifo only when it is an existing file
files: check the result of fdopen(), to avoid a possible crash
files: do not call fsync() on a fifo, to avoid a spurious error message
files: exclude the call of fsync() from the tiny version
files: give the user time to absorb a warning about someone else editing
files: making a backup of a fifo makes no sense, so do not try that
files: prepending to a fifo makes no sense, so do not try that
files: when the buffer is nameless, include the PID in name of dump file
files: when there is a slash after the dot, then there is no extension
files: write a lock file also for a freshly saved buffer
general: prevent die() from getting recursed into
gnulib: update to its current upstream state
help: make the keystrokes ^W^Y and ^W^V work again
history: emit a warning when file cannot be made private [coverity]
input: give up on the input stream only after millions of errors
memory: free any allocated strings, also in the emergency code path
po: delete the ancient PO files for Indonesian and Nynorsk
po: permit the Indonesian PO file to come back -- there was a big update
shutdown: when dying, do not install/restore a handler for Ctrl+C
startup: if TERM is unset, try falling back to VT220 instead of failing
syntax: nanorc: recognize also the template of the sample nanorc file
syntax: rust: update the license to GPL3 or newer
syntax: yaml: allow any character in tags except whitespace
syntax: yaml: allow double colon in key & do not colorize unspaced colon
syntax: yaml: allow slash and period in key names
syntax: yaml: colorize backslash-escaped characters as valid or invalid
syntax: yaml: colorize the question mark of complex mappings too
syntax: yaml: colorize the two known directives
syntax: yaml: new file -- coloring rules for YAML files
tweaks: add Schiermonnikoog to the list of friendly islands
tweaks: adjust a description of 'showcursor', to match the other ones
tweaks: adjust three parameters -- two were mistaken, one superfluous
tweaks: correct two typos and a spello [codespell]
tweaks: fix a typo
tweaks: fold two lines into two others, for conciseness
tweaks: harmonize the indentations in the FAQ somewhat
tweaks: in comments, say "buffer" instead of "file" where appropriate
tweaks: instead of "one" use "you", like in the rest of the man page
tweaks: remove a redundant feedback message
tweaks: rename a defined type, to fit within the general pattern
tweaks: rename a function, to be more fitting
tweaks: rename a parameter and invert its logic
tweaks: rename a parameter, to fit better what it is used for
tweaks: rename a variable and flip its logic, to avoid two negations
tweaks: rename a variable, away form an abbreviation
tweaks: rename a variable, to be more grammatical
tweaks: rename a variable, to be more visible and to match others
tweaks: rename a variable, to make more sense
tweaks: rename three variables, to follow the general scheme
tweaks: reshuffle a few lines, for esthetics and to elide an #ifdef
tweaks: reshuffle a few lines to avoid an #ifdef and unbalanced braces
tweaks: reshuffle a fragment of code, to prepare for the next change
tweaks: reshuffle some code to elide a variable, and improve a comment
tweaks: reshuffle some lines and adjust some indentation
tweaks: reshuffle some lines to elide a variable
tweaks: restore a quote that was accidentally deleted four months ago
tweaks: rewrap three lines, for esthetics
tweaks: slightly reword or rewrap some comments in the sample nanorc
tweaks: try chmodding a dump file only when it was actually written
tweaks: use five symbolic names, to make eight function calls clearer
usage: improve the description of the --positionlog option
David Michael (2):
syntax: gentoo: highlight additional EAPI 7/8 variables
syntax: gentoo: remove some obsolete keywords and add some new ones
Hussam al-Homsi (3):
docs: correct the default value of the errorcolor option
syntax: perl, ruby: remove arbitrary highlighting of here documents
tweaks: change 'return ++var;' to 'return var + 1;'
Changes between v5.7 and v5.8:
------------------------------

View File

@@ -2,7 +2,7 @@ Improvements in GNU nano
========================
Since 5.0:
- A search highlights the found text, in black on yellow by default.
- A search briefly spotlights the found text, in black on yellow by default.
- Option --minibar reduces the interface to a bottom bar with basic info.
- The cursor skips over combining characters, <Del> deletes them together
with the character they combine with, but <Bsp> deletes them separately.

21
NEWS
View File

@@ -1,3 +1,14 @@
2021.10.06 - GNU nano 5.9 "El manicomio ha decidido: mañana sol!"
• The extension of a filename is added to the name of a corresponding
temporary file, so that spell checking a C file, for example, will
check only the comments and strings (when using 'aspell').
• The process number is added to the name of an emergency save file,
so that when multiple nanos die they will not fight over a filename.
• Undoing a cutting operation will restore an anchor that was located
in the cut area to its original line.
• When using --locking, saving a new buffer will create a lock file.
• Syntax highlighting for YAML files has been added.
2021.06.15 - GNU nano 5.8 "Why is it necessary to be special?"
• After a search, the spotlighting is dropped after 1.5 seconds (0.8
seconds with --quick) to avoid the idea that the text is selected.
@@ -1212,9 +1223,9 @@
Have fun with it.
2005.06.30 - GNU nano 1.3.8 floats at its own level. This release
contains several new features. Among other things, you
can now move to a specified column number as well as
line number within a file, file backups saved in a
contains several new features. Among other things,
you can now move to a specified column number as well
as line number within a file, file backups saved in a
backup directory will have unique names, the search and
replace history routines should work more consistently,
you can get a word count by pressing Meta-D at the edit
@@ -1225,8 +1236,8 @@
screen updates, UTF-8 display, and flow control; a fix
for a segfault when displaying some lines ending with
tabs; better handling of constant cursor position
display; improved color parsing in the rcfile; and
support for the "Regexp" toggle in tiny mode
display; improved color parsing in the rcfile;
and support for the "Regexp" toggle in tiny mode
(-R/--regexp is gone, and --restricted's short option
has been changed to -R), among other things. Enjoy.

61
README
View File

@@ -1,10 +1,42 @@
GNU nano -- a simple editor, inspired by Pico
Overview
Purpose
The nano project was started because of a few "problems" with the
wonderfully easy-to-use and friendly Pico text editor.
Nano is a small and simple text editor for use on the terminal.
It copied the interface and key bindings of the Pico editor but
added several missing features: undo/redo, syntax highlighting,
line numbers, softwrapping, multiple buffers, selecting text by
holding Shift, search-and-replace with regular expressions, and
several other conveniences.
Appearance
In rough ASCII graphics, this is what nano's screen looks like:
____________________________________________________________________
| GNU nano 5.9 filename Modified |
--------------------------------------------------------------------
| This is the text window, displaying the contents of a 'buffer', |
| the contents of the file you are editing. |
| |
| The top row of the screen is the 'title bar'; it shows nano's |
| version, the name of the file, and whether you modified it. |
| The two bottom rows display the most important shortcuts; in |
| those lines ^ means Ctrl. The third row from the bottom shows |
| some feedback message, or gets replaced with a prompt bar when |
| you tell nano to do something that requires extra input. |
| |
--------------------------------------------------------------------
| [ Some status message ] |
|^G Help ^O Write Out ^W Where Is ^K Cut ^T Execute |
|^X Exit ^R Read File ^\ Replace ^U Paste ^J Justify |
--------------------------------------------------------------------
Origin
The nano project was started in 1999 because of a few "problems"
with the wonderfully easy-to-use and friendly Pico text editor.
First and foremost was its license: the Pine suite does not use
the GPL, and (before using the Apache License) it had unclear
@@ -23,6 +55,19 @@ Overview
The nano editor is an official GNU package. For more information on
GNU and the Free Software Foundation, please see https://www.gnu.org/.
License
Nano's code and documentation are covered by the GPL version 3 or
(at your option) any later version, except for two functions that
were copied from busybox which are under a BSD license. Nano's
documentation is additionally covered by the GNU Free Documentation
License version 1.2 or (at your option) any later version. See the
files COPYING and COPYING.DOC for the full text of these licenses.
When in any file of this package a copyright notice mentions a
year range (such as 1999-2011), it is a shorthand for a list of
all the years in that interval.
How to compile and install nano
Download the latest nano source tarball, and then:
@@ -70,10 +115,8 @@ Mailing Lists
Bug Reports
If you find a bug, please file a detailed description of the problem
on nano's bug tracker: https://savannah.gnu.org/bugs/?group=nano.
on nano's issue tracker: https://savannah.gnu.org/bugs/?group=nano
(you will need an account to be able to do so), or send an email
to the nano-devel list (no need to subscribe, but mention it if
you want to be CC'ed on an answer).
Copyright Years
When in any file of this package a copyright notice mentions a
year range (such as 1999-2011), it is a shorthand for a list of
all the years in that interval.

View File

@@ -84,7 +84,6 @@ Problems?
Please submit any bugs you find in the code in git via the bug tracker
on Savannah (https://savannah.gnu.org/bugs/?group=nano).
Contributing something
----------------------
@@ -114,3 +113,11 @@ to include 'set tabsize 4', or you could use -T4 on the command line.
To make git display things as intended, you can do:
$ git config --local core.pager "less -x1,5"
To see all types that are used in nano's source code colorized as types,
you can add these lines to your ~/.nanorc:
extendsyntax c color green "\<struct (dirent|option|passwd)\>"
extendsyntax c color green "\<struct (sigaction|stat|termios)\>"
extendsyntax c color green "\<struct (timespec|vt_stat|winsize)\>"
extendsyntax c color green "\<([[:lower:]_]+(struct|type)|va_list)\>"

View File

@@ -2,7 +2,7 @@
# Generate configure & friends for GIT users.
gnulib_url="git://git.sv.gnu.org/gnulib.git"
gnulib_hash="ff7c8b21e259fdc4bc721ed55519cfee06739efa"
gnulib_hash="9aca7b67333fd0a90bf56104325ce96199644451"
modules="
futimens
@@ -13,6 +13,7 @@ modules="
isblank
iswblank
lstat
mkstemps
nl_langinfo
regex
sigaction

View File

@@ -16,7 +16,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see https://www.gnu.org/licenses/.
AC_INIT([GNU nano], [5.8], [nano-devel@gnu.org], [nano])
AC_INIT([GNU nano], [5.9], [nano-devel@gnu.org], [nano])
AC_CONFIG_SRCDIR([src/nano.c])
AC_CANONICAL_HOST
AM_INIT_AUTOMAKE([1.14])

View File

@@ -5,6 +5,9 @@
<title>The GNU nano editor FAQ</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="description" content="The genesis story of the nano editor, plus the solution to some common problems.">
<style>
.indented { margin-left: 2em; font-family: courier; font-size: 110%; }
</style>
</head>
<body text="#330000" bgcolor="#ffffff" link="#0000ef" vlink="#51188e" alink="#ff0000">
@@ -40,7 +43,7 @@
</p></blockquote>
<h3><a href="#4">4. Running</a></h3>
<blockquote><p>
<a href="#4.1">4.1. How do I open a file with a name beginning with '+' from the command line?</a><br>
<a href="#4.1">4.1. Alt+Up does nothing on a Linux console. How can I make it scroll?</a><br>
<a href="#4.2">4.2. How can I make Ctrl+Shift+Left/Right select words on urxvt?</a><br>
<a href="#4.3">4.3. Ack! My numeric keypad's keys don't work properly when NumLock is off! What can I do?</a><br>
<a href="#4.4">4.4. With what keystroke can I paste text from the clipboard into nano?</a><br>
@@ -89,7 +92,7 @@
<h3><a name="1.3"></a>1.3. Why the name change from TIP?</h3>
<blockquote><p>On January 10, 2000, TIP was officially renamed to nano because of a namespace conflict with another program called 'tip'. The original 'tip' program &quot;establishes a full duplex terminal connection to a remote host&quot;, and was included with many older Unix systems (and newer ones like Solaris). The conflict was not noticed at first because there is no 'tip' utility included with most GNU/Linux distributions (where nano was developed).</p></blockquote>
<h3><a name="1.4"></a>1.4. What is the current version of nano?</h3>
<blockquote><p>The current version of nano <i>should</i> be <b>5.8</b>. Of course, you should always check the <a href="https://nano-editor.org/">nano homepage</a> to see what the latest and greatest version is.</p></blockquote>
<blockquote><p>The current version of nano <i>should</i> be <b>5.9</b>. Of course, you should always check the <a href="https://nano-editor.org/">nano homepage</a> to see what the latest and greatest version is.</p></blockquote>
<h3><a name="1.5"></a>1.5. I want to read the man page without having to download the program!</h3>
<blockquote><p>Jeez, demanding, aren't we? Okay, look <a href="https://nano-editor.org/dist/latest/nano.1.html">here</a>.</p></blockquote>
<hr width="100%">
@@ -127,39 +130,39 @@
<blockquote><p>It's simple really! As root, type <b>rpm -Uvh nano-x.y-1*.rpm</b> if you have a RedHat-ish system or <b>dpkg -i nano_x.y-1*.deb</b> if you have a Debian-ish system, where <b>x.y</b> is the version number of nano. There are other programs to install packages, and if you wish to use those, knock yourself out.</p></blockquote>
<h3><a name="3.2"></a>3.2. Compiling from source: WHAT THE HECK DO I DO NOW?</h3>
<blockquote><p>Okay, take a deep breath, this really isn't hard. Unpack the nano source with a command like:</p>
<p><b>tar -xvf nano-x.y.tar.gz</b></p>
<p class="indented"><b>tar -xvf nano-x.y.tar.gz</b></p>
<p>Then you need to run <b>configure</b> with any options you might want (if any).</p>
<p>The average case is this:</p>
<p><b>cd nano-x.y/</b><br>
<p class="indented"><b>cd nano-x.y/</b><br>
<b>./configure</b><br>
<b>make</b><br>
<b>make install</b> (as root, of course)</p></blockquote>
<b>make install</b>&nbsp;&nbsp; #(as root, of course)</p></blockquote>
<h3><a name="3.3"></a>3.3. Why does everything go into /usr/local?</h3>
<blockquote><p>Well, that's what the <b>configure</b> script defaults to. If you wish to change this, simply do this:</p>
<p><b>./configure --prefix=/usr</b></p>
<p class="indented"><b>./configure --prefix=/usr</b></p>
<p>This will put nano into /usr/bin when you run <b>make install</b>.</p></blockquote>
<h3><a name="3.4"></a>3.4. nano should automatically run strip on the binary when installing it!</h3>
<blockquote><p>It does when you use <b>make install-strip</b>. The default <b>make install</b> does not, and will not, run strip automatically.</p></blockquote>
<h3><a name="3.5"></a>3.5. How can I make the executable smaller? This is too bloated!</h3>
<blockquote><p>Actually, there are several parts of the editor that can be disabled. You can pass arguments to the <b>configure</b> script that disable certain features. Here's a brief list:</p>
<pre>
<b>--disable-browser</b> Disable the built-in file browser
<b>--disable-color</b> Disable color and syntax highlighting
<b>--disable-comment</b> Disable the comment/uncomment function
<b>--disable-extra</b> Disable the easter egg
<b>--disable-help</b> Disable the built-in help texts
<b>--disable-histories</b> Disable the saving of search strings and cursor positions
<b>--disable-justify</b> Disable the justify/unjustify functions
<b>--disable-libmagic</b> Disable the use of libmagic for determining a file's syntax
<b>--disable-linenumbers</b> Disable line numbering
<b>--disable-mouse</b> Disable mouse support
<b>--disable-multibuffer</b> Disable the opening of multiple file buffers
<b>--disable-nanorc</b> Disable the use of .nanorc files
<b>--disable-operatingdir</b> Disable the setting of an operating directory
<b>--disable-speller</b> Disable the spell-checker functions
<b>--disable-tabcomp</b> Disable the tab-completion functions
<b>--disable-wordcomp</b> Disable the word-completion function
<b>--disable-wrapping</b> Disable all hard-wrapping of text</pre>
<b>--disable-browser</b> Disable the built-in file browser
<b>--disable-color</b> Disable color and syntax highlighting
<b>--disable-comment</b> Disable the comment/uncomment function
<b>--disable-extra</b> Disable the easter egg
<b>--disable-help</b> Disable the built-in help texts
<b>--disable-histories</b> Disable the saving of search strings and cursor positions
<b>--disable-justify</b> Disable the justify/unjustify functions
<b>--disable-libmagic</b> Disable the use of libmagic for determining a file's syntax
<b>--disable-linenumbers</b> Disable line numbering
<b>--disable-mouse</b> Disable mouse support
<b>--disable-multibuffer</b> Disable the opening of multiple file buffers
<b>--disable-nanorc</b> Disable the use of .nanorc files
<b>--disable-operatingdir</b> Disable the setting of an operating directory
<b>--disable-speller</b> Disable the spell-checker functions
<b>--disable-tabcomp</b> Disable the tab-completion functions
<b>--disable-wordcomp</b> Disable the word-completion function
<b>--disable-wrapping</b> Disable all hard-wrapping of text</pre>
<p>There's also the <b>--enable-tiny</b> option which disables everything above, as well as some larger chunks of the program (like the undo/redo code and the code for selecting text). Also, if you know you don't need other languages, you can use <b>--disable-nls</b> to disable internationalization and save a few kilobytes. And finally, there's always good old <b>strip</b> to remove all unneeded symbols.</p>
</blockquote>
<h3><a name="3.6"></a>3.6. Tell me more about this multibuffer stuff!</h3>
@@ -175,13 +178,19 @@
<hr width="100%">
<h1><a name="4"></a>4. Running</h1>
<h3><a name="4.1"></a>4.1. How do I open a file with a name beginning with '+' from the command line?</h3>
<blockquote><p>If a command-line argument that begins with '+' is followed by another argument, the former is always treated as a starting line (plus column number), and the latter always as a filename. If a command-line argument that begins with '+' isn't followed by another argument, it's treated as a filename. Examples:</p>
<p>To open '+filename.txt': <b>nano +filename.txt</b><br>
To open '+filename.txt' starting on line 10: <b>nano +10 +filename.txt</b><br>
To open '+filename.txt' starting on line 1, column 20: <b>nano +,20 +filename.txt</b><br>
To open '+filename.txt' starting on line 10, column 20: <b>nano +10,20 +filename.txt</b><br>
To open '+filename.txt' starting on line 1 and 'filename.txt' starting on line 40: <b>nano +1 +filename.txt +40 filename.txt</b></p></blockquote>
<h3><a name="4.1"></a>4.1. Alt+Up does nothing on a Linux console. How can I make it scroll?</h3>
<blockquote><p>On Debian and its derivatives, the <b>Alt+Up</b> keystroke on a Linux console
produces by default a 'KeyboardSignal', which normally does absolutely nothing and is useless
for the average user. To get the keystroke to do what it ought to do (scroll the viewport
one row up), run this in a Linux console:</p>
<p class="indented"><b>dumpkeys --full | sed s/KeyboardSignal/Up/ | sudo loadkeys -</b></p>
<p>You will need to run this command whenever you first switch to a Linux console.</p>
<p>Or you can (as root) execute the following little script just once:</p>
<p class="indented"><b>for file in /etc/console-setup/cached*.kmap.gz; do<br>
&nbsp;&nbsp;&nbsp;&nbsp;gunzip $file;<br>
&nbsp;&nbsp;&nbsp;&nbsp;sed -i 's/KeyboardSignal/Up/' ${file%.gz};<br>
&nbsp;&nbsp;&nbsp;&nbsp;gzip ${file%.gz};<br>
done</b></p></blockquote>
<h3><a name="4.2"></a>4.2. How can I make Ctrl+Shift+Left/Right select words on urxvt?</h3>
<blockquote><p>The urxvt terminal emulator produces non-standard escape sequences for the modified cursor keys. These deviant sequences are not listed in the terminfo database, which means that ncurses does not recognize them. The easiest way around this is to tell urxvt to produce xterm-compatible escape sequences for the relevant keystrokes. To achieve this, add the following lines to your ~/.Xresources file:</p>
<pre>
@@ -219,16 +228,16 @@
<blockquote><p>If you want nano to actually use color, you have to specify the color configurations you want it to use in your .nanorc. Several example configurations are in the <b>syntax/</b> subdirectory of the nano source, which are normally installed to <b>/usr/local/share/nano/</b>. To enable all of them, uncomment the line <b># include "/usr/local/share/nano/*.nanorc"</b> in your nanorc. See also section <a href="#3.9">3.9</a>.</p></blockquote>
<h3><a name="4.9"></a>4.9. How do I make nano my default editor (in Pine, mutt, etc.)?</h3>
<blockquote><p>You need to make nano your $EDITOR. If you want this to be saved, you should put a line like this in your <b>.bashrc</b> if you use bash (or <b>.zshrc</b> if you believe in zsh):</p>
<p><b>export EDITOR=/usr/local/bin/nano</b></p>
<p class="indented"><b>export EDITOR=/usr/local/bin/nano</b></p>
<p>or, if you use tcsh, put this in your <b>.cshrc</b> file:</p>
<p><b>setenv EDITOR /usr/local/bin/nano</b></p>
<p class="indented"><b>setenv EDITOR /usr/local/bin/nano</b></p>
<p>Change /usr/local/bin/nano to wherever nano is installed on your system. Type &quot;which nano&quot; to find out. This will not take effect until the next time you log in. So log out and back in again.</p>
<p>Then, on top of that, if you use Pine, you must go into setup (type <b>S</b> at the main menu), and then configure (type <b>C</b>). Hit Enter on the lines that say:</p>
<p><b>[ ] enable-alternate-editor-cmd</b><br>
<p class="indented"><b>[ ] enable-alternate-editor-cmd</b><br>
<b>[ ] enable-alternate-editor-implicitly</b></p>
<p>Then exit (<b>E</b>) and select Yes (<b>Y</b>).</p>
<p>If you're a mutt user, you should see an effect immediately the next time you log in. No further configuration is needed. However, if you want to let people know you use nano to compose your email messages, you can put a line like this in your <b>.muttrc</b>:</p>
<p><b>my_hdr X-Composer: nano-x.y</b></p>
<p class="indented"><b>my_hdr X-Composer: nano-x.y</b></p>
<p>Again, replace x.y with the version of nano you use.</p></blockquote>
<hr width="100%">

View File

@@ -16,7 +16,7 @@
.\" Documentation License along with this program. If not, see
.\" <https://www.gnu.org/licenses/>.
.\"
.TH NANO 1 "version 5.8" "June 2021"
.TH NANO 1 "version 5.9" "October 2021"
.SH NAME
nano \- Nano's ANOther editor, inspired by Pico
@@ -27,20 +27,6 @@ nano \- Nano's ANOther editor, inspired by Pico
.sp
.BR nano " [" \fIoptions "] [[" + [ crCR ]( / | ? ) \fIstring "] " \fIfile ]...
.SH NOTICE
Since version 4.0, \fBnano\fR by default:
.sp
.RS 4
\(bu does not automatically hard-wrap lines that become overlong,
.br
\(bu includes the line below the title bar in the editing area,
.br
\(bu does linewise (smooth) scrolling.
.RE
.sp
If you want the old, Pico behavior back, you can use \fB\-\-breaklonglines\fR,
\fB\-\-emptyline\fR, and \fB\-\-jumpyscrolling\fR (or \fB\-bej\fR for short).
.SH DESCRIPTION
\fBnano\fP is a small and friendly editor. It copies the look and feel
of Pico, but is free software, and implements several features that Pico
@@ -58,7 +44,7 @@ regular expression by inserting \fBc\fR and/or \fBr\fR after the \fB+\fR sign.
These search modes can be explicitly disabled by using the uppercase variant
of those letters: \fBC\fR and/or \fBR\fR. When the string contains spaces,
it needs to be enclosed in quotes. To give an example: to open a file at
the first occurrence of the word "Foo", one would do:
the first occurrence of the word "Foo", you would do:
.sp
.RS 4
.BI "nano +c/Foo " file
@@ -77,11 +63,11 @@ Any cursor movement or executing any other command will cause the next
\fB^K\fR to overwrite the cutbuffer. A \fB^U\fR will paste the current
contents of the cutbuffer at the current cursor position.
.sp
When a more precise piece of text needs to be cut or copied, one can mark
When a more precise piece of text needs to be cut or copied, you can mark
its start with \fB^6\fR, move the cursor to its end (the marked text will be
highlighted), and then use \fB^K\fR to cut it, or \fBM\-6\fR to copy it to the
cutbuffer. One can also save the marked text to a file with \fB^O\fR, or
spell check it with \fB^T\fR.
cutbuffer. You can also save the marked text to a file with \fB^O\fR, or
spell check it with \fB^T^T\fR.
.sp
On some terminals, text can be selected also by holding down Shift while
using the arrow keys. Holding down the Ctrl or Alt key too will increase
@@ -93,6 +79,20 @@ the built-in help (\fB^G\fR) lists all the available ones.
The default key bindings can be changed via a \fInanorc\fR file -- see
.BR nanorc (5).
.SH NOTICE
Since version 4.0, \fBnano\fR by default:
.sp
.RS 4
\(bu does not automatically hard-wrap lines that become overlong,
.br
\(bu includes the line below the title bar in the editing area,
.br
\(bu does linewise (smooth) scrolling.
.RE
.sp
If you want the old, Pico behavior back, you can use \fB\-\-breaklonglines\fR,
\fB\-\-emptyline\fR, and \fB\-\-jumpyscrolling\fR (or \fB\-bej\fR for short).
.SH OPTIONS
.TP
.BR \-A ", " \-\-smarthome
@@ -118,7 +118,8 @@ by setting the options \fBtitlecolor\fP, \fBstatuscolor\fP, \fBkeycolor\fP,
nanorc file. See \fBnanorc\fR(5).
.TP
.BR \-E ", " \-\-tabstospaces
Convert typed tabs to spaces.
Convert each typed tab to spaces -- to the number of spaces
that a tab at that position would take up.
.TP
.BR \-F ", " \-\-multibuffer
Read a file into a new buffer by default.
@@ -340,14 +341,14 @@ filename in the center of the title bar.
.BR \-_ ", " \-\-minibar
Suppress the title bar and instead show information about
the current buffer at the bottom of the screen, in the space
for the status bar. In this "minibar" the file name is shown
for the status bar. In this "minibar" the filename is shown
on the left, followed by an asterisk if the buffer has been modified.
On the right are displayed the current line and column number, the
code of the character under the cursor (in Unicode format: U+xxxx),
the same flags as are shown by \fB\-\-stateflags\fR, and a percentage
that expresses how far the cursor is into the file (linewise).
When a file is loaded or saved, and also when switching between buffers,
the number of lines in the buffer is displayed after the file name.
the number of lines in the buffer is displayed after the filename.
This number is cleared upon the next keystroke, or replaced with an
[i/n] counter when multiple buffers are open.
The line plus column numbers and the character code are displayed only when

View File

@@ -8,8 +8,8 @@
@smallbook
@set EDITION 0.6
@set VERSION 5.8
@set UPDATED June 2021
@set VERSION 5.9
@set UPDATED October 2021
@dircategory Editors
@direntry
@@ -23,7 +23,7 @@
@titlepage
@title GNU @command{nano}
@subtitle a small and friendly text editor
@subtitle version 5.8
@subtitle version 5.9
@author Chris Allegretta
@page
@@ -65,7 +65,7 @@ For suggesting improvements: @email{nano-devel@@gnu.org}@*
@node Top
@top
This manual documents the GNU @command{nano} editor, version 5.8.
This manual documents the GNU @command{nano} editor, version 5.9.
@menu
* Introduction::
@@ -195,7 +195,8 @@ nanorc file. @xref{@code{set functioncolor}} for details.
@item -E
@itemx --tabstospaces
Convert typed tabs to spaces.
Convert each typed tab to spaces --- to the number of spaces
that a tab at that position would take up.
@item -F
@itemx --multibuffer
@@ -483,14 +484,14 @@ filename in the center of the title bar.
@itemx --minibar
Suppress the title bar and instead show information about
the current buffer at the bottom of the screen, in the space
for the status bar. In this "minibar" the file name is shown
for the status bar. In this "minibar" the filename is shown
on the left, followed by an asterisk if the buffer has been modified.
On the right are displayed the current line and column number, the
code of the character under the cursor (in Unicode format: U+xxxx),
the same flags as are shown by @code{--stateflags}, and a percentage
that expresses how far the cursor is into the file (linewise).
When a file is loaded or saved, and also when switching between buffers,
the number of lines in the buffer is displayed after the file name.
the number of lines in the buffer is displayed after the filename.
This number is cleared upon the next keystroke, or replaced with an
[i/n] counter when multiple buffers are open.
The line plus column numbers and the character code are displayed only when
@@ -590,7 +591,7 @@ or @kbd{M-A} and then moving the cursor to the other end of the portion
to be selected. The selected portion of text will be highlighted.
This selection can now be cut or copied in its entirety with a single
@kbd{^K} or @kbd{M-6}. Or the selection can be used to limit the scope of
a search-and-replace (@kbd{^\}) or spell-checking session (@kbd{^T}).
a search-and-replace (@kbd{^\}) or spell-checking session (@kbd{^T^T}).
On some terminals, text can be selected also by holding down @kbd{Shift}
while using the cursor keys. Holding down the @kbd{Ctrl} or @kbd{Alt}
@@ -858,7 +859,7 @@ Do not use the line below the title bar, leaving it entirely blank.
@item set errorcolor [bold,][italic,]@var{fgcolor},@var{bgcolor}
Use this color combination for the status bar when an error message is displayed.
The default value is @t{brightwhite,red}.
The default value is @t{bold,white,red}.
@xref{@code{set functioncolor}} for valid color names.
@item set fill @var{number}
@@ -936,14 +937,14 @@ The default value is "@t{(<[@{)>]@}}".
@item set minibar
Suppress the title bar and instead show information about
the current buffer at the bottom of the screen, in the space
for the status bar. In this "minibar" the file name is shown
for the status bar. In this "minibar" the filename is shown
on the left, followed by an asterisk if the buffer has been modified.
On the right are displayed the current line and column number, the
code of the character under the cursor (in Unicode format: U+xxxx),
the same flags as are shown by @code{set stateflags}, and a percentage
that expresses how far the cursor is into the file (linewise).
When a file is loaded or saved, and also when switching between buffers,
the number of lines in the buffer is displayed after the file name.
the number of lines in the buffer is displayed after the filename.
This number is cleared upon the next keystroke, or replaced with an
[i/n] counter when multiple buffers are open.
The line plus column numbers and the character code are displayed only when
@@ -1095,7 +1096,8 @@ Use a tab size of @var{number} columns. The value of @var{number} must be
greater than 0. The default value is @t{8}.
@item set tabstospaces
Convert typed tabs to spaces.
Convert each typed tab to spaces --- to the number of spaces
that a tab at that position would take up.
@item set titlecolor [bold,][italic,]@var{fgcolor},@var{bgcolor}
Use this color combination for the title bar.
@@ -1412,7 +1414,8 @@ the line, column, and character positions.
(The old name of this function, 'curpos', is deprecated.)
@item wordcount
Counts the number of words, lines and characters in the current buffer.
Counts and reports on the status bar the number of lines, words,
and characters in the current buffer (or in the marked region).
@item execute
Prompts for a program to execute. The program's output will be inserted
@@ -1430,27 +1433,28 @@ Invokes a full-buffer-processing program (if the active syntax defines one).
Invokes a syntax-checking program (if the active syntax defines one).
@item justify
Justifies the current paragraph. A paragraph is a group of contiguous lines
Justifies the current paragraph (or the marked region).
A paragraph is a group of contiguous lines
that, apart from possibly the first line, all have the same indentation. The
beginning of a paragraph is detected by either this lone line with a differing
indentation or by a preceding blank line.
@item fulljustify
Justifies the entire current buffer.
Justifies the entire current buffer (or the marked region).
@item indent
Indents (shifts to the right) the currently marked text.
Indents (shifts to the right) the current line or the marked lines.
@item unindent
Unindents (shifts to the left) the currently marked text.
Unindents (shifts to the left) the current line or the marked lines.
@item comment
Comments or uncomments the current line or marked lines, using the comment
style specified in the active syntax.
Comments or uncomments the current line or the marked lines,
using the comment style specified in the active syntax.
@item complete
Completes the fragment before the cursor to a full word found elsewhere
in the current buffer.
Completes (when possible) the fragment before the cursor
to a full word found elsewhere in the current buffer.
@item left
Goes left one position (in the editor or browser).
@@ -1467,10 +1471,14 @@ Goes one line down (in the editor or browser).
@item scrollup
Scrolls the viewport up one row (meaning that the text slides down)
while keeping the cursor in the same text position, if possible.
(This function is bound by default to <Alt+Up>.
If <Alt+Up> does nothing on your Linux console, see the FAQ:
@url{https://nano-editor.org/dist/latest/faq.html#4.1}.)
@item scrolldown
Scrolls the viewport down one row (meaning that the text slides up)
while keeping the cursor in the same text position, if possible.
(This function is bound by default to <Alt+Down>.)
@item center
Scrolls the line with the cursor to the middle of the screen.

View File

@@ -16,7 +16,7 @@
.\" Documentation License along with this program. If not, see
.\" <https://www.gnu.org/licenses/>.
.\"
.TH NANORC 5 "version 5.8 "June 2021"
.TH NANORC 5 "version 5.9" "October 2021"
.SH NAME
nanorc \- GNU nano's configuration file
@@ -127,7 +127,7 @@ Do not use the line below the title bar, leaving it entirely blank.
.TP
.B set errorcolor \fR[\fBbold,\fR][\fBitalic,\fR]\fIfgcolor\fB,\fIbgcolor\fR
Use this color combination for the status bar when an error message is displayed.
The default value is \fBbrightwhite,red\fR.
The default value is \fBbold,white,red\fR.
See \fBset titlecolor\fR for valid color names.
.TP
.B set fill \fInumber\fR
@@ -185,14 +185,14 @@ The default value is "\fB(<[{)>]}\fP".
.B set minibar
Suppress the title bar and instead show information about
the current buffer at the bottom of the screen, in the space
for the status bar. In this "minibar" the file name is shown
for the status bar. In this "minibar" the filename is shown
on the left, followed by an asterisk if the buffer has been modified.
On the right are displayed the current line and column number, the
code of the character under the cursor (in Unicode format: U+xxxx),
the same flags as are shown by \fBset stateflags\fR, and a percentage
that expresses how far the cursor is into the file (linewise).
When a file is loaded or saved, and also when switching between buffers,
the number of lines in the buffer is displayed after the file name.
the number of lines in the buffer is displayed after the filename.
This number is cleared upon the next keystroke, or replaced with an
[i/n] counter when multiple buffers are open.
The line plus column numbers and the character code are displayed only when
@@ -297,8 +297,9 @@ Use this color combination for selected text.
See \fBset titlecolor\fR for more details.
.TP
.B set showcursor
Put the cursor on the highlighted item in the file browser, to aid
braille users.
Put the cursor on the highlighted item in the file browser, and show
the cursor in the help viewer, to aid braille users and people with
poor vision.
.TP
.B set smarthome
Make the Home key smarter. When Home is pressed anywhere but at the
@@ -345,7 +346,8 @@ Use a tab size of \fInumber\fR columns. The value of \fInumber\fP must be
greater than 0. The default value is \fB8\fR.
.TP
.B set tabstospaces
Convert typed tabs to spaces.
Convert each typed tab to spaces -- to the number of spaces
that a tab at that position would take up.
.TP
.B set titlecolor \fR[\fBbold,\fR][\fBitalic,\fR]\fIfgcolor\fB,\fIbgcolor\fR
Use this color combination for the title bar.
@@ -655,7 +657,8 @@ the line, column, and character positions.
(The old name of this function, 'curpos', is deprecated.)
.TP
.B wordcount
Counts the number of words, lines and characters in the current buffer.
Counts and reports on the status bar the number of lines, words,
and characters in the current buffer (or in the marked region).
.TP
.B execute
Prompts for a program to execute. The program's output will be inserted
@@ -672,27 +675,28 @@ Invokes a full-buffer-processing program (if the active syntax defines one).
Invokes a syntax-checking program (if the active syntax defines one).
.TP
.B justify
Justifies the current paragraph. A paragraph is a group of contiguous lines
Justifies the current paragraph (or the marked region).
A paragraph is a group of contiguous lines
that, apart from possibly the first line, all have the same indentation. The
beginning of a paragraph is detected by either this lone line with a differing
indentation or by a preceding blank line.
.TP
.B fulljustify
Justifies the entire current buffer.
Justifies the entire current buffer (or the marked region).
.TP
.B indent
Indents (shifts to the right) the currently marked text.
Indents (shifts to the right) the current line or the marked lines.
.TP
.B unindent
Unindents (shifts to the left) the currently marked text.
Unindents (shifts to the left) the current line or the marked lines.
.TP
.B comment
Comments or uncomments the current line or marked lines, using the comment
style specified in the active syntax.
Comments or uncomments the current line or the marked lines,
using the comment style specified in the active syntax.
.TP
.B complete
Completes the fragment before the cursor to a full word found elsewhere
in the current buffer.
Completes (when possible) the fragment before the cursor
to a full word found elsewhere in the current buffer.
.TP
.B left
Goes left one position (in the editor or browser).
@@ -709,10 +713,15 @@ Goes one line down (in the editor or browser).
.B scrollup
Scrolls the viewport up one row (meaning that the text slides down)
while keeping the cursor in the same text position, if possible.
(This function is bound by default to <Alt+Up>.
If <Alt+Up> does nothing on your Linux console, see the FAQ:
.UR https://nano\-editor.org/dist/latest/faq.html#4.1
.UE .)
.TP
.B scrolldown
Scrolls the viewport down one row (meaning that the text slides up)
while keeping the cursor in the same text position, if possible.
(This function is bound by default to <Alt+Down>.)
.TP
.B center
Scrolls the line with the cursor to the middle of the screen.

View File

@@ -16,7 +16,7 @@
.\" Documentation License along with this program. If not, see
.\" <https://www.gnu.org/licenses/>.
.\"
.TH RNANO 1 "version 5.8" "June 2021"
.TH RNANO 1 "version 5.9" "October 2021"
.SH NAME
rnano \- a restricted nano

View File

@@ -78,18 +78,19 @@
## Fall back to slow libmagic to try and determine an applicable syntax.
# set magic
## The opening and closing brackets that can be found by bracket
## searches. They cannot contain blank characters. The former set must
## come before the latter set, and both must be in the same order.
## The opening and closing brackets that are found by a matching-bracket
## search. This may not contain blank characters. The opening brackets
## must come before the closing ones, and they must be in the same order.
# set matchbrackets "(<[{)>]}"
## Suppress title bar and show file name and editor state at the bottom.
## Suppress the title bar and show the filename plus a cursor-position
## percentage in the space of the status bar.
# set minibar
## Enable mouse support, if available for your system. When enabled,
## mouse clicks can be used to place the cursor, set the mark (with a
## double click), and execute shortcuts. The mouse will work in the X
## Window System, and on the console when gpm is running.
## double click), and execute shortcuts. The mouse will work in the
## X Window System, and on the console when gpm is running.
# set mouse
## Switch on multiple file buffers (inserting a file will put it into
@@ -117,10 +118,9 @@
## Preserve the XON and XOFF keys (^Q and ^S).
# set preserve
## The characters treated as closing punctuation when justifying
## paragraphs. They cannot contain blank characters. Only closing
## punctuation, optionally followed by closing brackets, can end
## sentences.
## The characters treated as closing punctuation when justifying paragraphs.
## This may not contain blank characters. Only these closing punctuations,
## optionally followed by closing brackets, can end sentences.
# set punct "!.?"
## Make status-bar messages disappear after 1 keystroke instead of after 20.
@@ -144,16 +144,16 @@
# set saveonexit
## (The old form of this option, 'set tempfile', is deprecated.)
## Put the cursor on the highlighted item in the file browser, and show
## the cursor in the help viewer; useful for people who use a braille
## display and people with poor vision.
## Put the cursor on the highlighted item in the file browser, and
## show the cursor in the help viewer; useful for people who use a
## braille display and people with poor vision.
# set showcursor
## Make the Home key smarter. When Home is pressed anywhere but at the
## Make the Home key smarter: when Home is pressed anywhere but at the
## very beginning of non-whitespace characters on a line, the cursor
## will jump to that beginning (either forwards or backwards). If the
## cursor is already at that position, it will jump to the true
## beginning of the line.
## cursor is already at that position, it will jump to the true start
## of the line (the left edge).
# set smarthome
## Spread overlong lines over multiple screen lines.
@@ -174,7 +174,7 @@
## Use this tab size instead of the default; it must be greater than 0.
# set tabsize 8
## Convert typed tabs to spaces.
## Convert each typed tab to the fitting number of spaces.
# set tabstospaces
## Snip whitespace at the end of lines when justifying or hard-wrapping.
@@ -204,11 +204,11 @@
## Paint the interface elements of nano. These are examples; there are
## no colors by default, except for errorcolor and spotlightcolor.
# set titlecolor bold,lightwhite,blue
# set promptcolor lightwhite,lightblack
# set statuscolor bold,lightwhite,green
# set errorcolor bold,lightwhite,red
# set spotlightcolor black,lime
# set titlecolor bold,white,blue
# set promptcolor lightwhite,grey
# set statuscolor bold,white,green
# set errorcolor bold,white,red
# set spotlightcolor black,lightyellow
# set selectedcolor lightwhite,magenta
# set stripecolor ,yellow
# set scrollercolor cyan
@@ -217,10 +217,10 @@
# set functioncolor green
## In root's .nanorc you might want to use:
# set titlecolor bold,lightwhite,magenta
# set titlecolor bold,white,magenta
# set promptcolor black,yellow
# set statuscolor bold,lightwhite,magenta
# set errorcolor bold,lightwhite,red
# set statuscolor bold,white,magenta
# set errorcolor bold,white,red
# set spotlightcolor black,orange
# set selectedcolor lightwhite,cyan
# set stripecolor ,yellow

View File

@@ -1,2 +1,2 @@
# List of available languages.
bg ca cs da de eo es eu fi fr ga gl hr hu id is it ja ko ms nb nl nn pl pt pt_BR ro ru sk sl sr sv tr uk vi zh_CN zh_TW
bg ca cs da de eo es eu fi fr ga gl hr hu id is it ja ko ms nb nl pl pt pt_BR ro ru sk sl sr sv tr uk vi zh_CN zh_TW

1008
po/bg.po

File diff suppressed because it is too large Load Diff

1026
po/ca.po

File diff suppressed because it is too large Load Diff

1012
po/cs.po

File diff suppressed because it is too large Load Diff

1008
po/da.po

File diff suppressed because it is too large Load Diff

1022
po/de.po

File diff suppressed because it is too large Load Diff

1014
po/eo.po

File diff suppressed because it is too large Load Diff

1013
po/es.po

File diff suppressed because it is too large Load Diff

1014
po/eu.po

File diff suppressed because it is too large Load Diff

1002
po/fi.po

File diff suppressed because it is too large Load Diff

1037
po/fr.po

File diff suppressed because it is too large Load Diff

1021
po/ga.po

File diff suppressed because it is too large Load Diff

1010
po/gl.po

File diff suppressed because it is too large Load Diff

1024
po/hr.po

File diff suppressed because it is too large Load Diff

1012
po/hu.po

File diff suppressed because it is too large Load Diff

2200
po/id.po

File diff suppressed because it is too large Load Diff

1000
po/is.po

File diff suppressed because it is too large Load Diff

1012
po/it.po

File diff suppressed because it is too large Load Diff

1018
po/ja.po

File diff suppressed because it is too large Load Diff

1024
po/ko.po

File diff suppressed because it is too large Load Diff

1037
po/ms.po

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

1139
po/nb.po

File diff suppressed because it is too large Load Diff

1014
po/nl.po

File diff suppressed because it is too large Load Diff

2885
po/nn.po

File diff suppressed because it is too large Load Diff

1024
po/pl.po

File diff suppressed because it is too large Load Diff

1016
po/pt.po

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

1008
po/ro.po

File diff suppressed because it is too large Load Diff

1014
po/ru.po

File diff suppressed because it is too large Load Diff

1037
po/sk.po

File diff suppressed because it is too large Load Diff

1010
po/sl.po

File diff suppressed because it is too large Load Diff

1008
po/sr.po

File diff suppressed because it is too large Load Diff

1008
po/sv.po

File diff suppressed because it is too large Load Diff

1018
po/tr.po

File diff suppressed because it is too large Load Diff

1014
po/uk.po

File diff suppressed because it is too large Load Diff

View File

@@ -9,6 +9,9 @@ rm *.po
wget --recursive --level=1 --accept=po --no-directories --no-verbose \
https://translationproject.org/latest/nano/ || exit 2
# This PO file is less than twenty percent translated:
rm -v nn.po
# Are there now PO files that are not in git yet?
NEWSTUFF=$(git status --porcelain *.po | grep "^??")

1010
po/vi.po

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
#!/bin/bash
VERSION="5.8"
VERSION="5.9"
./configure -C --enable-tiny && make && ./configure -C &&

View File

@@ -359,7 +359,8 @@ void search_filename(bool forwards)
#endif
}
findfile(last_search, forwards);
if (response == 0 || response == -2)
findfile(last_search, forwards);
}
/* Search again without prompting for the last given search string,
@@ -380,6 +381,18 @@ void research_filename(bool forwards)
}
}
/* Select the first file in the list -- called by ^W^Y. */
void to_first_file(void)
{
selected = 0;
}
/* Select the last file in the list -- called by ^W^V. */
void to_last_file(void)
{
selected = list_length - 1;
}
/* Strip one element from the end of path, and return the stripped path.
* The returned string is dynamically allocated, and should be freed. */
char *strip_last_component(const char *path)

View File

@@ -2,7 +2,7 @@
* chars.c -- This file is part of GNU nano. *
* *
* Copyright (C) 2001-2011, 2013-2021 Free Software Foundation, Inc. *
* Copyright (C) 2016-2020 Benno Schulenberg *
* Copyright (C) 2016-2021 Benno Schulenberg *
* *
* GNU nano is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published *
@@ -644,7 +644,7 @@ bool has_blank_char(const char *string)
return *string;
}
#endif /* ENABLE_NANORC && (!NANO_TINY || ENABLE_JUSTIFY) */
#endif
/* Return TRUE when the given string is empty or consists of only blanks. */
bool white_string(const char *string)

View File

@@ -2,7 +2,7 @@
* color.c -- This file is part of GNU nano. *
* *
* Copyright (C) 2001-2011, 2013-2021 Free Software Foundation, Inc. *
* Copyright (C) 2014-2017, 2020 Benno Schulenberg *
* Copyright (C) 2014-2017, 2020, 2021 Benno Schulenberg *
* *
* GNU nano is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published *

View File

@@ -249,27 +249,29 @@ void extract_segment(linestruct *top, size_t top_x, linestruct *bot, size_t bot_
bool same_line = (openfile->mark == top);
bool post_marked = (openfile->mark && (openfile->mark->lineno > top->lineno ||
(same_line && openfile->mark_x > top_x)));
bool was_anchored = top->has_anchor;
static bool inherited_anchor = FALSE;
bool had_anchor = top->has_anchor;
if (top == bot && top_x == bot_x)
return;
if (top != bot)
for (linestruct *line = top->next; line != bot->next; line = line->next)
was_anchored |= line->has_anchor;
had_anchor |= line->has_anchor;
#endif
if (top == bot) {
taken = make_new_node(NULL);
taken->data = measured_copy(top->data + top_x, bot_x - top_x);
memmove(top->data + top_x, top->data + bot_x,
strlen(top->data + bot_x) + 1);
memmove(top->data + top_x, top->data + bot_x, strlen(top->data + bot_x) + 1);
last = taken;
} else if (top_x == 0 && bot_x == 0) {
taken = top;
last = make_new_node(NULL);
last->data = copy_of("");
#ifndef NANO_TINY
last->has_anchor = bot->has_anchor;
#endif
last->prev = bot->prev;
bot->prev->next = last;
last->next = NULL;
@@ -309,11 +311,17 @@ void extract_segment(linestruct *top, size_t top_x, linestruct *bot, size_t bot_
if (cutbuffer == NULL) {
cutbuffer = taken;
cutbottom = last;
#ifndef NANO_TINY
inherited_anchor = taken->has_anchor;
#endif
} else {
cutbottom->data = nrealloc(cutbottom->data,
strlen(cutbottom->data) + strlen(taken->data) + 1);
strcat(cutbottom->data, taken->data);
#ifndef NANO_TINY
cutbottom->has_anchor = taken->has_anchor && !inherited_anchor;
inherited_anchor |= taken->has_anchor;
#endif
cutbottom->next = taken->next;
delete_node(taken);
@@ -326,7 +334,7 @@ void extract_segment(linestruct *top, size_t top_x, linestruct *bot, size_t bot_
openfile->current_x = top_x;
#ifndef NANO_TINY
openfile->current->has_anchor = was_anchored;
openfile->current->has_anchor = had_anchor;
if (post_marked || same_line)
openfile->mark = openfile->current;
@@ -686,10 +694,13 @@ void copy_text(void)
/* Copy text from the cutbuffer into the current buffer. */
void paste_text(void)
{
#ifndef NANO_TINY
/* Remember where the paste started. */
linestruct *was_current = openfile->current;
bool had_anchor = was_current->has_anchor;
#endif
ssize_t was_lineno = openfile->current->lineno;
/* The line number where we started the paste. */
size_t was_leftedge = 0;
/* The leftedge where we started the paste. */
if (cutbuffer == NULL) {
statusline(AHEM, _("Cutbuffer is empty"));
@@ -708,6 +719,12 @@ void paste_text(void)
copy_from_buffer(cutbuffer);
#ifndef NANO_TINY
/* Wipe any anchors in the pasted text, so that they don't proliferate. */
for (linestruct *line = was_current; line != openfile->current->next; line = line->next)
line->has_anchor = FALSE;
was_current->has_anchor = had_anchor;
update_undo(PASTE);
#endif

View File

@@ -29,6 +29,10 @@
#endif
#endif
#if defined(__HAIKU__) && !defined(_DEFAULT_SOURCE)
#define _DEFAULT_SOURCE 1
#endif
#ifdef __TANDEM
/* Tandem NonStop Kernel support. */
#include <floss.h>
@@ -111,6 +115,13 @@
#define REPLACING 1
#define INREGION 2
#define NORMAL TRUE
#define SPECIAL FALSE
#define TEMPORARY FALSE
#define ANNOTATE TRUE
#define NONOTES FALSE
#ifdef ENABLE_UTF8
/* In UTF-8 a valid character is at most four bytes long. */
#define MAXCHARLEN 4
@@ -216,6 +227,7 @@
#define INCLUDED_LAST_LINE (1<<3)
#define MARK_WAS_SET (1<<4)
#define CURSOR_WAS_AT_HEAD (1<<5)
#define HAD_ANCHOR_AT_START (1<<6)
#endif /* !NANO_TINY */
/* Identifiers for the different menus. */
@@ -624,8 +636,8 @@ typedef struct funcstruct {
} funcstruct;
#ifdef ENABLE_WORDCOMPLETION
typedef struct completion_word {
typedef struct completionstruct {
char *word;
struct completion_word *next;
} completion_word;
struct completionstruct *next;
} completionstruct;
#endif

View File

@@ -2,7 +2,7 @@
* files.c -- This file is part of GNU nano. *
* *
* Copyright (C) 1999-2011, 2013-2021 Free Software Foundation, Inc. *
* Copyright (C) 2015-2020 Benno Schulenberg *
* Copyright (C) 2015-2021 Benno Schulenberg *
* *
* GNU nano is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published *
@@ -40,19 +40,19 @@ void make_new_buffer(void)
#ifdef ENABLE_MULTIBUFFER
if (openfile == NULL) {
/* Make the first open file the only element in the list. */
/* Make the first buffer the only element in the list. */
newnode->prev = newnode;
newnode->next = newnode;
startfile = newnode;
} else {
/* Add the new open file after the current one in the list. */
/* Add the new buffer after the current one in the list. */
newnode->prev = openfile;
newnode->next = openfile->next;
openfile->next->prev = newnode;
openfile->next = newnode;
/* There is more than one file open: show "Close" in help lines. */
/* There is more than one buffer: show "Close" in help lines. */
exitfunc->desc = close_tag;
more_than_one = !inhelp || more_than_one;
}
@@ -122,7 +122,7 @@ char *crop_to_fit(const char *name, int room)
}
#ifndef NANO_TINY
/* Delete the lockfile. Return TRUE on success, and FALSE otherwise. */
/* Delete the lock file. Return TRUE on success, and FALSE otherwise. */
bool delete_lockfile(const char *lockfilename)
{
if (unlink(lockfilename) < 0 && errno != ENOENT) {
@@ -245,9 +245,11 @@ char *do_lockfile(const char *filename, bool ask_the_user)
free(secondcopy);
free(namecopy);
if (!ask_the_user && stat(lockfilename, &fileinfo) != -1)
warn_and_briefly_pause(_("Someone else is also editing this file"));
else if (stat(lockfilename, &fileinfo) != -1) {
if (!ask_the_user && stat(lockfilename, &fileinfo) != -1) {
blank_bottombars();
statusline(ALERT, _("Someone else is also editing this file"));
napms(1200);
} else if (stat(lockfilename, &fileinfo) != -1) {
char *lockbuf, *question, *pidstring, *postedname, *promptstr;
static char lockprog[11], lockuser[17];
int lockfd, lockpid, choice;
@@ -476,8 +478,8 @@ bool open_buffer(const char *filename, bool new_one)
return TRUE;
}
/* Mark the current file as modified if it isn't already, and
* then update the title bar to display the file's new status. */
/* Mark the current buffer as modified if it isn't already, and
* then update the title bar to display the buffer's new status. */
void set_modified(void)
{
if (openfile->modified)
@@ -567,14 +569,14 @@ void redecorate_after_switch(void)
mention_name_and_linecount();
}
/* Switch to the previous entry in the list of open files. */
/* Switch to the previous entry in the circular list of buffers. */
void switch_to_prev_buffer(void)
{
openfile = openfile->prev;
redecorate_after_switch();
}
/* Switch to the next entry in the list of open files. */
/* Switch to the next entry in the circular list of buffers. */
void switch_to_next_buffer(void)
{
openfile = openfile->next;
@@ -971,10 +973,10 @@ bool execute_command(const char *command)
{
int from_fd[2], to_fd[2];
/* The pipes through which text will be written and read. */
const bool should_pipe = (command[0] == '|');
FILE *stream;
struct sigaction oldaction, newaction = {{0}};
/* Original and temporary handlers for SIGINT. */
const bool should_pipe = (command[0] == '|');
FILE *stream;
/* Create a pipe to read the command's output from, and, if needed,
* a pipe to feed the command's input through. */
@@ -1281,7 +1283,7 @@ void do_insertfile(bool execute)
} else
#endif /* ENABLE_MULTIBUFFER */
{
/* If the file actually changed, mark it as modified. */
/* If the buffer actually changed, mark it as modified. */
if (openfile->current->lineno != was_current_lineno ||
openfile->current_x != was_current_x)
set_modified();
@@ -1357,7 +1359,7 @@ char *get_full_path(const char *origpath)
target = real_dir_from_tilde(origpath);
/* Determine whether the target path refers to a directory. If statting
* target fails, however, assume that it refers to a new, unsaved file. */
* target fails, however, assume that it refers to a new, unsaved buffer. */
path_only = (stat(target, &fileinfo) != -1 && S_ISDIR(fileinfo.st_mode));
/* If the target is a directory, make sure its path ends in a slash. */
@@ -1451,7 +1453,8 @@ char *safe_tempfile(FILE **stream)
{
const char *env_dir = getenv("TMPDIR");
char *tempdir = NULL, *tempfile_name = NULL;
int fd;
char *extension;
int descriptor;
/* Get the absolute path for the first directory among $TMPDIR
* and P_tmpdir that is writable, otherwise use /tmp/. */
@@ -1464,18 +1467,26 @@ char *safe_tempfile(FILE **stream)
if (tempdir == NULL)
tempdir = copy_of("/tmp/");
tempfile_name = nrealloc(tempdir, strlen(tempdir) + 12);
extension = strrchr(openfile->filename, '.');
if (!extension || strchr(extension, '/'))
extension = openfile->filename + strlen(openfile->filename);
tempfile_name = nrealloc(tempdir, strlen(tempdir) + 12 + strlen(extension));
strcat(tempfile_name, "nano.XXXXXX");
strcat(tempfile_name, extension);
fd = mkstemp(tempfile_name);
descriptor = mkstemps(tempfile_name, strlen(extension));
if (fd == -1) {
*stream = (descriptor > 0) ? fdopen(descriptor, "r+b") : NULL;
if (*stream == NULL) {
if (descriptor > 0)
close(descriptor);
free(tempfile_name);
return NULL;
}
*stream = fdopen(fd, "r+b");
return tempfile_name;
}
@@ -1735,19 +1746,19 @@ bool make_backup_of(char *realname)
#endif /* !NANO_TINY */
/* Write the current buffer to disk. If thefile isn't NULL, we write to a
* temporary file that is already open. If tmp is TRUE (when spell checking
* or emergency dumping, for example), we don't make a backup and don't give
* temporary file that is already open. If normal is FALSE (for a spellcheck
* or an emergency save, for example), we don't make a backup and don't give
* feedback. If method is APPEND or PREPEND, it means we will be appending
* or prepending instead of overwriting the given file. If fullbuffer is TRUE
* and when writing normally, we set the current filename and stat info.
* or prepending instead of overwriting the given file. If annotate is TRUE
* and when writing a normal file, we set the current filename and stat info.
* Return TRUE on success, and FALSE otherwise. */
bool write_file(const char *name, FILE *thefile, bool tmp,
kind_of_writing_type method, bool fullbuffer)
bool write_file(const char *name, FILE *thefile, bool normal,
kind_of_writing_type method, bool annotate)
{
#ifndef NANO_TINY
bool is_existing_file;
/* Becomes TRUE when the file is non-temporary and exists. */
struct stat st;
struct stat fileinfo;
/* The status fields filled in by statting the file. */
#endif
char *realname = real_dir_from_tilde(name);
@@ -1758,20 +1769,18 @@ bool write_file(const char *name, FILE *thefile, bool tmp,
/* An iterator for moving through the lines of the buffer. */
size_t lineswritten = 0;
/* The number of lines written, for feedback on the status bar. */
bool retval = FALSE;
/* The return value, to become TRUE when writing has succeeded. */
#ifdef ENABLE_OPERATINGDIR
/* If we're writing a temporary file, we're probably going outside
* the operating directory, so skip the operating directory test. */
if (!tmp && outside_of_confinement(realname, FALSE)) {
if (normal && outside_of_confinement(realname, FALSE)) {
statusline(ALERT, _("Can't write outside of %s"), operating_dir);
goto cleanup_and_exit;
}
#endif
#ifndef NANO_TINY
/* Check whether the file (at the end of the symlink) exists. */
is_existing_file = (!tmp) && (stat(realname, &st) != -1);
is_existing_file = normal && (stat(realname, &fileinfo) != -1);
/* If we haven't statted this file before (say, the user just specified
* it interactively), stat and save the value now, or else we will chase
@@ -1782,8 +1791,9 @@ bool write_file(const char *name, FILE *thefile, bool tmp,
/* When the user requested a backup, we do this only if the file exists and
* isn't temporary AND the file has not been modified by someone else since
* we opened it (or we are appending/prepending or writing a selection). */
if (ISSET(MAKE_BACKUP) && is_existing_file && openfile->statinfo &&
(openfile->statinfo->st_mtime == st.st_mtime ||
if (ISSET(MAKE_BACKUP) && is_existing_file && !S_ISFIFO(fileinfo.st_mode) &&
openfile->statinfo &&
(openfile->statinfo->st_mtime == fileinfo.st_mtime ||
method != OVERWRITE || openfile->mark)) {
if (!make_backup_of(realname))
goto cleanup_and_exit;
@@ -1791,10 +1801,17 @@ bool write_file(const char *name, FILE *thefile, bool tmp,
/* When prepending, first copy the existing file to a temporary file. */
if (method == PREPEND) {
FILE *source = fopen(realname, "rb");
FILE *source = NULL;
FILE *target = NULL;
int verdict;
if (is_existing_file && S_ISFIFO(fileinfo.st_mode)) {
statusline(ALERT, _("Error writing %s: %s"), realname, "FIFO");
goto cleanup_and_exit;
}
source = fopen(realname, "rb");
if (source == NULL) {
statusline(ALERT, _("Error reading %s: %s"), realname, strerror(errno));
goto cleanup_and_exit;
@@ -1821,27 +1838,29 @@ bool write_file(const char *name, FILE *thefile, bool tmp,
}
}
if (is_existing_file && S_ISFIFO(st.st_mode))
if (is_existing_file && S_ISFIFO(fileinfo.st_mode))
statusbar(_("Writing to FIFO..."));
#endif /* !NANO_TINY */
/* When it's not a temporary file, this is where we open or create it.
* For an emergency file, access is restricted to just the owner. */
if (thefile == NULL) {
mode_t permissions = (tmp ? S_IRUSR|S_IWUSR : RW_FOR_ALL);
mode_t permissions = (normal ? RW_FOR_ALL : S_IRUSR|S_IWUSR);
int fd;
#ifndef NANO_TINY
block_sigwinch(TRUE);
install_handler_for_Ctrl_C();
if (normal)
install_handler_for_Ctrl_C();
#endif
/* Now open the file. Use O_EXCL for an emergency file. */
fd = open(realname, O_WRONLY | O_CREAT | ((method == APPEND) ?
O_APPEND : (tmp ? O_EXCL : O_TRUNC)), permissions);
O_APPEND : (normal ? O_TRUNC : O_EXCL)), permissions);
#ifndef NANO_TINY
restore_handler_for_Ctrl_C();
if (normal)
restore_handler_for_Ctrl_C();
block_sigwinch(FALSE);
#endif
@@ -1867,7 +1886,7 @@ bool write_file(const char *name, FILE *thefile, bool tmp,
}
}
if (!tmp)
if (normal)
statusbar(_("Writing..."));
while (TRUE) {
@@ -1944,22 +1963,27 @@ bool write_file(const char *name, FILE *thefile, bool tmp,
unlink(tempname);
}
#endif
/* Ensure the data has reached the disk before reporting it as written. */
if (fflush(thefile) != 0 || fsync(fileno(thefile)) != 0) {
statusline(ALERT, _("Error writing %s: %s"), realname, strerror(errno));
fclose(thefile);
goto cleanup_and_exit;
}
if (!is_existing_file || !S_ISFIFO(fileinfo.st_mode))
/* Ensure the data has reached the disk before reporting it as written. */
if (fflush(thefile) != 0 || fsync(fileno(thefile)) != 0) {
statusline(ALERT, _("Error writing %s: %s"), realname, strerror(errno));
fclose(thefile);
goto cleanup_and_exit;
}
#endif
if (fclose(thefile) != 0) {
statusline(ALERT, _("Error writing %s: %s"), realname, strerror(errno));
goto cleanup_and_exit;
cleanup_and_exit:
free(tempname);
free(realname);
return FALSE;
}
/* When having written an entire buffer, update some administrivia. */
if (fullbuffer && method == OVERWRITE && !tmp) {
if (annotate && method == OVERWRITE) {
/* If the filename was changed, write a new lockfile when needed,
* and check whether it means a different syntax gets used. */
if (strcmp(openfile->filename, realname) != 0) {
@@ -1967,8 +1991,10 @@ bool write_file(const char *name, FILE *thefile, bool tmp,
if (openfile->lock_filename != NULL) {
delete_lockfile(openfile->lock_filename);
free(openfile->lock_filename);
openfile->lock_filename = do_lockfile(realname, FALSE);
}
if (ISSET(LOCKING))
openfile->lock_filename = do_lockfile(realname, FALSE);
#endif
openfile->filename = mallocstrcpy(openfile->filename, realname);
#ifdef ENABLE_COLOR
@@ -1995,7 +2021,7 @@ bool write_file(const char *name, FILE *thefile, bool tmp,
/* Get or update the stat info to reflect the current state. */
stat_with_alloc(realname, &openfile->statinfo);
/* Record at which point in the undo stack the file was saved. */
/* Record at which point in the undo stack the buffer was saved. */
openfile->last_saved = openfile->current_undo;
openfile->last_action = OTHER;
#endif
@@ -2004,26 +2030,24 @@ bool write_file(const char *name, FILE *thefile, bool tmp,
}
#ifndef NANO_TINY
if (ISSET(MINIBAR) && LINES > 1 && fullbuffer && !tmp)
if (ISSET(MINIBAR) && LINES > 1 && annotate)
report_size = TRUE;
else
#endif
if (!tmp)
if (normal)
statusline(REMARK, P_("Wrote %zu line", "Wrote %zu lines",
lineswritten), lineswritten);
retval = TRUE;
cleanup_and_exit:
free(tempname);
free(realname);
return retval;
return TRUE;
}
#ifndef NANO_TINY
/* Write the marked region of the current buffer out to disk.
* Return TRUE on success and FALSE on error. */
bool write_marked_file(const char *name, FILE *stream, bool tmp,
bool write_region_to_file(const char *name, FILE *stream, bool normal,
kind_of_writing_type method)
{
linestruct *birthline, *topline, *botline, *stopper, *afterline;
@@ -2050,7 +2074,7 @@ bool write_marked_file(const char *name, FILE *stream, bool tmp,
birthline = openfile->filetop;
openfile->filetop = topline;
retval = write_file(name, stream, tmp, method, FALSE);
retval = write_file(name, stream, normal, method, NONOTES);
/* Restore the proper state of the buffer. */
openfile->filetop = birthline;
@@ -2065,18 +2089,18 @@ bool write_marked_file(const char *name, FILE *stream, bool tmp,
}
#endif /* !NANO_TINY */
/* Write the current file to disk. If the mark is on, write the current
* marked selection to disk. If exiting is TRUE, write the entire file
/* Write the current buffer to disk. If the mark is on, write the current
* marked selection to disk. If exiting is TRUE, write the entire buffer
* to disk regardless of whether the mark is on. Do not ask for a name
* when withprompt is FALSE nor when the SAVE_ON_EXIT flag is set and the
* file already has a name. Return 0 on error, 1 on success, and 2 when
* buffer already has a name. Return 0 on error, 1 on success, and 2 when
* the buffer is to be discarded. */
int do_writeout(bool exiting, bool withprompt)
{
char *given;
/* The filename we offer, or what the user typed so far. */
bool maychange = (openfile->filename[0] == '\0');
/* Whether it's okay to save the file under a different name. */
/* Whether it's okay to save the buffer under a different name. */
kind_of_writing_type method = OVERWRITE;
#ifdef ENABLE_EXTRA
static bool did_credits = FALSE;
@@ -2201,12 +2225,12 @@ int do_writeout(bool exiting, bool withprompt)
if (method == OVERWRITE) {
bool name_exists, do_warning;
char *full_answer, *full_filename;
struct stat st;
struct stat fileinfo;
full_answer = get_full_path(answer);
full_filename = get_full_path(openfile->filename);
name_exists = (stat((full_answer == NULL) ?
answer : full_answer, &st) != -1);
answer : full_answer, &fileinfo) != -1);
if (openfile->filename[0] == '\0')
do_warning = name_exists;
@@ -2221,11 +2245,10 @@ int do_writeout(bool exiting, bool withprompt)
if (do_warning) {
/* When in restricted mode, we aren't allowed to overwrite
* an existing file with the current buffer, nor to change
* the name of the current file if it already has one. */
* the name of the current buffer if it already has one. */
if (ISSET(RESTRICTED)) {
/* TRANSLATORS: Restricted mode forbids overwriting. */
warn_and_briefly_pause(_("File exists -- "
"cannot overwrite"));
warn_and_briefly_pause(_("File exists -- cannot overwrite"));
continue;
}
@@ -2262,9 +2285,9 @@ int do_writeout(bool exiting, bool withprompt)
* and the stat information we had before does not match
* what we have now. */
else if (name_exists && openfile->statinfo &&
(openfile->statinfo->st_mtime < st.st_mtime ||
openfile->statinfo->st_dev != st.st_dev ||
openfile->statinfo->st_ino != st.st_ino)) {
(openfile->statinfo->st_mtime < fileinfo.st_mtime ||
openfile->statinfo->st_dev != fileinfo.st_dev ||
openfile->statinfo->st_ino != fileinfo.st_ino)) {
warn_and_briefly_pause(_("File on disk has changed"));
@@ -2279,7 +2302,7 @@ int do_writeout(bool exiting, bool withprompt)
free(given);
if (choice == 1)
return write_file(openfile->filename, NULL,
FALSE, OVERWRITE, TRUE);
NORMAL, OVERWRITE, NONOTES);
else if (choice == 0)
return 2;
else
@@ -2301,10 +2324,10 @@ int do_writeout(bool exiting, bool withprompt)
* the marked region; otherwise, write out the whole buffer. */
#ifndef NANO_TINY
if (openfile->mark && withprompt && !exiting && !ISSET(RESTRICTED))
return write_marked_file(answer, NULL, FALSE, method);
return write_region_to_file(answer, NULL, NORMAL, method);
else
#endif
return write_file(answer, NULL, FALSE, method, TRUE);
return write_file(answer, NULL, NORMAL, method, ANNOTATE);
}
/* Write the current buffer to disk, or discard it. */
@@ -2315,7 +2338,7 @@ void do_writeout_void(void)
close_and_go();
}
/* If it has a name, write the current file to disk without prompting. */
/* If it has a name, write the current buffer to disk without prompting. */
void do_savefile(void)
{
if (do_writeout(FALSE, FALSE) == 2)

View File

@@ -301,12 +301,6 @@ void flip_goto(void)
void to_files(void)
{
}
void to_first_file(void)
{
}
void to_last_file(void)
{
}
void goto_dir(void)
{
}
@@ -1448,11 +1442,9 @@ void shortcut_init(void)
add_to_sclist(MGOTOLINE, "^W", 0, to_para_begin, 0);
add_to_sclist(MGOTOLINE, "^O", 0, to_para_end, 0);
#endif
add_to_sclist(MGOTOLINE, "^Y", 0, to_first_line, 0);
add_to_sclist(MGOTOLINE, "^V", 0, to_last_line, 0);
/* Some people are used to having these keystrokes in the Search menu. */
add_to_sclist(MWHEREIS, "^Y", 0, to_first_line, 0);
add_to_sclist(MWHEREIS, "^V", 0, to_last_line, 0);
add_to_sclist(MGOTOLINE|MWHEREIS|MFINDINHELP, "^Y", 0, to_first_line, 0);
add_to_sclist(MGOTOLINE|MWHEREIS|MFINDINHELP, "^V", 0, to_last_line, 0);
#ifdef ENABLE_BROWSER
add_to_sclist(MWHEREISFILE, "^Y", 0, to_first_file, 0);
add_to_sclist(MWHEREISFILE, "^V", 0, to_last_file, 0);

View File

@@ -310,7 +310,7 @@ void help_init(void)
}
}
}
#endif /* !NANO_TINY */
#endif
}
/* Hard-wrap the concatenated help text, and write it into a new buffer. */

View File

@@ -367,7 +367,8 @@ void save_history(void)
}
/* Don't allow others to read or write the history file. */
chmod(histname, S_IRUSR | S_IWUSR);
if (chmod(histname, S_IRUSR | S_IWUSR) < 0)
jot_error(N_("Cannot limit permissions on %s: %s"), histname, strerror(errno));
if (!write_list(searchtop, histfile) || !write_list(replacetop, histfile) ||
!write_list(executetop, histfile))
@@ -465,7 +466,8 @@ void save_poshistory(void)
}
/* Don't allow others to read or write the history file. */
chmod(poshistname, S_IRUSR | S_IWUSR);
if (chmod(poshistname, S_IRUSR | S_IWUSR) < 0)
jot_error(N_("Cannot limit permissions on %s: %s"), poshistname, strerror(errno));
for (posptr = position_history; posptr != NULL; posptr = posptr->next) {
char *path_and_place;

View File

@@ -2,7 +2,7 @@
* nano.c -- This file is part of GNU nano. *
* *
* Copyright (C) 1999-2011, 2013-2021 Free Software Foundation, Inc. *
* Copyright (C) 2014-2020 Benno Schulenberg *
* Copyright (C) 2014-2021 Benno Schulenberg *
* *
* GNU nano is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published *
@@ -154,7 +154,7 @@ linestruct *copy_node(const linestruct *src)
#endif
dst->lineno = src->lineno;
#ifndef NANO_TINY
dst->has_anchor = FALSE;
dst->has_anchor = src->has_anchor;
#endif
return dst;
@@ -309,40 +309,37 @@ void do_exit(void)
statusbar(_("Cancelled"));
}
/* Save the current buffer under the given name (or under the name "nano"
* for a nameless buffer). If needed, the name is modified to be unique. */
void emergency_save(const char *plainname)
/* Save the current buffer under the given name (or "nano.<pid>" when nameless)
* with suffix ".save". If needed, the name is further suffixed to be unique. */
void emergency_save(const char *filename)
{
bool failed = TRUE;
char *targetname;
char *plainname, *targetname;
if (*plainname == '\0')
plainname = "nano";
if (*filename == '\0') {
plainname = nmalloc(28);
sprintf(plainname, "nano.%u", getpid());
} else
plainname = copy_of(filename);
targetname = get_next_filename(plainname, ".save");
if (*targetname != '\0')
failed = !write_file(targetname, NULL, TRUE, OVERWRITE, FALSE);
if (!failed)
if (*targetname == '\0')
fprintf(stderr, _("\nToo many .save files\n"));
else if (write_file(targetname, NULL, SPECIAL, OVERWRITE, NONOTES)) {
fprintf(stderr, _("\nBuffer written to %s\n"), targetname);
else if (*targetname != '\0')
fprintf(stderr, _("\nBuffer not written to %s: %s\n"),
targetname, strerror(errno));
else
fprintf(stderr, _("\nToo many .save files"));
#ifndef NANO_TINY
/* Try to chmod/chown the saved file to the values of the original file,
* but ignore any failure as we are in a hurry to get out. */
if (openfile->statinfo) {
IGNORE_CALL_RESULT(chmod(targetname, openfile->statinfo->st_mode));
IGNORE_CALL_RESULT(chown(targetname, openfile->statinfo->st_uid,
openfile->statinfo->st_gid));
}
/* Try to chmod/chown the saved file to the values of the original file,
* but ignore any failure as we are in a hurry to get out. */
if (openfile->statinfo) {
IGNORE_CALL_RESULT(chmod(targetname, openfile->statinfo->st_mode));
IGNORE_CALL_RESULT(chown(targetname, openfile->statinfo->st_uid,
openfile->statinfo->st_gid));
}
#endif
}
free(targetname);
free(plainname);
}
/* Die gracefully -- by restoring the terminal state and saving any buffers
@@ -351,6 +348,11 @@ void die(const char *msg, ...)
{
va_list ap;
openfilestruct *firstone = openfile;
static int stabs = 0;
/* When dying for a second time, just give up. */
if (++stabs > 1)
exit(11);
restore_terminal();
@@ -365,7 +367,7 @@ void die(const char *msg, ...)
while (openfile) {
#ifndef NANO_TINY
/* If the current buffer has a lockfile, remove it. */
/* If the current buffer has a lock file, remove it. */
if (openfile->lock_filename)
delete_lockfile(openfile->lock_filename);
#endif
@@ -518,7 +520,7 @@ void usage(void)
#ifdef ENABLE_HISTORIES
if (!ISSET(RESTRICTED))
print_opt("-H", "--historylog",
N_("Log & read search/replace string history"));
N_("Save & reload old search/replace strings"));
#endif
#ifdef ENABLE_NANORC
print_opt("-I", "--ignorercfiles", N_("Don't look at nanorc files"));
@@ -546,7 +548,7 @@ void usage(void)
#ifdef ENABLE_HISTORIES
if (!ISSET(RESTRICTED))
print_opt("-P", "--positionlog",
N_("Log & read location of cursor position"));
N_("Save & restore position of the cursor"));
#endif
#ifdef ENABLE_JUSTIFY
print_opt(_("-Q <regex>"), _("--quotestr=<regex>"),
@@ -1094,7 +1096,7 @@ void do_toggle(int flag)
if (flag == AUTOINDENT || flag == BREAK_LONG_LINES || flag == SOFTWRAP)
titlebar(NULL);
if (ISSET(MINIBAR) && (flag == NO_HELP || flag == LINE_NUMBERS ))
if (ISSET(MINIBAR) && (flag == NO_HELP || flag == LINE_NUMBERS))
return;
if (flag == CONSTANT_SHOW)
@@ -2053,6 +2055,10 @@ int main(int argc, char **argv)
}
}
/* Curses needs TERM; if it is unset, try falling back to a VT220. */
if (getenv("TERM") == NULL)
setenv("TERM", "vt220", 0);
/* Enter into curses mode. Abort if this fails. */
if (initscr() == NULL)
exit(1);
@@ -2203,7 +2209,7 @@ int main(int argc, char **argv)
load_history();
if (ISSET(POSITIONLOG))
load_poshistory();
#endif /* ENABLE_HISTORIES */
#endif
#ifndef NANO_TINY
/* If a backup directory was specified and we're not in restricted mode,
@@ -2237,7 +2243,7 @@ int main(int argc, char **argv)
die(_("Bad quoting regex \"%s\": %s\n"), quotestr, message);
} else
free(quotestr);
#endif /* ENABLE_JUSTIFY */
#endif
#ifdef ENABLE_SPELLER
/* If we don't have an alternative spell checker after reading the

View File

@@ -766,7 +766,7 @@ int do_yesno_prompt(bool all, const char *msg)
choice = -2;
}
}
#endif /* ENABLE_MOUSE */
#endif
else if (func_from_key(&kbinput) == full_refresh)
full_refresh();
#ifndef NANO_TINY

View File

@@ -191,6 +191,8 @@ typedef void (*functionptrtype)(void);
#ifdef ENABLE_BROWSER
void browser_refresh(void);
char *browse_in(const char *inpath);
void to_first_file(void);
void to_last_file(void);
#endif
/* Most functions in chars.c. */
@@ -294,11 +296,11 @@ bool outside_of_confinement(const char *currpath, bool allow_tabcomp);
void init_backup_dir(void);
#endif
int copy_file(FILE *inn, FILE *out, bool close_out);
bool write_file(const char *name, FILE *thefile, bool tmp,
kind_of_writing_type method, bool fullbuffer);
bool write_file(const char *name, FILE *thefile, bool normal,
kind_of_writing_type method, bool annotate);
#ifndef NANO_TINY
bool write_marked_file(const char *name, FILE *stream, bool tmp,
kind_of_writing_type method);
bool write_region_to_file(const char *name, FILE *stream, bool normal,
kind_of_writing_type method);
#endif
int do_writeout(bool exiting, bool withprompt);
void do_writeout_void(void);
@@ -636,8 +638,6 @@ void flip_replace(void);
void flip_goto(void);
#ifdef ENABLE_BROWSER
void to_files(void);
void to_first_file(void);
void to_last_file(void);
void goto_dir(void);
#endif
#ifndef NANO_TINY

View File

@@ -550,7 +550,7 @@ ssize_t do_replace_loop(const char *needle, bool whole_word_only,
openfile->current_x = bot_x;
}
}
#endif /* !NANO_TINY */
#endif
came_full_circle = FALSE;
@@ -606,17 +606,16 @@ ssize_t do_replace_loop(const char *needle, bool whole_word_only,
}
if (choice == 1 || replaceall) { /* Yes, replace it. */
char *copy;
size_t length_change;
char *altered;
altered = replace_line(needle);
length_change = strlen(altered) - strlen(openfile->current->data);
#ifndef NANO_TINY
add_undo(REPLACE, NULL);
#endif
copy = replace_line(needle);
length_change = strlen(copy) - strlen(openfile->current->data);
#ifndef NANO_TINY
/* If the mark was on and it was located after the cursor,
* then adjust its x position for any text length changes. */
if (was_mark && !right_side_up) {
@@ -632,8 +631,9 @@ ssize_t do_replace_loop(const char *needle, bool whole_word_only,
/* If the mark was not on or it was before the cursor, then
* adjust the cursor's x position for any text length changes. */
if (!was_mark || right_side_up) {
if (!was_mark || right_side_up)
#endif
{
if (openfile->current == real_current &&
openfile->current_x < *real_current_x) {
if (*real_current_x < openfile->current_x + match_len)
@@ -641,8 +641,8 @@ ssize_t do_replace_loop(const char *needle, bool whole_word_only,
*real_current_x += length_change;
#ifndef NANO_TINY
bot_x = *real_current_x;
}
#endif
}
}
/* Don't find the same zero-length or BOL match again. */
@@ -655,9 +655,9 @@ ssize_t do_replace_loop(const char *needle, bool whole_word_only,
openfile->current_x += match_len + length_change;
/* Update the file size, and put the changed line into place. */
openfile->totsize += mbstrlen(copy) - mbstrlen(openfile->current->data);
openfile->totsize += mbstrlen(altered) - mbstrlen(openfile->current->data);
free(openfile->current->data);
openfile->current->data = copy;
openfile->current->data = altered;
set_modified();
as_an_at = TRUE;

View File

@@ -6,7 +6,7 @@
* Copyright (C) 2016 Mike Scalora *
* Copyright (C) 2016 Sumedh Pendurkar *
* Copyright (C) 2018 Marco Diego Aurélio Mesquita *
* Copyright (C) 2015-2020 Benno Schulenberg *
* Copyright (C) 2015-2021 Benno Schulenberg *
* *
* GNU nano is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published *
@@ -39,7 +39,7 @@
#ifdef ENABLE_WORDCOMPLETION
static int pletion_x = 0;
/* The x position in pletion_line of the last found completion. */
static completion_word *list_of_completions;
static completionstruct *list_of_completions;
/* A linked list of the completions that have been attempted. */
#endif
@@ -58,7 +58,7 @@ void do_mark(void)
refresh_needed = TRUE;
}
}
#endif /* !NANO_TINY */
#endif
/* Insert a tab. Or, if --tabstospaces is in effect, insert the number
* of spaces that a tab would normally take up at this position. */
@@ -186,7 +186,7 @@ size_t length_of_white(const char *text)
while (TRUE) {
if (*text == '\t')
return ++white_count;
return white_count + 1;
if (*text != ' ')
return white_count;
@@ -463,6 +463,10 @@ void undo_cut(undostruct *u)
{
goto_line_posx(u->head_lineno, (u->xflags & WAS_WHOLE_LINE) ? 0 : u->head_x);
/* Clear an inherited anchor but not a user-placed one. */
if (!(u->xflags & HAD_ANCHOR_AT_START))
openfile->current->has_anchor = FALSE;
if (u->cutbuffer)
copy_from_buffer(u->cutbuffer);
@@ -661,7 +665,7 @@ void do_undo(void)
openfile->totsize = u->wassize;
/* When at the point where the file was last saved, unset "Modified". */
/* When at the point where the buffer was last saved, unset "Modified". */
if (openfile->current_undo == openfile->last_saved) {
openfile->modified = FALSE;
titlebar(NULL);
@@ -821,7 +825,7 @@ void do_redo(void)
openfile->totsize = u->newsize;
/* When at the point where the file was last saved, unset "Modified". */
/* When at the point where the buffer was last saved, unset "Modified". */
if (openfile->current_undo == openfile->last_saved) {
openfile->modified = FALSE;
titlebar(NULL);
@@ -1023,6 +1027,8 @@ void add_undo(undo_type action, const char *message)
#endif
case CUT_TO_EOF:
u->xflags |= (INCLUDED_LAST_LINE | CURSOR_WAS_AT_HEAD);
if (openfile->current->has_anchor)
u->xflags |= HAD_ANCHOR_AT_START;
break;
case ZAP:
case CUT:
@@ -1044,6 +1050,9 @@ void add_undo(undo_type action, const char *message)
u->tail_x = 0;
} else
u->xflags |= CURSOR_WAS_AT_HEAD;
if ((openfile->mark && mark_is_before_cursor() && openfile->mark->has_anchor) ||
((!openfile->mark || !mark_is_before_cursor()) && openfile->current->has_anchor))
u->xflags |= HAD_ANCHOR_AT_START;
break;
case PASTE:
u->cutbuffer = copy_buffer(cutbuffer);
@@ -1933,9 +1942,11 @@ void justify_text(bool whole_buffer)
}
#ifndef NANO_TINY
add_undo(PASTE, NULL);
/* Wipe an anchor on the first paragraph if it was only inherited. */
if (whole_buffer && !openfile->mark && !cutbuffer->has_anchor)
openfile->current->has_anchor = FALSE;
add_undo(PASTE, NULL);
#endif
/* Do the equivalent of a paste of the justified text. */
ingraft_buffer(cutbuffer);
@@ -1954,13 +1965,8 @@ void justify_text(bool whole_buffer)
}
add_undo(COUPLE_END, N_("justification"));
#endif
/* We're done justifying. Restore the old cutbuffer. */
cutbuffer = was_cutbuffer;
/* Show what we justified on the status bar. */
#ifndef NANO_TINY
/* Report on the status bar what we justified. */
if (openfile->mark)
statusline(REMARK, _("Justified selection"));
else
@@ -1970,6 +1976,9 @@ void justify_text(bool whole_buffer)
else
statusbar(_("Justified paragraph"));
/* We're done justifying. Restore the cutbuffer. */
cutbuffer = was_cutbuffer;
/* Set the desired screen column (always zero, except at EOF). */
openfile->placewewant = xplustabs();
@@ -2052,9 +2061,9 @@ bool replace_buffer(const char *filename, undo_type action, const char *operatio
/* Execute the given program, with the given temp file as last argument. */
void treat(char *tempfile_name, char *theprogram, bool spelling)
{
ssize_t lineno_save = openfile->current->lineno;
size_t current_x_save = openfile->current_x;
size_t pww_save = openfile->placewewant;
ssize_t was_lineno = openfile->current->lineno;
size_t was_pww = openfile->placewewant;
size_t was_x = openfile->current_x;
bool was_at_eol = (openfile->current->data[openfile->current_x] == '\0');
struct stat fileinfo;
long timestamp_sec = 0;
@@ -2138,7 +2147,7 @@ void treat(char *tempfile_name, char *theprogram, bool spelling)
/* Adjust the end point of the marked region for any change in
* length of the region's last line. */
if (upright)
current_x_save = openfile->current_x;
was_x = openfile->current_x;
else
openfile->mark_x = openfile->current_x;
@@ -2156,7 +2165,7 @@ void treat(char *tempfile_name, char *theprogram, bool spelling)
}
/* Go back to the old position. */
goto_line_posx(lineno_save, current_x_save);
goto_line_posx(was_lineno, was_x);
if (was_at_eol || openfile->current_x > strlen(openfile->current->data))
openfile->current_x = strlen(openfile->current->data);
@@ -2167,7 +2176,7 @@ void treat(char *tempfile_name, char *theprogram, bool spelling)
#endif
}
openfile->placewewant = pww_save;
openfile->placewewant = was_pww;
adjust_viewport(STATIONARY);
if (spelling)
@@ -2490,10 +2499,10 @@ void do_spell(void)
#ifndef NANO_TINY
if (openfile->mark)
okay = write_marked_file(temp_name, stream, TRUE, OVERWRITE);
okay = write_region_to_file(temp_name, stream, TEMPORARY, OVERWRITE);
else
#endif
okay = write_file(temp_name, stream, TRUE, OVERWRITE, TRUE);
okay = write_file(temp_name, stream, TEMPORARY, OVERWRITE, NONOTES);
if (!okay) {
statusline(ALERT, _("Error writing temp file: %s"), strerror(errno));
@@ -2894,7 +2903,7 @@ void do_formatter(void)
temp_name = safe_tempfile(&stream);
if (temp_name != NULL)
okay = write_file(temp_name, stream, TRUE, OVERWRITE, TRUE);
okay = write_file(temp_name, stream, TEMPORARY, OVERWRITE, NONOTES);
if (!okay) {
statusline(ALERT, _("Error writing temp file: %s"), strerror(errno));
@@ -3027,7 +3036,7 @@ void complete_a_word(void)
char *shard, *completion = NULL;
size_t start_of_shard, shard_length = 0;
size_t i = 0, j = 0;
completion_word *some_word;
completionstruct *some_word;
#ifdef ENABLE_WRAPPING
bool was_set_wrapping = ISSET(BREAK_LONG_LINES);
#endif
@@ -3036,7 +3045,7 @@ void complete_a_word(void)
if (pletion_line == NULL) {
/* Clear the list of words of a previous completion run. */
while (list_of_completions != NULL) {
completion_word *dropit = list_of_completions;
completionstruct *dropit = list_of_completions;
list_of_completions = list_of_completions->next;
free(dropit->word);
free(dropit);
@@ -3129,7 +3138,7 @@ void complete_a_word(void)
}
/* Add the found word to the list of completions. */
some_word = nmalloc(sizeof(completion_word));
some_word = nmalloc(sizeof(completionstruct));
some_word->word = completion;
some_word->next = list_of_completions;
list_of_completions = some_word;

View File

@@ -61,7 +61,7 @@ const char *tail(const char *path)
if (slash == NULL)
return path;
else
return ++slash;
return slash + 1;
}
/* Return a copy of the two given strings, welded together. */

View File

@@ -2,7 +2,7 @@
* winio.c -- This file is part of GNU nano. *
* *
* Copyright (C) 1999-2011, 2013-2021 Free Software Foundation, Inc. *
* Copyright (C) 2014-2020 Benno Schulenberg *
* Copyright (C) 2014-2021 Benno Schulenberg *
* *
* GNU nano is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published *
@@ -233,11 +233,11 @@ void read_keys_from(WINDOW *win)
}
}
#endif
/* When we've failed to get a keycode over a hundred times in a row,
/* When we've failed to get a keycode millions of times in a row,
* assume our input source is gone and die gracefully. We could
* check if errno is set to EIO ("Input/output error") and die in
* that case, but it's not always set properly. Argh. */
if (input == ERR && ++errcount == 123)
if (input == ERR && ++errcount == 12345678)
die(_("Too many errors from stdin\n"));
}
@@ -2149,7 +2149,7 @@ void minibar(void)
}
/* Right after reading or writing a file, display its number of lines;
* otherwise, when there a mutiple buffers, display an [x/n] counter. */
* otherwise, when there are multiple buffers, display an [x/n] counter. */
if (report_size && COLS > 35) {
size_t count = openfile->filebot->lineno - (openfile->filebot->data[0] == '\0');
@@ -2176,7 +2176,7 @@ void minibar(void)
mvwaddstr(bottomwin, 0, COLS - 27 - placewidth, location);
/* Display the hexadecimal code of the character under the cursor,
* plus the codes of upto two succeeding zero-width characters. */
* plus the codes of up to two succeeding zero-width characters. */
if (ISSET(CONSTANT_SHOW) && namewidth + tallywidth + 28 < COLS) {
char *this_position = openfile->current->data + openfile->current_x;
@@ -2254,32 +2254,36 @@ void statusline(message_type importance, const char *msg, ...)
bool old_whitespace = ISSET(WHITESPACE_DISPLAY);
UNSET(WHITESPACE_DISPLAY);
if (isendwin())
die("Out of curses -- please report a bug\n");
#endif
/* Ignore a message with an importance that is lower than the last one. */
if (importance < lastmessage && lastmessage > NOTICE)
return;
/* On a one-row terminal, ensure that any changes in the edit window are
* written out first, to prevent them from overwriting the message. */
if (LINES == 1 && importance < INFO)
wnoutrefresh(edit);
/* Construct the message out of all the arguments. */
compound = nmalloc(MAXCHARLEN * COLS + 1);
va_start(ap, msg);
vsnprintf(compound, MAXCHARLEN * COLS + 1, msg, ap);
va_end(ap);
/* When not in curses mode, write the message to standard error. */
if (isendwin()) {
fprintf(stderr, "\n%s\n", compound);
free(compound);
return;
}
#if !defined(NANO_TINY) && defined(ENABLE_MULTIBUFFER)
if (!we_are_running && importance == ALERT && openfile && !openfile->fmt &&
!openfile->errormessage && openfile->next != openfile)
openfile->errormessage = copy_of(compound);
#endif
/* On a one-row terminal, ensure that any changes in the edit window are
* written out first, to prevent them from overwriting the message. */
if (LINES == 1 && importance < INFO)
wnoutrefresh(edit);
/* If there are multiple alert messages, add trailing dots to the first. */
if (lastmessage == ALERT) {
if (start_col > 4) {
@@ -2498,7 +2502,7 @@ void draw_row(int row, const char *converted, linestruct *line, size_t from_col)
if (line->has_anchor && (from_col == 0 || !ISSET(SOFTWRAP)))
#ifdef ENABLE_UTF8
if (using_utf8())
wprintw(edit, "\xE2\x97\x86"); /* black diamond */
wprintw(edit, "\xE2\xAC\xA5"); /* black medium diamond */
else
#endif
wprintw(edit, "+");

View File

@@ -1,7 +1,7 @@
## Syntax highlighting for Gentoo ebuilds/eclasses,
## and (further down) for Portage control files.
syntax ebuild "\.e(build|class|blit)$"
syntax ebuild "\.e(build|class)$"
comment "#"
## All the standard portage functions:
@@ -17,25 +17,25 @@ color green "-(eq|ne|gt|lt|ge|le)\>"
## Variables... official portage ones in red, all others in bright red:
color brightred "\$[-0-9@*#?$!]" "\$[[:alpha:]_][[:alnum:]_]*"
color brightred "\$\{[#!]?([-@*#?$!]|[0-9]+|[[:alpha:]_][[:alnum:]_]*)(\[([[:digit:]]|@)+\])?(([#%/]|:?[-=?+])[^}]*\}|\[|\})"
color red "\<(EAPI|ARCH|HOMEPAGE|DESCRIPTION|IUSE|SRC_URI|LICENSE|SLOT|KEYWORDS|[BHPR]?DEPEND|PROVIDE|PROPERTIES|REQUIRED_USE|RESTRICT|USERLAND)\>"
color red "\<(S|E?D|T|PV|PF|P|PN|PR|PVR|A|CATEGORY|DISTDIR|FILESDIR|EPREFIX|E?ROOT|WORKDIR)\>"
color red "\<(EAPI|ARCH|HOMEPAGE|DESCRIPTION|IUSE|SRC_URI|LICENSE|SLOT|KEYWORDS|[BIPR]?DEPEND|PROVIDE|PROPERTIES|REQUIRED_USE|RESTRICT|USERLAND)\>"
color red "\<(S|E?D|T|PV|PF|P|PN|PR|PVR|A|CATEGORY|DISTDIR|FILESDIR|EPREFIX|(B|E|E?SYS)?ROOT|WORKDIR)\>"
color red "\<(AS|C(PP|XX)?|LD)FLAGS\>" "\<C(HOST|TARGET|BUILD)\>" "\<(MERGE_TYPE|REPLACING_VERSIONS|REPLACED_BY_VERSION)\>"
color red "\<EBUILD_PHASE(_FUNC)?\>"
color red "\<QA_((TEXTRELS|EXECSTACK|WX_LOAD)(_[a-zA-Z_0-9]+)?|DT_HASH|PRESTRIPPED)\>"
color red "\<(PATCHES|(HTML_)?DOCS)\>" "\<WANT_(AUTO(CONF|MAKE)|LIBTOOL)\>" "\<AT_M4DIR\>"
## Portage commands:
color magenta "\<(use(_(with|enable|if_iuse)|x)?|in_iuse) [!a-zA-Z0-9_+ -]*" "inherit.*"
color brightblue "\<e(begin|end|conf|install|make|qmake4|ant|(qa)?warn|infon?|error|log|patch(_user)?|new(group|user))\>"
color brightblue "\<e(apply(_user)?|begin|end|conf|install|make|ninja|qmake5|ant|(qa)?warn|infon?|error|log|patch(_user)?|new(group|user))\>"
color brightblue "\<e(pause|beep|mktemp|(cvs|svn)_clean|punt_cxx)\>" "\<e(aclocal|auto(reconf|header|conf|make)|libtoolize)\>"
color brightblue "\<e(stack|shopts|umask)_(push|pop)\>" "\<version_is_at_least\>"
color brightblue "\<e(stack|shopts|umask)_(push|pop)\>" "\<get_libdir\>" "\<ver_(cut|rs|test)\>" "\<version_is_at_least\>"
color brightblue "\<make_desktop_entry\>" "\<unpack(_(makeself|pdv))?\>"
color brightblue "\<(die|hasv?|inherit|nonfatal)\>" "\<(use(_(with|enable|if_iuse)|x)?|in_iuse)\>" "\<(has|best)_version\>"
color brightblue "\<(do|new)(ins|(games)?s?bin|doc|lib(\.so|\.a)?|man|info|exe|initd|confd|envd|pam|menu|icon)\>"
color brightblue "\<do(compress|header|python|sed|dir|hard|sym|html|jar|mo)\>" "\<keepdir\>"
color brightblue "\<prepall(docs|info|man|strip)?\>" "\<prep(info|lib|lib\.(so|a)|man|strip|gamesdirs)\>"
color brightblue "\<(doc|ins|exe)?into\>" "\<(f|games)(owners|perms)\>" "\<(exe|ins|dir)opts\>"
color brightblue "\<(do|new)(ins|s?bin|doc|header|lib(\.so|\.a)?|man|info|exe|initd|confd|envd|pam|menu|icon)\>"
color brightblue "\<do(compress|dir|html|mo|strip|sym)\>" "\<keepdir\>"
color brightblue "\<prepall(docs|info|man|strip)?\>" "\<prep(info|lib|lib\.(so|a)|man|strip)\>"
color brightblue "\<(doc|ins|exe)?into\>" "\<f(owners|perms)\>" "\<(exe|ins|dir)opts\>"
color brightblue "\<tc-get(BUILD_)?(AR|AS|CC|CPP|CXX|LD|NM|OBJCOPY|PKG_CONFIG|RANLIB)\>"
color brightblue "\<tc-(arch(-kernel)?|export|has-(tls|openmp))\>"
color brightblue "\<tc-(arch(-kernel)?|export|has-(tls|openmp)|is-cross-compiler)\>"
## Common commands used in ebuilds:
color blue "\<(awk|cat|cd|chmod|chown|cp|echo|env|find|e?grep|ln|make|mkdir|mv|popd|printf|pushd|rm|rmdir|sed|set|tar|touch|unset|xargs)\>"
## Comments (doesn't work that well):
@@ -60,7 +60,7 @@ color magenta ":[^[:space:]]+([[:space:]]|$)"
color brightred "[[:space:]]+\+?[A-Za-z0-9+_@-]+"
color brightblue "[[:space:]]+-[A-Za-z0-9+_@-]+"
## Accepted arches:
color white "[~-]?\<(alpha|amd64|arm(64)?|hppa|ia64|m68k|mips|nios2|ppc(64)?|riscv|s390|sh|sparc|x86)(-(aix|(f|free|net|open)bsd|cygwin|hpux|interix|linux|macos|mint|solaris|winnt))?\>"
color white "[~-]?\<(alpha|amd64|arm(64)?|hppa|ia64|m68k|mips|ppc(64)?|riscv|s390|sparc|x86)(-(cygwin|linux|macos|solaris|winnt))?\>"
color white "[[:space:]][*~-]?\*"
## Categories:
color cyan "^[[:space:]]*[^/]*/"

View File

@@ -1,6 +1,6 @@
## Syntax highlighting for nanorc files.
syntax nanorc "\.?nanorc$"
syntax nanorc "\.?nanorc(\.in)?$"
comment "#"
# Everything that does not get recolored is invalid

View File

@@ -20,5 +20,3 @@ color white start="(^use| = new)" end=";"
# Comments.
color green "(^|[[:blank:]])#.*"
color yellow start="<< 'STOP'" end="STOP"

View File

@@ -31,7 +31,5 @@ color green "'([^']|(\\'))*'" "%[qw]\{[^}]*\}" "%[qw]\([^)]*\)" "%[qw]<[^>]*>" "
# Comments.
color cyan "#[^{].*" "#$"
color brightcyan "##[^{].*" "##$"
# "Here" docs.
color green start="<<-?'?EOT'?" end="^EOT"
# Some common markers.
color brightcyan "XXX|TODO|FIXME|\?\?\?"

View File

@@ -1,7 +1,7 @@
## Syntax highlighting for Rust.
## Copyright 2015 Luke Francl.
## Licensed under GPL version 3.
## Licensed under GPL version 3 or newer.
syntax rust "\.(rlib|rs)$"
comment "//"

47
syntax/yaml.nanorc Normal file
View File

@@ -0,0 +1,47 @@
## Syntax highlighting for YAML files.
## Original author: Benno Schulenberg
## License: GPL version 3 or newer
syntax yaml "\.ya?ml$"
header "^%YAML |^---( |$)"
tabgives " "
comment "#"
# Keys:
color lightgreen "(\w|::|[/.-])+:( |$)"
color lightgreen "\[(\w|::|[/., -])+\]:( |$)"
# Values (booleans, numbers, octal/hex):
color lightmagenta "[:,] +(Y(es)?|No?|y(es)?|no?|[Tt]rue|[Ff]alse|[Oo](n|ff))( *[]}]|, | +#|$)"
color lightmagenta "[:,] +[+-]?[0-9]+(\.([0-9]+)?)?( *[]}]|, | +#|$)"
color lightmagenta " 0(o[0-7]+|x[[:xdigit:]]+)( *[]}]|, | +#|$)"
color normal "[:,]( |$)"
# Values (dates, strings):
color lightmagenta " [12][0-9]{3}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])"
color lightmagenta "("([^"]|\\")+"|'[^']+')"
# Anchors and aliases:
color pink " [&*](\w|-)+( |$)"
# Symbols:
color bold,lagoon "^(%YAML +[1-9]\.[0-9]$|%TAG |(---|\.\.\.)( |$))"
color bold,lagoon " [|>]([1-9]?[+-]|[+-][1-9]?)?$"
color bold,yellow "^ *(\?|([?:] +)?-) "
color yellow "[]{}[]"
color normal "^ *: "
# Tags:
color mint " !!(binary|bool|float|int|map|null|omap|seq|set|str)( |,|$)"
color mint " ![^! ][^ ]*( |$)"
# Escaped characters:
color orange "\\([0abefnrtv"/ \_NLP]|$)"
color orange "\\(x[[:xdigit:]]{2}|u[[:xdigit:]]{4}|U[[:xdigit:]]{8})"
# Mistakes (control codes, trailing space):
color ,red "[[:cntrl:]]| +$"
# Comments:
color italic,cyan "(^| )#.*"