mirror of git://git.sv.gnu.org/nano.git
2011-02-18 Chris Allegretta <chrisa@asty.org>
* New saved cursor position history option. Command line option -P or --poslog, rc file entry "poslog". Search history changes to ~/.nano/search_history, cursor position log is ~/.nano/filepos_history. Added checks to move the legacy .nano_history file to the new location. Several new functions to files.c: load_poshistory(), save_poshistory(), check_poshistory(), update_poshistory(), and reworking of histfilename(). New FAQ entry 4.15 discussing the change and offering an interoperability workaround. git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4530 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
This commit is contained in:
parent
9bfda9196b
commit
8e2a930714
|
@ -1,3 +1,11 @@
|
||||||
|
2011-02-18 Chris Allegretta <chrisa@asty.org>
|
||||||
|
* New saved cursor position history option. Command line option -P or --poslog, rc file
|
||||||
|
entry "poslog". Search history changes to ~/.nano/search_history, cursor position log
|
||||||
|
is ~/.nano/filepos_history. Added checks to move the legacy .nano_history file to the new
|
||||||
|
location. Several new functions to files.c: load_poshistory(), save_poshistory(),
|
||||||
|
check_poshistory(), update_poshistory(), and reworking of histfilename(). New FAQ entry
|
||||||
|
4.15 discussing the change and offering an interoperability workaround.
|
||||||
|
|
||||||
2011-02-12 Chris Allegretta <chrisa@asty.org>
|
2011-02-12 Chris Allegretta <chrisa@asty.org>
|
||||||
* Initial libmagic implementation, adapted from Eitan Adler <eitanadlerlist@gmail.com>.
|
* Initial libmagic implementation, adapted from Eitan Adler <eitanadlerlist@gmail.com>.
|
||||||
New nanorc entry "magic" to enable this functionality, nanorc file and man page updates.
|
New nanorc entry "magic" to enable this functionality, nanorc file and man page updates.
|
||||||
|
|
|
@ -46,7 +46,8 @@
|
||||||
<a href="#4.11">4.11. How do I make nano my default editor (in Pine, mutt, etc.)?</a><br>
|
<a href="#4.11">4.11. How do I make nano my default editor (in Pine, mutt, etc.)?</a><br>
|
||||||
<a href="#4.12">4.12. I've compiled nano with color support, but I don't see any color when I run it!</a><br>
|
<a href="#4.12">4.12. I've compiled nano with color support, but I don't see any color when I run it!</a><br>
|
||||||
<a href="#4.13">4.13. How do I select text for or paste text from the clipboard in an X terminal when I'm running nano in one and nano's mouse support is turned on?</a><br>
|
<a href="#4.13">4.13. How do I select text for or paste text from the clipboard in an X terminal when I'm running nano in one and nano's mouse support is turned on?</a><br>
|
||||||
<a href="#4.14">4.14. When I paste text into a document, each line gets indented further than the last. Why does nano do this, and how can I avoid it?</a></p></blockquote>
|
<a href="#4.14">4.14. When I paste text into a document, each line gets indented further than the last. Why does nano do this, and how can I avoid it?</a><br>
|
||||||
|
<a href="#4.15">4.15. On startup I get a message that says "Detected a legacy nano history file". Now other nano versionc can't find my search history!</a></p></blockquote>
|
||||||
<h2><a href="#5">5. Internationalization</a></h2>
|
<h2><a href="#5">5. Internationalization</a></h2>
|
||||||
<blockquote><p><a href="#5.1">5.1. There's no translation for my language!</a><br>
|
<blockquote><p><a href="#5.1">5.1. There's no translation for my language!</a><br>
|
||||||
<a href="#5.2">5.2. I don't like the translation for <x> in my language. How can I fix it?</a><br>
|
<a href="#5.2">5.2. I don't like the translation for <x> in my language. How can I fix it?</a><br>
|
||||||
|
@ -222,6 +223,11 @@
|
||||||
<blockquote><p>Try holding down the Shift key and selecting or pasting the text as you normally would.</p></blockquote>
|
<blockquote><p>Try holding down the Shift key and selecting or pasting the text as you normally would.</p></blockquote>
|
||||||
<h2><a name="4.14"></a>4.14. When I paste text into a document, each line gets indented further than the last. Why does nano do this, and how can I avoid it?</h2>
|
<h2><a name="4.14"></a>4.14. When I paste text into a document, each line gets indented further than the last. Why does nano do this, and how can I avoid it?</h2>
|
||||||
<blockquote><p>You have the autoindent feature turned on. Hit Meta-I to turn it off, paste your text, and then hit Meta-I again to turn it back on.</p></blockquote>
|
<blockquote><p>You have the autoindent feature turned on. Hit Meta-I to turn it off, paste your text, and then hit Meta-I again to turn it back on.</p></blockquote>
|
||||||
|
<h2><a name="4.15"></a>4.15. On startup I get a message that says "Detected a legacy nano history file". Now other nano versionc can't find my search history!</h2>
|
||||||
|
<blockquote><p>In nano 2.3.0, cursor position history was introduced, and both files now reside under a .nano directory in your home. Nano was trying to move this file into the new location so it could continue to use it. This means that if you try and use an earlier version of nano, it will be unable to see your previous search history. To fix this, run the following commands:<br>
|
||||||
|
mv ~/.nano/search_history ~/.nano_history<br>
|
||||||
|
ln -sf ~/.nano_history ~/.nano/search_history<br>
|
||||||
|
</p></blockquote>
|
||||||
<hr width="100%">
|
<hr width="100%">
|
||||||
<h1><a name="5"></a>5. Internationalization</h1>
|
<h1><a name="5"></a>5. Internationalization</h1>
|
||||||
<h2><a name="5.1"></a>5.1. There's no translation for my language!</h2>
|
<h2><a name="5.1"></a>5.1. There's no translation for my language!</h2>
|
||||||
|
|
|
@ -180,6 +180,9 @@ won't work properly with this option enabled.
|
||||||
.B set/unset regexp
|
.B set/unset regexp
|
||||||
Do extended regular expression searches by default.
|
Do extended regular expression searches by default.
|
||||||
.TP
|
.TP
|
||||||
|
.B set/unset poslog
|
||||||
|
Save the cursor position of files between editing sessions.
|
||||||
|
.TP
|
||||||
.B set/unset smarthome
|
.B set/unset smarthome
|
||||||
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
|
very beginning of non-whitespace characters on a line, the cursor will
|
||||||
|
|
|
@ -4,7 +4,7 @@ syntax "nanorc" "\.?nanorc$"
|
||||||
## Possible errors and parameters
|
## Possible errors and parameters
|
||||||
icolor brightwhite "^[[:space:]]*((un)?set|include|syntax|i?color).*$"
|
icolor brightwhite "^[[:space:]]*((un)?set|include|syntax|i?color).*$"
|
||||||
## Keywords
|
## Keywords
|
||||||
icolor brightgreen "^[[:space:]]*(set|unset)[[:space:]]+(allow_insecure_backup|autoindent|backup|backupdir|backwards|boldtext|brackets|casesensitive|const|cut|fill|historylog|matchbrackets|morespace|mouse|multibuffer|noconvert|nofollow|nohelp|nonewlines|nowrap|operatingdir|preserve|punct)\>" "^[[:space:]]*(set|unset)[[:space:]]+(quickblank|quotestr|rebinddelete|rebindkeypad|regexp|smarthome|smooth|softwrap|speller|suspend|suspendenable|tabsize|tabstospaces|tempfile|undo|view|whitespace|wordbounds)\>"
|
icolor brightgreen "^[[:space:]]*(set|unset)[[:space:]]+(allow_insecure_backup|autoindent|backup|backupdir|backwards|boldtext|brackets|casesensitive|const|cut|fill|historylog|matchbrackets|morespace|mouse|multibuffer|noconvert|nofollow|nohelp|nonewlines|nowrap|operatingdir|poslog|preserve|punct)\>" "^[[:space:]]*(set|unset)[[:space:]]+(quickblank|quotestr|rebinddelete|rebindkeypad|regexp|smarthome|smooth|softwrap|speller|suspend|suspendenable|tabsize|tabstospaces|tempfile|undo|view|whitespace|wordbounds)\>"
|
||||||
icolor green "^[[:space:]]*(set|unset|include|syntax|header|magic)\>"
|
icolor green "^[[:space:]]*(set|unset|include|syntax|header|magic)\>"
|
||||||
## Colors
|
## Colors
|
||||||
icolor yellow "^[[:space:]]*i?color[[:space:]]*(bright)?(white|black|red|blue|green|yellow|magenta|cyan)?(,(white|black|red|blue|green|yellow|magenta|cyan))?\>"
|
icolor yellow "^[[:space:]]*i?color[[:space:]]*(bright)?(white|black|red|blue|green|yellow|magenta|cyan)?(,(white|black|red|blue|green|yellow|magenta|cyan))?\>"
|
||||||
|
|
67
src/files.c
67
src/files.c
|
@ -279,6 +279,10 @@ bool close_buffer(void)
|
||||||
if (openfile == openfile->next)
|
if (openfile == openfile->next)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
|
#ifndef NANO_TINY
|
||||||
|
update_poshistory(openfile->filename, openfile->current->lineno, xplustabs()+1);
|
||||||
|
#endif /* NANO_TINY */
|
||||||
|
|
||||||
/* Switch to the next file buffer. */
|
/* Switch to the next file buffer. */
|
||||||
switch_to_next_buffer_void();
|
switch_to_next_buffer_void();
|
||||||
|
|
||||||
|
@ -2880,8 +2884,8 @@ void save_history(void)
|
||||||
void save_poshistory(void)
|
void save_poshistory(void)
|
||||||
{
|
{
|
||||||
char *poshist;
|
char *poshist;
|
||||||
char *statusstr;
|
char *statusstr = NULL;
|
||||||
openfilestruct *ofptr = openfile;
|
poshiststruct *posptr;
|
||||||
|
|
||||||
poshist = poshistfilename();
|
poshist = poshistfilename();
|
||||||
|
|
||||||
|
@ -2896,18 +2900,14 @@ void save_poshistory(void)
|
||||||
* history file. */
|
* history file. */
|
||||||
chmod(poshist, S_IRUSR | S_IWUSR);
|
chmod(poshist, S_IRUSR | S_IWUSR);
|
||||||
|
|
||||||
while (1) {
|
for (posptr = poshistory; posptr != NULL; posptr = posptr->next) {
|
||||||
char *name = get_full_path(ofptr->filename);
|
statusstr = charalloc(strlen(posptr->filename) + 2 * sizeof(ssize_t) + 4);
|
||||||
statusstr = charalloc(strlen(name) + 2 * sizeof(ssize_t) + 4);
|
sprintf(statusstr, "%s %d %d\n", posptr->filename, (int) posptr->lineno,
|
||||||
sprintf(statusstr, "%s %d %d\n", name, (int) ofptr->current->lineno,
|
(int) posptr->xno);
|
||||||
(int) strnlenpt(openfile->current->data, openfile->current_x) + 1);
|
|
||||||
if (fwrite(statusstr, sizeof(char), strlen(statusstr), hist) < strlen(statusstr))
|
if (fwrite(statusstr, sizeof(char), strlen(statusstr), hist) < strlen(statusstr))
|
||||||
history_error(N_("Error writing %s: %s"), poshist,
|
history_error(N_("Error writing %s: %s"), poshist,
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
free(name);
|
free(statusstr);
|
||||||
if (ofptr->next == ofptr)
|
|
||||||
break;
|
|
||||||
ofptr = ofptr->next;
|
|
||||||
}
|
}
|
||||||
fclose(hist);
|
fclose(hist);
|
||||||
}
|
}
|
||||||
|
@ -2915,7 +2915,44 @@ void save_poshistory(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check the POS history to see if file matches
|
/* Update the POS history, given a filename line and column.
|
||||||
|
* If no entry is found, add a new entry on the end
|
||||||
|
*/
|
||||||
|
void update_poshistory(char *filename, ssize_t lineno, ssize_t xpos)
|
||||||
|
{
|
||||||
|
poshiststruct *posptr, *posprev = NULL;
|
||||||
|
char *fullpath = get_full_path(filename);
|
||||||
|
|
||||||
|
if (fullpath == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
for (posptr = poshistory; posptr != NULL; posptr = posptr->next) {
|
||||||
|
if (!strcmp(posptr->filename, fullpath)) {
|
||||||
|
posptr->lineno = lineno;
|
||||||
|
posptr->xno = xpos;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
posprev = posptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Didn't find it, make a new node yo! */
|
||||||
|
|
||||||
|
posptr = nmalloc(sizeof(poshiststruct));
|
||||||
|
posptr->filename = mallocstrcpy(NULL, fullpath);
|
||||||
|
posptr->lineno = lineno;
|
||||||
|
posptr->xno = xpos;
|
||||||
|
posptr->next = NULL;
|
||||||
|
|
||||||
|
if (!poshistory)
|
||||||
|
poshistory = posptr;
|
||||||
|
else
|
||||||
|
posprev->next = posptr;
|
||||||
|
|
||||||
|
free(fullpath);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Check the POS history to see if file matches
|
||||||
* an existing entry. If so return 1 and set line and column
|
* an existing entry. If so return 1 and set line and column
|
||||||
* to the right values Otherwise return 0
|
* to the right values Otherwise return 0
|
||||||
*/
|
*/
|
||||||
|
@ -2931,9 +2968,11 @@ int check_poshistory(const char *file, ssize_t *line, ssize_t *column)
|
||||||
if (!strcmp(posptr->filename, fullpath)) {
|
if (!strcmp(posptr->filename, fullpath)) {
|
||||||
*line = posptr->lineno;
|
*line = posptr->lineno;
|
||||||
*column = posptr->xno;
|
*column = posptr->xno;
|
||||||
|
free(fullpath);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
free(fullpath);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2943,7 +2982,6 @@ void load_poshistory(void)
|
||||||
{
|
{
|
||||||
char *nanohist = poshistfilename();
|
char *nanohist = poshistfilename();
|
||||||
|
|
||||||
|
|
||||||
/* Assume do_rcfile() has reported a missing home directory. */
|
/* Assume do_rcfile() has reported a missing home directory. */
|
||||||
if (nanohist != NULL) {
|
if (nanohist != NULL) {
|
||||||
FILE *hist = fopen(nanohist, "rb");
|
FILE *hist = fopen(nanohist, "rb");
|
||||||
|
@ -2974,7 +3012,6 @@ void load_poshistory(void)
|
||||||
xptr = parse_next_word(lineptr);
|
xptr = parse_next_word(lineptr);
|
||||||
lineno = atoi(lineptr);
|
lineno = atoi(lineptr);
|
||||||
xno = atoi(xptr);
|
xno = atoi(xptr);
|
||||||
fprintf(stderr, "Read data: file %s, line %d, xpos %d\n", line, lineno, xno);
|
|
||||||
if (poshistory == NULL) {
|
if (poshistory == NULL) {
|
||||||
poshistory = nmalloc(sizeof(poshiststruct));
|
poshistory = nmalloc(sizeof(poshiststruct));
|
||||||
poshistory->filename = mallocstrcpy(NULL, line);
|
poshistory->filename = mallocstrcpy(NULL, line);
|
||||||
|
@ -2982,7 +3019,7 @@ void load_poshistory(void)
|
||||||
poshistory->xno = xno;
|
poshistory->xno = xno;
|
||||||
poshistory->next = NULL;
|
poshistory->next = NULL;
|
||||||
} else {
|
} else {
|
||||||
for (posptr = poshistory; posptr != NULL; posptr = posptr->next)
|
for (posptr = poshistory; posptr->next != NULL; posptr = posptr->next)
|
||||||
;
|
;
|
||||||
posptr->next = nmalloc(sizeof(poshiststruct));
|
posptr->next = nmalloc(sizeof(poshiststruct));
|
||||||
posptr->next->filename = mallocstrcpy(NULL, line);
|
posptr->next->filename = mallocstrcpy(NULL, line);
|
||||||
|
|
10
src/nano.c
10
src/nano.c
|
@ -605,8 +605,10 @@ void finish(void)
|
||||||
#if !defined(NANO_TINY) && defined(ENABLE_NANORC)
|
#if !defined(NANO_TINY) && defined(ENABLE_NANORC)
|
||||||
if (!no_rcfiles && ISSET(HISTORYLOG))
|
if (!no_rcfiles && ISSET(HISTORYLOG))
|
||||||
save_history();
|
save_history();
|
||||||
if (!no_rcfiles && ISSET(POS_HISTORY))
|
if (!no_rcfiles && ISSET(POS_HISTORY)) {
|
||||||
|
update_poshistory(openfile->filename, openfile->current->lineno, xplustabs()+1);
|
||||||
save_poshistory();
|
save_poshistory();
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
|
@ -859,8 +861,8 @@ void usage(void)
|
||||||
#endif
|
#endif
|
||||||
print_opt("-O", "--morespace", N_("Use one more line for editing"));
|
print_opt("-O", "--morespace", N_("Use one more line for editing"));
|
||||||
#ifndef NANO_TINY
|
#ifndef NANO_TINY
|
||||||
print_opt("-P", "--poshistory",
|
print_opt("-P", "--poslog",
|
||||||
N_("Save and load history of cursor position"));
|
N_("Log & read location of cursor position"));
|
||||||
#endif
|
#endif
|
||||||
#ifndef DISABLE_JUSTIFY
|
#ifndef DISABLE_JUSTIFY
|
||||||
print_opt(_("-Q <str>"), _("--quotestr=<str>"),
|
print_opt(_("-Q <str>"), _("--quotestr=<str>"),
|
||||||
|
@ -2098,7 +2100,7 @@ int main(int argc, char **argv)
|
||||||
{"tabstospaces", 0, NULL, 'E'},
|
{"tabstospaces", 0, NULL, 'E'},
|
||||||
{"historylog", 0, NULL, 'H'},
|
{"historylog", 0, NULL, 'H'},
|
||||||
{"noconvert", 0, NULL, 'N'},
|
{"noconvert", 0, NULL, 'N'},
|
||||||
{"poshistory", 0, NULL, 'P'},
|
{"poslog", 0, NULL, 'P'},
|
||||||
{"smooth", 0, NULL, 'S'},
|
{"smooth", 0, NULL, 'S'},
|
||||||
{"quickblank", 0, NULL, 'U'},
|
{"quickblank", 0, NULL, 'U'},
|
||||||
{"undo", 0, NULL, 'u'},
|
{"undo", 0, NULL, 'u'},
|
||||||
|
|
|
@ -114,6 +114,7 @@ extern filestruct *replace_history;
|
||||||
extern filestruct *replaceage;
|
extern filestruct *replaceage;
|
||||||
extern filestruct *replacebot;
|
extern filestruct *replacebot;
|
||||||
extern poshiststruct *poshistory;
|
extern poshiststruct *poshistory;
|
||||||
|
void update_poshistory(char *filename, ssize_t lineno, ssize_t xpos);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_REGEX_H
|
#ifdef HAVE_REGEX_H
|
||||||
|
|
|
@ -85,6 +85,7 @@ static const rcoption rcopts[] = {
|
||||||
{"historylog", HISTORYLOG},
|
{"historylog", HISTORYLOG},
|
||||||
{"matchbrackets", 0},
|
{"matchbrackets", 0},
|
||||||
{"noconvert", NO_CONVERT},
|
{"noconvert", NO_CONVERT},
|
||||||
|
{"poslog", POS_HISTORY},
|
||||||
{"quiet", QUIET},
|
{"quiet", QUIET},
|
||||||
{"quickblank", QUICK_BLANK},
|
{"quickblank", QUICK_BLANK},
|
||||||
{"smarthome", SMART_HOME},
|
{"smarthome", SMART_HOME},
|
||||||
|
|
Loading…
Reference in New Issue