;; ----------------------------------------
;;
;; Notice: for directory/host/user tracking you need to have something
-;; like this in your shell startup script ( this is for tcsh but should
-;; be quite easy to port to other shells )
+;; like this in your shell startup script (this is for a POSIXish shell
+;; like Bash but should be quite easy to port to other shells)
;;
;; ----------------------------------------
;;
-;;
-;; set os = `uname`
-;; set host = `hostname`
-;; set date = `date`
+;; # Set HOSTNAME if not already set.
+;; : ${HOSTNAME=$(uname -n)}
;;
;; # su does not change this but I'd like it to
;;
-;; set user = `whoami`
+;; USER=$(whoami)
;;
;; # ...
;;
-;; if ( eterm =~ $TERM ) then
-;;
-;; echo --------------------------------------------------------------
-;; echo Hello $user
-;; echo Today is $date
-;; echo We are on $host running $os under Emacs term mode
-;; echo --------------------------------------------------------------
-;;
-;; setenv EDITOR emacsclient
-;;
-;; # Notice: $host and $user have been set before to 'hostname' and 'whoami'
-;; # this is necessary because, f.e., certain versions of 'su' do not change
-;; # $user, YMMV: if you don't want to fiddle with them define a couple
-;; # of new variables and use these instead.
-;; # NOTICE that there is a space between "AnSiT?" and $whatever NOTICE
-;;
-;; # These are because we want the real cwd in the messages, not the login
-;; # time one !
-;;
-;; set cwd_hack='$cwd'
-;; set host_hack='$host'
-;; set user_hack='$user'
-;;
-;; # Notice that the ^[ character is an ESC, not two chars. You can
-;; # get it in various ways, for example by typing
-;; # echo -e '\033' > escape.file
-;; # or by using your favorite editor
+;; case $TERM in
+;; eterm*)
;;
-;; foreach temp (cd pushd)
-;; alias $temp "$temp \!* ; echo '\eAnSiTc' $cwd_hack"
-;; end
-;; alias popd 'popd ;echo "\eAnSiTc" $cwd'
+;; printf '%s\n' \
+;; -------------------------------------------------------------- \
+;; "Hello $user" \
+;; "Today is $(date)" \
+;; "We are on $HOSTNAME running $(uname) under Emacs term mode" \
+;; --------------------------------------------------------------
;;
-;; # Every command that can modify the user/host/directory should be aliased
-;; # as follows for the tracking mechanism to work.
+;; export EDITOR=emacsclient
;;
-;; foreach temp ( rlogin telnet rsh sh ksh csh tcsh zsh bash tcl su )
-;; alias $temp "$temp \!* ; echo '\eAnSiTh' $host_hack ; \
-;; echo '\eAnSiTu' $user_hack ;echo '\eAnSiTc' $cwd_hack"
-;; end
+;; # The \033 stands for ESC.
+;; # There is a space between "AnSiT?" and $whatever.
;;
-;; # Start up & use color ls
+;; cd() { command cd "$@"; printf '\033AnSiTc %s\n' "$PWD"; }
+;; pushd() { command pushd "$@"; printf '\033AnSiTc %s\n' "$PWD"; }
+;; popd() { command popd "$@"; printf '\033AnSiTc %s\n' "$PWD"; }
;;
-;; echo "\eAnSiTh" $host
-;; echo "\eAnSiTu" $user
-;; echo "\eAnSiTc" $cwd
+;; printf '\033AnSiTc %s\n' "$PWD"
+;; printf '\033AnSiTh %s\n' "$HOSTNAME"
+;; printf '\033AnSiTu %s\n' "$USER"
;;
-;; # some housekeeping
-;;
-;; unset cwd_hack
-;; unset host_hack
-;; unset user_hack
-;; unset temp
-;;
-;; eval `/bin/dircolors /home/marco/.emacs_dircolors`
-;; endif
+;; eval $(dircolors $HOME/.emacs_dircolors)
+;; esac
;;
;; # ...
;;
-;; # Let's not clutter user space
-;;
-;; unset os
-;; unset date
-;;
;;
;;; Original Commentary:
(make-local-variable 'term-scroll-show-maximum-output)
(make-local-variable 'term-ptyp)
(make-local-variable 'term-exec-hook)
- (make-local-variable 'term-vertical-motion)
+ (set (make-local-variable 'term-vertical-motion) 'vertical-motion)
(set (make-local-variable 'term-pending-delete-marker) (make-marker))
(make-local-variable 'term-current-face)
(term-ansi-reset)
(set (make-local-variable 'font-lock-defaults) '(nil t))
+ (add-function :filter-return
+ (local 'window-adjust-process-window-size-function)
+ (lambda (size)
+ (when size
+ (term-reset-size (cdr size) (car size)))
+ size))
+
(easy-menu-add term-terminal-menu)
(easy-menu-add term-signals-menu)
(or term-input-ring
(goto-char save-point)))
found))
-(defun term-check-size (process)
- (when (or (/= term-height (window-text-height))
- (/= term-width (term-window-width)))
- (term-reset-size (window-text-height) (term-window-width))
- (set-process-window-size process term-height term-width)))
-
(defun term-send-raw-string (chars)
(deactivate-mark)
(let ((proc (get-buffer-process (current-buffer))))
(format "TERMINFO=%s" data-directory)
(format term-termcap-format "TERMCAP="
term-term-name term-height term-width)
- ;; We are going to get rid of the binding for EMACS,
- ;; probably in Emacs 23, because it breaks
- ;; `./configure' of some packages that expect it to
- ;; say where to find EMACS.
- (format "EMACS=%s (term:%s)" emacs-version term-protocol-version)
(format "INSIDE_EMACS=%s,term:%s" emacs-version term-protocol-version)
(format "LINES=%d" term-height)
(format "COLUMNS=%d" term-width))
(let ((ch (read-event)))
(if (eq ch ?\s)
(set-window-configuration conf)
- (setq unread-command-events (list ch)))))))
+ (push ch unread-command-events))))))
(defun term-regexp-arg (prompt)
(defun term-within-quotes (beg end)
"Return t if the number of quotes between BEG and END is odd.
Quotes are single and double."
- (let ((countsq (term-how-many-region "\\(^\\|[^\\\\]\\)\'" beg end))
+ (let ((countsq (term-how-many-region "\\(^\\|[^\\\\]\\)'" beg end))
(countdq (term-how-many-region "\\(^\\|[^\\\\]\\)\"" beg end)))
(or (= (mod countsq 2) 1) (= (mod countdq 2) 1))))
(when (/= (point) (process-mark proc))
(setq save-point (point-marker)))
- ;; Note if the window size has changed. We used to reset
- ;; point too, but that gives incorrect results (Bug#4635).
- (if (eq (window-buffer) (current-buffer))
- (progn
- (setq term-vertical-motion (symbol-function 'vertical-motion))
- (term-check-size proc))
- (setq term-vertical-motion
- (symbol-function 'term-buffer-vertical-motion)))
- (setq save-marker (copy-marker (process-mark proc)))
+ (setf term-vertical-motion
+ (if (eq (window-buffer) (current-buffer))
+ 'vertical-motion
+ 'term-buffer-vertical-motion))
+ (setq save-marker (copy-marker (process-mark proc)))
(goto-char (process-mark proc))
(save-restriction
(eq (window-buffer selected) (current-buffer)))
(term-display-line (car term-pending-frame)
(cdr term-pending-frame))
- (setq term-pending-frame nil)
- ;; We have created a new window, so check the window size.
- (term-check-size proc))
+ (setq term-pending-frame nil))
;; Scroll each window displaying the buffer but (by default)
;; only if the point matches the process-mark we started with.
(set-window-configuration conf))
(if (eq first ?\s)
(set-window-configuration conf)
- (setq unread-command-events (listify-key-sequence key)))))))
+ (setq unread-command-events
+ (nconc (listify-key-sequence key)
+ unread-command-events)))))))
;; I need a make-term that doesn't surround with *s -mm
(defun term-ansi-make-term (name program &optional startfile &rest switches)