Your message dated Sat, 16 Aug 2008 17:56:37 -0400
with message-id <[EMAIL PROTECTED]>
and subject line Closing "[vim] swapfile found alert should notify the 
swapfile's owner tty"
has caused the Debian Bug report #241391,
regarding [vim] swapfile found alert should notify the swapfile's owner tty
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact [EMAIL PROTECTED]
immediately.)


-- 
241391: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=241391
Debian Bug Tracking System
Contact [EMAIL PROTECTED] with problems
--- Begin Message ---
Package: vim
Version: 6.1.018-1
Severity: wishlist
Tags: patch

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi.

Often I attempt to edit a file, vim informs me it's already being
edited, then i go clipboard-copy the PID reported by vim -> ps -eH|grep
<pasted PID> -> chvt <found tty>.  This is far from effective.

I suggest automating of this process:  vim would

(1) display the tty the swapfile owner occupies[1]
(2) offer chvt-ing to the tty among the action choices:
> [O]pen Read-Only, (E)dit anyway, (R)ecover, (Q)uit, Quit & (G)o there
                                                    ^^^^^^^^^^^^^^^^^^^
[1] Maybe other information would be useful, too, when we are at it

I was able to make a very crude, unportable and ugly patch for (1); (2)
clearly demands more coding expertise than I have.  I really don't
understand that heap of functions and macros (not that I understood C
proper much).

I wonder whether I shouldn't have been sending this directly to the
upstream?

Cheers,
Jan.


diff -ru vim-6.1.018/src/memline.c vim-6.1.018.RUNNING-ON-A-TTY.v1/src/memline.c
- --- vim-6.1.018/src/memline.c Sun Feb 17 13:45:43 2002
+++ vim-6.1.018.RUNNING-ON-A-TTY.v1/src/memline.c       Tue Mar 30 23:00:27 2004
@@ -1455,6 +1455,45 @@
 static int process_still_running;
 #endif
 
+
+/*
+ * Return tty on which supplied PID runs.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+// XXX kludge -- see below
+#define SIZEOF_TTY 1024
+
+void ttyof(const pid_t pid, char *tty);
+
+void
+ttyof(const pid_t pid, char *tty) {
+       int filedes[2];         // anonymous pipe()
+       char command[1024]; // construct the command for system() here
+
+       (void)pipe(filedes);
+       switch(fork()) {
+
+               /* Child */
+               case 0:
+                       (void)snprintf(command, sizeof(command), "/bin/ps 
-eopid,tty | /usr/bin/awk '$1~/^%d$/{print $2}' | /usr/bin/tr '\\n' '\\0' 
>&%d", pid, filedes[1]);
+                       (void)system(command);
+                       exit(0);
+                       break;
+
+               /* Parent */
+               default:
+                       (void)read(filedes[0], tty, /* XXX: DNW: sizeof(tty) */ 
SIZEOF_TTY);
+                       tty[SIZEOF_TTY] = 0; // Just for sure
+                       break;
+       };
+}
+
+
 /*
  * Give information about an existing swap file
  * Returns timestamp (0 when unknown).
@@ -1470,6 +1509,7 @@
 #ifdef UNIX
     char_u         uname[B0_UNAME_SIZE];
 #endif
+    char         tty[SIZEOF_TTY];
 
     /* print the swap file date */
     if (mch_stat((char *)fname, &st) != -1)
@@ -1547,6 +1587,12 @@
                    if (kill((pid_t)char_to_long(b0.b0_pid), 0) == 0)
                    {
                        MSG_PUTS(_(" (still running)"));
+
+                       ttyof((pid_t)char_to_long(b0.b0_pid), tty);
+                       MSG_PUTS(_(" (on "));
+                       msg_outtrans(tty);
+                       MSG_PUTS(_(")"));
+                       
 # if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG)
                        process_still_running = TRUE;
 # endif


- -- System Information
Debian Release: 3.0
Architecture: i386
Kernel: Linux kontryhel 2.4.25-jan #2 SMP Fri Feb 20 15:23:11 CET 2004 i686
Locale: LANG=C, LC_CTYPE=cs_CZ.ISO-8859-2

Versions of packages vim depends on:
ii  dpkg                     1.9.21          Package maintenance system for Deb
ii  libc6                    2.2.5-11.5      GNU C Library: Shared libraries an
ii  libgpmg1                 1.19.6-12       General Purpose Mouse Library [lib
ii  libncurses5              5.2.20020112a-7 Shared libraries for terminal hand

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQFAahh8+uczK20Fa5cRAq7/AJ4/3dKtKflCw6cgRdiFeDKH7ez10QCeLaFM
fF0IkcY5N5/vP+MSqdlUJU4=
=Fcig
-----END PGP SIGNATURE-----


--- End Message ---
--- Begin Message ---
tag 241391 wontfix
thanks

As discussed on IRC, although this feature is desireable, there is not
an easy way to do this portably.  Also, such an unportable (and of
limited use, being VT-specific) implementation as suggested in the
submission is very unlikely to be accepted upstream.

There exists $VIMRUNTIME/macros/editexisting.vim for achieving such
functionality when using gvim.  This script may possibly be extended
to detect other environments which could easily be handled as well, but
that is left up to the user.

-- 
James
GPG Key: 1024D/61326D40 2003-09-02 James Vega <[EMAIL PROTECTED]>

Attachment: signature.asc
Description: Digital signature


--- End Message ---

Reply via email to