unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Joe Wells <jbw@csb.bu.edu>
Subject: Re: ansi-term questions
Date: 12 Aug 2005 07:02:34 -0400	[thread overview]
Message-ID: <xnjzmrnv2np.fsf@csb.bu.edu> (raw)
In-Reply-To: mailman.3445.1123780765.20277.help-gnu-emacs@gnu.org

>>>>> "Angelina" == Angelina Carlton <brat@magma.ca> writes:

  Angelina> Hello emacs users..
  Angelina> In M-x ansi-term I no longer have the use of my direction keys, up
  Angelina> prints A, down prints B and left/right print D/C 

  Angelina> Is there a way to get the direction keys to work properly? I need them
  Angelina> for bash history and for some other apps that I run in that term inside
  Angelina> emacs.

See the discussion in term.el where it says:

  ;; Which would be better:  "\e[A" or "\eOA"? readline accepts either.

There are examples of how you can configure it like this:

  (defun term-send-up    () (interactive) (term-send-raw-string "\eOA"))

  Angelina> Second question, I use M-o to switch windows (M-x other-window)
  Angelina> Is it possible to make emacs skip the *ansi-term* window when I cycle my
  Angelina> windows?
  Angelina> I would like to have to explicitly call it with C-x b *ansi-term* and
  Angelina> have M-x other-window ignore it.

Here you go:

  (defvar my-other-window-excluded-buffer-regexp
    "\\`\\*.*term.*\\*\\'")

  (defun my-other-window (arg &optional all-frames)
    (interactive "p")
    (let* ((window (selected-window))
           (count (abs arg))
           (direction (if (< arg 0) 'previous-window 'next-window)))
      (while (> count 0)
        (while (progn
                 (setq window (funcall direction window nil all-frames))
                 (and (string-match
                       my-other-window-excluded-buffer-regexp
                       (buffer-name (window-buffer window)))
                      ;; need this to avoid possible infinite loop:
                      (not (equal window (selected-window))))))
        (setq count (1- count)))
      (select-window window)
      nil))

  (define-key global-map [remap other-window] 'my-other-window)

A cute programming exercise; it took me about 10 minutes, which was much
longer than I expected because I had to copy the C code definition of
other-window and turn it into Lisp.  If it had been written in Lisp, I
could have done something simpler by using defadvice on next-window and
previous-window.

  Angelina> Thanks!
 
You're welcome.  Hope this helps.

-- 
Joe

  "Did anyone write a function to switch to a buffer which is closest to the
  top of buffer stack and not displayed in all existing screens?
          --  Chi-Sharn Wu <swu@probe.att.com>

  No, but I wrote one once to switch to a buffer in a screen that lies under
  all other screens except for the screen containing a window that held a
  buffer that was below the original buffer in the buffer stack, unless the
  window was in a screen that was currently iconified and the buffer was
  unmodified but above any other buffer that was contained in more than one
  window in the buffer stack, in which case I looped through the screen list
  looking for windows holding buffers that were in windows that were
  iconified but raised over all other screens holding windows with buffers
  that were shown in multiple windows with buffers that were only in one
  screen."
          -- Marc Andreessen <marca@ncsa.uiuc.edu>, nowadays a Netscape millionaire

       reply	other threads:[~2005-08-12 11:02 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mailman.3445.1123780765.20277.help-gnu-emacs@gnu.org>
2005-08-12 11:02 ` Joe Wells [this message]
2005-08-11 17:12 ansi-term questions Angelina Carlton

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=xnjzmrnv2np.fsf@csb.bu.edu \
    --to=jbw@csb.bu.edu \
    /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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).