From alpha at student.uci.agh.edu.pl Tue Apr 1 17:18:54 2003 From: alpha at student.uci.agh.edu.pl (Adam Byrtek / alpha) Date: Tue, 1 Apr 2003 19:18:54 +0200 Subject: Charset conversion Message-ID: <20030401171854.GA3262@mentat.localdomain> Many people (especially from Russia) ask me to enable charset conversion in Debian mc binary package. Is it safe to do this with 4.6.0, or should I refuse? Regards Adam -- _.|._ |_ _. : Adam Byrtek /alpha alpha at debian.org (_|||_)| |(_| : http://krakow.linux.org.pl/ pgp 0xB25952C0 | From proski at gnu.org Tue Apr 1 17:32:20 2003 From: proski at gnu.org (Pavel Roskin) Date: Tue, 1 Apr 2003 12:32:20 -0500 (EST) Subject: Charset conversion In-Reply-To: <20030401171854.GA3262@mentat.localdomain> References: <20030401171854.GA3262@mentat.localdomain> Message-ID: Hello! > Many people (especially from Russia) ask me to enable charset > conversion in Debian mc binary package. Is it safe to do this with > 4.6.0, or should I refuse? I think it's safe for Debian GNU/Linux (and for every OS using GNU libc and 8-bit clean terminals). The interface is inconvenient, the documentation is missing, but if users want it, then they know about this feature and how to use it. -- Regards, Pavel Roskin From alpha at student.uci.agh.edu.pl Wed Apr 2 11:37:24 2003 From: alpha at student.uci.agh.edu.pl (Adam Byrtek / alpha) Date: Wed, 2 Apr 2003 13:37:24 +0200 Subject: [PATCH] Editor file locking Message-ID: <20030402113724.GA21652@mentat.localdomain> As discussed earlier, patch to implement file locking in editor. Try and tell me about any problems. Locking scheme described in edit/editlock.c TODO: 'Abort' option would be very useful, but it requires some more hacking in the undo stack. I'll do this when this patch will be considered stable. (Patch also sent to BTS) Regards Adam -- _.|._ |_ _. : Adam Byrtek /alpha alpha at debian.org (_|||_)| |(_| : http://krakow.linux.org.pl/ pgp 0xB25952C0 | -------------- next part -------------- Index: edit/Makefile.am =================================================================== RCS file: /cvs/gnome/mc/edit/Makefile.am,v retrieving revision 1.5 diff -u -r1.5 Makefile.am --- edit/Makefile.am 23 Dec 2002 10:13:35 -0000 1.5 +++ edit/Makefile.am 2 Apr 2003 11:17:41 -0000 @@ -9,6 +9,6 @@ libedit_a_SOURCES = \ bookmark.c edit.c editcmd.c editwidget.c editdraw.c editkeys.c \ editmenu.c editoptions.c editcmddef.h edit.h edit-widget.h \ - syntax.c wordproc.c + syntax.c wordproc.c editlock.c editlock.h EXTRA_DIST = ChangeLog Index: edit/edit-widget.h =================================================================== RCS file: /cvs/gnome/mc/edit/edit-widget.h,v retrieving revision 1.15 diff -u -r1.15 edit-widget.h --- edit/edit-widget.h 12 Mar 2003 07:07:28 -0000 1.15 +++ edit/edit-widget.h 2 Apr 2003 11:17:41 -0000 @@ -56,6 +56,7 @@ unsigned char overwrite; unsigned char modified; /* has the file been changed?: 1 if char inserted or deleted at all since last load or save */ + unsigned char locked; /* 1 if lock is held on current file */ unsigned char screen_modified; /* has the file been changed since the last screen draw? */ int delete_file; /* Has the file been created by the editor? Delete it at end of editing when it hasn't been modified Index: edit/edit.c =================================================================== RCS file: /cvs/gnome/mc/edit/edit.c,v retrieving revision 1.73 diff -u -r1.73 edit.c --- edit/edit.c 23 Dec 2002 10:13:35 -0000 1.73 +++ edit/edit.c 2 Apr 2003 11:17:41 -0000 @@ -22,6 +22,7 @@ #include #include "edit.h" +#include "editlock.h" #include "edit-widget.h" #include "editcmddef.h" @@ -554,6 +555,7 @@ return 0; } edit->modified = 0; + edit->locked = 0; edit_load_syntax (edit, 0, 0); { int color; @@ -811,8 +813,12 @@ static inline void edit_modification (WEdit * edit) { edit->caches_valid = 0; - edit->modified = 1; edit->screen_modified = 1; + + /* raise lock when file modified */ + if (!edit->modified && !edit->delete_file) + edit->locked = edit_lock_file (edit->filename); + edit->modified = 1; } /* Index: edit/editcmd.c =================================================================== RCS file: /cvs/gnome/mc/edit/editcmd.c,v retrieving revision 1.75 diff -u -r1.75 editcmd.c --- edit/editcmd.c 19 Dec 2002 13:01:34 -0000 1.75 +++ edit/editcmd.c 2 Apr 2003 11:17:43 -0000 @@ -27,6 +27,7 @@ #include #include "edit.h" +#include "editlock.h" #include "editcmddef.h" #include "edit-widget.h" @@ -184,9 +185,6 @@ doupdate(); } -/* "Oleg Yu. Repin" added backup filenames - ...thanks -paul */ - /* If 0 (quick save) then a) create/truncate file, b) save to ; if 1 (safe save) then a) save to , @@ -438,6 +436,7 @@ { /* This heads the 'Save As' dialog box */ char *exp = 0; + int save_lock = 0; int different_filename = 0; exp = edit_get_save_file (edit->filename, _(" Save As ")); @@ -465,8 +464,25 @@ return 0; } } + save_lock = edit_lock_file (exp); + } else { + /* filenames equal, check if already locked */ + if (!edit->locked && !edit->delete_file) + save_lock = edit_lock_file (exp); } + if (edit_save_file (edit, exp)) { + /* Succesful, so unlock both files */ + if (strcmp (edit->filename, exp)) { + if (save_lock) + edit_unlock_file (exp); + if (edit->locked) + edit->locked = edit_unlock_file (edit->filename); + } else { + if (edit->locked || save_lock) + edit->locked = edit_unlock_file (edit->filename); + } + edit_set_filename (edit, exp); g_free (exp); edit->modified = 0; @@ -476,6 +492,11 @@ edit->force |= REDRAW_COMPLETELY; return 1; } else { + /* Failed, so maintain modify (not save) lock */ + if (strcmp (edit->filename, exp) && save_lock) + edit_unlock_file (exp); + if (save_lock) + edit->locked = edit_unlock_file (edit->filename); g_free (exp); edit_error_dialog (_(" Save As "), get_sys_error (_ @@ -730,11 +751,22 @@ /* returns 1 on success */ int edit_save_cmd (WEdit * edit) { - if (!edit_save_file (edit, edit->filename)) + int res, save_lock = 0; + + if (!edit->locked && !edit->delete_file) + save_lock = edit_lock_file (edit->filename); + res = edit_save_file (edit, edit->filename); + + /* Maintain modify (not save) lock on failure */ + if ((res && edit->locked) || save_lock) + edit->locked = edit_unlock_file (edit->filename); + + /* On failure try 'save as', it does locking on its own */ + if (!res) return edit_save_as_cmd (edit); edit->force |= REDRAW_COMPLETELY; - edit->modified = 0; edit->delete_file = 0; + edit->modified = 0; return 1; } @@ -750,7 +782,9 @@ } } edit->force |= REDRAW_COMPLETELY; - edit->modified = 0; + + if (edit->locked) + edit->locked = edit_unlock_file (edit->filename); return edit_renew (edit); /* if this gives an error, something has really screwed up */ } @@ -758,10 +792,17 @@ static int edit_load_file_from_filename (WEdit * edit, char *exp) { - if (!edit_reload (edit, exp)) + int prev_locked = edit->locked; + char *prev_filename = g_strdup (edit->filename); + + if (!edit_reload (edit, exp)) { + g_free (prev_filename); return 1; - edit_set_filename (edit, exp); - edit->modified = 0; + } + + if (prev_locked) + edit_unlock_file (prev_filename); + g_free (prev_filename); return 0; } @@ -2023,6 +2064,8 @@ return; break; case 2: + if (edit->locked) + edit->locked = edit_unlock_file (edit->filename); if (edit->delete_file) unlink (edit->filename); break; --- /dev/null 2003-01-13 01:13:32.000000000 +0100 +++ edit/editlock.h 2003-04-02 01:05:26.000000000 +0200 @@ -0,0 +1,7 @@ +#ifndef __EDIT_LOCK_H +#define __EDIT_LOCK_H + +int edit_lock_file (char *fname); +int edit_unlock_file (char *fname); + +#endif /* !__EDIT_LOCK_H */ --- /dev/null 2003-01-13 01:13:32.000000000 +0100 +++ edit/editlock.c 2003-04-02 13:13:24.000000000 +0200 @@ -0,0 +1,169 @@ +/* editor file locking. + + Copyright (C) 2003 the Free Software Foundation + + Authors: 2003 Adam Byrtek + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307, USA. + +*/ + +#include +#include "edit.h" +#include "editlock.h" + +#include "src/wtools.h" /* edit_query_dialog () */ + +#define BUF_SIZE 255 + +/* Locking scheme used in mcedit is based on a documentation found + in JED editor sources. Abstract from lock.c file (by John E. Davis): + + The basic idea here is quite simple. Whenever a buffer is attached to + a file, and that buffer is modified, then attempt to lock the + file. Moreover, before writing to a file for any reason, lock the + file. The lock is really a protocol respected and not a real lock. + The protocol is this: If in the directory of the file is a + symbolic link with name ".#FILE", the FILE is considered to be locked + by the process specified by the link. +*/ + +/* Build user at host.domain.pid string (need to be freed) */ +static char *lock_build_name (char *fname) +{ + char host [BUF_SIZE], *user; + + if (!((user = getpwuid (getuid ()) -> pw_name) || + (user = getenv ("USER")) || + (user = getenv ("USERNAME")) || + (user = getenv ("LOGNAME")))) + user = ""; + + /* TODO: Use FQDN, no clean interface, so requires lot of code */ + if (gethostname (host, BUF_SIZE-1) == -1) + *host='\0'; + + return g_strdup_printf ("%s@%s.%d", user, host, getpid ()); +} + +/* Extract pid from user at host.domain.pid string */ +static pid_t lock_extract_pid (char *str) +{ + char *pid; + + for (pid = str+strlen(str)-1; isdigit(*pid) && pid>=str; pid--); + if (!*pid) + return -1; + return (pid_t) atol (pid+1); +} + +/* Extract user at host.domain.pid from lock file (static string) */ +static char *lock_get_info (char *lockfname) +{ + static char buf[BUF_SIZE]; + + if (readlink (lockfname, buf, BUF_SIZE-1) == -1 || !buf || !*buf) + return NULL; + return buf; +} + + +/* Tries to raise file lock + Returns 1 on success, 0 on failure, -1 if abort */ +int edit_lock_file (char *fname) +{ + char *lockfname, *newlock, *msg, *lock; + struct stat statbuf; + pid_t pid; + + /* Just to be sure (and don't lock new file) */ + if (!fname || !*fname) + return 0; + + /* Check if already locked */ + lockfname = g_strconcat (".#", fname, NULL); + if (lstat (lockfname, &statbuf) == 0) { + lock = lock_get_info (lockfname); + if (!lock) { + g_free (lockfname); + return 0; + } + pid = lock_extract_pid (lock); + + /* Check if locking process alive, ask user if required */ + if (pid <= 0 || !(kill (pid, 0) == -1 && errno == ESRCH)) { + msg = g_strconcat ( fname, _(" is already locked by "), lock , NULL); + /* TODO: Implement "Abort" - needs to rewind undo stack */ + switch (edit_query_dialog2 (_ ("File locked"), msg, + _ ("&Steal"), _ ("&Continue"))) { + case 0 : + break; + case 1 : case -1 : + g_free (lockfname); + g_free (msg); + return 0; + } + g_free (msg); + } + unlink (lockfname); + } + + /* Create lock symlink */ + newlock = lock_build_name (fname); + if (symlink (newlock, lockfname) == -1) { + g_free (lockfname); + g_free (newlock); + return 0; + } + + g_free (lockfname); + g_free (newlock); + return 1; +} + +/* Lowers file lock if possible + Always returns 0 to make 'lock = edit_unlock_file (f)' possible */ +int edit_unlock_file (char *fname) +{ + char *lockfname, *lock; + struct stat statbuf; + + /* Just to be sure */ + if (!fname || !*fname) + return 0; + + lockfname = g_strconcat (".#", fname, NULL); + + /* Check if lock exists */ + if (lstat (lockfname, &statbuf) == -1) { + g_free (lockfname); + return 0; + } + + lock = lock_get_info (lockfname); + if (lock) { + /* Don't touch if lock is not ours */ + if (lock_extract_pid (lock) != getpid ()) { + g_free (lockfname); + return 0; + } + } + + /* Remove lock */ + unlink (lockfname); + g_free (lockfname); + return 0; +} Index: edit/ChangeLog =================================================================== RCS file: /cvs/gnome/mc/edit/ChangeLog,v retrieving revision 1.157 diff -u -u -0 -r1.157 ChangeLog --- edit/ChangeLog 12 Mar 2003 07:07:27 -0000 1.157 +++ edit/ChangeLog 2 Apr 2003 11:29:04 -0000 @@ -0,0 +1,14 @@ +2003-04-01 Adam Byrtek + + * editlock.c, editlock.h: New files. Implement file locking in + Emacs style, as documented in JED editor sources. + Makefile.am: Add those files to build tree. + + * edit-widget.c (WEdit): New property 'locked', 0 on edit_init. + * edit.c (edit_modification): Lock buffer on modification. + * editcmd.c (edit_save_cmd, edit_save_as_cmd): Handle locking during + file save. + (edit_load_file_from_filename): Unlock. Remove 2 duplicate + lines (handled by edit_init). + (edit_quit_cmd): Unlock. + From pthomas at suse.de Wed Apr 2 12:13:32 2003 From: pthomas at suse.de (Philipp Thomas) Date: Wed, 2 Apr 2003 14:13:32 +0200 Subject: Charset conversion In-Reply-To: References: <20030401171854.GA3262@mentat.localdomain> Message-ID: <20030402121332.GQ3246@paradies.suse.de> * Pavel Roskin (proski at gnu.org) [20030401 19:33]: > and 8-bit clean terminals). The interface is inconvenient, the > documentation is missing, but if users want it, then they know about this > feature and how to use it. As this may cure some problems users have reported to me, how do I activate/use it? I may even contribute documentation afterwards :) Philipp -- Philipp Thomas SuSE Linux AG, Deutschherrnstr. 15-19, D-90429 Nuremberg, Germany From proski at gnu.org Wed Apr 2 16:37:07 2003 From: proski at gnu.org (Pavel Roskin) Date: Wed, 2 Apr 2003 11:37:07 -0500 (EST) Subject: [PATCH] Editor file locking In-Reply-To: <20030402113724.GA21652@mentat.localdomain> References: <20030402113724.GA21652@mentat.localdomain> Message-ID: Hello! > As discussed earlier, patch to implement file locking in editor. Try > and tell me about any problems. Locking scheme described in > edit/editlock.c > > TODO: 'Abort' option would be very useful, but it requires some more > hacking in the undo stack. I'll do this when this patch will be > considered stable. Thank you for your work! The patch looks good, but "Steal" and "Continue" looks a bit confusing for a new user. Maybe "Break lock" and "Ignore lock" would be better? Emacs 21.2.1 understands the locks created by mc, but mc doesn't under understand locks created by emacs, which have the timestamp after ":" at the end. I think the lock should be honored regardless of whether its text can be fully parsed. Locks can be left by mc in the following scenario. First mc opens and starts editing. Second mc starts editing, the user chooses "Continue". Second mc exits without saving. First mc exits without saving. The lock remains. -- Regards, Pavel Roskin From alpha at student.uci.agh.edu.pl Wed Apr 2 17:37:08 2003 From: alpha at student.uci.agh.edu.pl (Adam Byrtek / alpha) Date: Wed, 2 Apr 2003 19:37:08 +0200 Subject: [PATCH] Editor file locking In-Reply-To: References: <20030402113724.GA21652@mentat.localdomain> Message-ID: <20030402173708.GA653@mentat.localdomain> On Wed, Apr 02, 2003 at 11:37:07AM -0500, Pavel Roskin wrote: > The patch looks good, but "Steal" and "Continue" looks a bit confusing for > a new user. Maybe "Break lock" and "Ignore lock" would be better? Yes, they sound better. 'Steal' and 'continue' was based on JED. > Emacs 21.2.1 understands the locks created by mc, but mc doesn't under > understand locks created by emacs, which have the timestamp after ":" at Didn't test it with Emacs, just with JED. I thought that the format is the same - my mistake. Fixed. > the end. I think the lock should be honored regardless of whether its > text can be fully parsed. It is... but this issue was different. Mc treated the whole timestamp as a pid... and thought that the process with this pid has died. > Locks can be left by mc in the following scenario. First mc opens and > starts editing. Second mc starts editing, the user chooses "Continue". > Second mc exits without saving. First mc exits without saving. The lock > remains. Fixed patch attached. Regards Adam -- _.|._ |_ _. : Adam Byrtek /alpha alpha at debian.org (_|||_)| |(_| : http://krakow.linux.org.pl/ pgp 0xB25952C0 | -------------- next part -------------- Index: edit/ChangeLog =================================================================== RCS file: /cvs/gnome/mc/edit/ChangeLog,v retrieving revision 1.157 diff -u -r1.157 ChangeLog --- edit/ChangeLog 12 Mar 2003 07:07:27 -0000 1.157 +++ edit/ChangeLog 2 Apr 2003 17:35:23 -0000 @@ -1,0 +1,14 @@ +2003-04-01 Adam Byrtek + + * editlock.c, editlock.h: New files. Implement file locking in + Emacs style, as documented in JED editor sources. + Makefile.am: Add those files to build tree. + + * edit-widget.c (WEdit): New property 'locked', 0 on edit_init. + * edit.c (edit_modification): Lock buffer on modification. + * editcmd.c (edit_save_cmd, edit_save_as_cmd): Handle locking during + file save. + (edit_load_file_from_filename): Unlock. Remove 2 duplicate + lines (handled by edit_init). + (edit_quit_cmd): Unlock. + Index: edit/Makefile.am =================================================================== RCS file: /cvs/gnome/mc/edit/Makefile.am,v retrieving revision 1.5 diff -u -r1.5 Makefile.am --- edit/Makefile.am 23 Dec 2002 10:13:35 -0000 1.5 +++ edit/Makefile.am 2 Apr 2003 17:35:23 -0000 @@ -9,6 +9,6 @@ libedit_a_SOURCES = \ bookmark.c edit.c editcmd.c editwidget.c editdraw.c editkeys.c \ editmenu.c editoptions.c editcmddef.h edit.h edit-widget.h \ - syntax.c wordproc.c + syntax.c wordproc.c editlock.c editlock.h EXTRA_DIST = ChangeLog Index: edit/edit-widget.h =================================================================== RCS file: /cvs/gnome/mc/edit/edit-widget.h,v retrieving revision 1.15 diff -u -r1.15 edit-widget.h --- edit/edit-widget.h 12 Mar 2003 07:07:28 -0000 1.15 +++ edit/edit-widget.h 2 Apr 2003 17:35:23 -0000 @@ -56,6 +56,7 @@ unsigned char overwrite; unsigned char modified; /* has the file been changed?: 1 if char inserted or deleted at all since last load or save */ + unsigned char locked; /* 1 if lock is held on current file */ unsigned char screen_modified; /* has the file been changed since the last screen draw? */ int delete_file; /* Has the file been created by the editor? Delete it at end of editing when it hasn't been modified Index: edit/edit.c =================================================================== RCS file: /cvs/gnome/mc/edit/edit.c,v retrieving revision 1.73 diff -u -r1.73 edit.c --- edit/edit.c 23 Dec 2002 10:13:35 -0000 1.73 +++ edit/edit.c 2 Apr 2003 17:35:24 -0000 @@ -22,6 +22,7 @@ #include #include "edit.h" +#include "editlock.h" #include "edit-widget.h" #include "editcmddef.h" @@ -554,6 +555,7 @@ return 0; } edit->modified = 0; + edit->locked = 0; edit_load_syntax (edit, 0, 0); { int color; @@ -811,8 +813,12 @@ static inline void edit_modification (WEdit * edit) { edit->caches_valid = 0; - edit->modified = 1; edit->screen_modified = 1; + + /* raise lock when file modified */ + if (!edit->modified && !edit->delete_file) + edit->locked = edit_lock_file (edit->filename); + edit->modified = 1; } /* Index: edit/editcmd.c =================================================================== RCS file: /cvs/gnome/mc/edit/editcmd.c,v retrieving revision 1.75 diff -u -r1.75 editcmd.c --- edit/editcmd.c 19 Dec 2002 13:01:34 -0000 1.75 +++ edit/editcmd.c 2 Apr 2003 17:35:25 -0000 @@ -27,6 +27,7 @@ #include #include "edit.h" +#include "editlock.h" #include "editcmddef.h" #include "edit-widget.h" @@ -184,9 +185,6 @@ doupdate(); } -/* "Oleg Yu. Repin" added backup filenames - ...thanks -paul */ - /* If 0 (quick save) then a) create/truncate file, b) save to ; if 1 (safe save) then a) save to , @@ -438,6 +436,7 @@ { /* This heads the 'Save As' dialog box */ char *exp = 0; + int save_lock = 0; int different_filename = 0; exp = edit_get_save_file (edit->filename, _(" Save As ")); @@ -465,8 +464,25 @@ return 0; } } + save_lock = edit_lock_file (exp); + } else { + /* filenames equal, check if already locked */ + if (!edit->locked && !edit->delete_file) + save_lock = edit_lock_file (exp); } + if (edit_save_file (edit, exp)) { + /* Succesful, so unlock both files */ + if (strcmp (edit->filename, exp)) { + if (save_lock) + edit_unlock_file (exp); + if (edit->locked) + edit->locked = edit_unlock_file (edit->filename); + } else { + if (edit->locked || save_lock) + edit->locked = edit_unlock_file (edit->filename); + } + edit_set_filename (edit, exp); g_free (exp); edit->modified = 0; @@ -476,6 +492,11 @@ edit->force |= REDRAW_COMPLETELY; return 1; } else { + /* Failed, so maintain modify (not save) lock */ + if (strcmp (edit->filename, exp) && save_lock) + edit_unlock_file (exp); + if (save_lock) + edit->locked = edit_unlock_file (edit->filename); g_free (exp); edit_error_dialog (_(" Save As "), get_sys_error (_ @@ -730,11 +751,22 @@ /* returns 1 on success */ int edit_save_cmd (WEdit * edit) { - if (!edit_save_file (edit, edit->filename)) + int res, save_lock = 0; + + if (!edit->locked && !edit->delete_file) + save_lock = edit_lock_file (edit->filename); + res = edit_save_file (edit, edit->filename); + + /* Maintain modify (not save) lock on failure */ + if ((res && edit->locked) || save_lock) + edit->locked = edit_unlock_file (edit->filename); + + /* On failure try 'save as', it does locking on its own */ + if (!res) return edit_save_as_cmd (edit); edit->force |= REDRAW_COMPLETELY; - edit->modified = 0; edit->delete_file = 0; + edit->modified = 0; return 1; } @@ -750,7 +782,9 @@ } } edit->force |= REDRAW_COMPLETELY; - edit->modified = 0; + + if (edit->locked) + edit->locked = edit_unlock_file (edit->filename); return edit_renew (edit); /* if this gives an error, something has really screwed up */ } @@ -758,10 +792,17 @@ static int edit_load_file_from_filename (WEdit * edit, char *exp) { - if (!edit_reload (edit, exp)) + int prev_locked = edit->locked; + char *prev_filename = g_strdup (edit->filename); + + if (!edit_reload (edit, exp)) { + g_free (prev_filename); return 1; - edit_set_filename (edit, exp); - edit->modified = 0; + } + + if (prev_locked) + edit_unlock_file (prev_filename); + g_free (prev_filename); return 0; } @@ -2023,6 +2064,8 @@ return; break; case 2: + if (edit->locked) + edit->locked = edit_unlock_file (edit->filename); if (edit->delete_file) unlink (edit->filename); break; --- /dev/null 2003-01-13 01:13:32.000000000 +0100 +++ edit/editlock.h 2003-04-02 13:31:20.000000000 +0200 @@ -0,0 +1,7 @@ +#ifndef __EDIT_LOCK_H +#define __EDIT_LOCK_H + +int edit_lock_file (char *fname); +int edit_unlock_file (char *fname); + +#endif /* !__EDIT_LOCK_H */ --- /dev/null 2003-01-13 01:13:32.000000000 +0100 +++ edit/editlock.c 2003-04-02 19:33:11.000000000 +0200 @@ -0,0 +1,180 @@ +/* editor file locking. + + Copyright (C) 2003 the Free Software Foundation + + Authors: 2003 Adam Byrtek + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307, USA. + +*/ + +#include +#include "edit.h" +#include "editlock.h" + +#include "src/wtools.h" /* edit_query_dialog () */ + +#define BUF_SIZE 255 +#define PID_BUF_SIZE 10 + +/* Locking scheme used in mcedit is based on a documentation found + in JED editor sources. Abstract from lock.c file (by John E. Davis): + + The basic idea here is quite simple. Whenever a buffer is attached to + a file, and that buffer is modified, then attempt to lock the + file. Moreover, before writing to a file for any reason, lock the + file. The lock is really a protocol respected and not a real lock. + The protocol is this: If in the directory of the file is a + symbolic link with name ".#FILE", the FILE is considered to be locked + by the process specified by the link. +*/ + +/* Build user at host.domain.pid string (need to be freed) */ +static char *lock_build_name (char *fname) +{ + char host [BUF_SIZE], *user; + + if (!((user = getpwuid (getuid ()) -> pw_name) || + (user = getenv ("USER")) || + (user = getenv ("USERNAME")) || + (user = getenv ("LOGNAME")))) + user = ""; + + /* TODO: Use FQDN, no clean interface, so requires lot of code */ + if (gethostname (host, BUF_SIZE-1) == -1) + *host='\0'; + + return g_strdup_printf ("%s@%s.%d", user, host, getpid ()); +} + +/* Extract pid from user at host.domain.pid string */ +static pid_t lock_extract_pid (char *str) +{ + int i; + char *p, pid[PID_BUF_SIZE]; + + /* Treat text between '.' and ':' or '\0' as pid */ + for (p=str+strlen(str)-1; p>=str; p--) + if (*p == '.') + break; + + i = 0; + for (p=p+1; p i often accidentally do minor modifications (mostly partial escape sequences) which i undo of course. anyway, afterwards i still don't know if this was the only modification. oh, fwiw, this gives me an idea: sometimes it would be useful to be able to save the buffer to a temp file and run a diff against the original file. super-limited version control. :) greetings -- Hi! I'm a .signature virus! Copy me into your ~/.signature, please! -- Chaos, panic, and disorder - my work here is done. From proski at gnu.org Wed Apr 2 19:48:07 2003 From: proski at gnu.org (Pavel Roskin) Date: Wed, 2 Apr 2003 14:48:07 -0500 (EST) Subject: [PATCH] Editor file locking In-Reply-To: <20030402173708.GA653@mentat.localdomain> References: <20030402113724.GA21652@mentat.localdomain> <20030402173708.GA653@mentat.localdomain> Message-ID: On Wed, 2 Apr 2003, Adam Byrtek / alpha wrote: > On Wed, Apr 02, 2003 at 11:37:07AM -0500, Pavel Roskin wrote: > > The patch looks good, but "Steal" and "Continue" looks a bit confusing for > > a new user. Maybe "Break lock" and "Ignore lock" would be better? > > Yes, they sound better. 'Steal' and 'continue' was based on JED. I've applied your patch. The snapshot is ready. I had to change the strings. Please don't use concatenation in user-visible strings - different languages use different word order. Also, "file locked by %s" is hard to translate because the translator doesn't know if %s is a username or PID. "by" could translate differently. Ideally, mc should show all the data separately - host, user and PID (and maybe timestamp). One bug that needs to be fixed - if I use Enter to modify the file and I get a "file locked" message, the old current line is not repainted. Try it to see what I mean. -- Regards, Pavel Roskin From aliakc at web.de Wed Apr 2 19:55:33 2003 From: aliakc at web.de (Ali Akcaagac) Date: Wed, 2 Apr 2003 21:55:33 +0200 Subject: [OT] Re: rename improvement In-Reply-To: References: <1047030267.15960.9.camel@localhost> <1047058422.5584.5.camel@localhost> Message-ID: <200304022155.33194.aliakc@web.de> On Friday 07 March 2003 19:20, Pavel Roskin wrote: > > hm, should it do something ? i don't see the point to learn my shift key > > since it is a common key used on 100% of all machines, no fancy things > > that need to be learned. on the otherhand i don't see anything under > > learn keys that should bring me the requested rename feature. > > Not quite. Linux console may think that Shift-F4 is F16 in some keyboard > layouts. It would be nice to discover this situation and adjust to it, > but it has not been done. In fact, it has never been requested. Hello, I like to hook up this eMail again. I still have problems with this issue and F1...F12 - Shift+F1...Shift+F4 works perfectly but after that not. Ok this is Linux console related. Could you please go a bit deeper into this please and may give me a hint where I should look for this ? - Is it Getty related ? - Is it Console-Tools related ? - Is it Linux Kernel related ? OR - Is it Ncurses related ? I don't use a common Distribution so please don't ask for that but just for knowledge increasing an answer would be helpful. Maybe I can share it one day with someone else who needs it. From proski at gnu.org Wed Apr 2 20:19:16 2003 From: proski at gnu.org (Pavel Roskin) Date: Wed, 2 Apr 2003 15:19:16 -0500 (EST) Subject: Charset conversion In-Reply-To: <20030402121332.GQ3246@paradies.suse.de> References: <20030401171854.GA3262@mentat.localdomain> <20030402121332.GQ3246@paradies.suse.de> Message-ID: On Wed, 2 Apr 2003, Philipp Thomas wrote: > * Pavel Roskin (proski at gnu.org) [20030401 19:33]: > > > and 8-bit clean terminals). The interface is inconvenient, the > > documentation is missing, but if users want it, then they know about this > > feature and how to use it. > > As this may cure some problems users have reported to me, how do I > activate/use it? I may even contribute documentation afterwards :) Use --enable-charset with configure. To use it, press Ctrl-T in the viewer or editor. Also, there will be new options under Options->Display Bits, make sure to set them up. -- Regards, Pavel Roskin From proski at gnu.org Wed Apr 2 20:30:09 2003 From: proski at gnu.org (Pavel Roskin) Date: Wed, 2 Apr 2003 15:30:09 -0500 (EST) Subject: [OT] Re: rename improvement In-Reply-To: <200304022155.33194.aliakc@web.de> References: <1047030267.15960.9.camel@localhost> <1047058422.5584.5.camel@localhost> <200304022155.33194.aliakc@web.de> Message-ID: Hello! > Hello, I like to hook up this eMail again. I still have problems with this > issue and F1...F12 - Shift+F1...Shift+F4 works perfectly but after that not. > Ok this is Linux console related. Could you please go a bit deeper into this > please and may give me a hint where I should look for this ? man loadkeys man dumpkeys Different keymaps used by loadkeys use different sequences for Shift with functional keys. There is no standard. The terminal capabilities described in terminfo tie those sequences to F11-F20. Since terminfo doesn't know anything about real settings (as shown by dumpkeys), you end up with different sequences for F11-F20. > - Is it Getty related ? No. > - Is it Console-Tools related ? Yes. Different non-standard keymaps are included there. > - Is it Linux Kernel related ? OR Yes. The kernel has its default keymap. > - Is it Ncurses related ? I would say no. ncurses is not supposed to get terminal settings from any other place but terminfo or termcap. -- Regards, Pavel Roskin From aliakc at web.de Wed Apr 2 21:04:15 2003 From: aliakc at web.de (Ali Akcaagac) Date: Wed, 2 Apr 2003 23:04:15 +0200 Subject: [OT] Re: rename improvement In-Reply-To: References: <1047030267.15960.9.camel@localhost> <200304022155.33194.aliakc@web.de> Message-ID: <200304022304.15968.aliakc@web.de> On Wednesday 02 April 2003 22:30, Pavel Roskin wrote: > > Hello, I like to hook up this eMail again. I still have problems with > > this issue and F1...F12 - Shift+F1...Shift+F4 works perfectly but after > > that not. Ok this is Linux console related. Could you please go a bit > > deeper into this please and may give me a hint where I should look for > > this ? > > man loadkeys > man dumpkeys > > Different keymaps used by loadkeys use different sequences for Shift with > functional keys. There is no standard. The terminal capabilities > described in terminfo tie those sequences to F11-F20. Since terminfo > doesn't know anything about real settings (as shown by dumpkeys), you end > up with different sequences for F11-F20. Intresting, I was playing with loadkeys and here the results: 1) I removed the init script for a moment and rebooted into Linux Shift+F6 worked perfectly. 2) Then I manually entered loadkeys with all it's combinations, various different Keymaps, default, us, de and so on even different command line parameters and they all remove the higher Shift+Fx keys. This really sucks specially if you depend on a germany keyboard layout. To make sure I'm not referencing to old stuff here I would like to point out that I'm using this http://lct.sourceforge.net/ package to load german keymaps and like to verify if this is what you and others use as well or are there any new packages on different locations that I'm missing here. This package seem to be outdated for 4 years now and I wouldn't wonder if the keymaps used in the datapackages doesn't match the ones from the Kernel anymore. Any ideas ? From aliakc at web.de Wed Apr 2 21:34:32 2003 From: aliakc at web.de (Ali Akcaagac) Date: Wed, 2 Apr 2003 23:34:32 +0200 Subject: [OT] Re: rename improvement In-Reply-To: <200304022304.15968.aliakc@web.de> References: <1047030267.15960.9.camel@localhost> <200304022304.15968.aliakc@web.de> Message-ID: <200304022334.32187.aliakc@web.de> On Wednesday 02 April 2003 23:04, Ali Akcaagac wrote: > This package seem to be outdated for 4 years now and I wouldn't wonder if > the keymaps used in the datapackages doesn't match the ones from the Kernel > anymore. Any ideas ? Maybe I should switch to the original KBD-1.08 package. I saw that many other distros changed from console-tools http://lct.sourceforge.net to kbd ftp://ftp.win.tue.nl/pub/home/aeb/linux-local/utils/kbd/ and then try again. From proski at gnu.org Wed Apr 2 21:43:50 2003 From: proski at gnu.org (Pavel Roskin) Date: Wed, 2 Apr 2003 16:43:50 -0500 (EST) Subject: [OT] Re: rename improvement In-Reply-To: <200304022304.15968.aliakc@web.de> References: <1047030267.15960.9.camel@localhost> <200304022155.33194.aliakc@web.de> <200304022304.15968.aliakc@web.de> Message-ID: > This package seem to be outdated for 4 years now and I wouldn't wonder if the > keymaps used in the datapackages doesn't match the ones from the Kernel > anymore. Any ideas ? Try to contact them and ask to make Shift-Fx keys match the default sequences in the kernel. It's not very likely to work - they've had plenty of time to do it. Contact Linux Standard Base and make a standard for Linux console sequences on PC keyboards. Then apply pressure to LCT maintainers. Both are very long term solutions. A short term solution would be to include some code from dumpkeys in mc to read the actual escape sequences when mc runs on Linux console. -- Regards, Pavel Roskin From alpha at student.uci.agh.edu.pl Wed Apr 2 22:12:05 2003 From: alpha at student.uci.agh.edu.pl (Adam Byrtek / alpha) Date: Thu, 3 Apr 2003 00:12:05 +0200 Subject: [PATCH] Editor file locking In-Reply-To: References: <20030402113724.GA21652@mentat.localdomain> <20030402173708.GA653@mentat.localdomain> Message-ID: <20030402221205.GA2932@mentat.localdomain> On Wed, Apr 02, 2003 at 02:48:07PM -0500, Pavel Roskin wrote: > I've applied your patch. The snapshot is ready. After ten times of 'cvs up' I can see it now :) > differently. Ideally, mc should show all the data separately - host, user > and PID (and maybe timestamp). Ok, see the attached patch. BTW I don't see a point in dividing host and user. Why? > One bug that needs to be fixed - if I use Enter to modify the file and I > get a "file locked" message, the old current line is not repainted. Try > it to see what I mean. I see. I don't know why it happens. I haven't changed anything in editor main code. It has to have something to do with edit_query_dialog. I don't have time to debug it now... Regards Adam -- _.|._ |_ _. : Adam Byrtek /alpha alpha at debian.org (_|||_)| |(_| : http://krakow.linux.org.pl/ pgp 0xB25952C0 | -------------- next part -------------- ? .project.sl ? mc.prj ? mc.pws Index: edit/editlock.c =================================================================== RCS file: /cvs/gnome/mc/edit/editlock.c,v retrieving revision 1.1 diff -u -r1.1 editlock.c --- edit/editlock.c 2 Apr 2003 19:36:10 -0000 1.1 +++ edit/editlock.c 2 Apr 2003 22:07:20 -0000 @@ -30,6 +30,11 @@ #define BUF_SIZE 255 #define PID_BUF_SIZE 10 +struct lock_s { + char *who; + pid_t pid; +}; + /* Locking scheme used in mcedit is based on a documentation found in JED editor sources. Abstract from lock.c file (by John E. Davis): @@ -61,24 +66,34 @@ } /* Extract pid from user at host.domain.pid string */ -static pid_t -lock_extract_pid (char *str) +static struct lock_s * +lock_extract_info (char *str) { int i; - char *p, pid[PID_BUF_SIZE]; + char *p, *s; + static char pid[PID_BUF_SIZE], who[BUF_SIZE]; + static struct lock_s lock; - /* Treat text between '.' and ':' or '\0' as pid */ for (p = str + strlen (str) - 1; p >= str; p--) if (*p == '.') break; + /* Everything before last '.' is user at host */ + i = 0; + for (s = str; s < p && i < BUF_SIZE; s++) + who[i++] = *s; + who[i] = '\0'; + + /* Treat text between '.' and ':' or '\0' as pid */ i = 0; for (p = p + 1; p < str + strlen (str) && *p != ':' && i < PID_BUF_SIZE; p++) pid[i++] = *p; pid[i] = '\0'; - - return (pid_t) atol (pid); + + lock.pid = (pid_t) atol (pid); + lock.who = who; + return &lock; } /* Extract user at host.domain.pid from lock file (static string) */ @@ -103,7 +118,7 @@ { char *lockfname, *newlock, *msg, *lock; struct stat statbuf; - pid_t pid; + struct lock_s *lockinfo; /* Just to be sure (and don't lock new file) */ if (!fname || !*fname) @@ -117,13 +132,13 @@ g_free (lockfname); return 0; } - pid = lock_extract_pid (lock); + lockinfo = lock_extract_info (lock); /* Check if locking process alive, ask user if required */ - if (!pid || !(kill (pid, 0) == -1 && errno == ESRCH)) { + if (!lockinfo->pid || !(kill (lockinfo->pid, 0) == -1 && errno == ESRCH)) { msg = - g_strdup_printf (_("File %s is locked by lock %s"), fname, - lock); + g_strdup_printf (_("File %s is locked by %s (pid %d)"), + fname, lockinfo->who, lockinfo->pid); /* TODO: Implement "Abort" - needs to rewind undo stack */ switch (edit_query_dialog2 (_("File locked"), msg, _("&Grab lock"), @@ -177,7 +192,7 @@ lock = lock_get_info (lockfname); if (lock) { /* Don't touch if lock is not ours */ - if (lock_extract_pid (lock) != getpid ()) { + if (lock_extract_info (lock)->pid != getpid ()) { g_free (lockfname); return 0; } From gabucino at mplayerhq.hu Fri Apr 4 10:13:38 2003 From: gabucino at mplayerhq.hu (gabucino at mplayerhq.hu) Date: Fri, 4 Apr 2003 12:13:38 +0200 Subject: MC vs X11 Message-ID: <20030404101338.GA24358@woodstock.localdomain> What does mc want from my display? woodstock:~# mc Xlib: connection to ":0.0" refused by server Xlib: No protocol specified -- Gabucino MPlayer Core Team - Debian? - "This is our project and we can do whatever we want with it." Michael Stone -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 232 bytes Desc: not available URL: From alpha at student.uci.agh.edu.pl Fri Apr 4 13:24:18 2003 From: alpha at student.uci.agh.edu.pl (Adam Byrtek / alpha) Date: Fri, 4 Apr 2003 15:24:18 +0200 Subject: [PATCH] Editor file locking In-Reply-To: References: <20030402113724.GA21652@mentat.localdomain> <20030402173708.GA653@mentat.localdomain> Message-ID: <20030404132418.GA5278@mentat.localdomain> On Wed, Apr 02, 2003 at 02:48:07PM -0500, Pavel Roskin wrote: > One bug that needs to be fixed - if I use Enter to modify the file and I > get a "file locked" message, the old current line is not repainted. Try > it to see what I mean. Looks like it is because the screen gets refreshed after query_dialog, and edit->force value set in edit_insert is lost... Patch attached. -- _.|._ |_ _. : Adam Byrtek /alpha alpha at debian.org (_|||_)| |(_| : http://krakow.linux.org.pl/ pgp 0xB25952C0 | -------------- next part -------------- Index: edit.c =================================================================== RCS file: /cvs/gnome/mc/edit/edit.c,v retrieving revision 1.75 diff -u -r1.75 edit.c --- edit.c 2 Apr 2003 22:25:00 -0000 1.75 +++ edit.c 4 Apr 2003 13:23:21 -0000 @@ -838,6 +838,10 @@ if (c == '\n') edit->start_line++; } + + /* tell that we've modified the file */ + edit_modification (edit); + /* now we must update some info on the file and check if a redraw is required */ if (c == '\n') { if (edit->book_mark) @@ -846,8 +850,6 @@ edit->total_lines++; edit->force |= REDRAW_LINE_ABOVE | REDRAW_AFTER_CURSOR; } - /* tell that we've modified the file */ - edit_modification (edit); /* save the reverse command onto the undo stack */ edit_push_action (edit, BACKSPACE); @@ -885,13 +887,13 @@ if (c == '\n') edit->start_line++; } + edit_modification (edit); if (c == '\n') { if (edit->book_mark) book_mark_inc (edit, edit->curs_line); edit->total_lines++; edit->force |= REDRAW_AFTER_CURSOR; } - edit_modification (edit); edit_push_action (edit, DELCHAR); edit->mark1 += (edit->mark1 >= edit->curs1); @@ -926,6 +928,7 @@ edit->last_byte--; edit->curs2--; + edit_modification (edit); if (p == '\n') { if (edit->book_mark) book_mark_dec (edit, edit->curs_line); @@ -938,7 +941,6 @@ if (p == '\n') edit->start_line--; } - edit_modification (edit); return p; } @@ -963,6 +965,7 @@ edit->last_byte--; edit->curs1--; + edit_modification (edit); if (p == '\n') { if (edit->book_mark) book_mark_dec (edit, edit->curs_line); @@ -977,7 +980,6 @@ if (p == '\n') edit->start_line--; } - edit_modification (edit); return p; } Index: editlock.c =================================================================== RCS file: /cvs/gnome/mc/edit/editlock.c,v retrieving revision 1.2 diff -u -r1.2 editlock.c --- editlock.c 2 Apr 2003 22:25:00 -0000 1.2 +++ editlock.c 4 Apr 2003 13:23:22 -0000 @@ -97,7 +97,8 @@ /* Tries to raise file lock - Returns 1 on success, 0 on failure, -1 if abort */ + Returns 1 on success, 0 on failure, -1 if abort + Warning: Might do screen refresh and lose edit->force */ int edit_lock_file (char *fname) { From alpha at student.uci.agh.edu.pl Fri Apr 4 13:54:19 2003 From: alpha at student.uci.agh.edu.pl (Adam Byrtek / alpha) Date: Fri, 4 Apr 2003 15:54:19 +0200 Subject: annoyance: undo does not reset "modified" status In-Reply-To: <20030402180125.GA11141@ugly.local> References: <20030402180125.GA11141@ugly.local> Message-ID: <20030404135419.GB5278@mentat.localdomain> On Wed, Apr 02, 2003 at 08:01:25PM +0200, Oswald Buddenhagen wrote: > i often accidentally do minor modifications (mostly partial escape > sequences) which i undo of course. anyway, afterwards i still don't know > if this was the only modification. Patch attached. BTW I'm not sure if it is wide to undo every cursor movement. IMO pop_action should apply EVERY movement action till the last action which actually modified something (including this action). Regards -- _.|._ |_ _. : Adam Byrtek /alpha alpha at debian.org (_|||_)| |(_| : http://krakow.linux.org.pl/ pgp 0xB25952C0 | -------------- next part -------------- Index: edit-widget.h =================================================================== RCS file: /cvs/gnome/mc/edit/edit-widget.h,v retrieving revision 1.16 diff -u -r1.16 edit-widget.h --- edit-widget.h 2 Apr 2003 19:36:10 -0000 1.16 +++ edit-widget.h 4 Apr 2003 13:46:06 -0000 @@ -88,6 +88,7 @@ unsigned long stack_size; unsigned long stack_size_mask; unsigned long stack_bottom; + unsigned char stack_wrapped; int stack_disable; /* If not 0, don't save events in the undo stack */ struct stat stat1; /* Result of mc_fstat() on the file */ Index: edit.c =================================================================== RCS file: /cvs/gnome/mc/edit/edit.c,v retrieving revision 1.75 diff -u -r1.75 edit.c --- edit.c 2 Apr 2003 22:25:00 -0000 1.75 +++ edit.c 4 Apr 2003 13:46:15 -0000 @@ -457,6 +457,7 @@ if (!edit->filename || !*edit->filename) return; + edit->stack_disable = 1; filename = vfs_canon (edit->filename); load_file_position (filename, &line, &column); g_free (filename); @@ -465,6 +466,7 @@ edit->prev_col = column; edit_move_to_prev_col (edit, edit_bol (edit, edit->curs1)); edit_move_display (edit, line - (edit->num_widget_lines / 2)); + edit->stack_disable = 0; } /* Save cursor position in the file */ @@ -546,6 +548,7 @@ edit_set_filename (edit, filename); edit->stack_size = START_STACK_SIZE; edit->stack_size_mask = START_STACK_SIZE - 1; + edit->stack_wrapped = 0; edit->undo_stack = g_malloc ((edit->stack_size + 10) * sizeof (long)); if (edit_load_file (edit)) { /* edit_load_file already gives an error message */ @@ -770,17 +773,16 @@ if (c == edit->stack_bottom || ((c + 1) & edit->stack_size_mask) == edit->stack_bottom) do { edit->stack_bottom = (edit->stack_bottom + 1) & edit->stack_size_mask; + edit->stack_wrapped = 1; } while (edit->undo_stack[edit->stack_bottom] < KEY_PRESS && edit->stack_bottom != edit->stack_pointer); /*If a single key produced enough pushes to wrap all the way round then we would notice that the [stack_bottom] does not contain KEY_PRESS. The stack is then initialised: */ - if (edit->stack_pointer != edit->stack_bottom && edit->undo_stack[edit->stack_bottom] < KEY_PRESS) + if (edit->stack_pointer != edit->stack_bottom && edit->undo_stack[edit->stack_bottom] < KEY_PRESS) { edit->stack_bottom = edit->stack_pointer = 0; + edit->stack_wrapped = 1; + } } -/* - TODO: if the user undos until the stack bottom, and the stack has not wrapped, - then the file should be as it was when he loaded up. Then set edit->modified to 0. - */ static long pop_action (WEdit * edit) { @@ -1800,6 +1802,11 @@ while ((ac = pop_action (edit)) < KEY_PRESS) { switch ((int) ac) { case STACK_BOTTOM: + if (!edit->stack_wrapped) { + if (edit->locked) + edit->locked = edit_unlock_file (edit->filename); + edit->modified = 0; + } goto done_undo; case CURS_RIGHT: edit_cursor_move (edit, 1); Index: ChangeLog =================================================================== RCS file: /cvs/gnome/mc/edit/ChangeLog,v retrieving revision 1.159 diff -u -u -0 -r1.159 ChangeLog --- ChangeLog 2 Apr 2003 22:25:00 -0000 1.159 +++ ChangeLog 4 Apr 2003 13:51:11 -0000 @@ -0,0 +1,9 @@ +2003-04-03 Adam Byrtek + + * edit-widget.h: New property stack_wrapped. + * edit.c (edit_push_action, pop_action): When undo stack hits + bottom (without wrapping) buffer is treated as unmodified and + is unlocked. + + * edit.c (load_position): Disable undo stack. + From ossi at kde.org Fri Apr 4 15:21:35 2003 From: ossi at kde.org (Oswald Buddenhagen) Date: Fri, 4 Apr 2003 17:21:35 +0200 Subject: annoyance: undo does not reset "modified" status In-Reply-To: <20030404135419.GB5278@mentat.localdomain> References: <20030402180125.GA11141@ugly.local> <20030404135419.GB5278@mentat.localdomain> Message-ID: <20030404152135.GB10754@ugly.local> On Fri, Apr 04, 2003 at 03:54:19PM +0200, Adam Byrtek / alpha wrote: > On Wed, Apr 02, 2003 at 08:01:25PM +0200, Oswald Buddenhagen wrote: > > i often accidentally do minor modifications (mostly partial escape > > sequences) which i undo of course. anyway, afterwards i still don't > > know if this was the only modification. > > Patch attached. > thanks. does this re-assert the modified state if you undo past the save point? theoretically this would be correct. otoh, it's quite simple to miss this point if you hold your fingers on "undo". the optimal thing would be not undoing the stack wrap as a result of key auto-repeat - a simple timer, e.g., 'more than 5 times the same sequence in the last second == auto-repeat' would be sufficient, i think. > BTW I'm not sure if it is wide to undo every cursor movement. IMO > pop_action should apply EVERY movement action till the last action > which actually modified something > this is a quite controversial question, in fact. i'm very often annoyed by vim because it does not treat movements (and selections, fwiw) as undoable actions. otoh i sometimes wish mc would merge movements into blocks. i'm just not sure what the correct rules are. maybe temporally close "simple movements" (cursor keys) should be merged, while "big jumps" (like search next) are not merged. this would be less an issue for me if cooledit supported bookmarks and "jump to start/end of selection". > (including this action). > you mean, undo means "undo last editing action plus all following movements"? NO WAY! i absolutely HATE this behaviour in vim. while merging moves is negotiable, pretending that they don't exist is absolutely out of question for me. greetings -- Hi! I'm a .signature virus! Copy me into your ~/.signature, please! -- Chaos, panic, and disorder - my work here is done. From alpha at student.uci.agh.edu.pl Fri Apr 4 15:31:59 2003 From: alpha at student.uci.agh.edu.pl (Adam Byrtek / alpha) Date: Fri, 4 Apr 2003 17:31:59 +0200 Subject: annoyance: undo does not reset "modified" status In-Reply-To: <20030404152135.GB10754@ugly.local> References: <20030402180125.GA11141@ugly.local> <20030404135419.GB5278@mentat.localdomain> <20030404152135.GB10754@ugly.local> Message-ID: <20030404153159.GA658@mentat.localdomain> On Fri, Apr 04, 2003 at 05:21:35PM +0200, Oswald Buddenhagen wrote: > you mean, undo means "undo last editing action plus all following > movements"? NO WAY! i absolutely HATE this behaviour in vim. while > merging moves is negotiable, pretending that they don't exist is And mcedit behaviour is plain stupid for me. I wan't undo to unDO, not unMOVE. If I change something, browse the file (eg. 100 movement commands) and decide to undo my last change it will be very difficult for me to undo the real modification. And if I want to move back - I can just use arrow keys. Fortunately I don't use mcedit, but JED, which has undo implemented in a way I like. Regards Adam -- _.|._ |_ _. : Adam Byrtek /alpha alpha at debian.org (_|||_)| |(_| : http://krakow.linux.org.pl/ pgp 0xB25952C0 | From ossi at kde.org Fri Apr 4 16:09:01 2003 From: ossi at kde.org (Oswald Buddenhagen) Date: Fri, 4 Apr 2003 18:09:01 +0200 Subject: annoyance: undo does not reset "modified" status In-Reply-To: <20030404153159.GA658@mentat.localdomain> References: <20030402180125.GA11141@ugly.local> <20030404135419.GB5278@mentat.localdomain> <20030404152135.GB10754@ugly.local> <20030404153159.GA658@mentat.localdomain> Message-ID: <20030404160901.GA12802@ugly.local> On Fri, Apr 04, 2003 at 05:31:59PM +0200, Adam Byrtek / alpha wrote: > On Fri, Apr 04, 2003 at 05:21:35PM +0200, Oswald Buddenhagen wrote: > > you mean, undo means "undo last editing action plus all following > > movements"? NO WAY! i absolutely HATE this behaviour in vim. while > > merging moves is negotiable, pretending that they don't exist is > > And mcedit behaviour is plain stupid for me. I wan't undo to unDO, not > unMOVE. If I change something, browse the file (eg. 100 movement > commands) and decide to undo my last change it will be very difficult > for me to undo the real modification. And if I want to move back - I > can just use arrow keys. > that's a pretty weak argumentation. with move merging this adds one additional keypress, which is absolutely irrelevant given that edit action merging is not performed (that should be added and done based on timing, too, imho). moving to the old place otoh can be a _significant_ amount of keypresses. for me, moving around _is_ an editing action. i have a weak short-term memory, so being able to jump back (and forth, fwiw - where is "redo"? :) to recatch the context after some distraction is very valuable. greetings -- Hi! I'm a .signature virus! Copy me into your ~/.signature, please! -- Chaos, panic, and disorder - my work here is done. From proski at gnu.org Fri Apr 4 22:53:44 2003 From: proski at gnu.org (Pavel Roskin) Date: Fri, 4 Apr 2003 17:53:44 -0500 (EST) Subject: MC vs X11 In-Reply-To: <20030404101338.GA24358@woodstock.localdomain> References: <20030404101338.GA24358@woodstock.localdomain> Message-ID: Hello! > What does mc want from my display? > > woodstock:~# mc > Xlib: connection to ":0.0" refused by server > Xlib: No protocol specified mc wants to read keyboard modifiers from X11 (such as Shift and Ctrl), so that it can distinguish e.g. Enter from Ctrl-Enter. -- Regards, Pavel Roskin From proski at gnu.org Sat Apr 5 01:47:51 2003 From: proski at gnu.org (Pavel Roskin) Date: Fri, 4 Apr 2003 20:47:51 -0500 (EST) Subject: [PATCH] Editor file locking In-Reply-To: <20030402221205.GA2932@mentat.localdomain> References: <20030402113724.GA21652@mentat.localdomain> <20030402173708.GA653@mentat.localdomain> <20030402221205.GA2932@mentat.localdomain> Message-ID: Hello, Adam! > > differently. Ideally, mc should show all the data separately - host, user > > and PID (and maybe timestamp). > > Ok, see the attached patch. Thanks, applied. Sorry, I had to remake your string again. > BTW I don't see a point in dividing host and user. Why? Not every user would understand user at host. I just want mc to explain the situation in simple terms - who locked the file, from what machine and by which process. In fact, "file %s is locked by %s" cannot be translated into Russian (and probably other languages) without knowing if %s is a user or an abstract token. The translation would be "user %s has a lock on file %s" or "file %s has a lock with the name %s". Anyway, this dialog will be confusing until it's documented, regardless of what the message says. > > One bug that needs to be fixed - if I use Enter to modify the file and I > > get a "file locked" message, the old current line is not repainted. Try > > it to see what I mean. I've applied your patch. Thank you! -- Regards, Pavel Roskin From proski at gnu.org Sat Apr 5 02:08:27 2003 From: proski at gnu.org (Pavel Roskin) Date: Fri, 4 Apr 2003 21:08:27 -0500 (EST) Subject: annoyance: undo does not reset "modified" status In-Reply-To: <20030404135419.GB5278@mentat.localdomain> References: <20030402180125.GA11141@ugly.local> <20030404135419.GB5278@mentat.localdomain> Message-ID: Hello, Adam! > On Wed, Apr 02, 2003 at 08:01:25PM +0200, Oswald Buddenhagen wrote: > > i often accidentally do minor modifications (mostly partial escape > > sequences) which i undo of course. anyway, afterwards i still don't know > > if this was the only modification. > > Patch attached. Problems: 1) I need to press Ctrl-U twice to undo a single action. The first Ctrl-U reverts the action, the second Ctrl-U make the file unmodified. 2) If I start with movements and then change something, the file won't be unmodified until I undo all movements. 3) If I edit a file and save it, and then keep pressing Ctrl-U, the file will be restored to the original state (as it was opened) and will become unmodified. Then the editor would exit without prompting the user and without saving the file. I believe there should be only one stretch when the file is unmodified - starting from the point when the file was saved the last time and ending when the file was modified the first time after the last save. If it's hard to implement, I'd rather keep the existing behavior. > BTW I'm not sure if it is wide to undo every cursor movement. IMO > pop_action should apply EVERY movement action till the last action > which actually modified something (including this action). It's very convenient if I press Ctrl-PgUp and go to the beginning, and then I use Ctrl-U to return to the original position. We could have a separate key for the "real undo". -- Regards, Pavel Roskin From aragorn at spinningkids.org Sun Apr 6 13:23:29 2003 From: aragorn at spinningkids.org (Aragorn) Date: Sun, 6 Apr 2003 15:23:29 +0200 Subject: patch: Synchronous write Message-ID: <20030406152329.A13459@Thorin> Hi all, The attached patch adds a checkbox to the file operations dialog. When activated, the O_SYNC bit is set on open(2) calls when used for writing. This way, the kernel buffer-cache machinery doesn't take effect and you get ``real'' progress/eta/speed values. I use it when writing to low speed media (such as usb memory cards) in order to have MC display the real transfer speed and so not to sit back waiting minutes in front of a silent ``sync'' or ``umount''. Dunno the audience that such a functionality may have, but I'm submitting the patch anyway... thanks, -- Aragorn/sPINNING kIDS #!/usr/bin/perl $i=$j=$r=$b=-16.0;while((print"\n"),$b++<15){foreach$a(0..78){print +(split //,' .:-;!/>)|&IH%*#')[$k&15];for($i=$k=$r=0;$j=$r*$r-$i*$i -2+$a/25,$i=2*$r*$i+$b/10,$j*$j+$i*$i<11&&$k++<111;$r=$j){}}} -------------- next part -------------- A non-text attachment was scrubbed... Name: mc-4.6.0-synchronous_write.diff.gz Type: application/x-gzip Size: 1948 bytes Desc: not available URL: From feketga at delfin.klte.hu Sun Apr 6 12:44:02 2003 From: feketga at delfin.klte.hu (Fekete Gabor) Date: Sun, 6 Apr 2003 14:44:02 +0200 (DFT) Subject: Viewer syntax highlight Message-ID: Hi, Does anyone know whether someone is planning to implement syntax highlighting in the builtin viewer? I think it would be a very good feature (viewing source files this way would be much better) Of course you can use the editor for this but what if you accidentaly mess it up and save ;) I am not signed up on the list so please send a reply to me too. From Weigel_Andreas at t-online.de Sun Apr 6 12:48:13 2003 From: Weigel_Andreas at t-online.de (Weigel_Andreas) Date: Sun, 6 Apr 2003 14:48:13 +0200 Subject: Pg[UP|DOWN]- keys in mc Message-ID: <200304061448.13270.Weigel_Andreas@t-online.de> Hi, On linux (i.e. SuSE) are working the Pg[UP|DOWN]- keys to scroll the tree into the mc-window. I would like to use these keys also as the same in Solaris2.6. I don't know, where are to doing wich entries? Who can help? Andreas From alpha at student.uci.agh.edu.pl Sun Apr 6 19:16:13 2003 From: alpha at student.uci.agh.edu.pl (Adam Byrtek / alpha) Date: Sun, 6 Apr 2003 21:16:13 +0200 Subject: annoyance: undo does not reset "modified" status In-Reply-To: References: <20030402180125.GA11141@ugly.local> <20030404135419.GB5278@mentat.localdomain> Message-ID: <20030406191613.GA1133@mentat.localdomain> On Fri, Apr 04, 2003 at 09:08:27PM -0500, Pavel Roskin wrote: > Problems: > Sorry I didn't write this before - it wasn't a final patch for inclusion, just a quick fix. I didn't have time to test it properly because I was leaving for a weekend... I'll fight with it when I have some free time. -- _.|._ |_ _. : Adam Byrtek /alpha alpha at debian.org (_|||_)| |(_| : http://krakow.linux.org.pl/ pgp 0xB25952C0 | From alpha at student.uci.agh.edu.pl Sun Apr 6 19:23:12 2003 From: alpha at student.uci.agh.edu.pl (Adam Byrtek / alpha) Date: Sun, 6 Apr 2003 21:23:12 +0200 Subject: [PATCH] Editor file locking In-Reply-To: References: <20030402113724.GA21652@mentat.localdomain> <20030402173708.GA653@mentat.localdomain> <20030402221205.GA2932@mentat.localdomain> Message-ID: <20030406192312.GB1133@mentat.localdomain> On Fri, Apr 04, 2003 at 08:47:51PM -0500, Pavel Roskin wrote: > Not every user would understand user at host. In the age of Internet and email everybody understands user at host - especialy when using *nix. > I just want mc to explain the situation in simple terms - who locked > the file, from what machine and by which process. Emacs writes 'foo.bar locked by user at host (pid 111)' Jed writes 'foo.bar is locked by user at host.111' On the other hand mc pretends to be more user-friendly... if you want, divide user and hostname, it will be easy to do, but I don't see the point. > I've applied your patch. Thank you! Have you received my patch to fix the 'Enter-bug'? Regards Adam -- _.|._ |_ _. : Adam Byrtek /alpha alpha at debian.org (_|||_)| |(_| : http://krakow.linux.org.pl/ pgp 0xB25952C0 | From proski at gnu.org Mon Apr 7 16:43:00 2003 From: proski at gnu.org (Pavel Roskin) Date: Mon, 7 Apr 2003 12:43:00 -0400 (EDT) Subject: Viewer syntax highlight In-Reply-To: References: Message-ID: Hello! Please don't cross-post your messages to both mailing lists. > Does anyone know whether someone is planning to implement syntax > highlighting in the builtin viewer? As far as I know, nobody is working on that. > I think it would be a very good feature (viewing source files this way > would be much better) Of course you can use the editor for this but what > if you accidentaly mess it up and save ;) The viewer can work with very large files. Syntax highlighting in the form in which it's implemented in the editor could make loading such files very slow. I think it would be more useful to have a read-only mode in the editor. Once it works well, the existing viewer code could be replaced with the read-only editor. The problem is that the viewer also has a hex editor, and some users will miss it. -- Regards, Pavel Roskin From proski at gnu.org Mon Apr 7 16:47:11 2003 From: proski at gnu.org (Pavel Roskin) Date: Mon, 7 Apr 2003 12:47:11 -0400 (EDT) Subject: Pg[UP|DOWN]- keys in mc In-Reply-To: <200304061448.13270.Weigel_Andreas@t-online.de> References: <200304061448.13270.Weigel_Andreas@t-online.de> Message-ID: Hello! > On linux (i.e. SuSE) are working the Pg[UP|DOWN]- keys to scroll the > tree into the mc-window. I would like to use these keys also as the same > in Solaris2.6. I don't know, where are to doing wich entries? Who can > help? You forgot to mention the version of mc and the terminal name. You may need to read this document: http://www.ibiblio.org/mc/MAILING_LISTS Your question is answered in section 2.2 in the FAQ: http://cvs.gnome.org/lxr/source/mc/FAQ?raw=1 -- Regards, Pavel Roskin From alpha at student.uci.agh.edu.pl Fri Apr 11 21:22:31 2003 From: alpha at student.uci.agh.edu.pl (Adam Byrtek / alpha) Date: Fri, 11 Apr 2003 23:22:31 +0200 Subject: annoyance: undo does not reset "modified" status In-Reply-To: References: <20030402180125.GA11141@ugly.local> <20030404135419.GB5278@mentat.localdomain> Message-ID: <20030411212230.GA10039@mentat.localdomain> Pavel, I'm interested how would you like mcedit undo to behave? There are many controversional approaches (as we have seen on the list), and I don't know which could be the best. One is for sure - current approach (one char at time) is no good... My idea: 1) If there is a movement action on top of the stack: undo all movement actions till the last modify action (without modify action). 2) If there is a modify action on top of the stack: undo all movement actions till the last movement action OR a newline. This way we will undo one line at the time when dealing with large block of text, or till the last movement, if we just corrected something. Regards Adam -- _.|._ |_ _. : Adam Byrtek /alpha alpha at debian.org (_|||_)| |(_| : http://krakow.linux.org.pl/ pgp 0xB25952C0 | From proski at gnu.org Fri Apr 11 21:50:26 2003 From: proski at gnu.org (Pavel Roskin) Date: Fri, 11 Apr 2003 17:50:26 -0400 (EDT) Subject: annoyance: undo does not reset "modified" status In-Reply-To: <20030411212230.GA10039@mentat.localdomain> References: <20030402180125.GA11141@ugly.local> <20030404135419.GB5278@mentat.localdomain> <20030411212230.GA10039@mentat.localdomain> Message-ID: Hello, Adam! > Pavel, I'm interested how would you like mcedit undo to behave? There > are many controversional approaches (as we have seen on the list), and > I don't know which could be the best. One is for sure - current > approach (one char at time) is no good... I don't see any problems with the current behavior. Undoing one action a time is reasonable in my opinion. It's also more intuitive than any grouping. How often do you need to undo really big changes? Could you describe a realistic scenario? -- Regards, Pavel Roskin From alpha at student.uci.agh.edu.pl Fri Apr 11 22:06:02 2003 From: alpha at student.uci.agh.edu.pl (Adam Byrtek / alpha) Date: Sat, 12 Apr 2003 00:06:02 +0200 Subject: annoyance: undo does not reset "modified" status In-Reply-To: References: <20030402180125.GA11141@ugly.local> <20030404135419.GB5278@mentat.localdomain> <20030411212230.GA10039@mentat.localdomain> Message-ID: <20030411220602.GA10474@mentat.localdomain> On Fri, Apr 11, 2003 at 05:50:26PM -0400, Pavel Roskin wrote: > I don't see any problems with the current behavior. Undoing one action a > time is reasonable in my opinion. Yes, one ACTION at the time. Not one CHARACTER at the time or one arrow key move at the time. > How often do you need to undo really big changes? I often undo whole word, or whole sentence. In mcedit it would cost me about 5-15 keypresses for a word undo and 20-30 keypresses for a sentence undo. Moreover I navigate a lot in text, which gives me lots of additional keypresses for arrow key actions. I would like to note, that I don't use mcedit, so I won't force changes if nobody is interested :) Regardss Adam -- _.|._ |_ _. : Adam Byrtek /alpha alpha at debian.org (_|||_)| |(_| : http://krakow.linux.org.pl/ pgp 0xB25952C0 | From ossi at kde.org Fri Apr 11 23:50:40 2003 From: ossi at kde.org (Oswald Buddenhagen) Date: Sat, 12 Apr 2003 01:50:40 +0200 Subject: annoyance: undo does not reset "modified" status In-Reply-To: <20030411212230.GA10039@mentat.localdomain> References: <20030402180125.GA11141@ugly.local> <20030404135419.GB5278@mentat.localdomain> <20030411212230.GA10039@mentat.localdomain> Message-ID: <20030411235040.GA18629@ugly.local> On Fri, Apr 11, 2003 at 11:22:31PM +0200, Adam Byrtek / alpha wrote: > 1) If there is a movement action on top of the stack: undo all > movement actions till the last modify action (without modify action). > > 2) If there is a modify action on top of the stack: undo all > movement actions till the last movement action OR a newline. ^^^^^^^^ modify, you mean? interesting idea, even though i'd extend 2) by "burst grouping": temporally close _small_ movements (probably best measured as the flowed character distance of the merged move (e.g., "right" at the end of line is the same as "down"+"home", i.e., one char), the threshold being possibly the tty width) can be considered much more part of a "modification group" than two successive insertions with a considerable pause between them. the burst timeout should be configurable. greetigs ps: yes, i know, i should use fewer parentheses. :) -- Hi! I'm a .signature virus! Copy me into your ~/.signature, please! -- Chaos, panic, and disorder - my work here is done. From Dmitry.Semyonov at oktet.ru Fri Apr 11 23:57:22 2003 From: Dmitry.Semyonov at oktet.ru (Dmitry Semyonov) Date: Sat, 12 Apr 2003 03:57:22 +0400 (MSD) Subject: Undo/Redo (Was: Re: annoyance: undo does not reset "modified" status) In-Reply-To: <20030411212230.GA10039@mentat.localdomain> Message-ID: On Fri, 11 Apr 2003, Adam Byrtek / alpha wrote: > My idea: > > 1) If there is a movement action on top of the stack: undo all > movement actions till the last modify action (without modify action). I would like to be able to undo Ctrl+L like jumps one by one. > 2) If there is a modify action on top of the stack: undo all > movement actions till the last movement action OR a newline. ~~~~~~~~ modyfy? > This way we will undo one line at the time when dealing with large > block of text, or till the last movement, if we just corrected > something. This is too excessive for me. Although, it may be made optional (see below). My proposal. - First of all, redo is more important feature than grouping of undo actions. (If it is not implemented still.) - Additional option is required in editor preferences to turn _movements_ grouping on or off. - Detailed list of actions should be always saved in memory, so that turning grouping off in preferences while continuing to edit the same file gives an expected result. I.e. grouping is performed on the stage of undo/redo processing, not on the stage of recording user actions. - _Movement_ grouping is performed (if enabled) only if new cursor position lies on the current line, or on the nearest above or below line. (This allows to undo Ctrl+L or Ctrl+PgUp/Down jumps one by one). - _Modyfy_ actions are not grouped on C-U. - Special key combination is added for grouping _modify_ actions. The grouping is performed until white-space character is not reached. Note that Ctrl+Y, block delete, etc. operations are not grouped. (Another bahaviour may be selected optionally from editor preferences). - Extra option should be added to allow selection of modyfy grouping behaviour: based on words, based on lines and movements, etc. ...Bye..Dmitry. From alpha at student.uci.agh.edu.pl Sat Apr 12 13:28:10 2003 From: alpha at student.uci.agh.edu.pl (Adam Byrtek / alpha) Date: Sat, 12 Apr 2003 15:28:10 +0200 Subject: Undo/Redo (Was: Re: annoyance: undo does not reset "modified" status) In-Reply-To: References: <20030411212230.GA10039@mentat.localdomain> Message-ID: <20030412132810.GA2567@mentat.localdomain> Both Oswald's and Dmitry's approaches are too complicated: 1) We can't depend on timeout, this will be confusing for the user and lead to unconsistent behaviour. 2) We can't have options bloat or additional key combinations for such a simple thing as undo. -- _.|._ |_ _. : Adam Byrtek /alpha alpha at debian.org (_|||_)| |(_| : http://krakow.linux.org.pl/ pgp 0xB25952C0 | From ossi at kde.org Sat Apr 12 14:09:35 2003 From: ossi at kde.org (Oswald Buddenhagen) Date: Sat, 12 Apr 2003 16:09:35 +0200 Subject: Undo/Redo (Was: Re: annoyance: undo does not reset "modified" status) In-Reply-To: <20030412132810.GA2567@mentat.localdomain> References: <20030411212230.GA10039@mentat.localdomain> <20030412132810.GA2567@mentat.localdomain> Message-ID: <20030412140935.GB12504@ugly.local> On Sat, Apr 12, 2003 at 03:28:10PM +0200, Adam Byrtek / alpha wrote: > Both Oswald's and Dmitry's approaches are too complicated: > > 1) We can't depend on timeout, this will be confusing for the user and > lead to unconsistent behaviour. > i thought about this as well, and came to the conclusion that it does not matter. compared to your suggestion the worst thing what can happen is that less is undone at once than expected. > 2) We can't have options bloat > why not? if some of the features i requested get added, more options need to be added anyway, as some people would dislike them certainly. it's a matter of grouping them in an obvious way. > or additional key combinations > that's sort of true, i already have enough problems to choose between reply, group reply and list reply in mutt. ;) > for such a simple thing as undo. > but as you see, it is _not_ a simple thing. in fact, i consider undo capability the difference between a toy and a real editor. and getting it right (as in optimal) seems to be quite hard and subjective. greetings -- Hi! I'm a .signature virus! Copy me into your ~/.signature, please! -- Chaos, panic, and disorder - my work here is done. From dooligan at intergate.ca Thu Apr 17 05:30:12 2003 From: dooligan at intergate.ca (Miven Dooligan) Date: Wed, 16 Apr 2003 22:30:12 -0700 Subject: Thanks. Message-ID: <3E9E3BE4.20505@intergate.ca> I just got gnome2 and gnome-terminal 2.0.1 going with mc (4.6.0) as file manager (as always). Even though I love the console, I also have to have something pretty for my friends to see so they don't think I'm broken:) when they come over. Thank you very much to all you clever and hard-working souls who contribute to this project. I find it inspiring. After 20 years of computing, from assembly on the C64, to trying to grok C++ on linux, I still love to see a software project grow and mature like midnight commander has. Happy Easter, Peace to all. From ossi at kde.org Thu Apr 17 13:36:34 2003 From: ossi at kde.org (Oswald Buddenhagen) Date: Thu, 17 Apr 2003 15:36:34 +0200 Subject: minor nit Message-ID: <20030417133634.GA16806@ugly.local> moin, there should always be a space at the beginning of shell command lines executing temporary scripts to prevent having them in the history (at least when HISTCONTROL is properly set). this doesn't seem to be the case for invocations resulting from "User menu" commands. using mc 4.6.0. greetings -- Hi! I'm a .signature virus! Copy me into your ~/.signature, please! -- Chaos, panic, and disorder - my work here is done. From mikey at wirelabs.lublin.pl Mon Apr 28 01:11:48 2003 From: mikey at wirelabs.lublin.pl (=?iso-8859-2?Q?Micha=B3?= Szwaczko) Date: Mon, 28 Apr 2003 03:11:48 +0200 Subject: [PATCH] paste external command output Message-ID: <20030428011148.GA354@matrix> I crafted a little patch for mc-4.5.55 The only thing it does is let you paste output of a command (basically anything that produces output when run from shell) to the internal editor. Merge it or burn it ;-) or criticize if you find it lousy. please cc me, I am not on the list. Regards -- Micha? 'Mikey' Szwaczko Developer/Troubleshooter Never trust an operating system. -------------- next part -------------- diff -Nur mc-4.5.55-orig/edit/edit_key_translator.c mc-4.5.55/edit/edit_key_translator.c --- mc-4.5.55-orig/edit/edit_key_translator.c Sun Aug 12 20:04:17 2001 +++ mc-4.5.55/edit/edit_key_translator.c Sun Apr 27 22:57:36 2003 @@ -57,6 +57,7 @@ KEY_F (15), CK_Insert_File, XCTRL ('f'), CK_Save_Block, KEY_F (1), CK_Help, ALT ('t'), CK_Sort, ALT ('m'), CK_Mail, + ALT ('u'), CK_ExtCmd, XCTRL ('z'), CK_Word_Left, XCTRL ('x'), CK_Word_Right, KEY_F (4), CK_Replace, KEY_F (7), CK_Find, KEY_F (14), CK_Replace_Again, XCTRL ('h'), CK_BackSpace, ALT ('l'), CK_Goto, ALT ('L'), CK_Goto, XCTRL ('y'), CK_Delete_Line, @@ -75,6 +76,7 @@ KEY_F (2), CK_Save, ALT ('p'), CK_Paragraph_Format, ALT ('t'), CK_Sort, + ALT ('u'), CK_ExtCmd, XCTRL ('a'), CK_Home, XCTRL ('e'), CK_End, XCTRL ('b'), CK_Left, XCTRL ('f'), CK_Right, diff -Nur mc-4.5.55-orig/gtkedit/edit.c mc-4.5.55/gtkedit/edit.c --- mc-4.5.55-orig/gtkedit/edit.c Sun Aug 12 20:02:56 2001 +++ mc-4.5.55/gtkedit/edit.c Sun Apr 27 22:56:23 2003 @@ -2609,6 +2609,9 @@ case CK_Sort: edit_sort_cmd (edit); break; + case CK_ExtCmd: + edit_ext_cmd (edit); + break; case CK_Mail: edit_mail_dialog (edit); break; @@ -2620,6 +2623,7 @@ /* These commands are not handled and must be handled by the user application */ #ifndef MIDNIGHT case CK_Sort: + case CK_ExtCmd: case CK_Mail: case CK_Find_File: case CK_Ctags: diff -Nur mc-4.5.55-orig/gtkedit/edit.h mc-4.5.55/gtkedit/edit.h --- mc-4.5.55-orig/gtkedit/edit.h Sun Aug 19 19:01:01 2001 +++ mc-4.5.55/gtkedit/edit.h Sun Apr 27 23:00:32 2003 @@ -426,6 +426,7 @@ void edit_word_wrap (WEdit * edit); unsigned char *edit_get_block (WEdit * edit, long start, long finish, int *l); int edit_sort_cmd (WEdit * edit); +int edit_ext_cmd (WEdit * edit); void edit_help_cmd (WEdit * edit); void edit_left_word_move (WEdit * edit, int s); void edit_right_word_move (WEdit * edit, int s); diff -Nur mc-4.5.55-orig/gtkedit/editcmd.c mc-4.5.55/gtkedit/editcmd.c --- mc-4.5.55-orig/gtkedit/editcmd.c Thu Aug 23 19:21:13 2001 +++ mc-4.5.55/gtkedit/editcmd.c Sun Apr 27 23:01:17 2003 @@ -2944,6 +2944,31 @@ return 0; } +int edit_ext_cmd (WEdit * edit) +{ + char *exp; + int e; + + exp = ""; + exp = input_dialog(_(" Paste output of external command "), + _(" Enter shell command(s): "),exp); + + if (!exp) return 1; + + e = system (catstrs (exp, " "," > ", home_dir, TEMP_FILE, 0)); + + if (e) { + edit_error_dialog (_(" External "), + get_sys_error (_(" Error trying to execute command "))); + return -1; + } + + edit->force |= REDRAW_COMPLETELY; + + edit_printf(edit,catstrs("sh> ",exp,"\n",0)); + edit_insert_file (edit, catstrs (home_dir, TEMP_FILE, 0)); + return 0; +} /* if block is 1, a block must be highlighted and the shell command processes it. If block is 0 the shell command is a straight system command, that just produces some output which is to be inserted */ diff -Nur mc-4.5.55-orig/gtkedit/editcmddef.h mc-4.5.55/gtkedit/editcmddef.h --- mc-4.5.55-orig/gtkedit/editcmddef.h Sun Aug 12 20:02:56 2001 +++ mc-4.5.55/gtkedit/editcmddef.h Sun Apr 27 22:55:38 2003 @@ -91,6 +91,7 @@ #define CK_Match_Bracket 421 #define CK_Terminal 422 #define CK_Terminal_App 423 +#define CK_ExtCmd 424 #define CK_User_Menu 425 /* application control */ diff -Nur mc-4.5.55-orig/gtkedit/editmenu.c mc-4.5.55/gtkedit/editmenu.c --- mc-4.5.55-orig/gtkedit/editmenu.c Sun Aug 12 20:02:56 2001 +++ mc-4.5.55/gtkedit/editmenu.c Sun Apr 27 22:59:21 2003 @@ -108,6 +108,7 @@ void menu_c_form_cmd (void) { menu_key (KEY_F (19)); } void menu_ispell_cmd (void) { menu_cmd (CK_Pipe_Block (1)); } void menu_sort_cmd (void) { menu_cmd (CK_Sort); } +void menu_ext_cmd (void) { menu_cmd (CK_ExtCmd); } void menu_date_cmd (void) { menu_cmd (CK_Date); } void menu_undo_cmd (void) { menu_cmd (CK_Undo); } void menu_beginning_cmd (void) { menu_cmd (CK_Beginning_Of_Text); } @@ -228,6 +229,7 @@ {' ', N_("format p&Aragraph M-p"), 'A', menu_format_paragraph}, {' ', N_("'ispell' s&Pell check C-p"), 'P', menu_ispell_cmd}, {' ', N_("sor&T... M-t"), 'T', menu_sort_cmd}, + {' ', N_("Paste o&utput of ... M-u"), 'U', menu_ext_cmd}, {' ', N_("E&xternal Formatter F19"), 'C', menu_c_form_cmd}, {' ', N_("&Mail... "), 'M', menu_mail_cmd} }; @@ -251,6 +253,7 @@ {' ', N_("format p&Aragraph M-p"), 'a', menu_format_paragraph}, {' ', N_("'ispell' s&Pell check M-$"), 'P', menu_ispell_cmd}, {' ', N_("sor&T... M-t"), 'T', menu_sort_cmd}, + {' ', N_("Paste o&utput of ... M-u"), 'U', menu_ext_cmd}, {' ', N_("E&xternal Formatter F19"), 'C', menu_c_form_cmd} }; From proski at gnu.org Mon Apr 28 01:32:50 2003 From: proski at gnu.org (Pavel Roskin) Date: Sun, 27 Apr 2003 21:32:50 -0400 (EDT) Subject: [PATCH] paste external command output In-Reply-To: <20030428011148.GA354@matrix> References: <20030428011148.GA354@matrix> Message-ID: On Mon, 28 Apr 2003, [iso-8859-2] Micha? Szwaczko wrote: > I crafted a little patch for mc-4.5.55 The only thing it does is let you > paste output of a command (basically anything that produces output when > run from shell) to the internal editor. Merge it or burn it ;-) or > criticize if you find it lousy. But what's the point in improving an old version? mc-4.6.0 doesn't have edit/edit_key_translator.c. Also, adding new keys to the emacs map should be done very cautiously. Do you know what Alt-u (or M-u) does in emacs? If you checked this and believe that your binding should be used for emacs emulation, then please mention that. I'm not against the idea of your patch, but you are leaving a lot of work to other people. -- Regards, Pavel Roskin From mikey at wirelabs.lublin.pl Mon Apr 28 01:45:00 2003 From: mikey at wirelabs.lublin.pl (=?iso-8859-2?Q?Micha=B3?= Szwaczko) Date: Mon, 28 Apr 2003 03:45:00 +0200 Subject: [PATCH] paste external command output In-Reply-To: References: <20030428011148.GA354@matrix> Message-ID: <20030428014500.GA780@matrix> On Sun, Apr 27, 2003 at 09:32:50PM -0400, Pavel Roskin wrote: > But what's the point in improving an old version? mc-4.6.0 doesn't have > edit/edit_key_translator.c. mc-4.6.0 is part of gnome 2.0 huh ? I'll have to look on that then. I stick to 4.5, that's why I overlooked 4.6 ;-) > Also, adding new keys to the emacs map should be done very cautiously. > Do you know what Alt-u (or M-u) does in emacs? If you checked this and > believe that your binding should be used for emacs emulation, then please > mention that. AFAIR it's a free combination. > I'm not against the idea of your patch, but you are leaving a lot of work > to other people. That's why I am sending it to the list, so that the people working on this could take a look and give a hint maybe. OK, I'll try to do it in 4.6.0. Thanks -- Micha? 'Mikey' Szwaczko Developer/Troubleshooter Never trust an operating system. From alpha at student.uci.agh.edu.pl Mon Apr 28 11:07:42 2003 From: alpha at student.uci.agh.edu.pl (Adam Byrtek / alpha) Date: Mon, 28 Apr 2003 13:07:42 +0200 Subject: [PATCH] paste external command output In-Reply-To: <20030428014500.GA780@matrix> References: <20030428011148.GA354@matrix> <20030428014500.GA780@matrix> Message-ID: <20030428110742.GA1380@mentat.localdomain> On Mon, Apr 28, 2003 at 03:45:00AM +0200, Micha? Szwaczko wrote: > mc-4.6.0 is part of gnome 2.0 huh ? No, MC 4.6.0 is a standalone application... Maybe you are thinking about GMC - but GNOME code has been removed from MC with version 4.6.0. -- _.|._ |_ _. : Adam Byrtek /alpha alpha at debian.org (_|||_)| |(_| : http://krakow.linux.org.pl/ pgp 0xB25952C0 | From alpha at student.uci.agh.edu.pl Tue Apr 29 14:08:14 2003 From: alpha at student.uci.agh.edu.pl (Adam Byrtek / alpha) Date: Tue, 29 Apr 2003 16:08:14 +0200 Subject: Fw: iso vfs for mc Message-ID: <20030429140814.GB1845@mentat.localdomain> ----- Forwarded message from Dmitry Borodaenko ----- Date: Tue, 29 Apr 2003 12:50:30 +0300 From: Dmitry Borodaenko To: Adam Byrtek / alpha Cc: Michael Shigorin Subject: iso vfs for mc Hello Adam! Attached is extfs script for entering iso images from mc without having to loop-mount them. I assume that its author, Michael Shigorin, has no objections against including it under mc's GPL license ;-) -- Dmitry Borodaenko #! /bin/sh # ISO9660 VFS for MC by Michael Shigorin April 2003 # based on lslR by Tomas Novak April 2000 # -- look there for additional parsing comments if needed # tested to comply with isoinfo 2.0's output test_iso () { for i in '-J -R' '-J' '-R'; do ISOINFO="isoinfo $i" $ISOINFO "$1" >/dev/null 2>&1 && break done } mcisofs_list () { case "$1" in *.bz2) MYCAT="bzip2 -dc";; *.gz) MYCAT="gzip -dc";; *.z) MYCAT="gzip -dc";; *.Z) MYCAT="gzip -dc";; *) MYCAT="cat";; esac $ISOINFO -l -i "$1" | gawk ' BEGIN { dir=""; # Pattern to match 8 first fields. rx = "[^ ]+[ ]+"; rx = "^" rx rx rx rx rx rx rx rx; irx = "^. *[0-9]+. "; } /^$/ { next } /^d---------/ { next } /^Directory listing of [^ ].*$/ { dir=substr($0, 23); next; } { $11 != "" } { name=$0 sub(rx, "", name) attr=substr($0, 1, length($0)-length(name)) # strip inodes and extra dir entries; fix perms sub(irx, "", name) sub("^---------- 0 0 0", "-r--r--r-- 1 root root", attr) sub(" $", "", name) # skip . and .. if (name ~ /^\.\.?/) next; printf "%s%s%s\n", attr, dir, name }' } mcisofs_copyout () { $ISOINFO -i "$1" -x "/$2" > "$3" } export LC_ALL="C" case "$1" in list) test_iso "$2"; mcisofs_list "$2"; exit 0;; copyout) test_iso "$2"; mcisofs_copyout "$2" "$3" "$4"; exit 0;; esac exit 1 ----- End forwarded message ----- -- _.|._ |_ _. : Adam Byrtek /alpha alpha at debian.org (_|||_)| |(_| : http://krakow.linux.org.pl/ pgp 0xB25952C0 | From proski at gnu.org Tue Apr 29 16:09:47 2003 From: proski at gnu.org (Pavel Roskin) Date: Tue, 29 Apr 2003 12:09:47 -0400 (EDT) Subject: Fw: iso vfs for mc In-Reply-To: <20030429140814.GB1845@mentat.localdomain> References: <20030429140814.GB1845@mentat.localdomain> Message-ID: On Tue, 29 Apr 2003, Adam Byrtek / alpha wrote: > Attached is extfs script for entering iso images from mc without having > to loop-mount them. I assume that its author, Michael Shigorin, has no > objections against including it under mc's GPL license ;-) Applied. Thank you! -- Regards, Pavel Roskin