all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Antoine Levitt" <smeuuh@gmail.com>
To: "Jan Djärv" <jan.h.d@swipnet.se>
Cc: Stefan Monnier <monnier@iro.umontreal.ca>, emacs-devel@gnu.org
Subject: Re: [Patch] Resizing shells in shell-mode
Date: Sun, 25 May 2008 14:26:06 +0200	[thread overview]
Message-ID: <6fa54e4e0805250526w6635385cu4a8a685c5187d0@mail.gmail.com> (raw)
In-Reply-To: <48392134.6050309@swipnet.se>

[-- Attachment #1: Type: text/plain, Size: 2153 bytes --]

Hi,
I tested it, it works. I used a simple C program :
#include <sys/ioctl.h>
#include <stdio.h>
#include <fcntl.h>
int main(int argc, char **argv)
{
    int fd = open(argv[1], O_RDWR);
    struct winsize sz;
    sz.ws_row = atoi(argv[2]);
    sz.ws_col = atoi(argv[3]);
    ioctl(fd, TIOCSWINSZ, &sz);
    return 0;
}

Then in lisp, I added a hook to window-configuration-change-hook to call
this program with (process-tty-name), (window-width) and (window-height).
Interestingly, it worked in bash without needing a SIGWINCH, even when
deactivating the bash option in shopt that tells it to check for window size
changes.
I searched in the lisp manual, I didn't find any way to do what I did in C
in lisp. Is it possible ? Else a wrapper either to ioctl or directly
something like (change-size ttyname row col) (I don't know which one is
better) would need to be implemented in the C source code.
The resulting code in shell.el would like like :
(add-hook 'window-configuration-change-hook
      (lambda ()
        (if (eq major-mode 'shell-mode) (change-size))))

(defun change-size ()
  (ioctl (process-tty-name) (window-height) (window-size))
  (signal-process (get-buffer-process (current-buffer)) 'SIGWINCH))

There's many issues going on here I don't have any clue on how to solve, but
should be easy for an emacs developper : namespace cluttering, error
treatment (when a shell is stopped for example), performance, portability,
addition of the C source code ... could anyone tackle these in order to
solve the bug ?

Antoine
2008/5/25 Jan Djärv <jan.h.d@swipnet.se>:

>
>
> Stefan Monnier skrev:
>
>  Problem is: sending "export COLUMNS=%d" won't do the right thing if the
>> process running currently isn't some bourne derivative.  E.g. if it's
>> `csh' or some completely different process.
>>
>
> I think the right thing to do is to set the new size on the pty with ioctl
> TIOCSWINSZ and then send SIGWINCH to the inferior process.  AFAIK, shells
> react on that to set COLUMNS and LINES.  The signal is discarded by default
> so it does no harm if not caught.
>
>        Jan D.
>

[-- Attachment #2: Type: text/html, Size: 2891 bytes --]

  reply	other threads:[~2008-05-25 12:26 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-05-24 18:38 [Patch] Resizing shells in shell-mode Antoine Levitt
2008-05-24 19:04 ` Stefan Monnier
2008-05-24 20:23   ` Antoine Levitt
2008-05-24 20:47     ` Stefan Monnier
2008-05-24 20:56     ` Miles Bader
2008-05-24 21:58       ` Antoine Levitt
2008-05-25  8:20   ` Jan Djärv
2008-05-25 12:26     ` Antoine Levitt [this message]
2008-05-25 14:43       ` Miles Bader
2008-06-05  6:24       ` Stefan Monnier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6fa54e4e0805250526w6635385cu4a8a685c5187d0@mail.gmail.com \
    --to=smeuuh@gmail.com \
    --cc=emacs-devel@gnu.org \
    --cc=jan.h.d@swipnet.se \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.