2018-01-18 13:22:47 +00:00
|
|
|
|
;;; term.el --- general command interpreter in a window stuff -*- lexical-binding: t -*-
|
1995-10-30 17:35:01 +00:00
|
|
|
|
|
2022-01-01 07:45:51 +00:00
|
|
|
|
;; Copyright (C) 1988, 1990, 1992, 1994-1995, 2001-2022 Free Software
|
2013-01-01 09:11:05 +00:00
|
|
|
|
;; Foundation, Inc.
|
1994-10-13 06:30:49 +00:00
|
|
|
|
|
2004-10-17 07:05:11 +00:00
|
|
|
|
;; Author: Per Bothner <per@bothner.com>
|
|
|
|
|
;; Maintainer: Dan Nicolaescu <dann@ics.uci.edu>, Per Bothner <per@bothner.com>
|
2001-07-15 19:53:53 +00:00
|
|
|
|
;; Based on comint mode written by: Olin Shivers <shivers@cs.cmu.edu>
|
|
|
|
|
;; Keywords: processes
|
1994-10-13 06:30:49 +00:00
|
|
|
|
|
1999-01-11 12:59:36 +00:00
|
|
|
|
;; This file is part of GNU Emacs.
|
|
|
|
|
|
2008-05-06 08:06:51 +00:00
|
|
|
|
;; GNU Emacs is free software: you can redistribute it and/or modify
|
1999-01-11 12:59:36 +00:00
|
|
|
|
;; it under the terms of the GNU General Public License as published by
|
2008-05-06 08:06:51 +00:00
|
|
|
|
;; the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
;; (at your option) any later version.
|
1999-01-11 12:59:36 +00:00
|
|
|
|
|
|
|
|
|
;; GNU Emacs 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
|
2017-09-13 22:52:52 +00:00
|
|
|
|
;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
|
1999-01-11 12:59:36 +00:00
|
|
|
|
|
2019-10-02 13:50:54 +00:00
|
|
|
|
;; March 13 2001
|
2009-08-16 15:39:11 +00:00
|
|
|
|
;; Fixes for CJK support by Yong Lu <lyongu@yahoo.com>.
|
2001-03-13 11:21:52 +00:00
|
|
|
|
|
2009-08-16 15:39:11 +00:00
|
|
|
|
;; Dir/Hostname tracking and ANSI colorization by
|
|
|
|
|
;; Marco Melgazzi <marco@techie.com>.
|
1994-10-13 06:30:49 +00:00
|
|
|
|
|
2009-08-16 15:39:11 +00:00
|
|
|
|
;; To see what I've modified and where it came from search for '-mm'
|
1994-10-13 06:30:49 +00:00
|
|
|
|
|
2001-07-15 19:53:53 +00:00
|
|
|
|
;;; Commentary:
|
|
|
|
|
|
2019-07-25 02:02:59 +00:00
|
|
|
|
;; This file defines a general command-interpreter-in-a-buffer package
|
|
|
|
|
;; (term mode). The idea is that you can build specific process-in-a-buffer
|
2021-09-14 06:43:18 +00:00
|
|
|
|
;; modes on top of term mode -- e.g., Lisp, shell, Scheme, T, soar, ....
|
2019-07-25 02:02:59 +00:00
|
|
|
|
;; This way, all these specific packages share a common base functionality,
|
|
|
|
|
;; and a common set of bindings, which makes them easier to use (and
|
|
|
|
|
;; saves code, implementation time, etc., etc.).
|
|
|
|
|
|
|
|
|
|
;; If, instead of `term', you call `ansi-term', you get multiple term
|
|
|
|
|
;; buffers, after every new call ansi-term opens a new
|
|
|
|
|
;; "*ansi-term*<xx>" window, where <xx> is, as usual, a number...
|
|
|
|
|
|
|
|
|
|
;; For hints on converting existing process modes (e.g., tex-mode,
|
|
|
|
|
;; background, dbx, gdb, kermit, prolog, telnet) to use term-mode
|
|
|
|
|
;; instead of shell-mode, see the notes at the end of this file.
|
|
|
|
|
|
2009-08-16 15:39:11 +00:00
|
|
|
|
;; Speed considerations and a few caveats
|
|
|
|
|
;; --------------------------------------
|
|
|
|
|
;;
|
|
|
|
|
;; While the message passing and the colorization surely introduce some
|
2011-12-21 09:58:39 +00:00
|
|
|
|
;; overhead this has became so small that IMHO it is surely outweighed by
|
|
|
|
|
;; the benefits you get but, as usual, YMMV.
|
2009-08-16 15:39:11 +00:00
|
|
|
|
;;
|
2011-11-27 04:43:11 +00:00
|
|
|
|
;; Important caveat, when deciding the cursor/'gray keys' keycodes I had to
|
2009-08-16 15:39:11 +00:00
|
|
|
|
;; make a choice: on my Linux box this choice allows me to run all the
|
|
|
|
|
;; ncurses applications without problems but make these keys
|
2011-11-23 07:03:56 +00:00
|
|
|
|
;; incomprehensible to all the cursesX programs. Your mileage may vary so
|
2009-08-16 15:39:11 +00:00
|
|
|
|
;; you may consider changing the default 'emulation'. Just search for this
|
|
|
|
|
;; piece of code and modify it as you like:
|
|
|
|
|
;;
|
|
|
|
|
;; ;; Which would be better: "\e[A" or "\eOA"? readline accepts either.
|
|
|
|
|
;; ;; For my configuration it's definitely better \eOA but YMMV. -mm
|
|
|
|
|
;; ;; For example: vi works with \eOA while elm wants \e[A ...
|
|
|
|
|
;; (defun term-send-up () (interactive) (term-send-raw-string "\eOA"))
|
|
|
|
|
;; (defun term-send-down () (interactive) (term-send-raw-string "\eOB"))
|
|
|
|
|
;; (defun term-send-right () (interactive) (term-send-raw-string "\eOC"))
|
|
|
|
|
;; (defun term-send-left () (interactive) (term-send-raw-string "\eOD"))
|
|
|
|
|
;;
|
|
|
|
|
;;
|
|
|
|
|
;; IMPORTANT: additions & changes
|
|
|
|
|
;; ------------------------------
|
|
|
|
|
;;
|
|
|
|
|
;; With this enhanced ansi-term.el you will get a reliable mechanism of
|
|
|
|
|
;; directory/username/host tracking: the only drawback is that you will
|
|
|
|
|
;; have to modify your shell start-up script. It's worth it, believe me :).
|
|
|
|
|
;;
|
2022-08-02 15:18:22 +00:00
|
|
|
|
;; When you ssh/sudo/su and the account you access has a modified
|
2009-08-16 15:39:11 +00:00
|
|
|
|
;; startup script, you will be able to access the remote files as usual
|
|
|
|
|
;; with C-x C-f, if it's needed you will have to enter a password,
|
|
|
|
|
;; otherwise the file should get loaded straight away.
|
|
|
|
|
;;
|
|
|
|
|
;; This is useful even if you work only on one host: it often happens that,
|
|
|
|
|
;; for maintenance reasons, you have to edit files 'as root': before
|
|
|
|
|
;; patching term.el, I su-ed in a term.el buffer and used vi :), now I
|
|
|
|
|
;; simply do a C-x C-f and, via ange-ftp, the file is automatically loaded
|
2019-12-24 01:37:08 +00:00
|
|
|
|
;; 'as-root'. (If you don't want to enter the root password every time you
|
2009-08-16 15:39:11 +00:00
|
|
|
|
;; can put it in your .netrc: note that this is -not- advisable if you're
|
|
|
|
|
;; connected to the internet or if somebody else works on your workstation!)
|
|
|
|
|
;;
|
|
|
|
|
;; If you use wu-ftpd you can use some of its features to avoid root ftp
|
|
|
|
|
;; access to the rest of the world: just put in /etc/ftphosts something like
|
|
|
|
|
;;
|
|
|
|
|
;; # Local access
|
|
|
|
|
;; allow root 127.0.0.1
|
|
|
|
|
;;
|
|
|
|
|
;; # By default nobody can't do anything
|
|
|
|
|
;; deny root *
|
|
|
|
|
;;
|
|
|
|
|
;; ----------------------------------------
|
|
|
|
|
;;
|
2019-10-02 13:50:54 +00:00
|
|
|
|
;; With the variable term-buffer-maximum-size you can decide how many
|
|
|
|
|
;; scrollback lines to keep: its default is 8192.
|
2009-08-16 15:39:11 +00:00
|
|
|
|
;;
|
|
|
|
|
;; ----------------------------------------
|
|
|
|
|
;;
|
|
|
|
|
;;
|
2018-01-18 13:22:47 +00:00
|
|
|
|
;; ANSI colorization should work well. Blink, is not supported.
|
|
|
|
|
;; Currently it's mapped as bold.
|
2009-08-16 15:39:11 +00:00
|
|
|
|
;;
|
|
|
|
|
;; ----------------------------------------
|
|
|
|
|
;;
|
|
|
|
|
;; TODO:
|
|
|
|
|
;;
|
|
|
|
|
;; - Add hooks to allow raw-mode keys to be configurable
|
|
|
|
|
;; - Which keys are better ? \eOA or \e[A ?
|
|
|
|
|
;;
|
|
|
|
|
;; ----------------------------------------------------------------
|
|
|
|
|
;; You should/could have something like this in your .emacs to take
|
|
|
|
|
;; full advantage of this package
|
|
|
|
|
;;
|
|
|
|
|
;; (add-hook 'term-mode-hook
|
2020-11-17 17:42:38 +00:00
|
|
|
|
;; (lambda ()
|
|
|
|
|
;; (setq term-prompt-regexp "^[^#$%>\n]*[#$%>] *")
|
|
|
|
|
;; (setq-local mouse-yank-at-point t)
|
|
|
|
|
;; (setq-local transient-mark-mode nil)
|
|
|
|
|
;; (auto-fill-mode -1)
|
|
|
|
|
;; (setq tab-width 8)))
|
2009-08-16 15:39:11 +00:00
|
|
|
|
;;
|
|
|
|
|
;; ----------------------------------------
|
|
|
|
|
;;
|
|
|
|
|
;; If you want to use color ls the best setup is to have a different file
|
|
|
|
|
;; when you use eterm ( see above, mine is named .emacs_dircolors ). This
|
|
|
|
|
;; is necessary because some terminals, rxvt for example, need non-ansi
|
|
|
|
|
;; hacks to work ( for example on my rxvt white is wired to fg, and to
|
|
|
|
|
;; obtain normal white I have to do bold-white :)
|
|
|
|
|
;;
|
|
|
|
|
;; ----------------------------------------
|
|
|
|
|
;;
|
|
|
|
|
;; # Configuration file for the color ls utility
|
|
|
|
|
;; # This file goes in the /etc directory, and must be world readable.
|
|
|
|
|
;; # You can copy this file to .dir_colors in your $HOME directory to
|
|
|
|
|
;; # override the system defaults.
|
|
|
|
|
;;
|
|
|
|
|
;; # COLOR needs one of these arguments: 'tty' colorizes output to ttys, but
|
|
|
|
|
;; # not pipes. 'all' adds color characters to all output. 'none' shuts
|
|
|
|
|
;; # colorization off.
|
|
|
|
|
;; COLOR tty
|
|
|
|
|
;; OPTIONS -F
|
|
|
|
|
;;
|
|
|
|
|
;; # Below, there should be one TERM entry for each termtype that is
|
|
|
|
|
;; # colorizable
|
|
|
|
|
;; TERM eterm
|
|
|
|
|
;;
|
|
|
|
|
;; # EIGHTBIT, followed by '1' for on, '0' for off. (8-bit output)
|
|
|
|
|
;; EIGHTBIT 1
|
|
|
|
|
;;
|
|
|
|
|
;; # Below are the color init strings for the basic file types. A color init
|
|
|
|
|
;; # string consists of one or more of the following numeric codes:
|
|
|
|
|
;; # Attribute codes:
|
|
|
|
|
;; # 00=none 01=bold 04=underscore 05=blink 07=reverse 08=concealed
|
|
|
|
|
;; # Text color codes:
|
|
|
|
|
;; # 30=black 31=red 32=green 33=yellow 34=blue 35=magenta 36=cyan 37=white
|
|
|
|
|
;; # Background color codes:
|
|
|
|
|
;; # 40=black 41=red 42=green 43=yellow 44=blue 45=magenta 46=cyan 47=white
|
|
|
|
|
;; NORMAL 00 # global default, although everything should be something.
|
|
|
|
|
;; FILE 00 # normal file
|
|
|
|
|
;; DIR 00;37 # directory
|
|
|
|
|
;; LINK 00;36 # symbolic link
|
|
|
|
|
;; FIFO 00;37 # pipe
|
|
|
|
|
;; SOCK 40;35 # socket
|
|
|
|
|
;; BLK 33;01 # block device driver
|
|
|
|
|
;; CHR 33;01 # character device driver
|
|
|
|
|
;;
|
|
|
|
|
;; # This is for files with execute permission:
|
|
|
|
|
;; EXEC 00;32
|
|
|
|
|
;;
|
|
|
|
|
;; # List any file extensions like '.gz' or '.tar' that you would like ls
|
|
|
|
|
;; # to colorize below. Put the extension, a space, and the color init
|
|
|
|
|
;; # string. (and any comments you want to add after a '#')
|
|
|
|
|
;; .tar 01;33 # archives or compressed
|
|
|
|
|
;; .tgz 01;33
|
|
|
|
|
;; .arj 01;33
|
|
|
|
|
;; .taz 01;33
|
|
|
|
|
;; .lzh 01;33
|
|
|
|
|
;; .zip 01;33
|
|
|
|
|
;; .z 01;33
|
|
|
|
|
;; .Z 01;33
|
|
|
|
|
;; .gz 01;33
|
|
|
|
|
;; .jpg 01;35 # image formats
|
|
|
|
|
;; .gif 01;35
|
|
|
|
|
;; .bmp 01;35
|
|
|
|
|
;; .xbm 01;35
|
|
|
|
|
;; .xpm 01;35
|
|
|
|
|
;;
|
|
|
|
|
;; ----------------------------------------
|
|
|
|
|
;;
|
2019-07-25 02:02:59 +00:00
|
|
|
|
;; There are actually two methods for directory tracking, one
|
|
|
|
|
;; implemented in `term-command-hook' which sets the directory
|
2019-07-26 02:51:28 +00:00
|
|
|
|
;; according to an escape sequence of the form "\032/<directory>\n".
|
2019-07-25 02:02:59 +00:00
|
|
|
|
;; Some shells like bash will already send this escape sequence when
|
|
|
|
|
;; they detect they are running in Emacs. This can be configured or
|
|
|
|
|
;; disabled on the Emacs side by setting `term-command-hook' to
|
|
|
|
|
;; a different function.
|
|
|
|
|
;;
|
|
|
|
|
;; The second method is in `term-handle-ansi-terminal-messages' which
|
|
|
|
|
;; sets user, host, and directory according to escape sequences of the
|
|
|
|
|
;; form "\033AnSiTc <directory>\n" (replace the "c" with "u" and "h"
|
|
|
|
|
;; for user and host, respectively). If the user and host don't
|
|
|
|
|
;; match, it will set directory to a remote one, so it is important to
|
|
|
|
|
;; set user and host correctly first. See the example bash
|
|
|
|
|
;; configuration below.
|
2009-08-16 15:39:11 +00:00
|
|
|
|
;;
|
|
|
|
|
;; ----------------------------------------
|
|
|
|
|
;;
|
2018-05-03 13:29:42 +00:00
|
|
|
|
;; # Set HOSTNAME if not already set.
|
Use ‘echo’ safely with ‘\’ or leading ‘-’
POSIX says that ‘echo FOO’ produces implementation-defined output
if FOO contains leading ‘-’, or ‘\’ anywhere, so don’t assume GNU
behavior in that case.
* Makefile.in (removenullpaths): Remove.
(epaths-force): Rewrite to avoid the need for ‘echo’.
(install-etc): Be clearer about escaping the shell metacharacters
‘\’ and ‘$’.
* Makefile.in (install-arch-indep, install-etcdoc):
* admin/charsets/mapconv, admin/merge-gnulib, admin/merge-pkg-config:
* admin/quick-install-emacs, build-aux/gitlog-to-emacslog:
* configure.ac, lib-src/rcs2log, make-dist:
* src/Makefile.in (lisp.mk):
Don’t assume ‘echo’ outputs ‘\’ and leading ‘-’ unscathed.
For example, use ‘printf '%s\n' "$foo"’ rather than ‘echo "$foo"’
if $foo can contain arbitrary characters.
* lisp/Makefile.in (TAGS): Use ‘ls’, not ‘echo’, to avoid ‘\’ issues.
* doc/lispref/two-volume.make (vol1.pdf):
* test/etags/make-src/Makefile (web ftp publish):
Use ‘printf’ rather than ‘echo -e’.
2015-10-11 01:03:49 +00:00
|
|
|
|
;; : ${HOSTNAME=$(uname -n)}
|
2009-08-16 15:39:11 +00:00
|
|
|
|
;;
|
2018-05-03 13:29:42 +00:00
|
|
|
|
;; # su does not change this but I'd like it to
|
Use ‘echo’ safely with ‘\’ or leading ‘-’
POSIX says that ‘echo FOO’ produces implementation-defined output
if FOO contains leading ‘-’, or ‘\’ anywhere, so don’t assume GNU
behavior in that case.
* Makefile.in (removenullpaths): Remove.
(epaths-force): Rewrite to avoid the need for ‘echo’.
(install-etc): Be clearer about escaping the shell metacharacters
‘\’ and ‘$’.
* Makefile.in (install-arch-indep, install-etcdoc):
* admin/charsets/mapconv, admin/merge-gnulib, admin/merge-pkg-config:
* admin/quick-install-emacs, build-aux/gitlog-to-emacslog:
* configure.ac, lib-src/rcs2log, make-dist:
* src/Makefile.in (lisp.mk):
Don’t assume ‘echo’ outputs ‘\’ and leading ‘-’ unscathed.
For example, use ‘printf '%s\n' "$foo"’ rather than ‘echo "$foo"’
if $foo can contain arbitrary characters.
* lisp/Makefile.in (TAGS): Use ‘ls’, not ‘echo’, to avoid ‘\’ issues.
* doc/lispref/two-volume.make (vol1.pdf):
* test/etags/make-src/Makefile (web ftp publish):
Use ‘printf’ rather than ‘echo -e’.
2015-10-11 01:03:49 +00:00
|
|
|
|
;; USER=$(whoami)
|
2009-08-16 15:39:11 +00:00
|
|
|
|
;;
|
2018-05-03 13:29:42 +00:00
|
|
|
|
;; # ...
|
2009-08-16 15:39:11 +00:00
|
|
|
|
;;
|
Use ‘echo’ safely with ‘\’ or leading ‘-’
POSIX says that ‘echo FOO’ produces implementation-defined output
if FOO contains leading ‘-’, or ‘\’ anywhere, so don’t assume GNU
behavior in that case.
* Makefile.in (removenullpaths): Remove.
(epaths-force): Rewrite to avoid the need for ‘echo’.
(install-etc): Be clearer about escaping the shell metacharacters
‘\’ and ‘$’.
* Makefile.in (install-arch-indep, install-etcdoc):
* admin/charsets/mapconv, admin/merge-gnulib, admin/merge-pkg-config:
* admin/quick-install-emacs, build-aux/gitlog-to-emacslog:
* configure.ac, lib-src/rcs2log, make-dist:
* src/Makefile.in (lisp.mk):
Don’t assume ‘echo’ outputs ‘\’ and leading ‘-’ unscathed.
For example, use ‘printf '%s\n' "$foo"’ rather than ‘echo "$foo"’
if $foo can contain arbitrary characters.
* lisp/Makefile.in (TAGS): Use ‘ls’, not ‘echo’, to avoid ‘\’ issues.
* doc/lispref/two-volume.make (vol1.pdf):
* test/etags/make-src/Makefile (web ftp publish):
Use ‘printf’ rather than ‘echo -e’.
2015-10-11 01:03:49 +00:00
|
|
|
|
;; case $TERM in
|
|
|
|
|
;; eterm*)
|
2009-08-16 15:39:11 +00:00
|
|
|
|
;;
|
Use ‘echo’ safely with ‘\’ or leading ‘-’
POSIX says that ‘echo FOO’ produces implementation-defined output
if FOO contains leading ‘-’, or ‘\’ anywhere, so don’t assume GNU
behavior in that case.
* Makefile.in (removenullpaths): Remove.
(epaths-force): Rewrite to avoid the need for ‘echo’.
(install-etc): Be clearer about escaping the shell metacharacters
‘\’ and ‘$’.
* Makefile.in (install-arch-indep, install-etcdoc):
* admin/charsets/mapconv, admin/merge-gnulib, admin/merge-pkg-config:
* admin/quick-install-emacs, build-aux/gitlog-to-emacslog:
* configure.ac, lib-src/rcs2log, make-dist:
* src/Makefile.in (lisp.mk):
Don’t assume ‘echo’ outputs ‘\’ and leading ‘-’ unscathed.
For example, use ‘printf '%s\n' "$foo"’ rather than ‘echo "$foo"’
if $foo can contain arbitrary characters.
* lisp/Makefile.in (TAGS): Use ‘ls’, not ‘echo’, to avoid ‘\’ issues.
* doc/lispref/two-volume.make (vol1.pdf):
* test/etags/make-src/Makefile (web ftp publish):
Use ‘printf’ rather than ‘echo -e’.
2015-10-11 01:03:49 +00:00
|
|
|
|
;; printf '%s\n' \
|
|
|
|
|
;; -------------------------------------------------------------- \
|
2018-05-03 13:29:42 +00:00
|
|
|
|
;; "Hello $USER" \
|
Use ‘echo’ safely with ‘\’ or leading ‘-’
POSIX says that ‘echo FOO’ produces implementation-defined output
if FOO contains leading ‘-’, or ‘\’ anywhere, so don’t assume GNU
behavior in that case.
* Makefile.in (removenullpaths): Remove.
(epaths-force): Rewrite to avoid the need for ‘echo’.
(install-etc): Be clearer about escaping the shell metacharacters
‘\’ and ‘$’.
* Makefile.in (install-arch-indep, install-etcdoc):
* admin/charsets/mapconv, admin/merge-gnulib, admin/merge-pkg-config:
* admin/quick-install-emacs, build-aux/gitlog-to-emacslog:
* configure.ac, lib-src/rcs2log, make-dist:
* src/Makefile.in (lisp.mk):
Don’t assume ‘echo’ outputs ‘\’ and leading ‘-’ unscathed.
For example, use ‘printf '%s\n' "$foo"’ rather than ‘echo "$foo"’
if $foo can contain arbitrary characters.
* lisp/Makefile.in (TAGS): Use ‘ls’, not ‘echo’, to avoid ‘\’ issues.
* doc/lispref/two-volume.make (vol1.pdf):
* test/etags/make-src/Makefile (web ftp publish):
Use ‘printf’ rather than ‘echo -e’.
2015-10-11 01:03:49 +00:00
|
|
|
|
;; "Today is $(date)" \
|
|
|
|
|
;; "We are on $HOSTNAME running $(uname) under Emacs term mode" \
|
|
|
|
|
;; --------------------------------------------------------------
|
2009-08-16 15:39:11 +00:00
|
|
|
|
;;
|
Use ‘echo’ safely with ‘\’ or leading ‘-’
POSIX says that ‘echo FOO’ produces implementation-defined output
if FOO contains leading ‘-’, or ‘\’ anywhere, so don’t assume GNU
behavior in that case.
* Makefile.in (removenullpaths): Remove.
(epaths-force): Rewrite to avoid the need for ‘echo’.
(install-etc): Be clearer about escaping the shell metacharacters
‘\’ and ‘$’.
* Makefile.in (install-arch-indep, install-etcdoc):
* admin/charsets/mapconv, admin/merge-gnulib, admin/merge-pkg-config:
* admin/quick-install-emacs, build-aux/gitlog-to-emacslog:
* configure.ac, lib-src/rcs2log, make-dist:
* src/Makefile.in (lisp.mk):
Don’t assume ‘echo’ outputs ‘\’ and leading ‘-’ unscathed.
For example, use ‘printf '%s\n' "$foo"’ rather than ‘echo "$foo"’
if $foo can contain arbitrary characters.
* lisp/Makefile.in (TAGS): Use ‘ls’, not ‘echo’, to avoid ‘\’ issues.
* doc/lispref/two-volume.make (vol1.pdf):
* test/etags/make-src/Makefile (web ftp publish):
Use ‘printf’ rather than ‘echo -e’.
2015-10-11 01:03:49 +00:00
|
|
|
|
;; # The \033 stands for ESC.
|
|
|
|
|
;; # There is a space between "AnSiT?" and $whatever.
|
2019-07-25 02:02:59 +00:00
|
|
|
|
;; printf '\033AnSiTh %s\n' "$HOSTNAME"
|
|
|
|
|
;; printf '\033AnSiTu %s\n' "$USER"
|
|
|
|
|
;; printf '\033AnSiTc %s\n' "$PWD"
|
2009-08-16 15:39:11 +00:00
|
|
|
|
;;
|
2020-08-26 10:03:32 +00:00
|
|
|
|
;; cd() { command cd "$@" && printf '\033AnSiTc %s\n' "$PWD"; }
|
|
|
|
|
;; pushd() { command pushd "$@" && printf '\033AnSiTc %s\n' "$PWD"; }
|
|
|
|
|
;; popd() { command popd "$@" && printf '\033AnSiTc %s\n' "$PWD"; }
|
2009-08-16 15:39:11 +00:00
|
|
|
|
;;
|
2018-05-03 13:29:42 +00:00
|
|
|
|
;; # Use custom dircolors in term buffers.
|
|
|
|
|
;; # eval $(dircolors $HOME/.emacs_dircolors)
|
Use ‘echo’ safely with ‘\’ or leading ‘-’
POSIX says that ‘echo FOO’ produces implementation-defined output
if FOO contains leading ‘-’, or ‘\’ anywhere, so don’t assume GNU
behavior in that case.
* Makefile.in (removenullpaths): Remove.
(epaths-force): Rewrite to avoid the need for ‘echo’.
(install-etc): Be clearer about escaping the shell metacharacters
‘\’ and ‘$’.
* Makefile.in (install-arch-indep, install-etcdoc):
* admin/charsets/mapconv, admin/merge-gnulib, admin/merge-pkg-config:
* admin/quick-install-emacs, build-aux/gitlog-to-emacslog:
* configure.ac, lib-src/rcs2log, make-dist:
* src/Makefile.in (lisp.mk):
Don’t assume ‘echo’ outputs ‘\’ and leading ‘-’ unscathed.
For example, use ‘printf '%s\n' "$foo"’ rather than ‘echo "$foo"’
if $foo can contain arbitrary characters.
* lisp/Makefile.in (TAGS): Use ‘ls’, not ‘echo’, to avoid ‘\’ issues.
* doc/lispref/two-volume.make (vol1.pdf):
* test/etags/make-src/Makefile (web ftp publish):
Use ‘printf’ rather than ‘echo -e’.
2015-10-11 01:03:49 +00:00
|
|
|
|
;; esac
|
2009-08-16 15:39:11 +00:00
|
|
|
|
;;
|
2018-05-03 13:29:42 +00:00
|
|
|
|
;; # ...
|
2009-08-16 15:39:11 +00:00
|
|
|
|
;;
|
2019-07-25 02:02:59 +00:00
|
|
|
|
;; For troubleshooting in Bash, you can check the definition of the
|
|
|
|
|
;; custom functions with the "type" command. e.g. "type cd". If you
|
|
|
|
|
;; do not see the expected definition from the config below, then the
|
|
|
|
|
;; directory tracking will not work.
|
1994-10-13 06:30:49 +00:00
|
|
|
|
|
|
|
|
|
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;; Brief Command Documentation:
|
|
|
|
|
;;============================================================================
|
|
|
|
|
;; Term Mode Commands: (common to all derived modes, like cmushell & cmulisp
|
|
|
|
|
;; mode)
|
|
|
|
|
;;
|
2019-07-25 02:02:59 +00:00
|
|
|
|
;; M-p term-previous-input Cycle backwards in input history
|
|
|
|
|
;; M-n term-next-input Cycle forwards
|
|
|
|
|
;; M-r term-previous-matching-input Previous input matching a regexp
|
2020-12-08 22:41:24 +00:00
|
|
|
|
;; M-s term-next-matching-input Next input that matches
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;; return term-send-input
|
2019-07-25 02:02:59 +00:00
|
|
|
|
;; C-c C-a term-bol Beginning of line; skip prompt.
|
|
|
|
|
;; C-d term-delchar-or-maybe-eof Delete char unless at end of buff.
|
|
|
|
|
;; C-c C-u term-kill-input ^u
|
|
|
|
|
;; C-c C-w backward-kill-word ^w
|
|
|
|
|
;; C-c C-c term-interrupt-subjob ^c
|
|
|
|
|
;; C-c C-z term-stop-subjob ^z
|
|
|
|
|
;; C-c C-\ term-quit-subjob ^\
|
|
|
|
|
;; C-c C-o term-kill-output Delete last batch of process output
|
|
|
|
|
;; C-c C-r term-show-output Show last batch of process output
|
|
|
|
|
;; C-c C-h term-dynamic-list-input-ring List input history
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;;
|
|
|
|
|
;; Not bound by default in term-mode
|
|
|
|
|
;; term-send-invisible Read a line w/o echo, and send to proc
|
|
|
|
|
;; (These are bound in shell-mode)
|
|
|
|
|
;; term-dynamic-complete Complete filename at point.
|
|
|
|
|
;; term-dynamic-list-completions List completions in help buffer.
|
|
|
|
|
;; term-replace-by-expanded-filename Expand and complete filename at point;
|
|
|
|
|
;; replace with expanded/completed name.
|
|
|
|
|
;; term-kill-subjob No mercy.
|
2019-07-25 02:02:59 +00:00
|
|
|
|
;; term-show-maximum-output Show as much output as possible.
|
|
|
|
|
;; term-continue-subjob Send CONT signal to buffer's process
|
1997-04-02 03:46:39 +00:00
|
|
|
|
;; group. Useful if you accidentally
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;; suspend your process (with C-c C-z).
|
|
|
|
|
|
1997-04-02 03:46:39 +00:00
|
|
|
|
;; term-mode-hook is the term mode hook. Basically for your keybindings.
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;; term-load-hook is run after loading in this package.
|
|
|
|
|
|
2001-07-15 19:53:53 +00:00
|
|
|
|
;;; Code:
|
1996-01-14 07:34:30 +00:00
|
|
|
|
|
|
|
|
|
;; This is passed to the inferior in the EMACS environment variable,
|
|
|
|
|
;; so it is important to increase it if there are protocol-relevant changes.
|
2004-09-17 21:07:12 +00:00
|
|
|
|
(defconst term-protocol-version "0.96")
|
1994-10-13 06:30:49 +00:00
|
|
|
|
|
2020-04-17 09:27:36 +00:00
|
|
|
|
(eval-when-compile
|
|
|
|
|
(require 'ange-ftp)
|
|
|
|
|
(require 'cl-lib))
|
2018-02-15 00:09:50 +00:00
|
|
|
|
(require 'comint) ; Password regexp.
|
2021-09-25 21:28:08 +00:00
|
|
|
|
(require 'ansi-color)
|
2020-04-17 09:27:36 +00:00
|
|
|
|
(require 'ehelp)
|
|
|
|
|
(require 'ring)
|
|
|
|
|
(require 'shell)
|
lisp/*.el: Add missing declarations.
* descr-text.el (quail-find-key):
* dired.el (desktop-file-name):
* dirtrack.el (shell-prefixed-directory-name, shell-process-cd):
* generic-x.el (comint-mode, comint-exec):
* image-dired.el (widget-forward):
* info.el (speedbar-add-expansion-list, speedbar-center-buffer-smartly)
(speedbar-change-expand-button-char)
(speedbar-change-initial-expansion-list, speedbar-delete-subblock)
(speedbar-make-specialized-keymap, speedbar-make-tag-line):
* printing.el (easy-menu-add-item, easy-menu-remove-item)
(widget-field-action, widget-value-set):
* speedbar.el (imenu--make-index-alist):
* term.el (ring-empty-p, ring-ref, ring-insert-at-beginning)
(ring-length, ring-insert):
* vcursor.el (compare-windows-skip-whitespace):
* woman.el (dired-get-filename):
Declare functions.
* term/w32-win.el (cygwin-convert-path-from-windows): Fix declaration.
2012-11-17 21:52:12 +00:00
|
|
|
|
|
1997-04-12 02:51:38 +00:00
|
|
|
|
(defgroup term nil
|
2005-07-04 02:35:55 +00:00
|
|
|
|
"General command interpreter in a window."
|
2007-08-07 03:05:06 +00:00
|
|
|
|
:group 'processes)
|
1997-04-12 02:51:38 +00:00
|
|
|
|
|
1994-10-13 06:30:49 +00:00
|
|
|
|
|
|
|
|
|
;;; Buffer Local Variables:
|
2009-08-16 15:39:11 +00:00
|
|
|
|
;;============================================================================
|
|
|
|
|
;; Term mode buffer local variables:
|
|
|
|
|
;; term-prompt-regexp - string term-bol uses to match prompt.
|
|
|
|
|
;; term-delimiter-argument-list - list For delimiters and arguments
|
|
|
|
|
;; term-last-input-start - marker Handy if inferior always echoes
|
|
|
|
|
;; term-last-input-end - marker For term-kill-output command
|
1995-02-06 21:56:37 +00:00
|
|
|
|
;; For the input history mechanism:
|
|
|
|
|
(defvar term-input-ring-size 32 "Size of input history ring.")
|
2009-08-16 15:39:11 +00:00
|
|
|
|
;; term-input-ring-size - integer
|
|
|
|
|
;; term-input-ring - ring
|
|
|
|
|
;; term-input-ring-index - number ...
|
|
|
|
|
;; term-input-autoexpand - symbol ...
|
|
|
|
|
;; term-input-ignoredups - boolean ...
|
|
|
|
|
;; term-last-input-match - string ...
|
|
|
|
|
;; term-dynamic-complete-functions - hook For the completion mechanism
|
|
|
|
|
;; term-completion-fignore - list ...
|
|
|
|
|
;; term-get-old-input - function Hooks for specific
|
|
|
|
|
;; term-input-filter-functions - hook process-in-a-buffer
|
|
|
|
|
;; term-input-filter - function modes.
|
|
|
|
|
;; term-input-send - function
|
|
|
|
|
;; term-scroll-to-bottom-on-output - symbol ...
|
|
|
|
|
;; term-scroll-show-maximum-output - boolean...
|
|
|
|
|
(defvar term-height) ; Number of lines in window.
|
|
|
|
|
(defvar term-width) ; Number of columns in window.
|
|
|
|
|
(defvar term-home-marker) ; Marks the "home" position for cursor addressing.
|
|
|
|
|
(defvar term-saved-home-marker nil
|
|
|
|
|
"When using alternate sub-buffer,
|
2021-09-22 18:26:40 +00:00
|
|
|
|
contains saved `term-home-marker' from original sub-buffer.")
|
2009-08-16 15:39:11 +00:00
|
|
|
|
(defvar term-start-line-column 0
|
|
|
|
|
"(current-column) at start of screen line, or nil if unknown.")
|
|
|
|
|
(defvar term-current-column 0 "If non-nil, is cache for (current-column).")
|
|
|
|
|
(defvar term-current-row 0
|
|
|
|
|
"Current vertical row (relative to home-marker) or nil if unknown.")
|
1995-02-06 21:56:37 +00:00
|
|
|
|
(defvar term-insert-mode nil)
|
|
|
|
|
(defvar term-vertical-motion)
|
2018-01-18 13:22:47 +00:00
|
|
|
|
(defvar term-do-line-wrapping nil
|
|
|
|
|
"Last character was a graphic in the last column.
|
2009-08-16 15:39:11 +00:00
|
|
|
|
If next char is graphic, first move one column right
|
|
|
|
|
\(and line warp) before displaying it.
|
2018-01-18 13:22:47 +00:00
|
|
|
|
This emulates (more or less) the behavior of xterm.")
|
2009-08-16 15:39:11 +00:00
|
|
|
|
(defvar term-kill-echo-list nil
|
|
|
|
|
"A queue of strings whose echo we want suppressed.")
|
2016-12-29 01:13:20 +00:00
|
|
|
|
(defvar term-terminal-undecoded-bytes nil)
|
2012-11-10 01:40:48 +00:00
|
|
|
|
(defvar term-current-face 'term)
|
2019-04-29 17:53:38 +00:00
|
|
|
|
(defvar-local term-scroll-start 0
|
|
|
|
|
"Top-most line (inclusive) of the scrolling region.
|
|
|
|
|
`term-scroll-start' must be in the range [0,term-height). In addition, its
|
|
|
|
|
value has to be smaller than `term-scroll-end', i.e. one line scroll regions are
|
|
|
|
|
not allowed.")
|
|
|
|
|
(defvar-local term-scroll-end nil
|
|
|
|
|
"Bottom-most line (inclusive) of the scrolling region.
|
|
|
|
|
`term-scroll-end' must be in the range [0,term-height). In addition, its
|
2020-12-19 16:35:50 +00:00
|
|
|
|
value has to be greater than `term-scroll-start', i.e. one line scroll regions
|
|
|
|
|
are not allowed.")
|
2009-08-16 15:39:11 +00:00
|
|
|
|
(defvar term-pager-count nil
|
|
|
|
|
"Number of lines before we need to page; if nil, paging is disabled.")
|
1995-02-06 21:56:37 +00:00
|
|
|
|
(defvar term-saved-cursor nil)
|
2019-02-24 21:19:59 +00:00
|
|
|
|
(define-obsolete-variable-alias 'term-command-hook
|
|
|
|
|
'term-command-function "27.1")
|
|
|
|
|
(defvar term-command-function #'term-command-hook)
|
1995-02-06 21:56:37 +00:00
|
|
|
|
(defvar term-log-buffer nil)
|
2009-08-16 15:39:11 +00:00
|
|
|
|
(defvar term-scroll-with-delete nil
|
|
|
|
|
"If t, forward scrolling should be implemented by delete to
|
|
|
|
|
top-most line(s); and if nil, scrolling should be implemented
|
2021-09-22 18:26:40 +00:00
|
|
|
|
by moving `term-home-marker'. It is set to t if there is a
|
2009-08-16 15:39:11 +00:00
|
|
|
|
\(non-default) scroll-region OR the alternate buffer is used.")
|
|
|
|
|
(defvar term-pending-delete-marker) ; New user input in line mode
|
|
|
|
|
; needs to be deleted, because it gets echoed by the inferior.
|
|
|
|
|
; To reduce flicker, we defer the delete until the next output.
|
|
|
|
|
(defvar term-old-mode-map nil "Saves the old keymap when in char mode.")
|
|
|
|
|
(defvar term-old-mode-line-format) ; Saves old mode-line-format while paging.
|
|
|
|
|
(defvar term-pager-old-local-map nil "Saves old keymap while paging.")
|
|
|
|
|
(defvar term-pager-old-filter) ; Saved process-filter while paging.
|
2017-10-21 08:17:56 +00:00
|
|
|
|
(defvar-local term-line-mode-buffer-read-only nil
|
|
|
|
|
"The `buffer-read-only' state to set in `term-line-mode'.")
|
1994-10-13 06:30:49 +00:00
|
|
|
|
|
|
|
|
|
(defvar term-prompt-regexp "^"
|
2005-06-16 16:11:46 +00:00
|
|
|
|
"Regexp to recognize prompts in the inferior process.
|
1994-10-13 06:30:49 +00:00
|
|
|
|
Defaults to \"^\", the null string at BOL.
|
|
|
|
|
|
|
|
|
|
Good choices:
|
|
|
|
|
Canonical Lisp: \"^[^> \\n]*>+:? *\" (Lucid, franz, kcl, T, cscheme, oaklisp)
|
|
|
|
|
Lucid Common Lisp: \"^\\\\(>\\\\|\\\\(->\\\\)+\\\\) *\"
|
|
|
|
|
franz: \"^\\\\(->\\\\|<[0-9]*>:\\\\) *\"
|
|
|
|
|
kcl: \"^>+ *\"
|
|
|
|
|
shell: \"^[^#$%>\\n]*[#$%>] *\"
|
|
|
|
|
T: \"^>+ *\"
|
|
|
|
|
|
|
|
|
|
This is a good thing to set in mode hooks.")
|
|
|
|
|
|
|
|
|
|
(defvar term-delimiter-argument-list ()
|
2005-06-16 16:11:46 +00:00
|
|
|
|
"List of characters to recognize as separate arguments in input.
|
1994-10-13 06:30:49 +00:00
|
|
|
|
Strings comprising a character in this list will separate the arguments
|
2010-08-02 04:14:26 +00:00
|
|
|
|
surrounding them, and also be regarded as arguments in their own right
|
|
|
|
|
\(unlike whitespace). See `term-arguments'.
|
1994-10-13 06:30:49 +00:00
|
|
|
|
Defaults to the empty list.
|
|
|
|
|
|
1998-09-23 23:36:59 +00:00
|
|
|
|
For shells, a good value is (?\\| ?& ?< ?> ?\\( ?\\) ?\\;).
|
1994-10-13 06:30:49 +00:00
|
|
|
|
|
|
|
|
|
This is a good thing to set in mode hooks.")
|
|
|
|
|
|
1997-04-12 02:51:38 +00:00
|
|
|
|
(defcustom term-input-autoexpand nil
|
2008-12-03 05:48:14 +00:00
|
|
|
|
"If non-nil, expand input command history references on completion.
|
1994-10-13 06:30:49 +00:00
|
|
|
|
This mirrors the optional behavior of tcsh (its autoexpand and histlit).
|
|
|
|
|
|
|
|
|
|
If the value is `input', then the expansion is seen on input.
|
|
|
|
|
If the value is `history', then the expansion is only when inserting
|
|
|
|
|
into the buffer's input ring. See also `term-magic-space' and
|
|
|
|
|
`term-dynamic-complete'.
|
|
|
|
|
|
1997-04-12 02:51:38 +00:00
|
|
|
|
This variable is buffer-local."
|
|
|
|
|
:type '(choice (const nil) (const t) (const input) (const history))
|
|
|
|
|
:group 'term)
|
1994-10-13 06:30:49 +00:00
|
|
|
|
|
1997-04-12 02:51:38 +00:00
|
|
|
|
(defcustom term-input-ignoredups nil
|
2008-12-03 05:48:14 +00:00
|
|
|
|
"If non-nil, don't add input matching the last on the input ring.
|
1994-10-13 06:30:49 +00:00
|
|
|
|
This mirrors the optional behavior of bash.
|
|
|
|
|
|
1997-04-12 02:51:38 +00:00
|
|
|
|
This variable is buffer-local."
|
|
|
|
|
:type 'boolean
|
|
|
|
|
:group 'term)
|
1994-10-13 06:30:49 +00:00
|
|
|
|
|
1997-04-12 02:51:38 +00:00
|
|
|
|
(defcustom term-input-ring-file-name nil
|
2008-12-03 05:48:14 +00:00
|
|
|
|
"If non-nil, name of the file to read/write input history.
|
1994-10-13 06:30:49 +00:00
|
|
|
|
See also `term-read-input-ring' and `term-write-input-ring'.
|
|
|
|
|
|
1997-04-12 02:51:38 +00:00
|
|
|
|
This variable is buffer-local, and is a good thing to set in mode hooks."
|
|
|
|
|
:type 'boolean
|
|
|
|
|
:group 'term)
|
1994-10-13 06:30:49 +00:00
|
|
|
|
|
2017-10-21 08:17:56 +00:00
|
|
|
|
(defcustom term-char-mode-buffer-read-only t
|
|
|
|
|
"If non-nil, only the process filter may modify the buffer in char mode.
|
|
|
|
|
|
|
|
|
|
A non-nil value makes the buffer read-only in `term-char-mode',
|
|
|
|
|
which prevents editing commands from making the buffer state
|
|
|
|
|
inconsistent with the state of the terminal understood by the
|
|
|
|
|
inferior process. Only the process filter is allowed to make
|
|
|
|
|
changes to the buffer.
|
|
|
|
|
|
2018-03-05 01:09:52 +00:00
|
|
|
|
Customize this option to nil if you want the previous behavior."
|
2017-10-21 08:17:56 +00:00
|
|
|
|
:version "26.1"
|
|
|
|
|
:type 'boolean
|
|
|
|
|
:group 'term)
|
|
|
|
|
|
2020-08-15 12:35:16 +00:00
|
|
|
|
(defcustom term-set-terminal-size nil
|
|
|
|
|
"If non-nil, set the LINES and COLUMNS environment variables."
|
|
|
|
|
:type 'boolean
|
|
|
|
|
:version "28.1")
|
|
|
|
|
|
2017-10-21 08:17:56 +00:00
|
|
|
|
(defcustom term-char-mode-point-at-process-mark t
|
|
|
|
|
"If non-nil, keep point at the process mark in char mode.
|
|
|
|
|
|
|
|
|
|
A non-nil value causes point to be moved to the current process
|
|
|
|
|
mark after each command in `term-char-mode' (provided that the
|
|
|
|
|
pre-command point position was also at the process mark). This
|
|
|
|
|
prevents commands that move point from making the buffer state
|
|
|
|
|
inconsistent with the state of the terminal understood by the
|
|
|
|
|
inferior process.
|
|
|
|
|
|
|
|
|
|
Mouse events are not affected, so moving point and selecting text
|
|
|
|
|
is still possible in char mode via the mouse, after which other
|
|
|
|
|
commands can be invoked on the mouse-selected point or region,
|
|
|
|
|
until the process filter (or user) moves point to the process
|
|
|
|
|
mark once again.
|
|
|
|
|
|
2018-03-05 01:09:52 +00:00
|
|
|
|
Customize this option to nil if you want the previous behavior."
|
2017-10-21 08:17:56 +00:00
|
|
|
|
:version "26.1"
|
|
|
|
|
:type 'boolean
|
|
|
|
|
:group 'term)
|
|
|
|
|
|
1997-04-12 02:51:38 +00:00
|
|
|
|
(defcustom term-scroll-to-bottom-on-output nil
|
2008-12-03 05:48:14 +00:00
|
|
|
|
"Controls whether interpreter output causes window to scroll.
|
1994-10-13 06:30:49 +00:00
|
|
|
|
If nil, then do not scroll. If t or `all', scroll all windows showing buffer.
|
|
|
|
|
If `this', scroll only the selected window.
|
|
|
|
|
If `others', scroll only those that are not the selected window.
|
|
|
|
|
|
|
|
|
|
The default is nil.
|
|
|
|
|
|
|
|
|
|
See variable `term-scroll-show-maximum-output'.
|
1997-04-12 02:51:38 +00:00
|
|
|
|
This variable is buffer-local."
|
|
|
|
|
:type 'boolean
|
|
|
|
|
:group 'term)
|
1994-10-13 06:30:49 +00:00
|
|
|
|
|
2020-08-13 11:02:17 +00:00
|
|
|
|
(defcustom term-scroll-snap-to-bottom t
|
|
|
|
|
"Control whether to keep the prompt at the bottom of the window.
|
|
|
|
|
If non-nil, when the prompt is visible within the window, then
|
|
|
|
|
scroll so that the prompt is on the bottom on any input or
|
|
|
|
|
output."
|
2020-08-13 16:28:21 +00:00
|
|
|
|
:version "28.1"
|
2020-08-13 11:02:17 +00:00
|
|
|
|
:type 'boolean)
|
|
|
|
|
|
1997-04-12 02:51:38 +00:00
|
|
|
|
(defcustom term-scroll-show-maximum-output nil
|
2008-12-03 05:48:14 +00:00
|
|
|
|
"Controls how interpreter output causes window to scroll.
|
1994-10-13 06:30:49 +00:00
|
|
|
|
If non-nil, then show the maximum output when the window is scrolled.
|
|
|
|
|
|
|
|
|
|
See variable `term-scroll-to-bottom-on-output'.
|
1997-04-12 02:51:38 +00:00
|
|
|
|
This variable is buffer-local."
|
|
|
|
|
:type 'boolean
|
|
|
|
|
:group 'term)
|
1994-10-13 06:30:49 +00:00
|
|
|
|
|
2013-06-13 05:27:05 +00:00
|
|
|
|
(defcustom term-suppress-hard-newline nil
|
|
|
|
|
"Non-nil means interpreter should not break long lines with newlines.
|
|
|
|
|
This means text can automatically reflow if the window is resized."
|
|
|
|
|
:version "24.4"
|
|
|
|
|
:type 'boolean
|
|
|
|
|
:group 'term)
|
2019-01-21 00:08:17 +00:00
|
|
|
|
(make-obsolete-variable 'term-suppress-hard-newline nil
|
2019-02-24 21:19:59 +00:00
|
|
|
|
"27.1")
|
2013-06-13 05:27:05 +00:00
|
|
|
|
|
2022-01-23 20:13:24 +00:00
|
|
|
|
(defcustom term-clear-full-screen-programs t
|
2022-01-25 11:51:23 +00:00
|
|
|
|
"Whether to clear contents of full-screen terminal programs after exit.
|
|
|
|
|
If non-nil, output of full-screen terminal programs is cleared after
|
2022-01-23 20:13:24 +00:00
|
|
|
|
exiting them. Note however that a minority of such programs
|
|
|
|
|
don't send an appropriate escape sequence to the terminal before
|
|
|
|
|
exiting so their output isn't cleared regardless of this option."
|
|
|
|
|
:version "29.1"
|
|
|
|
|
:type 'boolean
|
|
|
|
|
:group 'term)
|
|
|
|
|
|
1994-10-13 06:30:49 +00:00
|
|
|
|
;; Where gud-display-frame should put the debugging arrow. This is
|
|
|
|
|
;; set by the marker-filter, which scans the debugger's output for
|
|
|
|
|
;; indications of the current pc.
|
|
|
|
|
(defvar term-pending-frame nil)
|
|
|
|
|
|
|
|
|
|
;;; Here are the per-interpreter hooks.
|
|
|
|
|
(defvar term-get-old-input (function term-get-old-input-default)
|
|
|
|
|
"Function that submits old text in term mode.
|
|
|
|
|
This function is called when return is typed while the point is in old text.
|
|
|
|
|
It returns the text to be submitted as process input. The default is
|
2005-06-17 14:37:55 +00:00
|
|
|
|
`term-get-old-input-default', which grabs the current line, and strips off
|
|
|
|
|
leading text matching `term-prompt-regexp'.")
|
1994-10-13 06:30:49 +00:00
|
|
|
|
|
|
|
|
|
(defvar term-dynamic-complete-functions
|
|
|
|
|
'(term-replace-by-expanded-history term-dynamic-complete-filename)
|
|
|
|
|
"List of functions called to perform completion.
|
|
|
|
|
Functions should return non-nil if completion was performed.
|
|
|
|
|
See also `term-dynamic-complete'.
|
|
|
|
|
|
|
|
|
|
This is a good thing to set in mode hooks.")
|
|
|
|
|
|
|
|
|
|
(defvar term-input-filter
|
2020-09-30 14:18:50 +00:00
|
|
|
|
(lambda (str) (not (string-match "\\`\\s *\\'" str)))
|
1994-10-13 06:30:49 +00:00
|
|
|
|
"Predicate for filtering additions to input history.
|
|
|
|
|
Only inputs answering true to this function are saved on the input
|
2005-06-17 14:37:55 +00:00
|
|
|
|
history list. Default is to save anything that isn't all whitespace.")
|
1994-10-13 06:30:49 +00:00
|
|
|
|
|
|
|
|
|
(defvar term-input-filter-functions '()
|
|
|
|
|
"Functions to call before input is sent to the process.
|
|
|
|
|
These functions get one argument, a string containing the text to send.
|
|
|
|
|
|
|
|
|
|
This variable is buffer-local.")
|
|
|
|
|
|
2019-02-24 21:19:59 +00:00
|
|
|
|
(defvar term-input-sender #'term-simple-send
|
1994-10-13 06:30:49 +00:00
|
|
|
|
"Function to actually send to PROCESS the STRING submitted by user.
|
2005-06-17 14:37:55 +00:00
|
|
|
|
Usually this is just `term-simple-send', but if your mode needs to
|
1997-04-02 03:46:39 +00:00
|
|
|
|
massage the input string, this is your hook. This is called from
|
2005-06-17 14:37:55 +00:00
|
|
|
|
the user command `term-send-input'. `term-simple-send' just sends
|
1994-10-13 06:30:49 +00:00
|
|
|
|
the string plus a newline.")
|
|
|
|
|
|
1997-04-12 02:51:38 +00:00
|
|
|
|
(defcustom term-eol-on-send t
|
2008-12-03 05:48:14 +00:00
|
|
|
|
"Non-nil means go to the end of the line before sending input.
|
1997-04-12 02:51:38 +00:00
|
|
|
|
See `term-send-input'."
|
|
|
|
|
:type 'boolean
|
|
|
|
|
:group 'term)
|
1995-03-08 00:54:20 +00:00
|
|
|
|
|
1997-04-12 02:51:38 +00:00
|
|
|
|
(defcustom term-mode-hook '()
|
2005-06-17 14:37:55 +00:00
|
|
|
|
"Called upon entry into term mode.
|
1997-04-12 02:51:38 +00:00
|
|
|
|
This is run before the process is cranked up."
|
|
|
|
|
:type 'hook
|
|
|
|
|
:group 'term)
|
1994-10-13 06:30:49 +00:00
|
|
|
|
|
1997-04-12 02:51:38 +00:00
|
|
|
|
(defcustom term-exec-hook '()
|
2005-06-17 14:37:55 +00:00
|
|
|
|
"Called each time a process is exec'd by `term-exec'.
|
1994-10-13 06:30:49 +00:00
|
|
|
|
This is called after the process is cranked up. It is useful for things that
|
2005-06-17 14:37:55 +00:00
|
|
|
|
must be done each time a process is executed in a term mode buffer (e.g.,
|
2018-03-09 01:18:18 +00:00
|
|
|
|
`set-process-query-on-exit-flag'). In contrast, `term-mode-hook' is only
|
|
|
|
|
executed once, when the buffer is created."
|
1997-04-12 02:51:38 +00:00
|
|
|
|
:type 'hook
|
|
|
|
|
:group 'term)
|
1994-10-13 06:30:49 +00:00
|
|
|
|
|
2008-12-03 05:48:14 +00:00
|
|
|
|
(defvar term-mode-map
|
2008-03-05 04:09:24 +00:00
|
|
|
|
(let ((map (make-sparse-keymap)))
|
|
|
|
|
(define-key map "\ep" 'term-previous-input)
|
|
|
|
|
(define-key map "\en" 'term-next-input)
|
|
|
|
|
(define-key map "\er" 'term-previous-matching-input)
|
|
|
|
|
(define-key map "\es" 'term-next-matching-input)
|
2019-09-14 13:15:27 +00:00
|
|
|
|
(define-key map [?\A-\M-r]
|
|
|
|
|
'term-previous-matching-input-from-input)
|
|
|
|
|
(define-key map [?\A-\M-s] 'term-next-matching-input-from-input)
|
2008-03-05 04:09:24 +00:00
|
|
|
|
(define-key map "\e\C-l" 'term-show-output)
|
|
|
|
|
(define-key map "\C-m" 'term-send-input)
|
|
|
|
|
(define-key map "\C-d" 'term-delchar-or-maybe-eof)
|
|
|
|
|
(define-key map "\C-c\C-a" 'term-bol)
|
|
|
|
|
(define-key map "\C-c\C-u" 'term-kill-input)
|
|
|
|
|
(define-key map "\C-c\C-w" 'backward-kill-word)
|
|
|
|
|
(define-key map "\C-c\C-c" 'term-interrupt-subjob)
|
|
|
|
|
(define-key map "\C-c\C-z" 'term-stop-subjob)
|
|
|
|
|
(define-key map "\C-c\C-\\" 'term-quit-subjob)
|
|
|
|
|
(define-key map "\C-c\C-m" 'term-copy-old-input)
|
|
|
|
|
(define-key map "\C-c\C-o" 'term-kill-output)
|
|
|
|
|
(define-key map "\C-c\C-r" 'term-show-output)
|
|
|
|
|
(define-key map "\C-c\C-e" 'term-show-maximum-output)
|
|
|
|
|
(define-key map "\C-c\C-l" 'term-dynamic-list-input-ring)
|
|
|
|
|
(define-key map "\C-c\C-n" 'term-next-prompt)
|
|
|
|
|
(define-key map "\C-c\C-p" 'term-previous-prompt)
|
|
|
|
|
(define-key map "\C-c\C-d" 'term-send-eof)
|
|
|
|
|
(define-key map "\C-c\C-k" 'term-char-mode)
|
|
|
|
|
(define-key map "\C-c\C-j" 'term-line-mode)
|
|
|
|
|
(define-key map "\C-c\C-q" 'term-pager-toggle)
|
2012-09-01 22:03:06 +00:00
|
|
|
|
;; completion: (line mode only)
|
|
|
|
|
(easy-menu-define nil map "Complete menu for Term mode."
|
|
|
|
|
'("Complete"
|
|
|
|
|
["Complete Before Point" term-dynamic-complete t]
|
|
|
|
|
["Complete File Name" term-dynamic-complete-filename t]
|
|
|
|
|
["File Completion Listing" term-dynamic-list-filename-completions t]
|
|
|
|
|
["Expand File Name" term-replace-by-expanded-filename t]))
|
2012-05-11 15:05:03 +00:00
|
|
|
|
;; Input history: (line mode only)
|
2012-09-01 22:03:06 +00:00
|
|
|
|
(easy-menu-define nil map "In/Out menu for Term mode."
|
|
|
|
|
'("In/Out"
|
|
|
|
|
["Expand History Before Point" term-replace-by-expanded-history
|
|
|
|
|
term-input-autoexpand]
|
|
|
|
|
["List Input History" term-dynamic-list-input-ring t]
|
|
|
|
|
["Previous Input" term-previous-input t]
|
|
|
|
|
["Next Input" term-next-input t]
|
|
|
|
|
["Previous Matching Current Input"
|
|
|
|
|
term-previous-matching-input-from-input t]
|
|
|
|
|
["Next Matching Current Input" term-next-matching-input-from-input t]
|
|
|
|
|
["Previous Matching Input..." term-previous-matching-input t]
|
|
|
|
|
["Next Matching Input..." term-next-matching-input t]
|
|
|
|
|
["Backward Matching Input..." term-backward-matching-input t]
|
|
|
|
|
["Forward Matching Input..." term-forward-matching-input t]
|
|
|
|
|
["Copy Old Input" term-copy-old-input t]
|
|
|
|
|
["Kill Current Input" term-kill-input t]
|
|
|
|
|
["Show Current Output Group" term-show-output t]
|
|
|
|
|
["Show Maximum Output" term-show-maximum-output t]
|
|
|
|
|
["Backward Output Group" term-previous-prompt t]
|
|
|
|
|
["Forward Output Group" term-next-prompt t]
|
|
|
|
|
["Kill Current Output Group" term-kill-output t]))
|
|
|
|
|
map)
|
|
|
|
|
"Keymap for Term mode.")
|
2008-03-05 04:09:24 +00:00
|
|
|
|
|
1995-06-14 22:30:16 +00:00
|
|
|
|
(defvar term-escape-char nil
|
2005-06-17 14:37:55 +00:00
|
|
|
|
"Escape character for char sub-mode of term mode.
|
(term-buffer-maximum-size, term-exec, term-escape-char, term-set-escape-char,
term-termcap-format, term-get-old-input-default, term-skip-prompt,
term-send-string, term-send-region, term-pager-page, term-pager-help):
Fix typos in docstrings.
2007-04-13 09:00:41 +00:00
|
|
|
|
Do not change it directly; use `term-set-escape-char' instead.")
|
1994-10-13 06:30:49 +00:00
|
|
|
|
|
2012-09-01 22:03:06 +00:00
|
|
|
|
(defvar term-pager-break-map
|
|
|
|
|
(let ((map (make-keymap)))
|
|
|
|
|
;; (dotimes (i 128)
|
|
|
|
|
;; (define-key map (make-string 1 i) 'term-send-raw))
|
|
|
|
|
(define-key map "\e" (lookup-key (current-global-map) "\e"))
|
|
|
|
|
(define-key map "\C-x" (lookup-key (current-global-map) "\C-x"))
|
|
|
|
|
(define-key map "\C-u" (lookup-key (current-global-map) "\C-u"))
|
|
|
|
|
(define-key map " " 'term-pager-page)
|
|
|
|
|
(define-key map "\r" 'term-pager-line)
|
|
|
|
|
(define-key map "?" 'term-pager-help)
|
|
|
|
|
(define-key map "h" 'term-pager-help)
|
|
|
|
|
(define-key map "b" 'term-pager-back-page)
|
|
|
|
|
(define-key map "\177" 'term-pager-back-line)
|
|
|
|
|
(define-key map "q" 'term-pager-discard)
|
|
|
|
|
(define-key map "D" 'term-pager-disable)
|
|
|
|
|
(define-key map "<" 'term-pager-bob)
|
|
|
|
|
(define-key map ">" 'term-pager-eob)
|
|
|
|
|
map)
|
|
|
|
|
"Keymap used in Term pager mode.")
|
1994-10-13 06:30:49 +00:00
|
|
|
|
|
|
|
|
|
(defvar term-ptyp t
|
2021-09-22 18:26:40 +00:00
|
|
|
|
"Non-nil if communications via pty; false if by pipe. Buffer local.
|
1997-04-02 03:46:39 +00:00
|
|
|
|
This is to work around a bug in Emacs process signaling.")
|
1994-10-13 06:30:49 +00:00
|
|
|
|
|
|
|
|
|
(defvar term-last-input-match ""
|
|
|
|
|
"Last string searched for by term input history search, for defaulting.
|
1997-04-02 03:46:39 +00:00
|
|
|
|
Buffer local variable.")
|
1994-10-13 06:30:49 +00:00
|
|
|
|
|
|
|
|
|
(defvar term-input-ring nil)
|
|
|
|
|
(defvar term-last-input-start)
|
|
|
|
|
(defvar term-last-input-end)
|
|
|
|
|
(defvar term-input-ring-index nil
|
|
|
|
|
"Index of last matched history element.")
|
|
|
|
|
(defvar term-matching-input-from-input-string ""
|
|
|
|
|
"Input previously used to match input history.")
|
2021-02-04 03:53:02 +00:00
|
|
|
|
; This argument to set-process-filter disables reading from the process.
|
1994-10-13 06:30:49 +00:00
|
|
|
|
(defvar term-pager-filter t)
|
|
|
|
|
|
|
|
|
|
(put 'term-input-ring 'permanent-local t)
|
|
|
|
|
(put 'term-input-ring-index 'permanent-local t)
|
|
|
|
|
(put 'term-input-autoexpand 'permanent-local t)
|
|
|
|
|
(put 'term-input-filter-functions 'permanent-local t)
|
|
|
|
|
(put 'term-scroll-to-bottom-on-output 'permanent-local t)
|
|
|
|
|
(put 'term-scroll-show-maximum-output 'permanent-local t)
|
|
|
|
|
(put 'term-ptyp 'permanent-local t)
|
|
|
|
|
|
|
|
|
|
(defmacro term-in-char-mode () '(eq (current-local-map) term-raw-map))
|
|
|
|
|
(defmacro term-in-line-mode () '(not (term-in-char-mode)))
|
1995-02-06 21:56:37 +00:00
|
|
|
|
;; True if currently doing PAGER handling.
|
|
|
|
|
(defmacro term-pager-enabled () 'term-pager-count)
|
|
|
|
|
(defmacro term-handling-pager () 'term-pager-old-local-map)
|
|
|
|
|
(defmacro term-using-alternate-sub-buffer () 'term-saved-home-marker)
|
|
|
|
|
|
2009-08-16 15:39:11 +00:00
|
|
|
|
;; Let's silence the byte-compiler -mm
|
1997-04-02 03:46:39 +00:00
|
|
|
|
(defvar term-ansi-at-host nil)
|
|
|
|
|
(defvar term-ansi-at-dir nil)
|
|
|
|
|
(defvar term-ansi-at-user nil)
|
|
|
|
|
(defvar term-ansi-at-message nil)
|
|
|
|
|
(defvar term-ansi-at-save-user nil)
|
|
|
|
|
(defvar term-ansi-at-save-pwd nil)
|
|
|
|
|
(defvar term-ansi-at-save-anon nil)
|
2005-04-11 20:47:25 +00:00
|
|
|
|
(defvar term-ansi-current-bold nil)
|
2021-09-27 13:15:57 +00:00
|
|
|
|
(defvar term-ansi-current-faint nil)
|
|
|
|
|
(defvar term-ansi-current-italic nil)
|
|
|
|
|
(defvar term-ansi-current-underline nil)
|
|
|
|
|
(defvar term-ansi-current-slow-blink nil)
|
|
|
|
|
(defvar term-ansi-current-fast-blink nil)
|
1997-04-02 03:46:39 +00:00
|
|
|
|
(defvar term-ansi-current-color 0)
|
2005-04-11 20:47:25 +00:00
|
|
|
|
(defvar term-ansi-face-already-done nil)
|
1997-04-02 03:46:39 +00:00
|
|
|
|
(defvar term-ansi-current-bg-color 0)
|
2005-04-11 20:47:25 +00:00
|
|
|
|
(defvar term-ansi-current-reverse nil)
|
|
|
|
|
(defvar term-ansi-current-invisible nil)
|
1997-04-02 03:46:39 +00:00
|
|
|
|
|
2021-09-25 21:28:08 +00:00
|
|
|
|
(make-obsolete-variable 'term-ansi-face-already-done
|
2021-10-05 09:14:22 +00:00
|
|
|
|
"it doesn't have any effect." "29.1")
|
2021-09-25 21:28:08 +00:00
|
|
|
|
|
2012-06-28 10:40:24 +00:00
|
|
|
|
;;; Faces
|
|
|
|
|
(defvar ansi-term-color-vector
|
2012-11-10 01:40:48 +00:00
|
|
|
|
[term
|
2012-06-28 10:40:24 +00:00
|
|
|
|
term-color-black
|
|
|
|
|
term-color-red
|
|
|
|
|
term-color-green
|
|
|
|
|
term-color-yellow
|
|
|
|
|
term-color-blue
|
|
|
|
|
term-color-magenta
|
|
|
|
|
term-color-cyan
|
Add support for "bright" ANSI colors in term-mode
* list/term.el (ansi-term-color-vector): Add new faces.
(term-color-black, term-color-red, term-color-green, term-color-yellow)
(term-color-blue, term-color-magenta, term-color-cyan, term-color-white):
Inherit from 'ansi-color-COLOR'.
(term-color-bright-black, term-color-bright-red, term-color-bright-green)
(term-color-bright-yellow, term-color-bright-blue)
(term-color-bright-magenta, term-color-bright-cyan)
(term-color-bright-white): New faces.
(term--maybe-brighten-color): New function.
(term-handle-colors-array): Handle bright colors.
* test/lisp/term-tests.el (term-colors, term-colors-bold-is-bright):
New functions.
2021-09-23 01:39:52 +00:00
|
|
|
|
term-color-white
|
|
|
|
|
term-color-bright-black
|
|
|
|
|
term-color-bright-red
|
|
|
|
|
term-color-bright-green
|
|
|
|
|
term-color-bright-yellow
|
|
|
|
|
term-color-bright-blue
|
|
|
|
|
term-color-bright-magenta
|
|
|
|
|
term-color-bright-cyan
|
|
|
|
|
term-color-bright-white])
|
2012-06-28 10:40:24 +00:00
|
|
|
|
|
2012-11-10 01:40:48 +00:00
|
|
|
|
(defface term
|
Delete many items obsolete since 24.3
* lisp/allout.el (allout-exposure-change-hook)
(allout-structure-added-hook, allout-structure-deleted-hook)
(allout-structure-shifted-hook):
* lisp/arc-mode.el (archive-extract-hooks):
* lisp/buff-menu.el (Buffer-menu-buffer+size-width):
* lisp/calendar/timeclock.el (timeclock-modeline-display)
(timeclock-modeline-display, timeclock-update-modeline):
* lisp/cedet/semantic/db-el.el
(semanticdb-elisp-sym-function-arglist):
* lisp/cedet/semantic/db-file.el (semanticdb-save-database-hooks):
* lisp/cedet/semantic/edit.el (semantic-change-hooks)
(semantic-edits-new-change-hooks)
(semantic-edits-delete-change-hooks)
(semantic-edits-reparse-change-hooks):
* lisp/cedet/semantic/lex.el (semantic-lex-reset-hooks):
* lisp/comint.el (comint--unquote&expand-filename)
(comint-unquote-filename):
* lisp/custom.el (user-variable-p):
* lisp/dired.el (dired-shrink-to-fit, dired-pop-to-buffer)
(dired-sort-set-modeline):
* lisp/ebuff-menu.el (Electric-buffer-menu-mode):
* lisp/emacs-lisp/byte-run.el (macro-declaration-function):
* lisp/emacs-lisp/checkdoc.el (custom-print-functions)
(checkdoc-comment-style-hooks):
* lisp/emacs-lisp/cl-lib.el (custom-print-functions):
* lisp/emacs-lisp/edebug.el (gud-inhibit-global-bindings):
* lisp/erc/erc-dcc.el (erc-dcc-chat-filter-hook):
* lisp/eshell/esh-mode.el (eshell-status-in-modeline):
* lisp/eshell/eshell.el (eshell-add-to-window-buffer-names)
(eshell-remove-from-window-buffer-names):
* lisp/faces.el (set-face-underline-p, font-list-limit):
* lisp/files.el (automount-dir-prefix, toggle-read-only):
* lisp/filesets.el (filesets-cache-fill-content-hooks):
* lisp/frame.el (automatic-hscrolling):
* lisp/generic-x.el (javascript-generic-mode)
(javascript-generic-mode-hook):
* lisp/gnus/gnus-start.el (gnus-subscribe-newsgroup-hooks):
* lisp/gnus/nndiary.el (nndiary-request-create-group-hooks)
(nndiary-request-update-info-hooks)
(nndiary-request-accept-article-hooks):
* lisp/htmlfontify.el (hfy-post-html-hooks):
* lisp/international/mule-cmds.el
(inactivate-current-input-method-function)
(inactivate-input-method, input-method-inactivate-hook)
(ucs-insert):
* lisp/international/quail.el (quail-inactivate)
(quail-inactivate-hook):
* lisp/international/robin.el (robin-inactivate)
(robin-inactivate-hook):
* lisp/leim/quail/hangul.el (hangul-input-method-inactivate):
* lisp/leim/quail/uni-input.el (ucs-input-inactivate):
* lisp/mail/emacsbug.el (report-emacs-bug-info):
* lisp/mh-e/mh-e.el (mh-kill-folder-suppress-prompt-hooks):
* lisp/mpc.el (mpc-string-prefix-p):
* lisp/net/rcirc.el (rcirc-print-hooks, rcirc-sentinel-hooks)
(rcirc-receive-message-hooks, rcirc-activity-hooks):
* lisp/obsolete/crisp.el (crisp-mode-modeline-string):
* lisp/pcomplete.el (pcomplete-arg-quote-list)
(pcomplete-quote-argument):
* lisp/progmodes/cc-mode.el (c-prepare-bug-report-hooks):
* lisp/progmodes/python.el (python-info-ppss-context)
(python-info-ppss-context-type)
(python-info-ppss-comment-or-string-p, python-indent)
(python-guess-indent, python-buffer, python-preoutput-result)
(python-proc, python-send-receive, python-send-string)
(python-use-skeletons):
* lisp/progmodes/sh-script.el (sh-maybe-here-document):
* lisp/replace.el (query-replace-interactive):
* lisp/strokes.el (strokes-modeline-string):
* lisp/subr.el (redraw-modeline):
* lisp/term.el (term-default-fg-color, term-default-bg-color):
* lisp/textmodes/tex-mode.el (latex-string-prefix-p)
(tex-string-prefix-p):
* lisp/url/url-parse.el (url-recreate-url-attributes):
* lisp/vc/add-log.el (change-log-acknowledgement):
* lisp/vc/ediff-wind.el
(ediff-choose-window-setup-function-automatically):
* lisp/vc/pcvs-util.el (cvs-string-prefix-p):
* lisp/vc/vc.el (vc-string-prefix-p):
* lisp/window.el (display-buffer-function):
* lisp/winner.el (winner-mode-leave-hook): Remove many functions and
variables obsolete since 24.3.
* lisp/buff-menu.el (list-buffers--refresh):
* lisp/dired.el (dired-mode-map):
* lisp/files.el (abbreviate-file-name):
* lisp/generic-x.el (generic-default-modes):
* lisp/mh-e/mh-funcs.el (mh-kill-folder):
* lisp/progmodes/hideif.el (hide-ifdef-mode-submap):
* lisp/replace.el (query-replace-read-from):
* lisp/term.el (term):
* lisp/window.el (display-buffer): Don't use above deleted
functions and variables.
* src/marker.c (Fbuffer_has_markers_at): Delete DEFUN obsolete
since 24.3.
(syms_of_marker) <Sbuffer_has_markers_at>: Delete defsubr.
* lisp/subr.el (buffer-has-markers-at): Remove obsoletion
of above deleted DEFUN.
* etc/TODO: Doc fix; don't mention above deleted function.
* admin/cus-test.el (cus-test-get-options):
* lisp/pcomplete.el: Doc fixes; don't mention removed items.
; * etc/NEWS: List removed items.
2022-07-10 11:27:36 +00:00
|
|
|
|
`((t :inherit default))
|
2012-06-28 10:40:24 +00:00
|
|
|
|
"Default face to use in Term mode."
|
|
|
|
|
:group 'term)
|
|
|
|
|
|
|
|
|
|
(defface term-bold
|
Add support for "bright" ANSI colors in term-mode
* list/term.el (ansi-term-color-vector): Add new faces.
(term-color-black, term-color-red, term-color-green, term-color-yellow)
(term-color-blue, term-color-magenta, term-color-cyan, term-color-white):
Inherit from 'ansi-color-COLOR'.
(term-color-bright-black, term-color-bright-red, term-color-bright-green)
(term-color-bright-yellow, term-color-bright-blue)
(term-color-bright-magenta, term-color-bright-cyan)
(term-color-bright-white): New faces.
(term--maybe-brighten-color): New function.
(term-handle-colors-array): Handle bright colors.
* test/lisp/term-tests.el (term-colors, term-colors-bold-is-bright):
New functions.
2021-09-23 01:39:52 +00:00
|
|
|
|
'((t :inherit ansi-color-bold))
|
2012-06-28 10:40:24 +00:00
|
|
|
|
"Default face to use for bold text."
|
Add support for "bright" ANSI colors in term-mode
* list/term.el (ansi-term-color-vector): Add new faces.
(term-color-black, term-color-red, term-color-green, term-color-yellow)
(term-color-blue, term-color-magenta, term-color-cyan, term-color-white):
Inherit from 'ansi-color-COLOR'.
(term-color-bright-black, term-color-bright-red, term-color-bright-green)
(term-color-bright-yellow, term-color-bright-blue)
(term-color-bright-magenta, term-color-bright-cyan)
(term-color-bright-white): New faces.
(term--maybe-brighten-color): New function.
(term-handle-colors-array): Handle bright colors.
* test/lisp/term-tests.el (term-colors, term-colors-bold-is-bright):
New functions.
2021-09-23 01:39:52 +00:00
|
|
|
|
:group 'term
|
|
|
|
|
:version "28.1")
|
2012-06-28 10:40:24 +00:00
|
|
|
|
|
2021-09-27 13:15:57 +00:00
|
|
|
|
(defface term-faint
|
|
|
|
|
'((t :inherit ansi-color-faint))
|
|
|
|
|
"Default face to use for faint text."
|
|
|
|
|
:group 'term
|
2021-10-16 15:23:57 +00:00
|
|
|
|
:version "29.1")
|
2021-09-27 13:15:57 +00:00
|
|
|
|
|
|
|
|
|
(defface term-italic
|
|
|
|
|
'((t :inherit ansi-color-italic))
|
|
|
|
|
"Default face to use for italic text."
|
|
|
|
|
:group 'term
|
2021-10-16 15:23:57 +00:00
|
|
|
|
:version "29.1")
|
2021-09-27 13:15:57 +00:00
|
|
|
|
|
2012-06-28 10:40:24 +00:00
|
|
|
|
(defface term-underline
|
Add support for "bright" ANSI colors in term-mode
* list/term.el (ansi-term-color-vector): Add new faces.
(term-color-black, term-color-red, term-color-green, term-color-yellow)
(term-color-blue, term-color-magenta, term-color-cyan, term-color-white):
Inherit from 'ansi-color-COLOR'.
(term-color-bright-black, term-color-bright-red, term-color-bright-green)
(term-color-bright-yellow, term-color-bright-blue)
(term-color-bright-magenta, term-color-bright-cyan)
(term-color-bright-white): New faces.
(term--maybe-brighten-color): New function.
(term-handle-colors-array): Handle bright colors.
* test/lisp/term-tests.el (term-colors, term-colors-bold-is-bright):
New functions.
2021-09-23 01:39:52 +00:00
|
|
|
|
'((t :inherit ansi-color-underline))
|
2012-06-28 10:40:24 +00:00
|
|
|
|
"Default face to use for underlined text."
|
Add support for "bright" ANSI colors in term-mode
* list/term.el (ansi-term-color-vector): Add new faces.
(term-color-black, term-color-red, term-color-green, term-color-yellow)
(term-color-blue, term-color-magenta, term-color-cyan, term-color-white):
Inherit from 'ansi-color-COLOR'.
(term-color-bright-black, term-color-bright-red, term-color-bright-green)
(term-color-bright-yellow, term-color-bright-blue)
(term-color-bright-magenta, term-color-bright-cyan)
(term-color-bright-white): New faces.
(term--maybe-brighten-color): New function.
(term-handle-colors-array): Handle bright colors.
* test/lisp/term-tests.el (term-colors, term-colors-bold-is-bright):
New functions.
2021-09-23 01:39:52 +00:00
|
|
|
|
:group 'term
|
|
|
|
|
:version "28.1")
|
2012-06-28 10:40:24 +00:00
|
|
|
|
|
2021-09-27 13:15:57 +00:00
|
|
|
|
(defface term-slow-blink
|
|
|
|
|
'((t :inherit ansi-color-slow-blink))
|
|
|
|
|
"Default face to use for slowly blinking text."
|
|
|
|
|
:group 'term
|
2021-10-16 15:23:57 +00:00
|
|
|
|
:version "29.1")
|
2021-09-27 13:15:57 +00:00
|
|
|
|
|
|
|
|
|
(defface term-fast-blink
|
|
|
|
|
'((t :inherit ansi-color-fast-blink))
|
|
|
|
|
"Default face to use for rapidly blinking text."
|
|
|
|
|
:group 'term
|
2021-10-16 15:23:57 +00:00
|
|
|
|
:version "29.1")
|
2021-09-27 13:15:57 +00:00
|
|
|
|
|
2012-06-28 10:40:24 +00:00
|
|
|
|
(defface term-color-black
|
Add support for "bright" ANSI colors in term-mode
* list/term.el (ansi-term-color-vector): Add new faces.
(term-color-black, term-color-red, term-color-green, term-color-yellow)
(term-color-blue, term-color-magenta, term-color-cyan, term-color-white):
Inherit from 'ansi-color-COLOR'.
(term-color-bright-black, term-color-bright-red, term-color-bright-green)
(term-color-bright-yellow, term-color-bright-blue)
(term-color-bright-magenta, term-color-bright-cyan)
(term-color-bright-white): New faces.
(term--maybe-brighten-color): New function.
(term-handle-colors-array): Handle bright colors.
* test/lisp/term-tests.el (term-colors, term-colors-bold-is-bright):
New functions.
2021-09-23 01:39:52 +00:00
|
|
|
|
'((t :inherit ansi-color-black))
|
2012-06-28 10:40:24 +00:00
|
|
|
|
"Face used to render black color code."
|
Add support for "bright" ANSI colors in term-mode
* list/term.el (ansi-term-color-vector): Add new faces.
(term-color-black, term-color-red, term-color-green, term-color-yellow)
(term-color-blue, term-color-magenta, term-color-cyan, term-color-white):
Inherit from 'ansi-color-COLOR'.
(term-color-bright-black, term-color-bright-red, term-color-bright-green)
(term-color-bright-yellow, term-color-bright-blue)
(term-color-bright-magenta, term-color-bright-cyan)
(term-color-bright-white): New faces.
(term--maybe-brighten-color): New function.
(term-handle-colors-array): Handle bright colors.
* test/lisp/term-tests.el (term-colors, term-colors-bold-is-bright):
New functions.
2021-09-23 01:39:52 +00:00
|
|
|
|
:group 'term
|
|
|
|
|
:version "28.1")
|
2012-06-28 10:40:24 +00:00
|
|
|
|
|
|
|
|
|
(defface term-color-red
|
Add support for "bright" ANSI colors in term-mode
* list/term.el (ansi-term-color-vector): Add new faces.
(term-color-black, term-color-red, term-color-green, term-color-yellow)
(term-color-blue, term-color-magenta, term-color-cyan, term-color-white):
Inherit from 'ansi-color-COLOR'.
(term-color-bright-black, term-color-bright-red, term-color-bright-green)
(term-color-bright-yellow, term-color-bright-blue)
(term-color-bright-magenta, term-color-bright-cyan)
(term-color-bright-white): New faces.
(term--maybe-brighten-color): New function.
(term-handle-colors-array): Handle bright colors.
* test/lisp/term-tests.el (term-colors, term-colors-bold-is-bright):
New functions.
2021-09-23 01:39:52 +00:00
|
|
|
|
'((t :inherit ansi-color-red))
|
2012-06-28 10:40:24 +00:00
|
|
|
|
"Face used to render red color code."
|
Add support for "bright" ANSI colors in term-mode
* list/term.el (ansi-term-color-vector): Add new faces.
(term-color-black, term-color-red, term-color-green, term-color-yellow)
(term-color-blue, term-color-magenta, term-color-cyan, term-color-white):
Inherit from 'ansi-color-COLOR'.
(term-color-bright-black, term-color-bright-red, term-color-bright-green)
(term-color-bright-yellow, term-color-bright-blue)
(term-color-bright-magenta, term-color-bright-cyan)
(term-color-bright-white): New faces.
(term--maybe-brighten-color): New function.
(term-handle-colors-array): Handle bright colors.
* test/lisp/term-tests.el (term-colors, term-colors-bold-is-bright):
New functions.
2021-09-23 01:39:52 +00:00
|
|
|
|
:group 'term
|
|
|
|
|
:version "28.1")
|
2012-06-28 10:40:24 +00:00
|
|
|
|
|
|
|
|
|
(defface term-color-green
|
Add support for "bright" ANSI colors in term-mode
* list/term.el (ansi-term-color-vector): Add new faces.
(term-color-black, term-color-red, term-color-green, term-color-yellow)
(term-color-blue, term-color-magenta, term-color-cyan, term-color-white):
Inherit from 'ansi-color-COLOR'.
(term-color-bright-black, term-color-bright-red, term-color-bright-green)
(term-color-bright-yellow, term-color-bright-blue)
(term-color-bright-magenta, term-color-bright-cyan)
(term-color-bright-white): New faces.
(term--maybe-brighten-color): New function.
(term-handle-colors-array): Handle bright colors.
* test/lisp/term-tests.el (term-colors, term-colors-bold-is-bright):
New functions.
2021-09-23 01:39:52 +00:00
|
|
|
|
'((t :inherit ansi-color-green))
|
2012-06-28 10:40:24 +00:00
|
|
|
|
"Face used to render green color code."
|
Add support for "bright" ANSI colors in term-mode
* list/term.el (ansi-term-color-vector): Add new faces.
(term-color-black, term-color-red, term-color-green, term-color-yellow)
(term-color-blue, term-color-magenta, term-color-cyan, term-color-white):
Inherit from 'ansi-color-COLOR'.
(term-color-bright-black, term-color-bright-red, term-color-bright-green)
(term-color-bright-yellow, term-color-bright-blue)
(term-color-bright-magenta, term-color-bright-cyan)
(term-color-bright-white): New faces.
(term--maybe-brighten-color): New function.
(term-handle-colors-array): Handle bright colors.
* test/lisp/term-tests.el (term-colors, term-colors-bold-is-bright):
New functions.
2021-09-23 01:39:52 +00:00
|
|
|
|
:group 'term
|
|
|
|
|
:version "28.1")
|
2012-06-28 10:40:24 +00:00
|
|
|
|
|
|
|
|
|
(defface term-color-yellow
|
Add support for "bright" ANSI colors in term-mode
* list/term.el (ansi-term-color-vector): Add new faces.
(term-color-black, term-color-red, term-color-green, term-color-yellow)
(term-color-blue, term-color-magenta, term-color-cyan, term-color-white):
Inherit from 'ansi-color-COLOR'.
(term-color-bright-black, term-color-bright-red, term-color-bright-green)
(term-color-bright-yellow, term-color-bright-blue)
(term-color-bright-magenta, term-color-bright-cyan)
(term-color-bright-white): New faces.
(term--maybe-brighten-color): New function.
(term-handle-colors-array): Handle bright colors.
* test/lisp/term-tests.el (term-colors, term-colors-bold-is-bright):
New functions.
2021-09-23 01:39:52 +00:00
|
|
|
|
'((t :inherit ansi-color-yellow))
|
2012-06-28 10:40:24 +00:00
|
|
|
|
"Face used to render yellow color code."
|
Add support for "bright" ANSI colors in term-mode
* list/term.el (ansi-term-color-vector): Add new faces.
(term-color-black, term-color-red, term-color-green, term-color-yellow)
(term-color-blue, term-color-magenta, term-color-cyan, term-color-white):
Inherit from 'ansi-color-COLOR'.
(term-color-bright-black, term-color-bright-red, term-color-bright-green)
(term-color-bright-yellow, term-color-bright-blue)
(term-color-bright-magenta, term-color-bright-cyan)
(term-color-bright-white): New faces.
(term--maybe-brighten-color): New function.
(term-handle-colors-array): Handle bright colors.
* test/lisp/term-tests.el (term-colors, term-colors-bold-is-bright):
New functions.
2021-09-23 01:39:52 +00:00
|
|
|
|
:group 'term
|
|
|
|
|
:version "28.1")
|
2012-06-28 10:40:24 +00:00
|
|
|
|
|
|
|
|
|
(defface term-color-blue
|
Add support for "bright" ANSI colors in term-mode
* list/term.el (ansi-term-color-vector): Add new faces.
(term-color-black, term-color-red, term-color-green, term-color-yellow)
(term-color-blue, term-color-magenta, term-color-cyan, term-color-white):
Inherit from 'ansi-color-COLOR'.
(term-color-bright-black, term-color-bright-red, term-color-bright-green)
(term-color-bright-yellow, term-color-bright-blue)
(term-color-bright-magenta, term-color-bright-cyan)
(term-color-bright-white): New faces.
(term--maybe-brighten-color): New function.
(term-handle-colors-array): Handle bright colors.
* test/lisp/term-tests.el (term-colors, term-colors-bold-is-bright):
New functions.
2021-09-23 01:39:52 +00:00
|
|
|
|
'((t :inherit ansi-color-blue))
|
2012-06-28 10:40:24 +00:00
|
|
|
|
"Face used to render blue color code."
|
Add support for "bright" ANSI colors in term-mode
* list/term.el (ansi-term-color-vector): Add new faces.
(term-color-black, term-color-red, term-color-green, term-color-yellow)
(term-color-blue, term-color-magenta, term-color-cyan, term-color-white):
Inherit from 'ansi-color-COLOR'.
(term-color-bright-black, term-color-bright-red, term-color-bright-green)
(term-color-bright-yellow, term-color-bright-blue)
(term-color-bright-magenta, term-color-bright-cyan)
(term-color-bright-white): New faces.
(term--maybe-brighten-color): New function.
(term-handle-colors-array): Handle bright colors.
* test/lisp/term-tests.el (term-colors, term-colors-bold-is-bright):
New functions.
2021-09-23 01:39:52 +00:00
|
|
|
|
:group 'term
|
|
|
|
|
:version "28.1")
|
2012-06-28 10:40:24 +00:00
|
|
|
|
|
|
|
|
|
(defface term-color-magenta
|
Add support for "bright" ANSI colors in term-mode
* list/term.el (ansi-term-color-vector): Add new faces.
(term-color-black, term-color-red, term-color-green, term-color-yellow)
(term-color-blue, term-color-magenta, term-color-cyan, term-color-white):
Inherit from 'ansi-color-COLOR'.
(term-color-bright-black, term-color-bright-red, term-color-bright-green)
(term-color-bright-yellow, term-color-bright-blue)
(term-color-bright-magenta, term-color-bright-cyan)
(term-color-bright-white): New faces.
(term--maybe-brighten-color): New function.
(term-handle-colors-array): Handle bright colors.
* test/lisp/term-tests.el (term-colors, term-colors-bold-is-bright):
New functions.
2021-09-23 01:39:52 +00:00
|
|
|
|
'((t :inherit ansi-color-magenta))
|
2012-06-28 10:40:24 +00:00
|
|
|
|
"Face used to render magenta color code."
|
Add support for "bright" ANSI colors in term-mode
* list/term.el (ansi-term-color-vector): Add new faces.
(term-color-black, term-color-red, term-color-green, term-color-yellow)
(term-color-blue, term-color-magenta, term-color-cyan, term-color-white):
Inherit from 'ansi-color-COLOR'.
(term-color-bright-black, term-color-bright-red, term-color-bright-green)
(term-color-bright-yellow, term-color-bright-blue)
(term-color-bright-magenta, term-color-bright-cyan)
(term-color-bright-white): New faces.
(term--maybe-brighten-color): New function.
(term-handle-colors-array): Handle bright colors.
* test/lisp/term-tests.el (term-colors, term-colors-bold-is-bright):
New functions.
2021-09-23 01:39:52 +00:00
|
|
|
|
:group 'term
|
|
|
|
|
:version "28.1")
|
2012-06-28 10:40:24 +00:00
|
|
|
|
|
|
|
|
|
(defface term-color-cyan
|
Add support for "bright" ANSI colors in term-mode
* list/term.el (ansi-term-color-vector): Add new faces.
(term-color-black, term-color-red, term-color-green, term-color-yellow)
(term-color-blue, term-color-magenta, term-color-cyan, term-color-white):
Inherit from 'ansi-color-COLOR'.
(term-color-bright-black, term-color-bright-red, term-color-bright-green)
(term-color-bright-yellow, term-color-bright-blue)
(term-color-bright-magenta, term-color-bright-cyan)
(term-color-bright-white): New faces.
(term--maybe-brighten-color): New function.
(term-handle-colors-array): Handle bright colors.
* test/lisp/term-tests.el (term-colors, term-colors-bold-is-bright):
New functions.
2021-09-23 01:39:52 +00:00
|
|
|
|
'((t :inherit ansi-color-cyan))
|
2012-06-28 10:40:24 +00:00
|
|
|
|
"Face used to render cyan color code."
|
Add support for "bright" ANSI colors in term-mode
* list/term.el (ansi-term-color-vector): Add new faces.
(term-color-black, term-color-red, term-color-green, term-color-yellow)
(term-color-blue, term-color-magenta, term-color-cyan, term-color-white):
Inherit from 'ansi-color-COLOR'.
(term-color-bright-black, term-color-bright-red, term-color-bright-green)
(term-color-bright-yellow, term-color-bright-blue)
(term-color-bright-magenta, term-color-bright-cyan)
(term-color-bright-white): New faces.
(term--maybe-brighten-color): New function.
(term-handle-colors-array): Handle bright colors.
* test/lisp/term-tests.el (term-colors, term-colors-bold-is-bright):
New functions.
2021-09-23 01:39:52 +00:00
|
|
|
|
:group 'term
|
|
|
|
|
:version "28.1")
|
2012-06-28 10:40:24 +00:00
|
|
|
|
|
|
|
|
|
(defface term-color-white
|
Add support for "bright" ANSI colors in term-mode
* list/term.el (ansi-term-color-vector): Add new faces.
(term-color-black, term-color-red, term-color-green, term-color-yellow)
(term-color-blue, term-color-magenta, term-color-cyan, term-color-white):
Inherit from 'ansi-color-COLOR'.
(term-color-bright-black, term-color-bright-red, term-color-bright-green)
(term-color-bright-yellow, term-color-bright-blue)
(term-color-bright-magenta, term-color-bright-cyan)
(term-color-bright-white): New faces.
(term--maybe-brighten-color): New function.
(term-handle-colors-array): Handle bright colors.
* test/lisp/term-tests.el (term-colors, term-colors-bold-is-bright):
New functions.
2021-09-23 01:39:52 +00:00
|
|
|
|
'((t :inherit ansi-color-white))
|
2021-08-26 13:21:52 +00:00
|
|
|
|
"Face used to render white color code."
|
Add support for "bright" ANSI colors in term-mode
* list/term.el (ansi-term-color-vector): Add new faces.
(term-color-black, term-color-red, term-color-green, term-color-yellow)
(term-color-blue, term-color-magenta, term-color-cyan, term-color-white):
Inherit from 'ansi-color-COLOR'.
(term-color-bright-black, term-color-bright-red, term-color-bright-green)
(term-color-bright-yellow, term-color-bright-blue)
(term-color-bright-magenta, term-color-bright-cyan)
(term-color-bright-white): New faces.
(term--maybe-brighten-color): New function.
(term-handle-colors-array): Handle bright colors.
* test/lisp/term-tests.el (term-colors, term-colors-bold-is-bright):
New functions.
2021-09-23 01:39:52 +00:00
|
|
|
|
:group 'term
|
|
|
|
|
:version "28.1")
|
|
|
|
|
|
|
|
|
|
(defface term-color-bright-black
|
|
|
|
|
'((t :inherit ansi-color-bright-black))
|
|
|
|
|
"Face used to render bright black color code."
|
|
|
|
|
:group 'term
|
|
|
|
|
:version "28.1")
|
|
|
|
|
|
|
|
|
|
(defface term-color-bright-red
|
|
|
|
|
'((t :inherit ansi-color-bright-red))
|
|
|
|
|
"Face used to render bright red color code."
|
|
|
|
|
:group 'term
|
|
|
|
|
:version "28.1")
|
|
|
|
|
|
|
|
|
|
(defface term-color-bright-green
|
|
|
|
|
'((t :inherit ansi-color-bright-green))
|
|
|
|
|
"Face used to render bright green color code."
|
|
|
|
|
:group 'term
|
|
|
|
|
:version "28.1")
|
|
|
|
|
|
|
|
|
|
(defface term-color-bright-yellow
|
|
|
|
|
'((t :inherit ansi-color-bright-yellow))
|
|
|
|
|
"Face used to render bright yellow color code."
|
|
|
|
|
:group 'term
|
|
|
|
|
:version "28.1")
|
|
|
|
|
|
|
|
|
|
(defface term-color-bright-blue
|
|
|
|
|
'((t :inherit ansi-color-bright-blue))
|
|
|
|
|
"Face used to render bright blue color code."
|
|
|
|
|
:group 'term
|
|
|
|
|
:version "28.1")
|
|
|
|
|
|
|
|
|
|
(defface term-color-bright-magenta
|
|
|
|
|
'((t :inherit ansi-color-bright-magenta))
|
|
|
|
|
"Face used to render bright magenta color code."
|
|
|
|
|
:group 'term
|
|
|
|
|
:version "28.1")
|
|
|
|
|
|
|
|
|
|
(defface term-color-bright-cyan
|
|
|
|
|
'((t :inherit ansi-color-bright-cyan))
|
|
|
|
|
"Face used to render bright cyan color code."
|
|
|
|
|
:group 'term
|
|
|
|
|
:version "28.1")
|
|
|
|
|
|
|
|
|
|
(defface term-color-bright-white
|
|
|
|
|
'((t :inherit ansi-color-bright-white))
|
|
|
|
|
"Face used to render bright white color code."
|
|
|
|
|
:group 'term
|
|
|
|
|
:version "28.1")
|
2021-08-24 22:46:06 +00:00
|
|
|
|
|
2019-10-02 13:50:54 +00:00
|
|
|
|
(defcustom term-buffer-maximum-size 8192
|
2011-02-17 05:13:17 +00:00
|
|
|
|
"The maximum size in lines for term buffers.
|
1997-04-02 03:46:39 +00:00
|
|
|
|
Term buffers are truncated from the top to be no greater than this number.
|
(term-buffer-maximum-size, term-exec, term-escape-char, term-set-escape-char,
term-termcap-format, term-get-old-input-default, term-skip-prompt,
term-send-string, term-send-region, term-pager-page, term-pager-help):
Fix typos in docstrings.
2007-04-13 09:00:41 +00:00
|
|
|
|
Notice that a setting of 0 means \"don't truncate anything\". This variable
|
2011-02-17 05:13:17 +00:00
|
|
|
|
is buffer-local."
|
|
|
|
|
:group 'term
|
2022-07-06 17:29:51 +00:00
|
|
|
|
:type 'natnum
|
2019-10-02 13:50:54 +00:00
|
|
|
|
:version "27.1")
|
|
|
|
|
|
2022-05-08 13:03:59 +00:00
|
|
|
|
(defcustom term-bind-function-keys nil
|
|
|
|
|
"If nil, don't alter <f1>, <f2> and so on.
|
|
|
|
|
If non-nil, bind these keys in `term-mode' and send them to the
|
|
|
|
|
underlying shell."
|
|
|
|
|
:type 'boolean
|
|
|
|
|
:version "29.1")
|
|
|
|
|
|
2003-02-04 11:43:01 +00:00
|
|
|
|
|
|
|
|
|
;; Set up term-raw-map, etc.
|
|
|
|
|
|
2012-05-11 15:05:03 +00:00
|
|
|
|
(defvar term-raw-map
|
|
|
|
|
(let* ((map (make-keymap))
|
|
|
|
|
(esc-map (make-keymap))
|
|
|
|
|
(i 0))
|
|
|
|
|
(while (< i 128)
|
|
|
|
|
(define-key map (make-string 1 i) 'term-send-raw)
|
|
|
|
|
;; Avoid O and [. They are used in escape sequences for various keys.
|
|
|
|
|
(unless (or (eq i ?O) (eq i 91))
|
|
|
|
|
(define-key esc-map (make-string 1 i) 'term-send-raw-meta))
|
|
|
|
|
(setq i (1+ i)))
|
|
|
|
|
(define-key map [remap self-insert-command] 'term-send-raw)
|
|
|
|
|
(define-key map "\e" esc-map)
|
|
|
|
|
|
|
|
|
|
;; Added nearly all the 'gray keys' -mm
|
|
|
|
|
|
2019-09-14 13:15:27 +00:00
|
|
|
|
(define-key map [mouse-2] 'term-mouse-paste)
|
2012-05-11 15:05:03 +00:00
|
|
|
|
(define-key map [up] 'term-send-up)
|
|
|
|
|
(define-key map [down] 'term-send-down)
|
|
|
|
|
(define-key map [right] 'term-send-right)
|
|
|
|
|
(define-key map [left] 'term-send-left)
|
2016-02-24 03:19:17 +00:00
|
|
|
|
(define-key map [C-up] 'term-send-ctrl-up)
|
|
|
|
|
(define-key map [C-down] 'term-send-ctrl-down)
|
|
|
|
|
(define-key map [C-right] 'term-send-ctrl-right)
|
|
|
|
|
(define-key map [C-left] 'term-send-ctrl-left)
|
2012-05-11 15:05:03 +00:00
|
|
|
|
(define-key map [delete] 'term-send-del)
|
|
|
|
|
(define-key map [deletechar] 'term-send-del)
|
|
|
|
|
(define-key map [backspace] 'term-send-backspace)
|
|
|
|
|
(define-key map [home] 'term-send-home)
|
|
|
|
|
(define-key map [end] 'term-send-end)
|
|
|
|
|
(define-key map [insert] 'term-send-insert)
|
|
|
|
|
(define-key map [S-prior] 'scroll-down)
|
|
|
|
|
(define-key map [S-next] 'scroll-up)
|
|
|
|
|
(define-key map [S-insert] 'term-paste)
|
|
|
|
|
(define-key map [prior] 'term-send-prior)
|
|
|
|
|
(define-key map [next] 'term-send-next)
|
2016-11-06 18:21:10 +00:00
|
|
|
|
(define-key map [xterm-paste] #'term--xterm-paste)
|
2020-09-30 23:17:26 +00:00
|
|
|
|
(define-key map [?\C-/] #'term-send-C-_)
|
2022-05-08 13:03:59 +00:00
|
|
|
|
|
|
|
|
|
(when term-bind-function-keys
|
|
|
|
|
(dotimes (key 21)
|
|
|
|
|
(keymap-set map (format "<f%d>" key) #'term-send-function-key)))
|
2012-05-11 15:05:03 +00:00
|
|
|
|
map)
|
|
|
|
|
"Keyboard map for sending characters directly to the inferior process.")
|
|
|
|
|
|
2012-09-01 22:03:06 +00:00
|
|
|
|
(easy-menu-define term-terminal-menu
|
|
|
|
|
(list term-mode-map term-raw-map term-pager-break-map)
|
|
|
|
|
"Terminal menu for Term mode."
|
|
|
|
|
'("Terminal"
|
|
|
|
|
["Line mode" term-line-mode :active (term-in-char-mode)
|
|
|
|
|
:help "Switch to line (cooked) sub-mode of term mode"]
|
|
|
|
|
["Character mode" term-char-mode :active (term-in-line-mode)
|
|
|
|
|
:help "Switch to char (raw) sub-mode of term mode"]
|
|
|
|
|
["Paging" term-pager-toggle :style toggle :selected term-pager-count
|
|
|
|
|
:help "Toggle paging feature"]))
|
|
|
|
|
|
2021-07-18 14:34:02 +00:00
|
|
|
|
(defun term--update-term-menu (&optional force)
|
|
|
|
|
(when (and (lookup-key term-mode-map [menu-bar terminal])
|
|
|
|
|
(or force (frame-or-buffer-changed-p)))
|
|
|
|
|
(let ((buffer-list
|
|
|
|
|
(seq-filter
|
|
|
|
|
(lambda (buffer)
|
|
|
|
|
(provided-mode-derived-p (buffer-local-value 'major-mode buffer)
|
|
|
|
|
'term-mode))
|
|
|
|
|
(buffer-list))))
|
|
|
|
|
(easy-menu-change
|
|
|
|
|
'("Terminal")
|
|
|
|
|
"Terminal Buffers"
|
|
|
|
|
(mapcar
|
|
|
|
|
(lambda (buffer)
|
|
|
|
|
(vector (format "%s (%s)" (buffer-name buffer)
|
|
|
|
|
(abbreviate-file-name
|
|
|
|
|
(buffer-local-value 'default-directory buffer)))
|
|
|
|
|
(lambda ()
|
|
|
|
|
(interactive)
|
|
|
|
|
(switch-to-buffer buffer))))
|
|
|
|
|
buffer-list)))))
|
|
|
|
|
|
2012-09-01 22:03:06 +00:00
|
|
|
|
(easy-menu-define term-signals-menu
|
2021-07-18 14:34:02 +00:00
|
|
|
|
(list term-mode-map term-raw-map term-pager-break-map)
|
2012-09-01 22:03:06 +00:00
|
|
|
|
"Signals menu for Term mode."
|
|
|
|
|
'("Signals"
|
|
|
|
|
["BREAK" term-interrupt-subjob :active t
|
|
|
|
|
:help "Interrupt the current subjob"]
|
|
|
|
|
["STOP" term-stop-subjob :active t :help "Stop the current subjob"]
|
|
|
|
|
["CONT" term-continue-subjob :active t
|
|
|
|
|
:help "Send CONT signal to process buffer's process group"]
|
|
|
|
|
["QUIT" term-quit-subjob :active t
|
|
|
|
|
:help "Send quit signal to the current subjob"]
|
|
|
|
|
["KILL" term-kill-subjob :active t
|
|
|
|
|
:help "Send kill signal to the current subjob"]
|
|
|
|
|
["EOF" term-send-eof :active t
|
|
|
|
|
:help "Send an EOF to the current buffer's process"]))
|
|
|
|
|
|
|
|
|
|
(easy-menu-define term-pager-menu term-pager-break-map
|
|
|
|
|
"Menu for Term pager mode."
|
|
|
|
|
'("More pages?"
|
|
|
|
|
["1 page forwards" term-pager-page t]
|
|
|
|
|
["1 page backwards" term-pager-back-page t]
|
|
|
|
|
["1 line backwards" term-pager-back-line t]
|
|
|
|
|
["1 line forwards" term-pager-line t]
|
|
|
|
|
["Goto to beginning" term-pager-bob t]
|
|
|
|
|
["Goto to end" term-pager-eob t]
|
|
|
|
|
["Discard remaining output" term-pager-discard t]
|
|
|
|
|
["Disable paging" term-pager-toggle t]
|
|
|
|
|
["Help" term-pager-help t]))
|
|
|
|
|
|
2012-05-11 15:05:03 +00:00
|
|
|
|
(defvar term-raw-escape-map
|
|
|
|
|
(let ((map (make-sparse-keymap)))
|
|
|
|
|
(set-keymap-parent map 'Control-X-prefix)
|
|
|
|
|
;; Define standard bindings in term-raw-escape-map.
|
|
|
|
|
(define-key map "\C-v" (lookup-key (current-global-map) "\C-v"))
|
|
|
|
|
(define-key map "\C-u" (lookup-key (current-global-map) "\C-u"))
|
|
|
|
|
(define-key map "\C-q" 'term-pager-toggle)
|
|
|
|
|
;; The keybinding for term-char-mode is needed by the menubar code.
|
|
|
|
|
(define-key map "\C-k" 'term-char-mode)
|
|
|
|
|
(define-key map "\C-j" 'term-line-mode)
|
|
|
|
|
;; It's convenient to have execute-extended-command here.
|
|
|
|
|
(define-key map [?\M-x] 'execute-extended-command)
|
|
|
|
|
map))
|
|
|
|
|
|
2012-05-11 13:13:09 +00:00
|
|
|
|
(defun term-set-escape-char (key)
|
(term-buffer-maximum-size, term-exec, term-escape-char, term-set-escape-char,
term-termcap-format, term-get-old-input-default, term-skip-prompt,
term-send-string, term-send-region, term-pager-page, term-pager-help):
Fix typos in docstrings.
2007-04-13 09:00:41 +00:00
|
|
|
|
"Change `term-escape-char' and keymaps that depend on it."
|
(term-if-xemacs, term-ifnot-xemacs): Delete, replace
uses with a simple test.
(term-set-escape-char, term-mode, term-check-kill-echo-list)
(term-send-raw-string, term-send-raw, term-mouse-paste)
(term-char-mode, term-line-mode, term-exec, term-sentinel)
(term-handle-exit, term-read-input-ring)
(term-previous-matching-input-string)
(term-previous-matching-input-string-position)
(term-previous-matching-input-from-input)
(term-replace-by-expanded-history, term-send-input)
(term-skip-prompt, term-bol, term-send-invisible)
(term-kill-input, term-delchar-or-maybe-eof)
(term-backward-matching-input, term-check-source)
(term-proc-query, term-emulate-terminal)
(term-handle-colors-array, term-process-pager, term-pager-line)
(term-pager-bob, term-unwrap-line, term-word)
(term-dynamic-complete-filename)
(term-dynamic-complete-as-filename)
(term-dynamic-simple-complete): Replace one arm ifs with whens or
unlesses.
2006-05-29 06:11:33 +00:00
|
|
|
|
(when term-escape-char
|
2012-05-11 13:13:09 +00:00
|
|
|
|
;; Undo previous term-set-escape-char.
|
2022-06-20 21:33:51 +00:00
|
|
|
|
(define-key term-raw-map term-escape-char 'term-send-raw)
|
|
|
|
|
(define-key term-raw-escape-map term-escape-char nil t))
|
2013-05-11 02:15:46 +00:00
|
|
|
|
(setq term-escape-char (if (vectorp key) key (vector key)))
|
2012-05-11 13:13:09 +00:00
|
|
|
|
(define-key term-raw-map term-escape-char term-raw-escape-map)
|
2012-05-11 15:05:03 +00:00
|
|
|
|
(define-key term-raw-escape-map term-escape-char 'term-send-raw))
|
2003-02-04 11:43:01 +00:00
|
|
|
|
|
2012-05-11 15:05:03 +00:00
|
|
|
|
(term-set-escape-char (or term-escape-char ?\C-c))
|
2004-04-16 12:51:06 +00:00
|
|
|
|
|
2003-02-04 11:43:01 +00:00
|
|
|
|
|
|
|
|
|
(put 'term-mode 'mode-class 'special)
|
|
|
|
|
|
2004-09-26 18:39:10 +00:00
|
|
|
|
|
2009-08-16 15:39:11 +00:00
|
|
|
|
;; Use this variable as a display table for `term-mode'.
|
2004-09-26 18:39:10 +00:00
|
|
|
|
(defvar term-display-table
|
|
|
|
|
(let ((dt (or (copy-sequence standard-display-table)
|
|
|
|
|
(make-display-table)))
|
|
|
|
|
i)
|
|
|
|
|
;; avoid changing the display table for ^J
|
2005-06-10 00:43:13 +00:00
|
|
|
|
(setq i 0)
|
2004-09-26 18:39:10 +00:00
|
|
|
|
(while (< i 10)
|
|
|
|
|
(aset dt i (vector i))
|
|
|
|
|
(setq i (1+ i)))
|
2005-06-10 00:43:13 +00:00
|
|
|
|
(setq i 11)
|
2004-09-26 18:39:10 +00:00
|
|
|
|
(while (< i 32)
|
|
|
|
|
(aset dt i (vector i))
|
|
|
|
|
(setq i (1+ i)))
|
|
|
|
|
(setq i 128)
|
|
|
|
|
(while (< i 256)
|
|
|
|
|
(aset dt i (vector i))
|
|
|
|
|
(setq i (1+ i)))
|
|
|
|
|
dt))
|
|
|
|
|
|
2009-09-24 02:04:25 +00:00
|
|
|
|
(defun term-ansi-reset ()
|
2012-11-10 01:40:48 +00:00
|
|
|
|
(setq term-current-face 'term)
|
2009-09-24 02:04:25 +00:00
|
|
|
|
(setq term-ansi-current-bold nil)
|
2021-09-27 13:15:57 +00:00
|
|
|
|
(setq term-ansi-current-faint nil)
|
|
|
|
|
(setq term-ansi-current-italic nil)
|
|
|
|
|
(setq term-ansi-current-underline nil)
|
|
|
|
|
(setq term-ansi-current-slow-blink nil)
|
|
|
|
|
(setq term-ansi-current-fast-blink nil)
|
2009-09-24 02:04:25 +00:00
|
|
|
|
(setq term-ansi-current-reverse nil)
|
|
|
|
|
(setq term-ansi-current-color 0)
|
|
|
|
|
(setq term-ansi-current-invisible nil)
|
|
|
|
|
(setq term-ansi-current-bg-color 0))
|
|
|
|
|
|
2012-06-20 08:34:21 +00:00
|
|
|
|
(define-derived-mode term-mode fundamental-mode "Term"
|
2003-02-04 11:43:01 +00:00
|
|
|
|
"Major mode for interacting with an inferior interpreter.
|
|
|
|
|
The interpreter name is same as buffer name, sans the asterisks.
|
|
|
|
|
|
|
|
|
|
There are two submodes: line mode and char mode. By default, you are
|
|
|
|
|
in char mode. In char sub-mode, each character (except
|
2004-11-25 02:54:20 +00:00
|
|
|
|
`term-escape-char') is sent immediately to the subprocess.
|
|
|
|
|
The escape character is equivalent to the usual meaning of C-x.
|
2003-02-04 11:43:01 +00:00
|
|
|
|
|
|
|
|
|
In line mode, you send a line of input at a time; use
|
|
|
|
|
\\[term-send-input] to send.
|
|
|
|
|
|
|
|
|
|
In line mode, this maintains an input history of size
|
|
|
|
|
`term-input-ring-size', and you can access it with the commands
|
|
|
|
|
\\[term-next-input], \\[term-previous-input], and
|
|
|
|
|
\\[term-dynamic-list-input-ring]. Input ring history expansion can be
|
|
|
|
|
achieved with the commands \\[term-replace-by-expanded-history] or
|
|
|
|
|
\\[term-magic-space]. Input ring expansion is controlled by the
|
|
|
|
|
variable `term-input-autoexpand', and addition is controlled by the
|
|
|
|
|
variable `term-input-ignoredups'.
|
|
|
|
|
|
|
|
|
|
Input to, and output from, the subprocess can cause the window to scroll to
|
|
|
|
|
the end of the buffer. See variables `term-scroll-to-bottom-on-input',
|
|
|
|
|
and `term-scroll-to-bottom-on-output'.
|
|
|
|
|
|
|
|
|
|
If you accidentally suspend your process, use \\[term-continue-subjob]
|
|
|
|
|
to continue it.
|
|
|
|
|
|
2005-06-10 00:43:13 +00:00
|
|
|
|
This mode can be customized to create specific modes for running
|
2003-02-04 11:43:01 +00:00
|
|
|
|
particular subprocesses. This can be done by setting the hooks
|
|
|
|
|
`term-input-filter-functions', `term-input-filter',
|
|
|
|
|
`term-input-sender' and `term-get-old-input' to appropriate functions,
|
|
|
|
|
and the variable `term-prompt-regexp' to the appropriate regular
|
|
|
|
|
expression.
|
|
|
|
|
|
|
|
|
|
Commands in raw mode:
|
|
|
|
|
|
|
|
|
|
\\{term-raw-map}
|
|
|
|
|
|
|
|
|
|
Commands in line mode:
|
|
|
|
|
|
|
|
|
|
\\{term-mode-map}
|
1994-10-13 06:30:49 +00:00
|
|
|
|
|
2003-02-04 11:43:01 +00:00
|
|
|
|
Entry to this mode runs the hooks on `term-mode-hook'."
|
2004-09-26 18:39:10 +00:00
|
|
|
|
;; we do not want indent to sneak in any tabs
|
|
|
|
|
(setq indent-tabs-mode nil)
|
|
|
|
|
(setq buffer-display-table term-display-table)
|
2020-12-08 07:52:57 +00:00
|
|
|
|
(setq-local term-home-marker (copy-marker 0))
|
|
|
|
|
(setq-local term-height (floor (window-screen-lines)))
|
|
|
|
|
(setq-local term-width (window-max-chars-per-line))
|
|
|
|
|
(setq-local term-last-input-start (make-marker))
|
|
|
|
|
(setq-local term-last-input-end (make-marker))
|
|
|
|
|
(setq-local term-last-input-match "")
|
2012-06-20 08:34:21 +00:00
|
|
|
|
|
|
|
|
|
;; These local variables are set to their local values:
|
2003-02-04 11:43:01 +00:00
|
|
|
|
(make-local-variable 'term-saved-home-marker)
|
|
|
|
|
(make-local-variable 'term-saved-cursor)
|
2012-06-20 08:34:21 +00:00
|
|
|
|
(make-local-variable 'term-prompt-regexp)
|
|
|
|
|
(make-local-variable 'term-input-ring-size)
|
2003-02-04 11:43:01 +00:00
|
|
|
|
(make-local-variable 'term-input-ring)
|
|
|
|
|
(make-local-variable 'term-input-ring-file-name)
|
|
|
|
|
(make-local-variable 'term-input-ring-index)
|
2012-06-20 08:34:21 +00:00
|
|
|
|
(unless term-input-ring
|
|
|
|
|
(setq term-input-ring (make-ring term-input-ring-size)))
|
2003-02-04 11:43:01 +00:00
|
|
|
|
|
2009-08-16 15:39:11 +00:00
|
|
|
|
;; I'm not sure these saves are necessary but, since I
|
|
|
|
|
;; haven't tested the whole thing on a net connected machine with
|
|
|
|
|
;; a properly configured ange-ftp, I've decided to be conservative
|
|
|
|
|
;; and put them in. -mm
|
2003-02-04 11:43:01 +00:00
|
|
|
|
|
2020-12-08 07:52:57 +00:00
|
|
|
|
(setq-local term-ansi-at-host (system-name))
|
|
|
|
|
(setq-local term-ansi-at-dir default-directory)
|
|
|
|
|
(setq-local term-ansi-at-message nil)
|
2003-02-04 11:43:01 +00:00
|
|
|
|
|
2009-08-16 15:39:11 +00:00
|
|
|
|
;; For user tracking purposes -mm
|
2003-02-04 11:43:01 +00:00
|
|
|
|
(make-local-variable 'ange-ftp-default-user)
|
|
|
|
|
(make-local-variable 'ange-ftp-default-password)
|
|
|
|
|
(make-local-variable 'ange-ftp-generate-anonymous-password)
|
|
|
|
|
|
2009-08-16 15:39:11 +00:00
|
|
|
|
;; You may want to have different scroll-back sizes -mm
|
2003-02-04 11:43:01 +00:00
|
|
|
|
(make-local-variable 'term-buffer-maximum-size)
|
|
|
|
|
|
2009-08-16 15:39:11 +00:00
|
|
|
|
;; Of course these have to be buffer-local -mm
|
2003-02-04 11:43:01 +00:00
|
|
|
|
(make-local-variable 'term-ansi-current-bold)
|
|
|
|
|
(make-local-variable 'term-ansi-current-color)
|
|
|
|
|
(make-local-variable 'term-ansi-face-already-done)
|
|
|
|
|
(make-local-variable 'term-ansi-current-bg-color)
|
|
|
|
|
(make-local-variable 'term-ansi-current-underline)
|
|
|
|
|
(make-local-variable 'term-ansi-current-reverse)
|
|
|
|
|
(make-local-variable 'term-ansi-current-invisible)
|
|
|
|
|
|
2016-12-29 01:13:20 +00:00
|
|
|
|
(make-local-variable 'term-terminal-undecoded-bytes)
|
2006-01-15 19:36:10 +00:00
|
|
|
|
|
2018-01-18 13:22:47 +00:00
|
|
|
|
(make-local-variable 'term-do-line-wrapping)
|
2003-02-04 11:43:01 +00:00
|
|
|
|
(make-local-variable 'term-kill-echo-list)
|
|
|
|
|
(make-local-variable 'term-start-line-column)
|
|
|
|
|
(make-local-variable 'term-current-column)
|
|
|
|
|
(make-local-variable 'term-current-row)
|
|
|
|
|
(make-local-variable 'term-log-buffer)
|
|
|
|
|
(make-local-variable 'term-pager-count)
|
|
|
|
|
(make-local-variable 'term-pager-old-local-map)
|
|
|
|
|
(make-local-variable 'term-old-mode-map)
|
|
|
|
|
(make-local-variable 'term-insert-mode)
|
|
|
|
|
(make-local-variable 'term-completion-fignore)
|
|
|
|
|
(make-local-variable 'term-get-old-input)
|
|
|
|
|
(make-local-variable 'term-matching-input-from-input-string)
|
|
|
|
|
(make-local-variable 'term-input-autoexpand)
|
|
|
|
|
(make-local-variable 'term-input-ignoredups)
|
|
|
|
|
(make-local-variable 'term-delimiter-argument-list)
|
|
|
|
|
(make-local-variable 'term-input-filter)
|
|
|
|
|
(make-local-variable 'term-input-sender)
|
|
|
|
|
(make-local-variable 'term-eol-on-send)
|
|
|
|
|
(make-local-variable 'term-scroll-to-bottom-on-output)
|
|
|
|
|
(make-local-variable 'term-scroll-show-maximum-output)
|
|
|
|
|
(make-local-variable 'term-ptyp)
|
2020-12-08 07:52:57 +00:00
|
|
|
|
(setq-local term-vertical-motion 'vertical-motion)
|
|
|
|
|
(setq-local term-pending-delete-marker (make-marker))
|
2003-02-04 11:43:01 +00:00
|
|
|
|
(make-local-variable 'term-current-face)
|
2009-09-24 02:04:25 +00:00
|
|
|
|
(term-ansi-reset)
|
2021-07-18 14:34:02 +00:00
|
|
|
|
(add-hook 'menu-bar-update-hook 'term--update-term-menu)
|
2020-12-08 07:52:57 +00:00
|
|
|
|
(setq-local term-pending-frame nil)
|
(term-buffer-maximum-size, term-exec, term-escape-char, term-set-escape-char,
term-termcap-format, term-get-old-input-default, term-skip-prompt,
term-send-string, term-send-region, term-pager-page, term-pager-help):
Fix typos in docstrings.
2007-04-13 09:00:41 +00:00
|
|
|
|
;; Cua-mode's keybindings interfere with the term keybindings, disable it.
|
2020-12-08 07:52:57 +00:00
|
|
|
|
(setq-local cua-mode nil)
|
2012-06-20 09:21:06 +00:00
|
|
|
|
|
2020-12-08 07:52:57 +00:00
|
|
|
|
(setq-local font-lock-defaults '(nil t))
|
2012-06-20 09:21:06 +00:00
|
|
|
|
|
2019-01-21 00:08:17 +00:00
|
|
|
|
(add-function :filter-return
|
|
|
|
|
(local 'filter-buffer-substring-function)
|
|
|
|
|
#'term--filter-buffer-substring)
|
2015-03-23 04:09:21 +00:00
|
|
|
|
(add-function :filter-return
|
|
|
|
|
(local 'window-adjust-process-window-size-function)
|
|
|
|
|
(lambda (size)
|
|
|
|
|
(when size
|
|
|
|
|
(term-reset-size (cdr size) (car size)))
|
2018-01-07 00:28:09 +00:00
|
|
|
|
size)
|
|
|
|
|
'((name . term-maybe-reset-size)))
|
2015-03-23 04:09:21 +00:00
|
|
|
|
|
2017-10-21 08:17:56 +00:00
|
|
|
|
(add-hook 'read-only-mode-hook #'term-line-mode-buffer-read-only-update nil t)
|
|
|
|
|
|
2019-04-29 17:53:38 +00:00
|
|
|
|
(term--reset-scroll-region)
|
|
|
|
|
|
2003-02-04 11:43:01 +00:00
|
|
|
|
(or term-input-ring
|
|
|
|
|
(setq term-input-ring (make-ring term-input-ring-size)))
|
|
|
|
|
(term-update-mode-line))
|
|
|
|
|
|
2019-01-21 00:08:17 +00:00
|
|
|
|
(defun term--remove-fake-newlines ()
|
|
|
|
|
(goto-char (point-min))
|
|
|
|
|
(let (fake-newline)
|
|
|
|
|
(while (setq fake-newline (next-single-property-change (point)
|
|
|
|
|
'term-line-wrap))
|
|
|
|
|
(goto-char fake-newline)
|
2019-02-24 21:19:59 +00:00
|
|
|
|
(cl-assert (eq ?\n (char-after)))
|
2019-01-21 00:08:17 +00:00
|
|
|
|
(let ((inhibit-read-only t))
|
|
|
|
|
(delete-char 1)))))
|
|
|
|
|
|
2019-04-29 17:53:38 +00:00
|
|
|
|
(defun term--last-line ()
|
|
|
|
|
(1- term-height))
|
|
|
|
|
|
2019-01-21 00:08:17 +00:00
|
|
|
|
(defun term--filter-buffer-substring (content)
|
|
|
|
|
(with-temp-buffer
|
|
|
|
|
(insert content)
|
|
|
|
|
(term--remove-fake-newlines)
|
|
|
|
|
(buffer-string)))
|
|
|
|
|
|
|
|
|
|
(defun term--unwrap-visible-long-lines (width)
|
|
|
|
|
;; Unwrap lines longer than width using fake newlines. Only do it
|
|
|
|
|
;; for lines that are currently visible (i.e. following the home
|
|
|
|
|
;; marker). Invisible lines don't have to be unwrapped since they
|
|
|
|
|
;; are unreachable using the cursor movement anyway. Not having to
|
|
|
|
|
;; unwrap the entire buffer means the runtime of this function is
|
|
|
|
|
;; bounded by the size of the screen instead of the buffer size.
|
|
|
|
|
|
|
|
|
|
(save-excursion
|
|
|
|
|
;; We will just assume that our accounting for the home marker is
|
|
|
|
|
;; correct, i.e. programs will not try to reach any position
|
|
|
|
|
;; earlier than this marker.
|
|
|
|
|
(goto-char term-home-marker)
|
|
|
|
|
|
|
|
|
|
(move-to-column width)
|
|
|
|
|
(while (not (eobp))
|
|
|
|
|
(if (eolp)
|
|
|
|
|
(forward-char)
|
|
|
|
|
(let ((inhibit-read-only t))
|
|
|
|
|
(term-unwrap-line)))
|
|
|
|
|
(move-to-column width))))
|
|
|
|
|
|
1994-10-13 06:30:49 +00:00
|
|
|
|
(defun term-reset-size (height width)
|
2016-10-15 13:53:36 +00:00
|
|
|
|
(when (or (/= height term-height)
|
|
|
|
|
(/= width term-width))
|
2019-01-21 00:08:17 +00:00
|
|
|
|
;; Delete all newlines used for wrapping
|
|
|
|
|
(when (/= width term-width)
|
|
|
|
|
(save-excursion
|
|
|
|
|
(term--remove-fake-newlines)))
|
2022-01-23 20:13:24 +00:00
|
|
|
|
(let ((point (point))
|
|
|
|
|
(home-marker (marker-position term-home-marker)))
|
2016-10-15 13:53:36 +00:00
|
|
|
|
(setq term-height height)
|
|
|
|
|
(setq term-width width)
|
|
|
|
|
(setq term-start-line-column nil)
|
|
|
|
|
(setq term-current-row nil)
|
|
|
|
|
(setq term-current-column nil)
|
2019-04-29 17:53:38 +00:00
|
|
|
|
(term--reset-scroll-region)
|
2018-04-02 10:55:29 +00:00
|
|
|
|
;; `term-set-scroll-region' causes these to be set, we have to
|
|
|
|
|
;; clear them again since we're changing point (Bug#30544).
|
2022-01-23 20:13:24 +00:00
|
|
|
|
(term--unwrap-visible-long-lines width)
|
2018-04-02 10:55:29 +00:00
|
|
|
|
(setq term-start-line-column nil)
|
|
|
|
|
(setq term-current-row nil)
|
|
|
|
|
(setq term-current-column nil)
|
2022-01-23 20:13:24 +00:00
|
|
|
|
(goto-char point)
|
|
|
|
|
|
|
|
|
|
(when (term-using-alternate-sub-buffer)
|
|
|
|
|
(term-handle-deferred-scroll)
|
|
|
|
|
;; When using an alternative sub-buffer, the home marker should
|
|
|
|
|
;; not move forward. Bring it back by deleting text in front of
|
|
|
|
|
;; it.
|
|
|
|
|
(when (> term-home-marker home-marker)
|
|
|
|
|
(let ((inhibit-read-only t))
|
|
|
|
|
(delete-region home-marker term-home-marker)))))))
|
1994-10-13 06:30:49 +00:00
|
|
|
|
|
|
|
|
|
;; Recursive routine used to check if any string in term-kill-echo-list
|
|
|
|
|
;; matches part of the buffer before point.
|
|
|
|
|
;; If so, delete that matched part of the buffer - this suppresses echo.
|
|
|
|
|
;; Also, remove that string from the term-kill-echo-list.
|
|
|
|
|
;; We *also* remove any older string on the list, as a sanity measure,
|
|
|
|
|
;; in case something gets out of sync. (Except for type-ahead, there
|
|
|
|
|
;; should only be one element in the list.)
|
|
|
|
|
|
|
|
|
|
(defun term-check-kill-echo-list ()
|
|
|
|
|
(let ((cur term-kill-echo-list) (found nil) (save-point (point)))
|
|
|
|
|
(unwind-protect
|
|
|
|
|
(progn
|
|
|
|
|
(end-of-line)
|
|
|
|
|
(while cur
|
|
|
|
|
(let* ((str (car cur)) (len (length str)) (start (- (point) len)))
|
|
|
|
|
(if (and (>= start (point-min))
|
|
|
|
|
(string= str (buffer-substring start (point))))
|
Replace Lisp calls to delete-backward-char by delete-char.
* bs.el, expand.el, ido.el, image-dired.el, lpr.el, pcomplete.el,
skeleton.el, term.el, time.el, wid-edit.el, woman.el,
calc/calc-graph.el, calc/calc-help.el, calc/calc-incom.el,
calc/calc.el, emacs-cl-extra.el, emacs-cl-loaddefs.el,
emulation/cua-rect.el, emulation/viper-ex.el, eshell/esh-test.el,
eshell/eshell.el, gnus/gnus-uu.el, gnus/nndoc.el, gnus/nnrss.el,
gnus/rfc2047.el, gnus/utf7.el, international/utf-7.el,
language/ethio-util.el, mh-e/mh-alias.el, mh-e/mh-search.el,
net/imap.el, net/rcirc.el, obsolete/complete.el, play/decipher.el,
progmodes/ada-mode.el, progmodes/cc-awk.el, progmodes/dcl-mode.el,
progmodes/ps-mode.el, progmodes/verilog-mode.el,
progmodes/vhdl-mode.el, textmodes/bibtex.el, textmodes/fill.el,
textmodes/reftex-auc.el, textmodes/rst.el, textmodes/sgml-mode.el,
textmodes/table.el, textmodes/texinfmt.el: Replace Lisp calls to
delete-backward-char by calls to delete-char.
2010-05-25 02:11:08 +00:00
|
|
|
|
(progn (delete-char (- len))
|
1994-10-13 06:30:49 +00:00
|
|
|
|
(setq term-kill-echo-list (cdr cur))
|
|
|
|
|
(setq term-current-column nil)
|
|
|
|
|
(setq term-current-row nil)
|
|
|
|
|
(setq term-start-line-column nil)
|
|
|
|
|
(setq cur nil found t))
|
|
|
|
|
(setq cur (cdr cur))))))
|
(term-if-xemacs, term-ifnot-xemacs): Delete, replace
uses with a simple test.
(term-set-escape-char, term-mode, term-check-kill-echo-list)
(term-send-raw-string, term-send-raw, term-mouse-paste)
(term-char-mode, term-line-mode, term-exec, term-sentinel)
(term-handle-exit, term-read-input-ring)
(term-previous-matching-input-string)
(term-previous-matching-input-string-position)
(term-previous-matching-input-from-input)
(term-replace-by-expanded-history, term-send-input)
(term-skip-prompt, term-bol, term-send-invisible)
(term-kill-input, term-delchar-or-maybe-eof)
(term-backward-matching-input, term-check-source)
(term-proc-query, term-emulate-terminal)
(term-handle-colors-array, term-process-pager, term-pager-line)
(term-pager-bob, term-unwrap-line, term-word)
(term-dynamic-complete-filename)
(term-dynamic-complete-as-filename)
(term-dynamic-simple-complete): Replace one arm ifs with whens or
unlesses.
2006-05-29 06:11:33 +00:00
|
|
|
|
(when (not found)
|
|
|
|
|
(goto-char save-point)))
|
1994-10-13 06:30:49 +00:00
|
|
|
|
found))
|
|
|
|
|
|
|
|
|
|
(defun term-send-raw-string (chars)
|
2009-03-13 01:43:03 +00:00
|
|
|
|
(deactivate-mark)
|
1994-10-13 06:30:49 +00:00
|
|
|
|
(let ((proc (get-buffer-process (current-buffer))))
|
|
|
|
|
(if (not proc)
|
|
|
|
|
(error "Current buffer has no process")
|
|
|
|
|
;; Note that (term-current-row) must be called *after*
|
|
|
|
|
;; (point) has been updated to (process-mark proc).
|
|
|
|
|
(goto-char (process-mark proc))
|
(term-if-xemacs, term-ifnot-xemacs): Delete, replace
uses with a simple test.
(term-set-escape-char, term-mode, term-check-kill-echo-list)
(term-send-raw-string, term-send-raw, term-mouse-paste)
(term-char-mode, term-line-mode, term-exec, term-sentinel)
(term-handle-exit, term-read-input-ring)
(term-previous-matching-input-string)
(term-previous-matching-input-string-position)
(term-previous-matching-input-from-input)
(term-replace-by-expanded-history, term-send-input)
(term-skip-prompt, term-bol, term-send-invisible)
(term-kill-input, term-delchar-or-maybe-eof)
(term-backward-matching-input, term-check-source)
(term-proc-query, term-emulate-terminal)
(term-handle-colors-array, term-process-pager, term-pager-line)
(term-pager-bob, term-unwrap-line, term-word)
(term-dynamic-complete-filename)
(term-dynamic-complete-as-filename)
(term-dynamic-simple-complete): Replace one arm ifs with whens or
unlesses.
2006-05-29 06:11:33 +00:00
|
|
|
|
(when (term-pager-enabled)
|
|
|
|
|
(setq term-pager-count (term-current-row)))
|
1996-05-17 21:16:00 +00:00
|
|
|
|
(process-send-string proc chars))))
|
1994-10-13 06:30:49 +00:00
|
|
|
|
|
|
|
|
|
(defun term-send-raw ()
|
2021-09-22 18:26:40 +00:00
|
|
|
|
"Send last typed character to the terminal-emulator without any interpretation."
|
1994-10-13 06:30:49 +00:00
|
|
|
|
(interactive)
|
2009-12-04 04:39:21 +00:00
|
|
|
|
(let ((keys (this-command-keys)))
|
|
|
|
|
(term-send-raw-string (string (aref keys (1- (length keys)))))))
|
1994-10-13 06:30:49 +00:00
|
|
|
|
|
|
|
|
|
(defun term-send-raw-meta ()
|
|
|
|
|
(interactive)
|
2010-01-20 17:14:37 +00:00
|
|
|
|
(let ((char last-input-event))
|
2012-06-20 16:21:57 +00:00
|
|
|
|
(when (symbolp char)
|
2010-01-20 17:14:37 +00:00
|
|
|
|
;; Convert `return' to C-m, etc.
|
|
|
|
|
(let ((tmp (get char 'event-symbol-elements)))
|
2012-06-20 16:21:57 +00:00
|
|
|
|
(if tmp (setq char (car tmp)))
|
|
|
|
|
(and (symbolp char)
|
|
|
|
|
(setq tmp (get char 'ascii-character))
|
|
|
|
|
(setq char tmp))))
|
|
|
|
|
(when (numberp char)
|
|
|
|
|
(let ((base (event-basic-type char))
|
|
|
|
|
(mods (delq 'meta (event-modifiers char))))
|
|
|
|
|
(if (memq 'control mods)
|
|
|
|
|
(setq mods (delq 'shift mods)))
|
|
|
|
|
(term-send-raw-string
|
|
|
|
|
(format "\e%c"
|
|
|
|
|
(event-convert-list (append mods (list base)))))))))
|
1994-10-13 06:30:49 +00:00
|
|
|
|
|
2011-08-21 17:56:19 +00:00
|
|
|
|
(defun term-mouse-paste (click)
|
|
|
|
|
"Insert the primary selection at the position clicked on."
|
|
|
|
|
(interactive "e")
|
2019-09-14 13:15:27 +00:00
|
|
|
|
;; Give temporary modes such as isearch a chance to turn off.
|
|
|
|
|
(run-hooks 'mouse-leave-buffer-hook)
|
|
|
|
|
(setq this-command 'yank)
|
|
|
|
|
(mouse-set-point click)
|
|
|
|
|
(term-send-raw-string (gui-get-primary-selection)))
|
1994-10-13 06:30:49 +00:00
|
|
|
|
|
2004-09-26 18:39:10 +00:00
|
|
|
|
(defun term-paste ()
|
|
|
|
|
"Insert the last stretch of killed text at point."
|
|
|
|
|
(interactive)
|
|
|
|
|
(term-send-raw-string (current-kill 0)))
|
|
|
|
|
|
2016-11-06 18:21:10 +00:00
|
|
|
|
(defun term--xterm-paste ()
|
|
|
|
|
"Insert the text pasted in an XTerm bracketed paste operation."
|
|
|
|
|
(interactive)
|
|
|
|
|
(term-send-raw-string (xterm--pasted-text)))
|
|
|
|
|
|
|
|
|
|
(declare-function xterm--pasted-text "term/xterm" ())
|
|
|
|
|
|
1994-10-13 06:30:49 +00:00
|
|
|
|
;; Which would be better: "\e[A" or "\eOA"? readline accepts either.
|
1997-04-02 03:46:39 +00:00
|
|
|
|
;; For my configuration it's definitely better \eOA but YMMV. -mm
|
|
|
|
|
;; For example: vi works with \eOA while elm wants \e[A ...
|
2009-08-16 15:39:11 +00:00
|
|
|
|
;; (terminfo: kcuu1, kcud1, kcuf1, kcub1, khome, kend, kpp, knp, kdch1, kbs)
|
1997-04-02 03:46:39 +00:00
|
|
|
|
(defun term-send-up () (interactive) (term-send-raw-string "\eOA"))
|
|
|
|
|
(defun term-send-down () (interactive) (term-send-raw-string "\eOB"))
|
|
|
|
|
(defun term-send-right () (interactive) (term-send-raw-string "\eOC"))
|
|
|
|
|
(defun term-send-left () (interactive) (term-send-raw-string "\eOD"))
|
2016-02-24 03:19:17 +00:00
|
|
|
|
(defun term-send-ctrl-up () (interactive) (term-send-raw-string "\e[1;5A"))
|
|
|
|
|
(defun term-send-ctrl-down () (interactive) (term-send-raw-string "\e[1;5B"))
|
|
|
|
|
(defun term-send-ctrl-right () (interactive) (term-send-raw-string "\e[1;5C"))
|
|
|
|
|
(defun term-send-ctrl-left () (interactive) (term-send-raw-string "\e[1;5D"))
|
1999-01-11 12:59:36 +00:00
|
|
|
|
(defun term-send-home () (interactive) (term-send-raw-string "\e[1~"))
|
2006-01-15 19:36:10 +00:00
|
|
|
|
(defun term-send-insert() (interactive) (term-send-raw-string "\e[2~"))
|
1999-01-11 12:59:36 +00:00
|
|
|
|
(defun term-send-end () (interactive) (term-send-raw-string "\e[4~"))
|
1997-04-02 03:46:39 +00:00
|
|
|
|
(defun term-send-prior () (interactive) (term-send-raw-string "\e[5~"))
|
|
|
|
|
(defun term-send-next () (interactive) (term-send-raw-string "\e[6~"))
|
2004-09-26 18:39:10 +00:00
|
|
|
|
(defun term-send-del () (interactive) (term-send-raw-string "\e[3~"))
|
|
|
|
|
(defun term-send-backspace () (interactive) (term-send-raw-string "\C-?"))
|
2020-09-30 23:17:26 +00:00
|
|
|
|
(defun term-send-C-_ () (interactive) (term-send-raw-string "\C-_"))
|
2022-05-08 13:03:59 +00:00
|
|
|
|
|
|
|
|
|
(defun term-send-function-key ()
|
|
|
|
|
"If bound to a function key, this will send that key to the underlying shell."
|
|
|
|
|
(interactive)
|
|
|
|
|
(let ((key (this-command-keys-vector)))
|
|
|
|
|
(when (and (= (length key) 1)
|
|
|
|
|
(symbolp (elt key 0)))
|
|
|
|
|
(let ((name (symbol-name (elt key 0))))
|
2022-05-08 21:37:10 +00:00
|
|
|
|
(when (string-match "\\`f\\([0-9]+\\)\\'" name)
|
2022-05-08 13:03:59 +00:00
|
|
|
|
(let* ((num (string-to-number (match-string 1 name)))
|
|
|
|
|
(ansi
|
|
|
|
|
(cond
|
|
|
|
|
((<= num 5) (+ num 10))
|
|
|
|
|
((<= num 10) (+ num 11))
|
|
|
|
|
((<= num 14) (+ num 12))
|
|
|
|
|
((<= num 16) (+ num 13))
|
|
|
|
|
((<= num 20) (+ num 14)))))
|
|
|
|
|
(when ansi
|
|
|
|
|
(term-send-raw-string (format "\e[%d~" ansi)))))))))
|
|
|
|
|
|
2003-02-04 11:43:01 +00:00
|
|
|
|
|
1994-10-13 06:30:49 +00:00
|
|
|
|
(defun term-char-mode ()
|
1995-01-22 02:21:32 +00:00
|
|
|
|
"Switch to char (\"raw\") sub-mode of term mode.
|
|
|
|
|
Each character you type is sent directly to the inferior without
|
2022-06-26 14:45:09 +00:00
|
|
|
|
intervention from Emacs, except for the escape character (usually C-c)."
|
1994-10-13 06:30:49 +00:00
|
|
|
|
(interactive)
|
|
|
|
|
;; FIXME: Emit message? Cfr ilisp-raw-message
|
(term-if-xemacs, term-ifnot-xemacs): Delete, replace
uses with a simple test.
(term-set-escape-char, term-mode, term-check-kill-echo-list)
(term-send-raw-string, term-send-raw, term-mouse-paste)
(term-char-mode, term-line-mode, term-exec, term-sentinel)
(term-handle-exit, term-read-input-ring)
(term-previous-matching-input-string)
(term-previous-matching-input-string-position)
(term-previous-matching-input-from-input)
(term-replace-by-expanded-history, term-send-input)
(term-skip-prompt, term-bol, term-send-invisible)
(term-kill-input, term-delchar-or-maybe-eof)
(term-backward-matching-input, term-check-source)
(term-proc-query, term-emulate-terminal)
(term-handle-colors-array, term-process-pager, term-pager-line)
(term-pager-bob, term-unwrap-line, term-word)
(term-dynamic-complete-filename)
(term-dynamic-complete-as-filename)
(term-dynamic-simple-complete): Replace one arm ifs with whens or
unlesses.
2006-05-29 06:11:33 +00:00
|
|
|
|
(when (term-in-line-mode)
|
|
|
|
|
(setq term-old-mode-map (current-local-map))
|
|
|
|
|
(use-local-map term-raw-map)
|
|
|
|
|
|
2017-10-21 08:17:56 +00:00
|
|
|
|
;; Don't allow changes to the buffer or to point which are not
|
|
|
|
|
;; caused by the process filter.
|
|
|
|
|
(when term-char-mode-buffer-read-only
|
|
|
|
|
(setq buffer-read-only t))
|
|
|
|
|
(add-hook 'pre-command-hook #'term-set-goto-process-mark nil t)
|
|
|
|
|
(add-hook 'post-command-hook #'term-goto-process-mark-maybe nil t)
|
|
|
|
|
|
(term-if-xemacs, term-ifnot-xemacs): Delete, replace
uses with a simple test.
(term-set-escape-char, term-mode, term-check-kill-echo-list)
(term-send-raw-string, term-send-raw, term-mouse-paste)
(term-char-mode, term-line-mode, term-exec, term-sentinel)
(term-handle-exit, term-read-input-ring)
(term-previous-matching-input-string)
(term-previous-matching-input-string-position)
(term-previous-matching-input-from-input)
(term-replace-by-expanded-history, term-send-input)
(term-skip-prompt, term-bol, term-send-invisible)
(term-kill-input, term-delchar-or-maybe-eof)
(term-backward-matching-input, term-check-source)
(term-proc-query, term-emulate-terminal)
(term-handle-colors-array, term-process-pager, term-pager-line)
(term-pager-bob, term-unwrap-line, term-word)
(term-dynamic-complete-filename)
(term-dynamic-complete-as-filename)
(term-dynamic-simple-complete): Replace one arm ifs with whens or
unlesses.
2006-05-29 06:11:33 +00:00
|
|
|
|
;; Send existing partial line to inferior (without newline).
|
2019-02-24 21:19:59 +00:00
|
|
|
|
(let ((pmark (process-mark (get-buffer-process (current-buffer)))))
|
(term-if-xemacs, term-ifnot-xemacs): Delete, replace
uses with a simple test.
(term-set-escape-char, term-mode, term-check-kill-echo-list)
(term-send-raw-string, term-send-raw, term-mouse-paste)
(term-char-mode, term-line-mode, term-exec, term-sentinel)
(term-handle-exit, term-read-input-ring)
(term-previous-matching-input-string)
(term-previous-matching-input-string-position)
(term-previous-matching-input-from-input)
(term-replace-by-expanded-history, term-send-input)
(term-skip-prompt, term-bol, term-send-invisible)
(term-kill-input, term-delchar-or-maybe-eof)
(term-backward-matching-input, term-check-source)
(term-proc-query, term-emulate-terminal)
(term-handle-colors-array, term-process-pager, term-pager-line)
(term-pager-bob, term-unwrap-line, term-word)
(term-dynamic-complete-filename)
(term-dynamic-complete-as-filename)
(term-dynamic-simple-complete): Replace one arm ifs with whens or
unlesses.
2006-05-29 06:11:33 +00:00
|
|
|
|
(when (> (point) pmark)
|
|
|
|
|
(unwind-protect
|
|
|
|
|
(progn
|
2022-06-21 11:41:51 +00:00
|
|
|
|
(add-function :override (local 'term-input-sender) #'term-send-string)
|
(term-if-xemacs, term-ifnot-xemacs): Delete, replace
uses with a simple test.
(term-set-escape-char, term-mode, term-check-kill-echo-list)
(term-send-raw-string, term-send-raw, term-mouse-paste)
(term-char-mode, term-line-mode, term-exec, term-sentinel)
(term-handle-exit, term-read-input-ring)
(term-previous-matching-input-string)
(term-previous-matching-input-string-position)
(term-previous-matching-input-from-input)
(term-replace-by-expanded-history, term-send-input)
(term-skip-prompt, term-bol, term-send-invisible)
(term-kill-input, term-delchar-or-maybe-eof)
(term-backward-matching-input, term-check-source)
(term-proc-query, term-emulate-terminal)
(term-handle-colors-array, term-process-pager, term-pager-line)
(term-pager-bob, term-unwrap-line, term-word)
(term-dynamic-complete-filename)
(term-dynamic-complete-as-filename)
(term-dynamic-simple-complete): Replace one arm ifs with whens or
unlesses.
2006-05-29 06:11:33 +00:00
|
|
|
|
(end-of-line)
|
|
|
|
|
(term-send-input))
|
2022-06-21 11:41:51 +00:00
|
|
|
|
(remove-function (local 'term-input-sender) #'term-send-string))))
|
(term-if-xemacs, term-ifnot-xemacs): Delete, replace
uses with a simple test.
(term-set-escape-char, term-mode, term-check-kill-echo-list)
(term-send-raw-string, term-send-raw, term-mouse-paste)
(term-char-mode, term-line-mode, term-exec, term-sentinel)
(term-handle-exit, term-read-input-ring)
(term-previous-matching-input-string)
(term-previous-matching-input-string-position)
(term-previous-matching-input-from-input)
(term-replace-by-expanded-history, term-send-input)
(term-skip-prompt, term-bol, term-send-invisible)
(term-kill-input, term-delchar-or-maybe-eof)
(term-backward-matching-input, term-check-source)
(term-proc-query, term-emulate-terminal)
(term-handle-colors-array, term-process-pager, term-pager-line)
(term-pager-bob, term-unwrap-line, term-word)
(term-dynamic-complete-filename)
(term-dynamic-complete-as-filename)
(term-dynamic-simple-complete): Replace one arm ifs with whens or
unlesses.
2006-05-29 06:11:33 +00:00
|
|
|
|
(term-update-mode-line)))
|
1994-10-13 06:30:49 +00:00
|
|
|
|
|
|
|
|
|
(defun term-line-mode ()
|
1995-01-22 02:21:32 +00:00
|
|
|
|
"Switch to line (\"cooked\") sub-mode of term mode.
|
1997-04-02 03:46:39 +00:00
|
|
|
|
This means that Emacs editing commands work as normally, until
|
1995-01-22 02:21:32 +00:00
|
|
|
|
you type \\[term-send-input] which sends the current line to the inferior."
|
1994-10-13 06:30:49 +00:00
|
|
|
|
(interactive)
|
(term-if-xemacs, term-ifnot-xemacs): Delete, replace
uses with a simple test.
(term-set-escape-char, term-mode, term-check-kill-echo-list)
(term-send-raw-string, term-send-raw, term-mouse-paste)
(term-char-mode, term-line-mode, term-exec, term-sentinel)
(term-handle-exit, term-read-input-ring)
(term-previous-matching-input-string)
(term-previous-matching-input-string-position)
(term-previous-matching-input-from-input)
(term-replace-by-expanded-history, term-send-input)
(term-skip-prompt, term-bol, term-send-invisible)
(term-kill-input, term-delchar-or-maybe-eof)
(term-backward-matching-input, term-check-source)
(term-proc-query, term-emulate-terminal)
(term-handle-colors-array, term-process-pager, term-pager-line)
(term-pager-bob, term-unwrap-line, term-word)
(term-dynamic-complete-filename)
(term-dynamic-complete-as-filename)
(term-dynamic-simple-complete): Replace one arm ifs with whens or
unlesses.
2006-05-29 06:11:33 +00:00
|
|
|
|
(when (term-in-char-mode)
|
2017-10-21 08:17:56 +00:00
|
|
|
|
(when term-char-mode-buffer-read-only
|
|
|
|
|
(setq buffer-read-only term-line-mode-buffer-read-only))
|
|
|
|
|
(remove-hook 'pre-command-hook #'term-set-goto-process-mark t)
|
|
|
|
|
(remove-hook 'post-command-hook #'term-goto-process-mark-maybe t)
|
(term-if-xemacs, term-ifnot-xemacs): Delete, replace
uses with a simple test.
(term-set-escape-char, term-mode, term-check-kill-echo-list)
(term-send-raw-string, term-send-raw, term-mouse-paste)
(term-char-mode, term-line-mode, term-exec, term-sentinel)
(term-handle-exit, term-read-input-ring)
(term-previous-matching-input-string)
(term-previous-matching-input-string-position)
(term-previous-matching-input-from-input)
(term-replace-by-expanded-history, term-send-input)
(term-skip-prompt, term-bol, term-send-invisible)
(term-kill-input, term-delchar-or-maybe-eof)
(term-backward-matching-input, term-check-source)
(term-proc-query, term-emulate-terminal)
(term-handle-colors-array, term-process-pager, term-pager-line)
(term-pager-bob, term-unwrap-line, term-word)
(term-dynamic-complete-filename)
(term-dynamic-complete-as-filename)
(term-dynamic-simple-complete): Replace one arm ifs with whens or
unlesses.
2006-05-29 06:11:33 +00:00
|
|
|
|
(use-local-map term-old-mode-map)
|
|
|
|
|
(term-update-mode-line)))
|
1995-02-06 21:56:37 +00:00
|
|
|
|
|
2017-10-21 08:17:56 +00:00
|
|
|
|
(defun term-line-mode-buffer-read-only-update ()
|
|
|
|
|
"Update the user-set state of `buffer-read-only' in `term-line-mode'.
|
|
|
|
|
|
|
|
|
|
Called as a buffer-local `read-only-mode-hook' function."
|
|
|
|
|
(when (term-in-line-mode)
|
|
|
|
|
(setq term-line-mode-buffer-read-only buffer-read-only)))
|
|
|
|
|
|
1995-02-06 21:56:37 +00:00
|
|
|
|
(defun term-update-mode-line ()
|
2012-09-01 22:03:06 +00:00
|
|
|
|
(let ((term-mode
|
|
|
|
|
(if (term-in-char-mode)
|
|
|
|
|
(propertize "char"
|
|
|
|
|
'help-echo "mouse-1: Switch to line mode"
|
|
|
|
|
'mouse-face 'mode-line-highlight
|
|
|
|
|
'local-map
|
|
|
|
|
'(keymap
|
|
|
|
|
(mode-line keymap (down-mouse-1 . term-line-mode))))
|
|
|
|
|
(propertize "line"
|
|
|
|
|
'help-echo "mouse-1: Switch to char mode"
|
|
|
|
|
'mouse-face 'mode-line-highlight
|
|
|
|
|
'local-map
|
|
|
|
|
'(keymap
|
|
|
|
|
(mode-line keymap (down-mouse-1 . term-char-mode))))))
|
|
|
|
|
(term-page
|
|
|
|
|
(when (term-pager-enabled)
|
|
|
|
|
(concat " "
|
|
|
|
|
(propertize
|
|
|
|
|
"page"
|
|
|
|
|
'help-echo "mouse-1: Disable paging"
|
|
|
|
|
'mouse-face 'mode-line-highlight
|
|
|
|
|
'local-map
|
|
|
|
|
'(keymap
|
|
|
|
|
(mode-line keymap (down-mouse-1 .
|
|
|
|
|
term-pager-toggle)))))))
|
2008-06-13 08:04:56 +00:00
|
|
|
|
(serial-item-speed)
|
|
|
|
|
(serial-item-config)
|
|
|
|
|
(proc (get-buffer-process (current-buffer))))
|
|
|
|
|
(when (and (term-check-proc (current-buffer))
|
|
|
|
|
(equal (process-type nil) 'serial))
|
|
|
|
|
(let ((temp (serial-speed)))
|
|
|
|
|
(setq serial-item-speed
|
|
|
|
|
`(:propertize
|
|
|
|
|
,(or (and temp (format " %d" temp)) "")
|
|
|
|
|
help-echo "mouse-1: Change the speed of the serial port"
|
|
|
|
|
mouse-face mode-line-highlight
|
|
|
|
|
local-map (keymap (mode-line keymap
|
|
|
|
|
(down-mouse-1 . serial-mode-line-speed-menu-1))))))
|
|
|
|
|
(let ((temp (process-contact proc :summary)))
|
|
|
|
|
(setq serial-item-config
|
|
|
|
|
`(:propertize
|
|
|
|
|
,(or (and temp (format " %s" temp)) "")
|
|
|
|
|
help-echo "mouse-1: Change the configuration of the serial port"
|
|
|
|
|
mouse-face mode-line-highlight
|
|
|
|
|
local-map (keymap (mode-line keymap
|
|
|
|
|
(down-mouse-1 . serial-mode-line-config-menu-1)))))))
|
|
|
|
|
(setq mode-line-process
|
|
|
|
|
(list ": " term-mode term-page
|
|
|
|
|
serial-item-speed
|
|
|
|
|
serial-item-config
|
|
|
|
|
" %s")))
|
1995-04-25 22:25:25 +00:00
|
|
|
|
(force-mode-line-update))
|
1994-10-13 06:30:49 +00:00
|
|
|
|
|
|
|
|
|
(defun term-check-proc (buffer)
|
2021-09-22 18:26:40 +00:00
|
|
|
|
"Non-nil if there is a process associated w/buffer BUFFER, and it is alive.
|
|
|
|
|
BUFFER can be either a buffer or the name of one."
|
1994-10-13 06:30:49 +00:00
|
|
|
|
(let ((proc (get-buffer-process buffer)))
|
2008-06-13 08:04:56 +00:00
|
|
|
|
(and proc (memq (process-status proc) '(run stop open listen connect)))))
|
1994-10-13 06:30:49 +00:00
|
|
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
|
(defun make-term (name program &optional startfile &rest switches)
|
|
|
|
|
"Make a term process NAME in a buffer, running PROGRAM.
|
|
|
|
|
The name of the buffer is made by surrounding NAME with `*'s.
|
|
|
|
|
If there is already a running process in that buffer, it is not restarted.
|
1997-04-02 03:46:39 +00:00
|
|
|
|
Optional third arg STARTFILE is the name of a file to send the contents of to
|
1994-10-13 06:30:49 +00:00
|
|
|
|
the process. Any more args are arguments to PROGRAM."
|
|
|
|
|
(let ((buffer (get-buffer-create (concat "*" name "*"))))
|
|
|
|
|
;; If no process, or nuked process, crank up a new one and put buffer in
|
1997-04-02 03:46:39 +00:00
|
|
|
|
;; term mode. Otherwise, leave buffer and existing process alone.
|
1994-10-13 06:30:49 +00:00
|
|
|
|
(cond ((not (term-check-proc buffer))
|
* x-dnd.el (x-dnd-maybe-call-test-function):
* window.el (split-window-vertically):
* whitespace.el (whitespace-help-on):
* vc-rcs.el (vc-rcs-consult-headers):
* userlock.el (ask-user-about-lock-help)
(ask-user-about-supersession-help):
* type-break.el (type-break-force-mode-line-update):
* time-stamp.el (time-stamp-conv-warn):
* terminal.el (te-set-output-log, te-more-break, te-filter)
(te-sentinel,terminal-emulator):
* term.el (make-term, term-exec, term-sentinel, term-read-input-ring)
(term-write-input-ring, term-check-source, term-start-output-log):
(term-display-buffer-line, term-dynamic-list-completions):
(term-ansi-make-term, serial-term):
* subr.el (selective-display):
* strokes.el (strokes-xpm-to-compressed-string, strokes-decode-buffer)
(strokes-encode-buffer, strokes-xpm-for-compressed-string):
* speedbar.el (speedbar-buffers-tail-notes, speedbar-buffers-item-info)
(speedbar-reconfigure-keymaps, speedbar-add-localized-speedbar-support)
(speedbar-remove-localized-speedbar-support)
(speedbar-set-mode-line-format, speedbar-create-tag-hierarchy)
(speedbar-update-special-contents, speedbar-buffer-buttons-engine)
(speedbar-buffers-line-directory):
* simple.el (shell-command-on-region, append-to-buffer)
(prepend-to-buffer):
* shadowfile.el (shadow-save-todo-file):
* scroll-bar.el (scroll-bar-set-window-start, scroll-bar-drag-1)
(scroll-bar-maybe-set-window-start):
* sb-image.el (speedbar-image-dump):
* saveplace.el (save-place-alist-to-file, save-places-to-alist)
(load-save-place-alist-from-file):
* ps-samp.el (ps-print-message-from-summary):
* ps-print.el (ps-flush-output, ps-insert-file, ps-get-boundingbox)
(ps-background-image, ps-begin-job, ps-do-despool):
* ps-bdf.el (bdf-find-file, bdf-read-font-info):
* printing.el (pr-interface, pr-ps-file-print, pr-find-buffer-visiting)
(pr-ps-message-from-summary, pr-lpr-message-from-summary):
(pr-call-process, pr-file-list, pr-interface-save):
* novice.el (disabled-command-function)
(enable-command, disable-command):
* mouse.el (mouse-buffer-menu-alist):
* mouse-copy.el (mouse-kill-preserving-secondary):
* macros.el (kbd-macro-query):
* ledit.el (ledit-go-to-lisp, ledit-go-to-liszt):
* informat.el (batch-info-validate):
* ido.el (ido-copy-current-word, ido-initiate-auto-merge):
* hippie-exp.el (try-expand-dabbrev-visible):
* help-mode.el (help-make-xrefs):
* help-fns.el (describe-variable):
* generic-x.el (bat-generic-mode-run-as-comint):
* finder.el (finder-mouse-select):
* find-dired.el (find-dired-sentinel):
* filesets.el (filesets-file-close):
* files.el (list-directory):
* faces.el (list-faces-display, describe-face):
* facemenu.el (list-colors-display):
* ezimage.el (ezimage-image-association-dump, ezimage-image-dump):
* epg.el (epg--process-filter, epg-cancel):
* epa.el (epa--marked-keys, epa--select-keys, epa-display-info)
(epa--read-signature-type):
* emerge.el (emerge-copy-as-kill-A, emerge-copy-as-kill-B)
(emerge-file-names):
* ehelp.el (electric-helpify):
* ediff.el (ediff-regions-wordwise, ediff-regions-linewise):
* ediff-vers.el (rcs-ediff-view-revision):
* ediff-util.el (ediff-setup):
* ediff-mult.el (ediff-append-custom-diff):
* ediff-diff.el (ediff-exec-process, ediff-process-sentinel)
(ediff-wordify):
* echistory.el (Electric-command-history-redo-expression):
* dos-w32.el (find-file-not-found-set-buffer-file-coding-system):
* disp-table.el (describe-display-table):
* dired.el (dired-find-buffer-nocreate):
* dired-aux.el (dired-rename-subdir, dired-dwim-target-directory):
* dabbrev.el (dabbrev--same-major-mode-p):
* chistory.el (list-command-history):
* apropos.el (apropos-documentation):
* allout.el (allout-obtain-passphrase):
(allout-copy-exposed-to-buffer):
(allout-verify-passphrase): Use with-current-buffer.
2009-11-13 22:19:45 +00:00
|
|
|
|
(with-current-buffer buffer
|
1994-10-13 06:30:49 +00:00
|
|
|
|
(term-mode)) ; Install local vars, mode, keymap, ...
|
|
|
|
|
(term-exec buffer name program startfile switches)))
|
|
|
|
|
buffer))
|
|
|
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
|
(defun term (program)
|
2003-02-04 11:43:01 +00:00
|
|
|
|
"Start a terminal-emulator in a new buffer.
|
|
|
|
|
The buffer is in Term mode; see `term-mode' for the
|
|
|
|
|
commands to use in that buffer.
|
|
|
|
|
|
|
|
|
|
\\<term-raw-map>Type \\[switch-to-buffer] to switch to another buffer."
|
2021-09-04 06:59:14 +00:00
|
|
|
|
(interactive (list (read-shell-command "Run program: "
|
|
|
|
|
(or explicit-shell-file-name
|
|
|
|
|
(getenv "ESHELL")
|
|
|
|
|
shell-file-name))))
|
2022-05-11 15:10:30 +00:00
|
|
|
|
(let ((prog (split-string-shell-command program)))
|
|
|
|
|
(set-buffer (apply #'make-term "terminal" (car prog) nil (cdr prog))))
|
1994-10-13 06:30:49 +00:00
|
|
|
|
(term-char-mode)
|
2021-12-22 12:00:55 +00:00
|
|
|
|
(pop-to-buffer-same-window "*terminal*"))
|
1994-10-13 06:30:49 +00:00
|
|
|
|
|
|
|
|
|
(defun term-exec (buffer name command startfile switches)
|
|
|
|
|
"Start up a process in buffer for term modes.
|
1997-04-02 03:46:39 +00:00
|
|
|
|
Blasts any old process running in the buffer. Doesn't set the buffer mode.
|
1994-10-13 06:30:49 +00:00
|
|
|
|
You can use this to cheaply run a series of processes in the same term
|
(term-buffer-maximum-size, term-exec, term-escape-char, term-set-escape-char,
term-termcap-format, term-get-old-input-default, term-skip-prompt,
term-send-string, term-send-region, term-pager-page, term-pager-help):
Fix typos in docstrings.
2007-04-13 09:00:41 +00:00
|
|
|
|
buffer. The hook `term-exec-hook' is run after each exec."
|
* x-dnd.el (x-dnd-maybe-call-test-function):
* window.el (split-window-vertically):
* whitespace.el (whitespace-help-on):
* vc-rcs.el (vc-rcs-consult-headers):
* userlock.el (ask-user-about-lock-help)
(ask-user-about-supersession-help):
* type-break.el (type-break-force-mode-line-update):
* time-stamp.el (time-stamp-conv-warn):
* terminal.el (te-set-output-log, te-more-break, te-filter)
(te-sentinel,terminal-emulator):
* term.el (make-term, term-exec, term-sentinel, term-read-input-ring)
(term-write-input-ring, term-check-source, term-start-output-log):
(term-display-buffer-line, term-dynamic-list-completions):
(term-ansi-make-term, serial-term):
* subr.el (selective-display):
* strokes.el (strokes-xpm-to-compressed-string, strokes-decode-buffer)
(strokes-encode-buffer, strokes-xpm-for-compressed-string):
* speedbar.el (speedbar-buffers-tail-notes, speedbar-buffers-item-info)
(speedbar-reconfigure-keymaps, speedbar-add-localized-speedbar-support)
(speedbar-remove-localized-speedbar-support)
(speedbar-set-mode-line-format, speedbar-create-tag-hierarchy)
(speedbar-update-special-contents, speedbar-buffer-buttons-engine)
(speedbar-buffers-line-directory):
* simple.el (shell-command-on-region, append-to-buffer)
(prepend-to-buffer):
* shadowfile.el (shadow-save-todo-file):
* scroll-bar.el (scroll-bar-set-window-start, scroll-bar-drag-1)
(scroll-bar-maybe-set-window-start):
* sb-image.el (speedbar-image-dump):
* saveplace.el (save-place-alist-to-file, save-places-to-alist)
(load-save-place-alist-from-file):
* ps-samp.el (ps-print-message-from-summary):
* ps-print.el (ps-flush-output, ps-insert-file, ps-get-boundingbox)
(ps-background-image, ps-begin-job, ps-do-despool):
* ps-bdf.el (bdf-find-file, bdf-read-font-info):
* printing.el (pr-interface, pr-ps-file-print, pr-find-buffer-visiting)
(pr-ps-message-from-summary, pr-lpr-message-from-summary):
(pr-call-process, pr-file-list, pr-interface-save):
* novice.el (disabled-command-function)
(enable-command, disable-command):
* mouse.el (mouse-buffer-menu-alist):
* mouse-copy.el (mouse-kill-preserving-secondary):
* macros.el (kbd-macro-query):
* ledit.el (ledit-go-to-lisp, ledit-go-to-liszt):
* informat.el (batch-info-validate):
* ido.el (ido-copy-current-word, ido-initiate-auto-merge):
* hippie-exp.el (try-expand-dabbrev-visible):
* help-mode.el (help-make-xrefs):
* help-fns.el (describe-variable):
* generic-x.el (bat-generic-mode-run-as-comint):
* finder.el (finder-mouse-select):
* find-dired.el (find-dired-sentinel):
* filesets.el (filesets-file-close):
* files.el (list-directory):
* faces.el (list-faces-display, describe-face):
* facemenu.el (list-colors-display):
* ezimage.el (ezimage-image-association-dump, ezimage-image-dump):
* epg.el (epg--process-filter, epg-cancel):
* epa.el (epa--marked-keys, epa--select-keys, epa-display-info)
(epa--read-signature-type):
* emerge.el (emerge-copy-as-kill-A, emerge-copy-as-kill-B)
(emerge-file-names):
* ehelp.el (electric-helpify):
* ediff.el (ediff-regions-wordwise, ediff-regions-linewise):
* ediff-vers.el (rcs-ediff-view-revision):
* ediff-util.el (ediff-setup):
* ediff-mult.el (ediff-append-custom-diff):
* ediff-diff.el (ediff-exec-process, ediff-process-sentinel)
(ediff-wordify):
* echistory.el (Electric-command-history-redo-expression):
* dos-w32.el (find-file-not-found-set-buffer-file-coding-system):
* disp-table.el (describe-display-table):
* dired.el (dired-find-buffer-nocreate):
* dired-aux.el (dired-rename-subdir, dired-dwim-target-directory):
* dabbrev.el (dabbrev--same-major-mode-p):
* chistory.el (list-command-history):
* apropos.el (apropos-documentation):
* allout.el (allout-obtain-passphrase):
(allout-copy-exposed-to-buffer):
(allout-verify-passphrase): Use with-current-buffer.
2009-11-13 22:19:45 +00:00
|
|
|
|
(with-current-buffer buffer
|
2009-12-04 04:39:21 +00:00
|
|
|
|
(let ((proc (get-buffer-process buffer))) ; Blast any old process.
|
(term-if-xemacs, term-ifnot-xemacs): Delete, replace
uses with a simple test.
(term-set-escape-char, term-mode, term-check-kill-echo-list)
(term-send-raw-string, term-send-raw, term-mouse-paste)
(term-char-mode, term-line-mode, term-exec, term-sentinel)
(term-handle-exit, term-read-input-ring)
(term-previous-matching-input-string)
(term-previous-matching-input-string-position)
(term-previous-matching-input-from-input)
(term-replace-by-expanded-history, term-send-input)
(term-skip-prompt, term-bol, term-send-invisible)
(term-kill-input, term-delchar-or-maybe-eof)
(term-backward-matching-input, term-check-source)
(term-proc-query, term-emulate-terminal)
(term-handle-colors-array, term-process-pager, term-pager-line)
(term-pager-bob, term-unwrap-line, term-word)
(term-dynamic-complete-filename)
(term-dynamic-complete-as-filename)
(term-dynamic-simple-complete): Replace one arm ifs with whens or
unlesses.
2006-05-29 06:11:33 +00:00
|
|
|
|
(when proc (delete-process proc)))
|
1994-10-13 06:30:49 +00:00
|
|
|
|
;; Crank up a new process
|
|
|
|
|
(let ((proc (term-exec-1 name buffer command switches)))
|
2020-12-08 07:52:57 +00:00
|
|
|
|
(setq-local term-ptyp process-connection-type) ; t if pty, nil if pipe.
|
1994-10-13 06:30:49 +00:00
|
|
|
|
;; Jump to the end, and set the process mark.
|
|
|
|
|
(goto-char (point-max))
|
|
|
|
|
(set-marker (process-mark proc) (point))
|
2019-02-24 21:19:59 +00:00
|
|
|
|
(set-process-filter proc #'term-emulate-terminal)
|
|
|
|
|
(set-process-sentinel proc #'term-sentinel)
|
1994-10-13 06:30:49 +00:00
|
|
|
|
;; Feed it the startfile.
|
2009-12-04 04:39:21 +00:00
|
|
|
|
(when startfile
|
|
|
|
|
;;This is guaranteed to wait long enough
|
|
|
|
|
;;but has bad results if the term does not prompt at all
|
|
|
|
|
;; (while (= size (buffer-size))
|
|
|
|
|
;; (sleep-for 1))
|
|
|
|
|
;;I hope 1 second is enough!
|
|
|
|
|
(sleep-for 1)
|
|
|
|
|
(goto-char (point-max))
|
|
|
|
|
(insert-file-contents startfile)
|
|
|
|
|
(term-send-string
|
|
|
|
|
proc (delete-and-extract-region (point) (point-max)))))
|
1994-10-13 06:30:49 +00:00
|
|
|
|
(run-hooks 'term-exec-hook)
|
2009-12-04 04:39:21 +00:00
|
|
|
|
buffer))
|
1994-10-13 06:30:49 +00:00
|
|
|
|
|
(term-buffer-maximum-size, term-exec, term-escape-char, term-set-escape-char,
term-termcap-format, term-get-old-input-default, term-skip-prompt,
term-send-string, term-send-region, term-pager-page, term-pager-help):
Fix typos in docstrings.
2007-04-13 09:00:41 +00:00
|
|
|
|
(defun term-sentinel (proc msg)
|
2004-04-16 12:51:06 +00:00
|
|
|
|
"Sentinel for term buffers.
|
|
|
|
|
The main purpose is to get rid of the local keymap."
|
|
|
|
|
(let ((buffer (process-buffer proc)))
|
(term-if-xemacs, term-ifnot-xemacs): Delete, replace
uses with a simple test.
(term-set-escape-char, term-mode, term-check-kill-echo-list)
(term-send-raw-string, term-send-raw, term-mouse-paste)
(term-char-mode, term-line-mode, term-exec, term-sentinel)
(term-handle-exit, term-read-input-ring)
(term-previous-matching-input-string)
(term-previous-matching-input-string-position)
(term-previous-matching-input-from-input)
(term-replace-by-expanded-history, term-send-input)
(term-skip-prompt, term-bol, term-send-invisible)
(term-kill-input, term-delchar-or-maybe-eof)
(term-backward-matching-input, term-check-source)
(term-proc-query, term-emulate-terminal)
(term-handle-colors-array, term-process-pager, term-pager-line)
(term-pager-bob, term-unwrap-line, term-word)
(term-dynamic-complete-filename)
(term-dynamic-complete-as-filename)
(term-dynamic-simple-complete): Replace one arm ifs with whens or
unlesses.
2006-05-29 06:11:33 +00:00
|
|
|
|
(when (memq (process-status proc) '(signal exit))
|
|
|
|
|
(if (null (buffer-name buffer))
|
|
|
|
|
;; buffer killed
|
|
|
|
|
(set-process-buffer proc nil)
|
* x-dnd.el (x-dnd-maybe-call-test-function):
* window.el (split-window-vertically):
* whitespace.el (whitespace-help-on):
* vc-rcs.el (vc-rcs-consult-headers):
* userlock.el (ask-user-about-lock-help)
(ask-user-about-supersession-help):
* type-break.el (type-break-force-mode-line-update):
* time-stamp.el (time-stamp-conv-warn):
* terminal.el (te-set-output-log, te-more-break, te-filter)
(te-sentinel,terminal-emulator):
* term.el (make-term, term-exec, term-sentinel, term-read-input-ring)
(term-write-input-ring, term-check-source, term-start-output-log):
(term-display-buffer-line, term-dynamic-list-completions):
(term-ansi-make-term, serial-term):
* subr.el (selective-display):
* strokes.el (strokes-xpm-to-compressed-string, strokes-decode-buffer)
(strokes-encode-buffer, strokes-xpm-for-compressed-string):
* speedbar.el (speedbar-buffers-tail-notes, speedbar-buffers-item-info)
(speedbar-reconfigure-keymaps, speedbar-add-localized-speedbar-support)
(speedbar-remove-localized-speedbar-support)
(speedbar-set-mode-line-format, speedbar-create-tag-hierarchy)
(speedbar-update-special-contents, speedbar-buffer-buttons-engine)
(speedbar-buffers-line-directory):
* simple.el (shell-command-on-region, append-to-buffer)
(prepend-to-buffer):
* shadowfile.el (shadow-save-todo-file):
* scroll-bar.el (scroll-bar-set-window-start, scroll-bar-drag-1)
(scroll-bar-maybe-set-window-start):
* sb-image.el (speedbar-image-dump):
* saveplace.el (save-place-alist-to-file, save-places-to-alist)
(load-save-place-alist-from-file):
* ps-samp.el (ps-print-message-from-summary):
* ps-print.el (ps-flush-output, ps-insert-file, ps-get-boundingbox)
(ps-background-image, ps-begin-job, ps-do-despool):
* ps-bdf.el (bdf-find-file, bdf-read-font-info):
* printing.el (pr-interface, pr-ps-file-print, pr-find-buffer-visiting)
(pr-ps-message-from-summary, pr-lpr-message-from-summary):
(pr-call-process, pr-file-list, pr-interface-save):
* novice.el (disabled-command-function)
(enable-command, disable-command):
* mouse.el (mouse-buffer-menu-alist):
* mouse-copy.el (mouse-kill-preserving-secondary):
* macros.el (kbd-macro-query):
* ledit.el (ledit-go-to-lisp, ledit-go-to-liszt):
* informat.el (batch-info-validate):
* ido.el (ido-copy-current-word, ido-initiate-auto-merge):
* hippie-exp.el (try-expand-dabbrev-visible):
* help-mode.el (help-make-xrefs):
* help-fns.el (describe-variable):
* generic-x.el (bat-generic-mode-run-as-comint):
* finder.el (finder-mouse-select):
* find-dired.el (find-dired-sentinel):
* filesets.el (filesets-file-close):
* files.el (list-directory):
* faces.el (list-faces-display, describe-face):
* facemenu.el (list-colors-display):
* ezimage.el (ezimage-image-association-dump, ezimage-image-dump):
* epg.el (epg--process-filter, epg-cancel):
* epa.el (epa--marked-keys, epa--select-keys, epa-display-info)
(epa--read-signature-type):
* emerge.el (emerge-copy-as-kill-A, emerge-copy-as-kill-B)
(emerge-file-names):
* ehelp.el (electric-helpify):
* ediff.el (ediff-regions-wordwise, ediff-regions-linewise):
* ediff-vers.el (rcs-ediff-view-revision):
* ediff-util.el (ediff-setup):
* ediff-mult.el (ediff-append-custom-diff):
* ediff-diff.el (ediff-exec-process, ediff-process-sentinel)
(ediff-wordify):
* echistory.el (Electric-command-history-redo-expression):
* dos-w32.el (find-file-not-found-set-buffer-file-coding-system):
* disp-table.el (describe-display-table):
* dired.el (dired-find-buffer-nocreate):
* dired-aux.el (dired-rename-subdir, dired-dwim-target-directory):
* dabbrev.el (dabbrev--same-major-mode-p):
* chistory.el (list-command-history):
* apropos.el (apropos-documentation):
* allout.el (allout-obtain-passphrase):
(allout-copy-exposed-to-buffer):
(allout-verify-passphrase): Use with-current-buffer.
2009-11-13 22:19:45 +00:00
|
|
|
|
(with-current-buffer buffer
|
|
|
|
|
;; Write something in the compilation buffer
|
|
|
|
|
;; and hack its mode line.
|
|
|
|
|
;; Get rid of local keymap.
|
|
|
|
|
(use-local-map nil)
|
|
|
|
|
(term-handle-exit (process-name proc) msg)
|
|
|
|
|
;; Since the buffer and mode line will show that the
|
|
|
|
|
;; process is dead, we can delete it now. Otherwise it
|
|
|
|
|
;; will stay around until M-x list-processes.
|
|
|
|
|
(delete-process proc))))))
|
2004-04-16 12:51:06 +00:00
|
|
|
|
|
|
|
|
|
(defun term-handle-exit (process-name msg)
|
|
|
|
|
"Write process exit (or other change) message MSG in the current buffer."
|
|
|
|
|
(let ((buffer-read-only nil)
|
|
|
|
|
(omax (point-max))
|
|
|
|
|
(opoint (point)))
|
2018-04-22 03:01:11 +00:00
|
|
|
|
;; Remove hooks to avoid errors due to dead process.
|
|
|
|
|
(remove-hook 'pre-command-hook #'term-set-goto-process-mark t)
|
|
|
|
|
(remove-hook 'post-command-hook #'term-goto-process-mark-maybe t)
|
2004-04-16 12:51:06 +00:00
|
|
|
|
;; Record where we put the message, so we can ignore it
|
|
|
|
|
;; later on.
|
|
|
|
|
(goto-char omax)
|
|
|
|
|
(insert ?\n "Process " process-name " " msg)
|
|
|
|
|
;; Force mode line redisplay soon.
|
|
|
|
|
(force-mode-line-update)
|
(term-if-xemacs, term-ifnot-xemacs): Delete, replace
uses with a simple test.
(term-set-escape-char, term-mode, term-check-kill-echo-list)
(term-send-raw-string, term-send-raw, term-mouse-paste)
(term-char-mode, term-line-mode, term-exec, term-sentinel)
(term-handle-exit, term-read-input-ring)
(term-previous-matching-input-string)
(term-previous-matching-input-string-position)
(term-previous-matching-input-from-input)
(term-replace-by-expanded-history, term-send-input)
(term-skip-prompt, term-bol, term-send-invisible)
(term-kill-input, term-delchar-or-maybe-eof)
(term-backward-matching-input, term-check-source)
(term-proc-query, term-emulate-terminal)
(term-handle-colors-array, term-process-pager, term-pager-line)
(term-pager-bob, term-unwrap-line, term-word)
(term-dynamic-complete-filename)
(term-dynamic-complete-as-filename)
(term-dynamic-simple-complete): Replace one arm ifs with whens or
unlesses.
2006-05-29 06:11:33 +00:00
|
|
|
|
(when (and opoint (< opoint omax))
|
|
|
|
|
(goto-char opoint))))
|
2004-04-16 12:51:06 +00:00
|
|
|
|
|
|
|
|
|
|
2009-08-16 15:39:11 +00:00
|
|
|
|
(defvar term-term-name "eterm-color"
|
|
|
|
|
"Name to use for TERM.
|
|
|
|
|
Using \"emacs\" loses, because bash disables editing if $TERM == emacs.")
|
|
|
|
|
;; Format string, usage:
|
|
|
|
|
;; (format term-termcap-string emacs-term-name "TERMCAP=" 24 80)
|
1994-10-13 06:30:49 +00:00
|
|
|
|
(defvar term-termcap-format
|
1994-11-22 10:47:06 +00:00
|
|
|
|
"%s%s:li#%d:co#%d:cl=\\E[H\\E[J:cd=\\E[J:bs:am:xn:cm=\\E[%%i%%d;%%dH\
|
1994-10-13 06:30:49 +00:00
|
|
|
|
:nd=\\E[C:up=\\E[A:ce=\\E[K:ho=\\E[H:pt\
|
2004-09-17 21:07:12 +00:00
|
|
|
|
:al=\\E[L:dl=\\E[M:DL=\\E[%%dM:AL=\\E[%%dL:cs=\\E[%%i%%d;%%dr:sf=^J\
|
2022-01-23 20:13:24 +00:00
|
|
|
|
:NR:te=\\E[47l:ti=\\E[47h\
|
1994-11-22 10:47:06 +00:00
|
|
|
|
:dc=\\E[P:DC=\\E[%%dP:IC=\\E[%%d@:im=\\E[4h:ei=\\E[4l:mi:\
|
2021-09-27 13:15:57 +00:00
|
|
|
|
:mb=\\E[5m:mh=\\E[2m:ZR=\\E[23m:ZH=\\E[3m\
|
1994-10-13 06:30:49 +00:00
|
|
|
|
:so=\\E[7m:se=\\E[m:us=\\E[4m:ue=\\E[m:md=\\E[1m:mr=\\E[7m:me=\\E[m\
|
2004-09-17 21:07:12 +00:00
|
|
|
|
:UP=\\E[%%dA:DO=\\E[%%dB:LE=\\E[%%dD:RI=\\E[%%dC\
|
|
|
|
|
:kl=\\EOD:kd=\\EOB:kr=\\EOC:ku=\\EOA:kN=\\E[6~:kP=\\E[5~:@7=\\E[4~:kh=\\E[1~\
|
2021-09-25 21:28:08 +00:00
|
|
|
|
:mk=\\E[8m:cb=\\E[1K:op=\\E[39;49m:Co#256:pa#32767\
|
|
|
|
|
:AB=\\E[48;5;%%dm:AF=\\E[38;5;%%dm:cr=^M\
|
2015-12-19 10:17:10 +00:00
|
|
|
|
:bl=^G:do=^J:le=^H:ta=^I:se=\\E[27m:ue=\\E[24m\
|
2005-11-15 17:13:22 +00:00
|
|
|
|
:kb=^?:kD=^[[3~:sc=\\E7:rc=\\E8:r1=\\Ec:"
|
2009-08-16 15:39:11 +00:00
|
|
|
|
;; : -undefine ic
|
|
|
|
|
;; don't define :te=\\E[2J\\E[?47l\\E8:ti=\\E7\\E[?47h\
|
(term-buffer-maximum-size, term-exec, term-escape-char, term-set-escape-char,
term-termcap-format, term-get-old-input-default, term-skip-prompt,
term-send-string, term-send-region, term-pager-page, term-pager-help):
Fix typos in docstrings.
2007-04-13 09:00:41 +00:00
|
|
|
|
"Termcap capabilities supported.")
|
1994-10-13 06:30:49 +00:00
|
|
|
|
|
2018-05-26 20:29:06 +00:00
|
|
|
|
;; This private hack is for backwards compatibility with Bash 4.3 and earlier.
|
|
|
|
|
;; It can be useful even when running a program other than Bash, as the
|
|
|
|
|
;; program might invoke Bash as an interactive subshell. See this thread:
|
|
|
|
|
;; https://lists.gnu.org/r/emacs-devel/2018-05/msg00670.html
|
|
|
|
|
;; Remove this hack and its uses once Bash 4.4-or-later is reasonably
|
|
|
|
|
;; universal, because it slows down execution slightly when
|
|
|
|
|
;; term--bash-needs-EMACSp is first called.
|
|
|
|
|
(defvar term--bash-needs-EMACS-status nil
|
|
|
|
|
"43 if Bash is so old that it needs EMACS set.
|
|
|
|
|
Some other integer if Bash is new or not in use.
|
|
|
|
|
Nil if unknown.")
|
|
|
|
|
(defun term--bash-needs-EMACSp ()
|
2021-09-22 18:26:40 +00:00
|
|
|
|
"Return t if Bash is old, nil if it is new or not in use."
|
2018-05-26 20:29:06 +00:00
|
|
|
|
(eq 43
|
|
|
|
|
(or term--bash-needs-EMACS-status
|
|
|
|
|
(setf
|
|
|
|
|
term--bash-needs-EMACS-status
|
|
|
|
|
(let ((process-environment
|
|
|
|
|
(cons "BASH_ENV" process-environment)))
|
|
|
|
|
(condition-case nil
|
|
|
|
|
(call-process
|
|
|
|
|
"bash" nil nil nil "-c"
|
|
|
|
|
"case $BASH_VERSION in [0123].*|4.[0123].*) exit 43;; esac")
|
|
|
|
|
(error 0)))))))
|
|
|
|
|
|
2009-08-16 15:39:11 +00:00
|
|
|
|
;; This auxiliary function cranks up the process for term-exec in
|
|
|
|
|
;; the appropriate environment.
|
1994-10-13 06:30:49 +00:00
|
|
|
|
|
|
|
|
|
(defun term-exec-1 (name buffer command switches)
|
1994-11-22 10:47:06 +00:00
|
|
|
|
;; We need to do an extra (fork-less) exec to run stty.
|
1997-04-02 03:46:39 +00:00
|
|
|
|
;; (This would not be needed if we had suitable Emacs primitives.)
|
1994-11-22 10:47:06 +00:00
|
|
|
|
;; The 'if ...; then shift; fi' hack is because Bourne shell
|
|
|
|
|
;; loses one arg when called with -c, and newer shells (bash, ksh) don't.
|
|
|
|
|
;; Thus we add an extra dummy argument "..", and then remove it.
|
|
|
|
|
(let ((process-environment
|
|
|
|
|
(nconc
|
|
|
|
|
(list
|
|
|
|
|
(format "TERM=%s" term-term-name)
|
2004-09-17 21:07:12 +00:00
|
|
|
|
(format "TERMINFO=%s" data-directory)
|
|
|
|
|
(format term-termcap-format "TERMCAP="
|
|
|
|
|
term-term-name term-height term-width)
|
2016-03-23 22:07:56 +00:00
|
|
|
|
|
2020-08-15 12:35:16 +00:00
|
|
|
|
(format "INSIDE_EMACS=%s,term:%s"
|
|
|
|
|
emacs-version term-protocol-version))
|
|
|
|
|
(when term-set-terminal-size
|
|
|
|
|
(list
|
|
|
|
|
(format "LINES=%d" term-height)
|
|
|
|
|
(format "COLUMNS=%d" term-width)))
|
1996-06-23 15:51:57 +00:00
|
|
|
|
process-environment))
|
1997-10-23 12:03:07 +00:00
|
|
|
|
(process-connection-type t)
|
|
|
|
|
;; We should suppress conversion of end-of-line format.
|
|
|
|
|
(inhibit-eol-conversion t)
|
2004-09-26 18:39:10 +00:00
|
|
|
|
;; The process's output contains not just chars but also binary
|
|
|
|
|
;; escape codes, so we need to see the raw output. We will have to
|
|
|
|
|
;; do the decoding by hand on the parts that are made of chars.
|
|
|
|
|
(coding-system-for-read 'binary))
|
2018-05-26 20:29:06 +00:00
|
|
|
|
(when (term--bash-needs-EMACSp)
|
|
|
|
|
(push (format "EMACS=%s (term:%s)" emacs-version term-protocol-version)
|
|
|
|
|
process-environment))
|
2019-02-24 21:19:59 +00:00
|
|
|
|
(apply #'start-process name buffer
|
1994-11-22 10:47:06 +00:00
|
|
|
|
"/bin/sh" "-c"
|
2020-11-25 21:13:33 +00:00
|
|
|
|
(format "stty -nl echo rows %d columns %d sane 2>%s;\
|
1994-11-22 10:47:06 +00:00
|
|
|
|
if [ $1 = .. ]; then shift; fi; exec \"$@\""
|
2020-11-25 21:13:33 +00:00
|
|
|
|
term-height term-width null-device)
|
1994-11-22 10:47:06 +00:00
|
|
|
|
".."
|
|
|
|
|
command switches)))
|
1994-10-13 06:30:49 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;; Input history processing in a buffer
|
2009-08-16 15:39:11 +00:00
|
|
|
|
;; ===========================================================================
|
|
|
|
|
;; Useful input history functions, courtesy of the Ergo group.
|
|
|
|
|
|
|
|
|
|
;; Eleven commands:
|
|
|
|
|
;; term-dynamic-list-input-ring List history in help buffer.
|
|
|
|
|
;; term-previous-input Previous input...
|
|
|
|
|
;; term-previous-matching-input ...matching a string.
|
|
|
|
|
;; term-previous-matching-input-from-input ... matching the current input.
|
|
|
|
|
;; term-next-input Next input...
|
|
|
|
|
;; term-next-matching-input ...matching a string.
|
|
|
|
|
;; term-next-matching-input-from-input ... matching the current input.
|
|
|
|
|
;; term-backward-matching-input Backwards input...
|
|
|
|
|
;; term-forward-matching-input ...matching a string.
|
|
|
|
|
;; term-replace-by-expanded-history Expand history at point;
|
|
|
|
|
;; replace with expanded history.
|
|
|
|
|
;; term-magic-space Expand history and insert space.
|
|
|
|
|
;;
|
|
|
|
|
;; Three functions:
|
|
|
|
|
;; term-read-input-ring Read into term-input-ring...
|
|
|
|
|
;; term-write-input-ring Write to term-input-ring-file-name.
|
|
|
|
|
;; term-replace-by-expanded-history-before-point Workhorse function.
|
1994-10-13 06:30:49 +00:00
|
|
|
|
|
|
|
|
|
(defun term-read-input-ring (&optional silent)
|
2010-08-02 04:14:26 +00:00
|
|
|
|
"Set the buffer's `term-input-ring' from a history file.
|
1994-10-13 06:30:49 +00:00
|
|
|
|
The name of the file is given by the variable `term-input-ring-file-name'.
|
|
|
|
|
The history ring is of size `term-input-ring-size', regardless of file size.
|
|
|
|
|
If `term-input-ring-file-name' is nil this function does nothing.
|
|
|
|
|
|
|
|
|
|
If the optional argument SILENT is non-nil, we say nothing about a
|
|
|
|
|
failure to read the history file.
|
|
|
|
|
|
|
|
|
|
This function is useful for major mode commands and mode hooks.
|
|
|
|
|
|
|
|
|
|
The structure of the history file should be one input command per line,
|
|
|
|
|
with the most recent command last.
|
|
|
|
|
See also `term-input-ignoredups' and `term-write-input-ring'."
|
|
|
|
|
(cond ((or (null term-input-ring-file-name)
|
|
|
|
|
(equal term-input-ring-file-name ""))
|
|
|
|
|
nil)
|
|
|
|
|
((not (file-readable-p term-input-ring-file-name))
|
|
|
|
|
(or silent
|
|
|
|
|
(message "Cannot read history file %s"
|
|
|
|
|
term-input-ring-file-name)))
|
|
|
|
|
(t
|
2011-01-20 22:36:12 +00:00
|
|
|
|
(let ((file term-input-ring-file-name)
|
1994-10-13 06:30:49 +00:00
|
|
|
|
(count 0)
|
|
|
|
|
(ring (make-ring term-input-ring-size)))
|
2011-01-20 22:36:12 +00:00
|
|
|
|
(with-temp-buffer
|
|
|
|
|
(insert-file-contents file)
|
|
|
|
|
;; Save restriction in case file is already visited...
|
|
|
|
|
;; Watch for those date stamps in history files!
|
|
|
|
|
(goto-char (point-max))
|
|
|
|
|
(while (and (< count term-input-ring-size)
|
|
|
|
|
(re-search-backward "^[ \t]*\\([^#\n].*\\)[ \t]*$"
|
|
|
|
|
nil t))
|
|
|
|
|
(let ((history (buffer-substring (match-beginning 1)
|
|
|
|
|
(match-end 1))))
|
|
|
|
|
(when (or (null term-input-ignoredups)
|
|
|
|
|
(ring-empty-p ring)
|
|
|
|
|
(not (string-equal (ring-ref ring 0) history)))
|
|
|
|
|
(ring-insert-at-beginning ring history)))
|
|
|
|
|
(setq count (1+ count))))
|
1994-10-13 06:30:49 +00:00
|
|
|
|
(setq term-input-ring ring
|
|
|
|
|
term-input-ring-index nil)))))
|
|
|
|
|
|
|
|
|
|
(defun term-write-input-ring ()
|
2010-08-02 04:14:26 +00:00
|
|
|
|
"Write the buffer's `term-input-ring' to a history file.
|
1994-10-13 06:30:49 +00:00
|
|
|
|
The name of the file is given by the variable `term-input-ring-file-name'.
|
|
|
|
|
The original contents of the file are lost if `term-input-ring' is not empty.
|
|
|
|
|
If `term-input-ring-file-name' is nil this function does nothing.
|
|
|
|
|
|
|
|
|
|
Useful within process sentinels.
|
|
|
|
|
|
|
|
|
|
See also `term-read-input-ring'."
|
|
|
|
|
(cond ((or (null term-input-ring-file-name)
|
|
|
|
|
(equal term-input-ring-file-name "")
|
|
|
|
|
(null term-input-ring) (ring-empty-p term-input-ring))
|
|
|
|
|
nil)
|
|
|
|
|
((not (file-writable-p term-input-ring-file-name))
|
|
|
|
|
(message "Cannot write history file %s" term-input-ring-file-name))
|
|
|
|
|
(t
|
|
|
|
|
(let* ((history-buf (get-buffer-create " *Temp Input History*"))
|
|
|
|
|
(ring term-input-ring)
|
|
|
|
|
(file term-input-ring-file-name)
|
|
|
|
|
(index (ring-length ring)))
|
|
|
|
|
;; Write it all out into a buffer first. Much faster, but messier,
|
|
|
|
|
;; than writing it one line at a time.
|
* x-dnd.el (x-dnd-maybe-call-test-function):
* window.el (split-window-vertically):
* whitespace.el (whitespace-help-on):
* vc-rcs.el (vc-rcs-consult-headers):
* userlock.el (ask-user-about-lock-help)
(ask-user-about-supersession-help):
* type-break.el (type-break-force-mode-line-update):
* time-stamp.el (time-stamp-conv-warn):
* terminal.el (te-set-output-log, te-more-break, te-filter)
(te-sentinel,terminal-emulator):
* term.el (make-term, term-exec, term-sentinel, term-read-input-ring)
(term-write-input-ring, term-check-source, term-start-output-log):
(term-display-buffer-line, term-dynamic-list-completions):
(term-ansi-make-term, serial-term):
* subr.el (selective-display):
* strokes.el (strokes-xpm-to-compressed-string, strokes-decode-buffer)
(strokes-encode-buffer, strokes-xpm-for-compressed-string):
* speedbar.el (speedbar-buffers-tail-notes, speedbar-buffers-item-info)
(speedbar-reconfigure-keymaps, speedbar-add-localized-speedbar-support)
(speedbar-remove-localized-speedbar-support)
(speedbar-set-mode-line-format, speedbar-create-tag-hierarchy)
(speedbar-update-special-contents, speedbar-buffer-buttons-engine)
(speedbar-buffers-line-directory):
* simple.el (shell-command-on-region, append-to-buffer)
(prepend-to-buffer):
* shadowfile.el (shadow-save-todo-file):
* scroll-bar.el (scroll-bar-set-window-start, scroll-bar-drag-1)
(scroll-bar-maybe-set-window-start):
* sb-image.el (speedbar-image-dump):
* saveplace.el (save-place-alist-to-file, save-places-to-alist)
(load-save-place-alist-from-file):
* ps-samp.el (ps-print-message-from-summary):
* ps-print.el (ps-flush-output, ps-insert-file, ps-get-boundingbox)
(ps-background-image, ps-begin-job, ps-do-despool):
* ps-bdf.el (bdf-find-file, bdf-read-font-info):
* printing.el (pr-interface, pr-ps-file-print, pr-find-buffer-visiting)
(pr-ps-message-from-summary, pr-lpr-message-from-summary):
(pr-call-process, pr-file-list, pr-interface-save):
* novice.el (disabled-command-function)
(enable-command, disable-command):
* mouse.el (mouse-buffer-menu-alist):
* mouse-copy.el (mouse-kill-preserving-secondary):
* macros.el (kbd-macro-query):
* ledit.el (ledit-go-to-lisp, ledit-go-to-liszt):
* informat.el (batch-info-validate):
* ido.el (ido-copy-current-word, ido-initiate-auto-merge):
* hippie-exp.el (try-expand-dabbrev-visible):
* help-mode.el (help-make-xrefs):
* help-fns.el (describe-variable):
* generic-x.el (bat-generic-mode-run-as-comint):
* finder.el (finder-mouse-select):
* find-dired.el (find-dired-sentinel):
* filesets.el (filesets-file-close):
* files.el (list-directory):
* faces.el (list-faces-display, describe-face):
* facemenu.el (list-colors-display):
* ezimage.el (ezimage-image-association-dump, ezimage-image-dump):
* epg.el (epg--process-filter, epg-cancel):
* epa.el (epa--marked-keys, epa--select-keys, epa-display-info)
(epa--read-signature-type):
* emerge.el (emerge-copy-as-kill-A, emerge-copy-as-kill-B)
(emerge-file-names):
* ehelp.el (electric-helpify):
* ediff.el (ediff-regions-wordwise, ediff-regions-linewise):
* ediff-vers.el (rcs-ediff-view-revision):
* ediff-util.el (ediff-setup):
* ediff-mult.el (ediff-append-custom-diff):
* ediff-diff.el (ediff-exec-process, ediff-process-sentinel)
(ediff-wordify):
* echistory.el (Electric-command-history-redo-expression):
* dos-w32.el (find-file-not-found-set-buffer-file-coding-system):
* disp-table.el (describe-display-table):
* dired.el (dired-find-buffer-nocreate):
* dired-aux.el (dired-rename-subdir, dired-dwim-target-directory):
* dabbrev.el (dabbrev--same-major-mode-p):
* chistory.el (list-command-history):
* apropos.el (apropos-documentation):
* allout.el (allout-obtain-passphrase):
(allout-copy-exposed-to-buffer):
(allout-verify-passphrase): Use with-current-buffer.
2009-11-13 22:19:45 +00:00
|
|
|
|
(with-current-buffer history-buf
|
1994-10-13 06:30:49 +00:00
|
|
|
|
(erase-buffer)
|
|
|
|
|
(while (> index 0)
|
|
|
|
|
(setq index (1- index))
|
|
|
|
|
(insert (ring-ref ring index) ?\n))
|
|
|
|
|
(write-region (buffer-string) nil file nil 'no-message)
|
|
|
|
|
(kill-buffer nil))))))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defun term-dynamic-list-input-ring ()
|
|
|
|
|
"List in help buffer the buffer's input history."
|
|
|
|
|
(interactive)
|
|
|
|
|
(if (or (not (ring-p term-input-ring))
|
|
|
|
|
(ring-empty-p term-input-ring))
|
|
|
|
|
(message "No history")
|
|
|
|
|
(let ((history nil)
|
|
|
|
|
(history-buffer " *Input History*")
|
|
|
|
|
(index (1- (ring-length term-input-ring)))
|
|
|
|
|
(conf (current-window-configuration)))
|
|
|
|
|
;; We have to build up a list ourselves from the ring vector.
|
|
|
|
|
(while (>= index 0)
|
|
|
|
|
(setq history (cons (ring-ref term-input-ring index) history)
|
|
|
|
|
index (1- index)))
|
|
|
|
|
;; Change "completion" to "history reference"
|
|
|
|
|
;; to make the display accurate.
|
|
|
|
|
(with-output-to-temp-buffer history-buffer
|
|
|
|
|
(display-completion-list history)
|
|
|
|
|
(set-buffer history-buffer)
|
|
|
|
|
(forward-line 3)
|
|
|
|
|
(while (search-backward "completion" nil 'move)
|
|
|
|
|
(replace-match "history reference")))
|
|
|
|
|
(sit-for 0)
|
|
|
|
|
(message "Hit space to flush")
|
|
|
|
|
(let ((ch (read-event)))
|
2005-07-04 02:35:55 +00:00
|
|
|
|
(if (eq ch ?\s)
|
1994-10-13 06:30:49 +00:00
|
|
|
|
(set-window-configuration conf)
|
2015-07-25 16:54:42 +00:00
|
|
|
|
(push ch unread-command-events))))))
|
1994-10-13 06:30:49 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defun term-regexp-arg (prompt)
|
|
|
|
|
;; Return list of regexp and prefix arg using PROMPT.
|
1997-10-02 03:03:50 +00:00
|
|
|
|
(let* (;; Don't clobber this.
|
1994-10-13 06:30:49 +00:00
|
|
|
|
(last-command last-command)
|
|
|
|
|
(regexp (read-from-minibuffer prompt nil nil nil
|
|
|
|
|
'minibuffer-history-search-history)))
|
|
|
|
|
(list (if (string-equal regexp "")
|
|
|
|
|
(setcar minibuffer-history-search-history
|
|
|
|
|
(nth 1 minibuffer-history-search-history))
|
|
|
|
|
regexp)
|
|
|
|
|
(prefix-numeric-value current-prefix-arg))))
|
|
|
|
|
|
|
|
|
|
(defun term-search-arg (arg)
|
|
|
|
|
;; First make sure there is a ring and that we are after the process mark
|
|
|
|
|
(cond ((not (term-after-pmark-p))
|
|
|
|
|
(error "Not at command line"))
|
|
|
|
|
((or (null term-input-ring)
|
|
|
|
|
(ring-empty-p term-input-ring))
|
|
|
|
|
(error "Empty input ring"))
|
|
|
|
|
((zerop arg)
|
|
|
|
|
;; arg of zero resets search from beginning, and uses arg of 1
|
|
|
|
|
(setq term-input-ring-index nil)
|
|
|
|
|
1)
|
|
|
|
|
(t
|
|
|
|
|
arg)))
|
|
|
|
|
|
|
|
|
|
(defun term-search-start (arg)
|
|
|
|
|
;; Index to start a directional search, starting at term-input-ring-index
|
|
|
|
|
(if term-input-ring-index
|
|
|
|
|
;; If a search is running, offset by 1 in direction of arg
|
|
|
|
|
(mod (+ term-input-ring-index (if (> arg 0) 1 -1))
|
|
|
|
|
(ring-length term-input-ring))
|
|
|
|
|
;; For a new search, start from beginning or end, as appropriate
|
|
|
|
|
(if (>= arg 0)
|
|
|
|
|
0 ; First elt for forward search
|
|
|
|
|
(1- (ring-length term-input-ring))))) ; Last elt for backward search
|
|
|
|
|
|
|
|
|
|
(defun term-previous-input-string (arg)
|
|
|
|
|
"Return the string ARG places along the input ring.
|
|
|
|
|
Moves relative to `term-input-ring-index'."
|
|
|
|
|
(ring-ref term-input-ring (if term-input-ring-index
|
1997-04-02 03:46:39 +00:00
|
|
|
|
(mod (+ arg term-input-ring-index)
|
1994-10-13 06:30:49 +00:00
|
|
|
|
(ring-length term-input-ring))
|
|
|
|
|
arg)))
|
|
|
|
|
|
|
|
|
|
(defun term-previous-input (arg)
|
|
|
|
|
"Cycle backwards through input history."
|
|
|
|
|
(interactive "*p")
|
|
|
|
|
(term-previous-matching-input "." arg))
|
|
|
|
|
|
|
|
|
|
(defun term-next-input (arg)
|
|
|
|
|
"Cycle forwards through input history."
|
|
|
|
|
(interactive "*p")
|
|
|
|
|
(term-previous-input (- arg)))
|
|
|
|
|
|
|
|
|
|
(defun term-previous-matching-input-string (regexp arg)
|
|
|
|
|
"Return the string matching REGEXP ARG places along the input ring.
|
|
|
|
|
Moves relative to `term-input-ring-index'."
|
|
|
|
|
(let* ((pos (term-previous-matching-input-string-position regexp arg)))
|
(term-if-xemacs, term-ifnot-xemacs): Delete, replace
uses with a simple test.
(term-set-escape-char, term-mode, term-check-kill-echo-list)
(term-send-raw-string, term-send-raw, term-mouse-paste)
(term-char-mode, term-line-mode, term-exec, term-sentinel)
(term-handle-exit, term-read-input-ring)
(term-previous-matching-input-string)
(term-previous-matching-input-string-position)
(term-previous-matching-input-from-input)
(term-replace-by-expanded-history, term-send-input)
(term-skip-prompt, term-bol, term-send-invisible)
(term-kill-input, term-delchar-or-maybe-eof)
(term-backward-matching-input, term-check-source)
(term-proc-query, term-emulate-terminal)
(term-handle-colors-array, term-process-pager, term-pager-line)
(term-pager-bob, term-unwrap-line, term-word)
(term-dynamic-complete-filename)
(term-dynamic-complete-as-filename)
(term-dynamic-simple-complete): Replace one arm ifs with whens or
unlesses.
2006-05-29 06:11:33 +00:00
|
|
|
|
(when pos (ring-ref term-input-ring pos))))
|
1994-10-13 06:30:49 +00:00
|
|
|
|
|
1997-04-02 03:46:39 +00:00
|
|
|
|
(defun term-previous-matching-input-string-position
|
|
|
|
|
(regexp arg &optional start)
|
1994-10-13 06:30:49 +00:00
|
|
|
|
"Return the index matching REGEXP ARG places along the input ring.
|
|
|
|
|
Moves relative to START, or `term-input-ring-index'."
|
(term-if-xemacs, term-ifnot-xemacs): Delete, replace
uses with a simple test.
(term-set-escape-char, term-mode, term-check-kill-echo-list)
(term-send-raw-string, term-send-raw, term-mouse-paste)
(term-char-mode, term-line-mode, term-exec, term-sentinel)
(term-handle-exit, term-read-input-ring)
(term-previous-matching-input-string)
(term-previous-matching-input-string-position)
(term-previous-matching-input-from-input)
(term-replace-by-expanded-history, term-send-input)
(term-skip-prompt, term-bol, term-send-invisible)
(term-kill-input, term-delchar-or-maybe-eof)
(term-backward-matching-input, term-check-source)
(term-proc-query, term-emulate-terminal)
(term-handle-colors-array, term-process-pager, term-pager-line)
(term-pager-bob, term-unwrap-line, term-word)
(term-dynamic-complete-filename)
(term-dynamic-complete-as-filename)
(term-dynamic-simple-complete): Replace one arm ifs with whens or
unlesses.
2006-05-29 06:11:33 +00:00
|
|
|
|
(when (or (not (ring-p term-input-ring))
|
|
|
|
|
(ring-empty-p term-input-ring))
|
|
|
|
|
(error "No history"))
|
1994-10-13 06:30:49 +00:00
|
|
|
|
(let* ((len (ring-length term-input-ring))
|
|
|
|
|
(motion (if (> arg 0) 1 -1))
|
|
|
|
|
(n (mod (- (or start (term-search-start arg)) motion) len))
|
|
|
|
|
(tried-each-ring-item nil)
|
|
|
|
|
(prev nil))
|
|
|
|
|
;; Do the whole search as many times as the argument says.
|
|
|
|
|
(while (and (/= arg 0) (not tried-each-ring-item))
|
|
|
|
|
;; Step once.
|
|
|
|
|
(setq prev n
|
|
|
|
|
n (mod (+ n motion) len))
|
|
|
|
|
;; If we haven't reached a match, step some more.
|
|
|
|
|
(while (and (< n len) (not tried-each-ring-item)
|
|
|
|
|
(not (string-match regexp (ring-ref term-input-ring n))))
|
|
|
|
|
(setq n (mod (+ n motion) len)
|
|
|
|
|
;; If we have gone all the way around in this search.
|
|
|
|
|
tried-each-ring-item (= n prev)))
|
|
|
|
|
(setq arg (if (> arg 0) (1- arg) (1+ arg))))
|
|
|
|
|
;; Now that we know which ring element to use, if we found it, return that.
|
(term-if-xemacs, term-ifnot-xemacs): Delete, replace
uses with a simple test.
(term-set-escape-char, term-mode, term-check-kill-echo-list)
(term-send-raw-string, term-send-raw, term-mouse-paste)
(term-char-mode, term-line-mode, term-exec, term-sentinel)
(term-handle-exit, term-read-input-ring)
(term-previous-matching-input-string)
(term-previous-matching-input-string-position)
(term-previous-matching-input-from-input)
(term-replace-by-expanded-history, term-send-input)
(term-skip-prompt, term-bol, term-send-invisible)
(term-kill-input, term-delchar-or-maybe-eof)
(term-backward-matching-input, term-check-source)
(term-proc-query, term-emulate-terminal)
(term-handle-colors-array, term-process-pager, term-pager-line)
(term-pager-bob, term-unwrap-line, term-word)
(term-dynamic-complete-filename)
(term-dynamic-complete-as-filename)
(term-dynamic-simple-complete): Replace one arm ifs with whens or
unlesses.
2006-05-29 06:11:33 +00:00
|
|
|
|
(when (string-match regexp (ring-ref term-input-ring n))
|
|
|
|
|
n)))
|
1994-10-13 06:30:49 +00:00
|
|
|
|
|
2009-01-21 11:03:25 +00:00
|
|
|
|
(defun term-previous-matching-input (regexp n)
|
1994-10-13 06:30:49 +00:00
|
|
|
|
"Search backwards through input history for match for REGEXP.
|
|
|
|
|
\(Previous history elements are earlier commands.)
|
|
|
|
|
With prefix argument N, search for Nth previous match.
|
|
|
|
|
If N is negative, find the next or Nth next match."
|
|
|
|
|
(interactive (term-regexp-arg "Previous input matching (regexp): "))
|
2009-01-21 11:03:25 +00:00
|
|
|
|
(setq n (term-search-arg n))
|
|
|
|
|
(let ((pos (term-previous-matching-input-string-position regexp n)))
|
1994-10-13 06:30:49 +00:00
|
|
|
|
;; Has a match been found?
|
|
|
|
|
(if (null pos)
|
|
|
|
|
(error "Not found")
|
|
|
|
|
(setq term-input-ring-index pos)
|
|
|
|
|
(message "History item: %d" (1+ pos))
|
1997-04-02 03:46:39 +00:00
|
|
|
|
(delete-region
|
1994-10-13 06:30:49 +00:00
|
|
|
|
;; Can't use kill-region as it sets this-command
|
|
|
|
|
(process-mark (get-buffer-process (current-buffer))) (point))
|
|
|
|
|
(insert (ring-ref term-input-ring pos)))))
|
|
|
|
|
|
2009-01-21 11:03:25 +00:00
|
|
|
|
(defun term-next-matching-input (regexp n)
|
1994-10-13 06:30:49 +00:00
|
|
|
|
"Search forwards through input history for match for REGEXP.
|
|
|
|
|
\(Later history elements are more recent commands.)
|
|
|
|
|
With prefix argument N, search for Nth following match.
|
|
|
|
|
If N is negative, find the previous or Nth previous match."
|
|
|
|
|
(interactive (term-regexp-arg "Next input matching (regexp): "))
|
2009-01-21 11:03:25 +00:00
|
|
|
|
(term-previous-matching-input regexp (- n)))
|
1994-10-13 06:30:49 +00:00
|
|
|
|
|
2009-01-21 11:03:25 +00:00
|
|
|
|
(defun term-previous-matching-input-from-input (n)
|
1994-10-13 06:30:49 +00:00
|
|
|
|
"Search backwards through input history for match for current input.
|
|
|
|
|
\(Previous history elements are earlier commands.)
|
|
|
|
|
With prefix argument N, search for Nth previous match.
|
|
|
|
|
If N is negative, search forwards for the -Nth following match."
|
|
|
|
|
(interactive "p")
|
(term-if-xemacs, term-ifnot-xemacs): Delete, replace
uses with a simple test.
(term-set-escape-char, term-mode, term-check-kill-echo-list)
(term-send-raw-string, term-send-raw, term-mouse-paste)
(term-char-mode, term-line-mode, term-exec, term-sentinel)
(term-handle-exit, term-read-input-ring)
(term-previous-matching-input-string)
(term-previous-matching-input-string-position)
(term-previous-matching-input-from-input)
(term-replace-by-expanded-history, term-send-input)
(term-skip-prompt, term-bol, term-send-invisible)
(term-kill-input, term-delchar-or-maybe-eof)
(term-backward-matching-input, term-check-source)
(term-proc-query, term-emulate-terminal)
(term-handle-colors-array, term-process-pager, term-pager-line)
(term-pager-bob, term-unwrap-line, term-word)
(term-dynamic-complete-filename)
(term-dynamic-complete-as-filename)
(term-dynamic-simple-complete): Replace one arm ifs with whens or
unlesses.
2006-05-29 06:11:33 +00:00
|
|
|
|
(when (not (memq last-command '(term-previous-matching-input-from-input
|
1994-10-13 06:30:49 +00:00
|
|
|
|
term-next-matching-input-from-input)))
|
(term-if-xemacs, term-ifnot-xemacs): Delete, replace
uses with a simple test.
(term-set-escape-char, term-mode, term-check-kill-echo-list)
(term-send-raw-string, term-send-raw, term-mouse-paste)
(term-char-mode, term-line-mode, term-exec, term-sentinel)
(term-handle-exit, term-read-input-ring)
(term-previous-matching-input-string)
(term-previous-matching-input-string-position)
(term-previous-matching-input-from-input)
(term-replace-by-expanded-history, term-send-input)
(term-skip-prompt, term-bol, term-send-invisible)
(term-kill-input, term-delchar-or-maybe-eof)
(term-backward-matching-input, term-check-source)
(term-proc-query, term-emulate-terminal)
(term-handle-colors-array, term-process-pager, term-pager-line)
(term-pager-bob, term-unwrap-line, term-word)
(term-dynamic-complete-filename)
(term-dynamic-complete-as-filename)
(term-dynamic-simple-complete): Replace one arm ifs with whens or
unlesses.
2006-05-29 06:11:33 +00:00
|
|
|
|
;; Starting a new search
|
|
|
|
|
(setq term-matching-input-from-input-string
|
|
|
|
|
(buffer-substring
|
|
|
|
|
(process-mark (get-buffer-process (current-buffer)))
|
|
|
|
|
(point))
|
|
|
|
|
term-input-ring-index nil))
|
1994-10-13 06:30:49 +00:00
|
|
|
|
(term-previous-matching-input
|
|
|
|
|
(concat "^" (regexp-quote term-matching-input-from-input-string))
|
2009-01-21 11:03:25 +00:00
|
|
|
|
n))
|
1994-10-13 06:30:49 +00:00
|
|
|
|
|
2009-01-21 11:03:25 +00:00
|
|
|
|
(defun term-next-matching-input-from-input (n)
|
1994-10-13 06:30:49 +00:00
|
|
|
|
"Search forwards through input history for match for current input.
|
|
|
|
|
\(Following history elements are more recent commands.)
|
|
|
|
|
With prefix argument N, search for Nth following match.
|
|
|
|
|
If N is negative, search backwards for the -Nth previous match."
|
|
|
|
|
(interactive "p")
|
2009-01-21 11:03:25 +00:00
|
|
|
|
(term-previous-matching-input-from-input (- n)))
|
1994-10-13 06:30:49 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defun term-replace-by-expanded-history (&optional silent)
|
|
|
|
|
"Expand input command history references before point.
|
|
|
|
|
Expansion is dependent on the value of `term-input-autoexpand'.
|
|
|
|
|
|
|
|
|
|
This function depends on the buffer's idea of the input history, which may not
|
|
|
|
|
match the command interpreter's idea, assuming it has one.
|
|
|
|
|
|
1997-04-02 03:46:39 +00:00
|
|
|
|
Assumes history syntax is like typical Un*x shells'. However, since Emacs
|
1994-10-13 06:30:49 +00:00
|
|
|
|
cannot know the interpreter's idea of input line numbers, assuming it has one,
|
|
|
|
|
it cannot expand absolute input line number references.
|
|
|
|
|
|
|
|
|
|
If the optional argument SILENT is non-nil, never complain
|
|
|
|
|
even if history reference seems erroneous.
|
|
|
|
|
|
|
|
|
|
See `term-magic-space' and `term-replace-by-expanded-history-before-point'.
|
|
|
|
|
|
|
|
|
|
Returns t if successful."
|
|
|
|
|
(interactive)
|
(term-if-xemacs, term-ifnot-xemacs): Delete, replace
uses with a simple test.
(term-set-escape-char, term-mode, term-check-kill-echo-list)
(term-send-raw-string, term-send-raw, term-mouse-paste)
(term-char-mode, term-line-mode, term-exec, term-sentinel)
(term-handle-exit, term-read-input-ring)
(term-previous-matching-input-string)
(term-previous-matching-input-string-position)
(term-previous-matching-input-from-input)
(term-replace-by-expanded-history, term-send-input)
(term-skip-prompt, term-bol, term-send-invisible)
(term-kill-input, term-delchar-or-maybe-eof)
(term-backward-matching-input, term-check-source)
(term-proc-query, term-emulate-terminal)
(term-handle-colors-array, term-process-pager, term-pager-line)
(term-pager-bob, term-unwrap-line, term-word)
(term-dynamic-complete-filename)
(term-dynamic-complete-as-filename)
(term-dynamic-simple-complete): Replace one arm ifs with whens or
unlesses.
2006-05-29 06:11:33 +00:00
|
|
|
|
(when (and term-input-autoexpand
|
|
|
|
|
(string-match "[!^]" (funcall term-get-old-input))
|
|
|
|
|
(save-excursion (beginning-of-line)
|
|
|
|
|
(looking-at term-prompt-regexp)))
|
|
|
|
|
;; Looks like there might be history references in the command.
|
|
|
|
|
(let ((previous-modified-tick (buffer-modified-tick)))
|
|
|
|
|
(message "Expanding history references...")
|
|
|
|
|
(term-replace-by-expanded-history-before-point silent)
|
|
|
|
|
(/= previous-modified-tick (buffer-modified-tick)))))
|
1994-10-13 06:30:49 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defun term-replace-by-expanded-history-before-point (silent)
|
|
|
|
|
"Expand directory stack reference before point.
|
|
|
|
|
See `term-replace-by-expanded-history'. Returns t if successful."
|
|
|
|
|
(save-excursion
|
Use line-end-position rather than end-of-line, etc.
* textmodes/texnfo-upd.el (texinfo-start-menu-description)
(texinfo-update-menu-region-beginning, texinfo-menu-first-node)
(texinfo-delete-existing-pointers, texinfo-find-pointer)
(texinfo-clean-up-node-line, texinfo-insert-node-lines)
(texinfo-multiple-files-update):
* textmodes/table.el (table--probe-cell-left-up)
(table--probe-cell-right-bottom):
* textmodes/picture.el (picture-tab-search):
* textmodes/page-ext.el (pages-copy-header-and-position)
(pages-directory-for-addresses):
* progmodes/vera-mode.el (vera-get-offset):
* progmodes/simula.el (simula-calculate-indent):
* progmodes/python.el (python-pdbtrack-overlay-arrow):
* progmodes/prolog.el (end-of-prolog-clause):
* progmodes/perl-mode.el (perl-calculate-indent, perl-indent-exp):
* progmodes/icon.el (indent-icon-exp):
* progmodes/etags.el (tag-re-match-p):
* progmodes/ebrowse.el (ebrowse-show-file-name-at-point):
* progmodes/ebnf2ps.el (ebnf-begin-file):
* progmodes/dcl-mode.el (dcl-back-to-indentation-1)
(dcl-save-local-variable):
* play/life.el (life-setup):
* play/gametree.el (gametree-looking-at-ply):
* nxml/nxml-maint.el (nxml-insert-target-repertoire-glyph-set):
* mail/sendmail.el (mail-mode-auto-fill):
* emacs-lisp/lisp-mode.el (calculate-lisp-indent):
* emacs-lisp/edebug.el (edebug-overlay-arrow):
* emacs-lisp/checkdoc.el (checkdoc-this-string-valid):
* woman.el (woman-parse-numeric-value, woman2-TH, woman2-SH)
(woman-tab-to-tab-stop, WoMan-warn-ignored):
* type-break.el (type-break-file-keystroke-count):
* term.el (term-replace-by-expanded-history-before-point)
(term-skip-prompt, term-extract-string):
* speedbar.el (speedbar-edit-line, speedbar-expand-line)
(speedbar-contract-line, speedbar-toggle-line-expansion)
(speedbar-parse-c-or-c++tag, speedbar-parse-tex-string)
(speedbar-buffer-revert-buffer, speedbar-highlight-one-tag-line):
* sort.el (sort-skip-fields):
* skeleton.el (skeleton-internal-list):
* simple.el (line-move-finish, line-move-to-column):
* shell.el (shell-forward-command):
* misc.el (copy-from-above-command):
* makesum.el (double-column):
* ebuff-menu.el (electric-buffer-update-highlight):
* dired.el (dired-move-to-end-of-filename):
* dframe.el (dframe-popup-kludge):
* bookmark.el (bookmark-kill-line, bookmark-bmenu-show-filenames):
* arc-mode.el (archive-get-lineno):
Use line-end-position and line-beginning-position.
* net/ange-ftp.el, progmodes/hideif.el, reposition.el:
Same, but only in comments.
2010-11-06 20:23:42 +00:00
|
|
|
|
(let ((toend (- (line-end-position) (point)))
|
1994-10-13 06:30:49 +00:00
|
|
|
|
(start (progn (term-bol nil) (point))))
|
|
|
|
|
(while (progn
|
Use line-end-position rather than end-of-line, etc.
* textmodes/texnfo-upd.el (texinfo-start-menu-description)
(texinfo-update-menu-region-beginning, texinfo-menu-first-node)
(texinfo-delete-existing-pointers, texinfo-find-pointer)
(texinfo-clean-up-node-line, texinfo-insert-node-lines)
(texinfo-multiple-files-update):
* textmodes/table.el (table--probe-cell-left-up)
(table--probe-cell-right-bottom):
* textmodes/picture.el (picture-tab-search):
* textmodes/page-ext.el (pages-copy-header-and-position)
(pages-directory-for-addresses):
* progmodes/vera-mode.el (vera-get-offset):
* progmodes/simula.el (simula-calculate-indent):
* progmodes/python.el (python-pdbtrack-overlay-arrow):
* progmodes/prolog.el (end-of-prolog-clause):
* progmodes/perl-mode.el (perl-calculate-indent, perl-indent-exp):
* progmodes/icon.el (indent-icon-exp):
* progmodes/etags.el (tag-re-match-p):
* progmodes/ebrowse.el (ebrowse-show-file-name-at-point):
* progmodes/ebnf2ps.el (ebnf-begin-file):
* progmodes/dcl-mode.el (dcl-back-to-indentation-1)
(dcl-save-local-variable):
* play/life.el (life-setup):
* play/gametree.el (gametree-looking-at-ply):
* nxml/nxml-maint.el (nxml-insert-target-repertoire-glyph-set):
* mail/sendmail.el (mail-mode-auto-fill):
* emacs-lisp/lisp-mode.el (calculate-lisp-indent):
* emacs-lisp/edebug.el (edebug-overlay-arrow):
* emacs-lisp/checkdoc.el (checkdoc-this-string-valid):
* woman.el (woman-parse-numeric-value, woman2-TH, woman2-SH)
(woman-tab-to-tab-stop, WoMan-warn-ignored):
* type-break.el (type-break-file-keystroke-count):
* term.el (term-replace-by-expanded-history-before-point)
(term-skip-prompt, term-extract-string):
* speedbar.el (speedbar-edit-line, speedbar-expand-line)
(speedbar-contract-line, speedbar-toggle-line-expansion)
(speedbar-parse-c-or-c++tag, speedbar-parse-tex-string)
(speedbar-buffer-revert-buffer, speedbar-highlight-one-tag-line):
* sort.el (sort-skip-fields):
* skeleton.el (skeleton-internal-list):
* simple.el (line-move-finish, line-move-to-column):
* shell.el (shell-forward-command):
* misc.el (copy-from-above-command):
* makesum.el (double-column):
* ebuff-menu.el (electric-buffer-update-highlight):
* dired.el (dired-move-to-end-of-filename):
* dframe.el (dframe-popup-kludge):
* bookmark.el (bookmark-kill-line, bookmark-bmenu-show-filenames):
* arc-mode.el (archive-get-lineno):
Use line-end-position and line-beginning-position.
* net/ange-ftp.el, progmodes/hideif.el, reposition.el:
Same, but only in comments.
2010-11-06 20:23:42 +00:00
|
|
|
|
(skip-chars-forward "^!^" (- (line-end-position) toend))
|
|
|
|
|
(< (point) (- (line-end-position) toend)))
|
1994-10-13 06:30:49 +00:00
|
|
|
|
;; This seems a bit complex. We look for references such as !!, !-num,
|
|
|
|
|
;; !foo, !?foo, !{bar}, !?{bar}, ^oh, ^my^, ^god^it, ^never^ends^.
|
|
|
|
|
;; If that wasn't enough, the plings can be suffixed with argument
|
|
|
|
|
;; range specifiers.
|
|
|
|
|
;; Argument ranges are complex too, so we hive off the input line,
|
|
|
|
|
;; referenced with plings, with the range string to `term-args'.
|
|
|
|
|
(setq term-input-ring-index nil)
|
|
|
|
|
(cond ((or (= (preceding-char) ?\\)
|
|
|
|
|
(term-within-quotes start (point)))
|
|
|
|
|
;; The history is quoted, or we're in quotes.
|
|
|
|
|
(goto-char (1+ (point))))
|
|
|
|
|
((looking-at "![0-9]+\\($\\|[^-]\\)")
|
|
|
|
|
;; We cannot know the interpreter's idea of input line numbers.
|
|
|
|
|
(goto-char (match-end 0))
|
|
|
|
|
(message "Absolute reference cannot be expanded"))
|
|
|
|
|
((looking-at "!-\\([0-9]+\\)\\(:?[0-9^$*-]+\\)?")
|
|
|
|
|
;; Just a number of args from `number' lines backward.
|
|
|
|
|
(let ((number (1- (string-to-number
|
|
|
|
|
(buffer-substring (match-beginning 1)
|
|
|
|
|
(match-end 1))))))
|
|
|
|
|
(if (<= number (ring-length term-input-ring))
|
|
|
|
|
(progn
|
|
|
|
|
(replace-match
|
|
|
|
|
(term-args (term-previous-input-string number)
|
|
|
|
|
(match-beginning 2) (match-end 2))
|
|
|
|
|
t t)
|
|
|
|
|
(setq term-input-ring-index number)
|
|
|
|
|
(message "History item: %d" (1+ number)))
|
|
|
|
|
(goto-char (match-end 0))
|
|
|
|
|
(message "Relative reference exceeds input history size"))))
|
|
|
|
|
((or (looking-at "!!?:?\\([0-9^$*-]+\\)") (looking-at "!!"))
|
|
|
|
|
;; Just a number of args from the previous input line.
|
|
|
|
|
(replace-match
|
|
|
|
|
(term-args (term-previous-input-string 0)
|
|
|
|
|
(match-beginning 1) (match-end 1))
|
|
|
|
|
t t)
|
|
|
|
|
(message "History item: previous"))
|
|
|
|
|
((looking-at
|
|
|
|
|
"!\\??\\({\\(.+\\)}\\|\\(\\sw+\\)\\)\\(:?[0-9^$*-]+\\)?")
|
|
|
|
|
;; Most recent input starting with or containing (possibly
|
|
|
|
|
;; protected) string, maybe just a number of args. Phew.
|
|
|
|
|
(let* ((mb1 (match-beginning 1)) (me1 (match-end 1))
|
|
|
|
|
(mb2 (match-beginning 2)) (me2 (match-end 2))
|
|
|
|
|
(exp (buffer-substring (or mb2 mb1) (or me2 me1)))
|
|
|
|
|
(pref (if (save-match-data (looking-at "!\\?")) "" "^"))
|
|
|
|
|
(pos (save-match-data
|
|
|
|
|
(term-previous-matching-input-string-position
|
|
|
|
|
(concat pref (regexp-quote exp)) 1))))
|
|
|
|
|
(if (null pos)
|
|
|
|
|
(progn
|
|
|
|
|
(goto-char (match-end 0))
|
|
|
|
|
(or silent
|
|
|
|
|
(progn (message "Not found")
|
|
|
|
|
(ding))))
|
|
|
|
|
(setq term-input-ring-index pos)
|
|
|
|
|
(replace-match
|
|
|
|
|
(term-args (ring-ref term-input-ring pos)
|
|
|
|
|
(match-beginning 4) (match-end 4))
|
|
|
|
|
t t)
|
|
|
|
|
(message "History item: %d" (1+ pos)))))
|
|
|
|
|
((looking-at "\\^\\([^^]+\\)\\^?\\([^^]*\\)\\^?")
|
|
|
|
|
;; Quick substitution on the previous input line.
|
|
|
|
|
(let ((old (buffer-substring (match-beginning 1) (match-end 1)))
|
|
|
|
|
(new (buffer-substring (match-beginning 2) (match-end 2)))
|
|
|
|
|
(pos nil))
|
|
|
|
|
(replace-match (term-previous-input-string 0) t t)
|
|
|
|
|
(setq pos (point))
|
|
|
|
|
(goto-char (match-beginning 0))
|
|
|
|
|
(if (not (search-forward old pos t))
|
|
|
|
|
(or silent
|
|
|
|
|
(error "Not found"))
|
|
|
|
|
(replace-match new t t)
|
|
|
|
|
(message "History item: substituted"))))
|
|
|
|
|
(t
|
|
|
|
|
(goto-char (match-end 0))))))))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defun term-magic-space (arg)
|
|
|
|
|
"Expand input history references before point and insert ARG spaces.
|
|
|
|
|
A useful command to bind to SPC. See `term-replace-by-expanded-history'."
|
|
|
|
|
(interactive "p")
|
|
|
|
|
(term-replace-by-expanded-history)
|
|
|
|
|
(self-insert-command arg))
|
|
|
|
|
|
|
|
|
|
(defun term-within-quotes (beg end)
|
|
|
|
|
"Return t if the number of quotes between BEG and END is odd.
|
|
|
|
|
Quotes are single and double."
|
2019-03-19 00:02:01 +00:00
|
|
|
|
(let ((countsq (term-how-many-region "\\(^\\|[^\\]\\)'" beg end))
|
|
|
|
|
(countdq (term-how-many-region "\\(^\\|[^\\]\\)\"" beg end)))
|
1994-10-13 06:30:49 +00:00
|
|
|
|
(or (= (mod countsq 2) 1) (= (mod countdq 2) 1))))
|
|
|
|
|
|
|
|
|
|
(defun term-how-many-region (regexp beg end)
|
|
|
|
|
"Return number of matches for REGEXP from BEG to END."
|
|
|
|
|
(let ((count 0))
|
|
|
|
|
(save-excursion
|
|
|
|
|
(save-match-data
|
|
|
|
|
(goto-char beg)
|
|
|
|
|
(while (re-search-forward regexp end t)
|
|
|
|
|
(setq count (1+ count)))))
|
|
|
|
|
count))
|
|
|
|
|
|
|
|
|
|
(defun term-args (string begin end)
|
|
|
|
|
;; From STRING, return the args depending on the range specified in the text
|
|
|
|
|
;; from BEGIN to END. If BEGIN is nil, assume all args. Ignore leading `:'.
|
|
|
|
|
;; Range can be x-y, x-, -y, where x/y can be [0-9], *, ^, $.
|
|
|
|
|
(save-match-data
|
|
|
|
|
(if (null begin)
|
|
|
|
|
(term-arguments string 0 nil)
|
|
|
|
|
(let* ((range (buffer-substring
|
|
|
|
|
(if (eq (char-after begin) ?:) (1+ begin) begin) end))
|
|
|
|
|
(nth (cond ((string-match "^[*^]" range) 1)
|
|
|
|
|
((string-match "^-" range) 0)
|
|
|
|
|
((string-equal range "$") nil)
|
|
|
|
|
(t (string-to-number range))))
|
|
|
|
|
(mth (cond ((string-match "[-*$]$" range) nil)
|
|
|
|
|
((string-match "-" range)
|
|
|
|
|
(string-to-number (substring range (match-end 0))))
|
|
|
|
|
(t nth))))
|
|
|
|
|
(term-arguments string nth mth)))))
|
|
|
|
|
|
|
|
|
|
;; Return a list of arguments from ARG. Break it up at the
|
|
|
|
|
;; delimiters in term-delimiter-argument-list. Returned list is backwards.
|
|
|
|
|
(defun term-delim-arg (arg)
|
|
|
|
|
(if (null term-delimiter-argument-list)
|
|
|
|
|
(list arg)
|
|
|
|
|
(let ((args nil)
|
|
|
|
|
(pos 0)
|
|
|
|
|
(len (length arg)))
|
|
|
|
|
(while (< pos len)
|
|
|
|
|
(let ((char (aref arg pos))
|
|
|
|
|
(start pos))
|
|
|
|
|
(if (memq char term-delimiter-argument-list)
|
|
|
|
|
(while (and (< pos len) (eq (aref arg pos) char))
|
|
|
|
|
(setq pos (1+ pos)))
|
|
|
|
|
(while (and (< pos len)
|
|
|
|
|
(not (memq (aref arg pos)
|
|
|
|
|
term-delimiter-argument-list)))
|
|
|
|
|
(setq pos (1+ pos))))
|
|
|
|
|
(setq args (cons (substring arg start pos) args))))
|
|
|
|
|
args)))
|
|
|
|
|
|
|
|
|
|
(defun term-arguments (string nth mth)
|
|
|
|
|
"Return from STRING the NTH to MTH arguments.
|
|
|
|
|
NTH and/or MTH can be nil, which means the last argument.
|
|
|
|
|
Returned arguments are separated by single spaces.
|
|
|
|
|
We assume whitespace separates arguments, except within quotes.
|
|
|
|
|
Also, a run of one or more of a single character
|
|
|
|
|
in `term-delimiter-argument-list' is a separate argument.
|
|
|
|
|
Argument 0 is the command name."
|
|
|
|
|
(let ((argpart "[^ \n\t\"'`]+\\|\\(\"[^\"]*\"\\|'[^']*'\\|`[^`]*`\\)")
|
|
|
|
|
(args ()) (pos 0)
|
|
|
|
|
(count 0)
|
1996-05-17 21:16:00 +00:00
|
|
|
|
beg str quotes)
|
1994-10-13 06:30:49 +00:00
|
|
|
|
;; Build a list of all the args until we have as many as we want.
|
|
|
|
|
(while (and (or (null mth) (<= count mth))
|
|
|
|
|
(string-match argpart string pos))
|
|
|
|
|
(if (and beg (= pos (match-beginning 0)))
|
|
|
|
|
;; It's contiguous, part of the same arg.
|
|
|
|
|
(setq pos (match-end 0)
|
|
|
|
|
quotes (or quotes (match-beginning 1)))
|
|
|
|
|
;; It's a new separate arg.
|
|
|
|
|
(if beg
|
|
|
|
|
;; Put the previous arg, if there was one, onto ARGS.
|
|
|
|
|
(setq str (substring string beg pos)
|
|
|
|
|
args (if quotes (cons str args)
|
|
|
|
|
(nconc (term-delim-arg str) args))
|
|
|
|
|
count (1+ count)))
|
|
|
|
|
(setq quotes (match-beginning 1))
|
|
|
|
|
(setq beg (match-beginning 0))
|
|
|
|
|
(setq pos (match-end 0))))
|
|
|
|
|
(if beg
|
|
|
|
|
(setq str (substring string beg pos)
|
|
|
|
|
args (if quotes (cons str args)
|
|
|
|
|
(nconc (term-delim-arg str) args))
|
|
|
|
|
count (1+ count)))
|
|
|
|
|
(let ((n (or nth (1- count)))
|
|
|
|
|
(m (if mth (1- (- count mth)) 0)))
|
|
|
|
|
(mapconcat
|
2019-02-24 21:19:59 +00:00
|
|
|
|
#'identity (nthcdr n (nreverse (nthcdr m args))) " "))))
|
1994-10-13 06:30:49 +00:00
|
|
|
|
|
|
|
|
|
;;;
|
|
|
|
|
;;; Input processing stuff [line mode]
|
|
|
|
|
;;;
|
|
|
|
|
|
1997-04-02 03:46:39 +00:00
|
|
|
|
(defun term-send-input ()
|
1994-10-13 06:30:49 +00:00
|
|
|
|
"Send input to process.
|
|
|
|
|
After the process output mark, sends all text from the process mark to
|
|
|
|
|
point as input to the process. Before the process output mark, calls value
|
2010-08-02 04:14:26 +00:00
|
|
|
|
of variable `term-get-old-input' to retrieve old input, copies it to the
|
1994-10-13 06:30:49 +00:00
|
|
|
|
process mark, and sends it. A terminal newline is also inserted into the
|
2018-01-21 04:34:55 +00:00
|
|
|
|
buffer and sent to the process. The functions in `term-input-filter-functions'
|
|
|
|
|
are called on the input before sending it.
|
|
|
|
|
|
1994-10-13 06:30:49 +00:00
|
|
|
|
The input is entered into the input history ring, if the value of variable
|
2018-01-21 04:34:55 +00:00
|
|
|
|
`term-input-filter' returns non-nil when called on the input. Any history
|
|
|
|
|
reference may be expanded depending on the value of the variable
|
|
|
|
|
`term-input-autoexpand'.
|
1994-10-13 06:30:49 +00:00
|
|
|
|
|
1995-03-08 00:54:20 +00:00
|
|
|
|
If variable `term-eol-on-send' is non-nil, then point is moved to the
|
|
|
|
|
end of line before sending the input.
|
|
|
|
|
|
1994-10-13 06:30:49 +00:00
|
|
|
|
The values of `term-get-old-input', `term-input-filter-functions', and
|
|
|
|
|
`term-input-filter' are chosen according to the command interpreter running
|
|
|
|
|
in the buffer. E.g.,
|
|
|
|
|
|
|
|
|
|
If the interpreter is the csh,
|
2021-09-22 18:26:40 +00:00
|
|
|
|
`term-get-old-input' is the default: take the current line, discard any
|
|
|
|
|
initial string matching regexp `term-prompt-regexp'.
|
|
|
|
|
`term-input-filter-functions' monitors input for \"cd\", \"pushd\", and
|
1997-04-02 03:46:39 +00:00
|
|
|
|
\"popd\" commands. When it sees one, it cd's the buffer.
|
2021-09-22 18:26:40 +00:00
|
|
|
|
`term-input-filter' is the default: returns t if the input isn't all white
|
1994-10-13 06:30:49 +00:00
|
|
|
|
space.
|
|
|
|
|
|
1997-04-02 03:46:39 +00:00
|
|
|
|
If the term is Lucid Common Lisp,
|
2021-09-22 18:26:40 +00:00
|
|
|
|
`term-get-old-input' snarfs the sexp ending at point.
|
|
|
|
|
`term-input-filter-functions' does nothing.
|
|
|
|
|
`term-input-filter' returns nil if the input matches input-filter-regexp,
|
1994-10-13 06:30:49 +00:00
|
|
|
|
which matches (1) all whitespace (2) :a, :c, etc.
|
|
|
|
|
|
|
|
|
|
Similarly for Soar, Scheme, etc."
|
|
|
|
|
(interactive)
|
|
|
|
|
;; Note that the input string does not include its terminal newline.
|
|
|
|
|
(let ((proc (get-buffer-process (current-buffer))))
|
|
|
|
|
(if (not proc) (error "Current buffer has no process")
|
|
|
|
|
(let* ((pmark (process-mark proc))
|
|
|
|
|
(pmark-val (marker-position pmark))
|
1995-03-08 00:54:20 +00:00
|
|
|
|
(input-is-new (>= (point) pmark-val))
|
|
|
|
|
(intxt (if input-is-new
|
|
|
|
|
(progn (if term-eol-on-send (end-of-line))
|
|
|
|
|
(buffer-substring pmark (point)))
|
1994-10-13 06:30:49 +00:00
|
|
|
|
(funcall term-get-old-input)))
|
|
|
|
|
(input (if (not (eq term-input-autoexpand 'input))
|
|
|
|
|
;; Just whatever's already there
|
|
|
|
|
intxt
|
|
|
|
|
;; Expand and leave it visible in buffer
|
|
|
|
|
(term-replace-by-expanded-history t)
|
|
|
|
|
(buffer-substring pmark (point))))
|
|
|
|
|
(history (if (not (eq term-input-autoexpand 'history))
|
|
|
|
|
input
|
|
|
|
|
;; This is messy 'cos ultimately the original
|
|
|
|
|
;; functions used do insertion, rather than return
|
|
|
|
|
;; strings. We have to expand, then insert back.
|
|
|
|
|
(term-replace-by-expanded-history t)
|
|
|
|
|
(let ((copy (buffer-substring pmark (point))))
|
|
|
|
|
(delete-region pmark (point))
|
|
|
|
|
(insert input)
|
|
|
|
|
copy))))
|
(term-if-xemacs, term-ifnot-xemacs): Delete, replace
uses with a simple test.
(term-set-escape-char, term-mode, term-check-kill-echo-list)
(term-send-raw-string, term-send-raw, term-mouse-paste)
(term-char-mode, term-line-mode, term-exec, term-sentinel)
(term-handle-exit, term-read-input-ring)
(term-previous-matching-input-string)
(term-previous-matching-input-string-position)
(term-previous-matching-input-from-input)
(term-replace-by-expanded-history, term-send-input)
(term-skip-prompt, term-bol, term-send-invisible)
(term-kill-input, term-delchar-or-maybe-eof)
(term-backward-matching-input, term-check-source)
(term-proc-query, term-emulate-terminal)
(term-handle-colors-array, term-process-pager, term-pager-line)
(term-pager-bob, term-unwrap-line, term-word)
(term-dynamic-complete-filename)
(term-dynamic-complete-as-filename)
(term-dynamic-simple-complete): Replace one arm ifs with whens or
unlesses.
2006-05-29 06:11:33 +00:00
|
|
|
|
(when (term-pager-enabled)
|
|
|
|
|
(save-excursion
|
|
|
|
|
(goto-char (process-mark proc))
|
|
|
|
|
(setq term-pager-count (term-current-row))))
|
|
|
|
|
(when (and (funcall term-input-filter history)
|
|
|
|
|
(or (null term-input-ignoredups)
|
|
|
|
|
(not (ring-p term-input-ring))
|
|
|
|
|
(ring-empty-p term-input-ring)
|
|
|
|
|
(not (string-equal (ring-ref term-input-ring 0)
|
|
|
|
|
history))))
|
|
|
|
|
(ring-insert term-input-ring history))
|
2019-02-24 21:19:59 +00:00
|
|
|
|
(run-hook-with-args 'term-input-filter-functions (concat input "\n"))
|
1994-10-13 06:30:49 +00:00
|
|
|
|
(setq term-input-ring-index nil)
|
1995-03-08 00:54:20 +00:00
|
|
|
|
|
1994-10-13 06:30:49 +00:00
|
|
|
|
;; Update the markers before we send the input
|
|
|
|
|
;; in case we get output amidst sending the input.
|
|
|
|
|
(set-marker term-last-input-start pmark)
|
|
|
|
|
(set-marker term-last-input-end (point))
|
(term-if-xemacs, term-ifnot-xemacs): Delete, replace
uses with a simple test.
(term-set-escape-char, term-mode, term-check-kill-echo-list)
(term-send-raw-string, term-send-raw, term-mouse-paste)
(term-char-mode, term-line-mode, term-exec, term-sentinel)
(term-handle-exit, term-read-input-ring)
(term-previous-matching-input-string)
(term-previous-matching-input-string-position)
(term-previous-matching-input-from-input)
(term-replace-by-expanded-history, term-send-input)
(term-skip-prompt, term-bol, term-send-invisible)
(term-kill-input, term-delchar-or-maybe-eof)
(term-backward-matching-input, term-check-source)
(term-proc-query, term-emulate-terminal)
(term-handle-colors-array, term-process-pager, term-pager-line)
(term-pager-bob, term-unwrap-line, term-word)
(term-dynamic-complete-filename)
(term-dynamic-complete-as-filename)
(term-dynamic-simple-complete): Replace one arm ifs with whens or
unlesses.
2006-05-29 06:11:33 +00:00
|
|
|
|
(when input-is-new
|
|
|
|
|
;; Set up to delete, because inferior should echo.
|
|
|
|
|
(when (marker-buffer term-pending-delete-marker)
|
|
|
|
|
(delete-region term-pending-delete-marker pmark))
|
|
|
|
|
(set-marker term-pending-delete-marker pmark-val)
|
|
|
|
|
(set-marker (process-mark proc) (point)))
|
1995-03-08 00:54:20 +00:00
|
|
|
|
(goto-char pmark)
|
1994-10-13 06:30:49 +00:00
|
|
|
|
(funcall term-input-sender proc input)))))
|
|
|
|
|
|
|
|
|
|
(defun term-get-old-input-default ()
|
(term-buffer-maximum-size, term-exec, term-escape-char, term-set-escape-char,
term-termcap-format, term-get-old-input-default, term-skip-prompt,
term-send-string, term-send-region, term-pager-page, term-pager-help):
Fix typos in docstrings.
2007-04-13 09:00:41 +00:00
|
|
|
|
"Default for `term-get-old-input'.
|
1994-10-13 06:30:49 +00:00
|
|
|
|
Take the current line, and discard any initial text matching
|
(term-buffer-maximum-size, term-exec, term-escape-char, term-set-escape-char,
term-termcap-format, term-get-old-input-default, term-skip-prompt,
term-send-string, term-send-region, term-pager-page, term-pager-help):
Fix typos in docstrings.
2007-04-13 09:00:41 +00:00
|
|
|
|
`term-prompt-regexp'."
|
1994-10-13 06:30:49 +00:00
|
|
|
|
(save-excursion
|
|
|
|
|
(beginning-of-line)
|
|
|
|
|
(term-skip-prompt)
|
|
|
|
|
(let ((beg (point)))
|
|
|
|
|
(end-of-line)
|
|
|
|
|
(buffer-substring beg (point)))))
|
|
|
|
|
|
|
|
|
|
(defun term-copy-old-input ()
|
|
|
|
|
"Insert after prompt old input at point as new input to be edited.
|
|
|
|
|
Calls `term-get-old-input' to get old input."
|
|
|
|
|
(interactive)
|
|
|
|
|
(let ((input (funcall term-get-old-input))
|
|
|
|
|
(process (get-buffer-process (current-buffer))))
|
|
|
|
|
(if (not process)
|
|
|
|
|
(error "Current buffer has no process")
|
|
|
|
|
(goto-char (process-mark process))
|
|
|
|
|
(insert input))))
|
|
|
|
|
|
|
|
|
|
(defun term-skip-prompt ()
|
(term-buffer-maximum-size, term-exec, term-escape-char, term-set-escape-char,
term-termcap-format, term-get-old-input-default, term-skip-prompt,
term-send-string, term-send-region, term-pager-page, term-pager-help):
Fix typos in docstrings.
2007-04-13 09:00:41 +00:00
|
|
|
|
"Skip past the text matching regexp `term-prompt-regexp'.
|
1994-10-13 06:30:49 +00:00
|
|
|
|
If this takes us past the end of the current line, don't skip at all."
|
Use line-end-position rather than end-of-line, etc.
* textmodes/texnfo-upd.el (texinfo-start-menu-description)
(texinfo-update-menu-region-beginning, texinfo-menu-first-node)
(texinfo-delete-existing-pointers, texinfo-find-pointer)
(texinfo-clean-up-node-line, texinfo-insert-node-lines)
(texinfo-multiple-files-update):
* textmodes/table.el (table--probe-cell-left-up)
(table--probe-cell-right-bottom):
* textmodes/picture.el (picture-tab-search):
* textmodes/page-ext.el (pages-copy-header-and-position)
(pages-directory-for-addresses):
* progmodes/vera-mode.el (vera-get-offset):
* progmodes/simula.el (simula-calculate-indent):
* progmodes/python.el (python-pdbtrack-overlay-arrow):
* progmodes/prolog.el (end-of-prolog-clause):
* progmodes/perl-mode.el (perl-calculate-indent, perl-indent-exp):
* progmodes/icon.el (indent-icon-exp):
* progmodes/etags.el (tag-re-match-p):
* progmodes/ebrowse.el (ebrowse-show-file-name-at-point):
* progmodes/ebnf2ps.el (ebnf-begin-file):
* progmodes/dcl-mode.el (dcl-back-to-indentation-1)
(dcl-save-local-variable):
* play/life.el (life-setup):
* play/gametree.el (gametree-looking-at-ply):
* nxml/nxml-maint.el (nxml-insert-target-repertoire-glyph-set):
* mail/sendmail.el (mail-mode-auto-fill):
* emacs-lisp/lisp-mode.el (calculate-lisp-indent):
* emacs-lisp/edebug.el (edebug-overlay-arrow):
* emacs-lisp/checkdoc.el (checkdoc-this-string-valid):
* woman.el (woman-parse-numeric-value, woman2-TH, woman2-SH)
(woman-tab-to-tab-stop, WoMan-warn-ignored):
* type-break.el (type-break-file-keystroke-count):
* term.el (term-replace-by-expanded-history-before-point)
(term-skip-prompt, term-extract-string):
* speedbar.el (speedbar-edit-line, speedbar-expand-line)
(speedbar-contract-line, speedbar-toggle-line-expansion)
(speedbar-parse-c-or-c++tag, speedbar-parse-tex-string)
(speedbar-buffer-revert-buffer, speedbar-highlight-one-tag-line):
* sort.el (sort-skip-fields):
* skeleton.el (skeleton-internal-list):
* simple.el (line-move-finish, line-move-to-column):
* shell.el (shell-forward-command):
* misc.el (copy-from-above-command):
* makesum.el (double-column):
* ebuff-menu.el (electric-buffer-update-highlight):
* dired.el (dired-move-to-end-of-filename):
* dframe.el (dframe-popup-kludge):
* bookmark.el (bookmark-kill-line, bookmark-bmenu-show-filenames):
* arc-mode.el (archive-get-lineno):
Use line-end-position and line-beginning-position.
* net/ange-ftp.el, progmodes/hideif.el, reposition.el:
Same, but only in comments.
2010-11-06 20:23:42 +00:00
|
|
|
|
(let ((eol (line-end-position)))
|
(term-if-xemacs, term-ifnot-xemacs): Delete, replace
uses with a simple test.
(term-set-escape-char, term-mode, term-check-kill-echo-list)
(term-send-raw-string, term-send-raw, term-mouse-paste)
(term-char-mode, term-line-mode, term-exec, term-sentinel)
(term-handle-exit, term-read-input-ring)
(term-previous-matching-input-string)
(term-previous-matching-input-string-position)
(term-previous-matching-input-from-input)
(term-replace-by-expanded-history, term-send-input)
(term-skip-prompt, term-bol, term-send-invisible)
(term-kill-input, term-delchar-or-maybe-eof)
(term-backward-matching-input, term-check-source)
(term-proc-query, term-emulate-terminal)
(term-handle-colors-array, term-process-pager, term-pager-line)
(term-pager-bob, term-unwrap-line, term-word)
(term-dynamic-complete-filename)
(term-dynamic-complete-as-filename)
(term-dynamic-simple-complete): Replace one arm ifs with whens or
unlesses.
2006-05-29 06:11:33 +00:00
|
|
|
|
(when (and (looking-at term-prompt-regexp)
|
|
|
|
|
(<= (match-end 0) eol))
|
|
|
|
|
(goto-char (match-end 0)))))
|
1994-10-13 06:30:49 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defun term-after-pmark-p ()
|
|
|
|
|
"Is point after the process output marker?"
|
|
|
|
|
;; Since output could come into the buffer after we looked at the point
|
1997-04-02 03:46:39 +00:00
|
|
|
|
;; but before we looked at the process marker's value, we explicitly
|
2011-11-20 02:29:42 +00:00
|
|
|
|
;; serialize. This is just because I don't know whether or not Emacs
|
1994-10-13 06:30:49 +00:00
|
|
|
|
;; services input during execution of lisp commands.
|
|
|
|
|
(let ((proc-pos (marker-position
|
|
|
|
|
(process-mark (get-buffer-process (current-buffer))))))
|
|
|
|
|
(<= proc-pos (point))))
|
|
|
|
|
|
|
|
|
|
(defun term-simple-send (proc string)
|
|
|
|
|
"Default function for sending to PROC input STRING.
|
1997-04-02 03:46:39 +00:00
|
|
|
|
This just sends STRING plus a newline. To override this,
|
2005-06-10 00:43:13 +00:00
|
|
|
|
set the hook `term-input-sender'."
|
1994-10-13 06:30:49 +00:00
|
|
|
|
(term-send-string proc string)
|
|
|
|
|
(term-send-string proc "\n"))
|
|
|
|
|
|
|
|
|
|
(defun term-bol (arg)
|
2010-08-02 04:14:26 +00:00
|
|
|
|
"Go to the beginning of line, then skip past the prompt, if any.
|
1997-04-02 03:46:39 +00:00
|
|
|
|
If a prefix argument is given (\\[universal-argument]), then no prompt skip
|
1994-10-13 06:30:49 +00:00
|
|
|
|
-- go straight to column 0.
|
|
|
|
|
|
|
|
|
|
The prompt skip is done by skipping text matching the regular expression
|
(term-buffer-maximum-size, term-exec, term-escape-char, term-set-escape-char,
term-termcap-format, term-get-old-input-default, term-skip-prompt,
term-send-string, term-send-region, term-pager-page, term-pager-help):
Fix typos in docstrings.
2007-04-13 09:00:41 +00:00
|
|
|
|
`term-prompt-regexp', a buffer local variable."
|
1994-10-13 06:30:49 +00:00
|
|
|
|
(interactive "P")
|
|
|
|
|
(beginning-of-line)
|
(term-if-xemacs, term-ifnot-xemacs): Delete, replace
uses with a simple test.
(term-set-escape-char, term-mode, term-check-kill-echo-list)
(term-send-raw-string, term-send-raw, term-mouse-paste)
(term-char-mode, term-line-mode, term-exec, term-sentinel)
(term-handle-exit, term-read-input-ring)
(term-previous-matching-input-string)
(term-previous-matching-input-string-position)
(term-previous-matching-input-from-input)
(term-replace-by-expanded-history, term-send-input)
(term-skip-prompt, term-bol, term-send-invisible)
(term-kill-input, term-delchar-or-maybe-eof)
(term-backward-matching-input, term-check-source)
(term-proc-query, term-emulate-terminal)
(term-handle-colors-array, term-process-pager, term-pager-line)
(term-pager-bob, term-unwrap-line, term-word)
(term-dynamic-complete-filename)
(term-dynamic-complete-as-filename)
(term-dynamic-simple-complete): Replace one arm ifs with whens or
unlesses.
2006-05-29 06:11:33 +00:00
|
|
|
|
(when (null arg) (term-skip-prompt)))
|
1994-10-13 06:30:49 +00:00
|
|
|
|
|
2009-08-16 15:39:11 +00:00
|
|
|
|
;; These two functions are for entering text you don't want echoed or
|
|
|
|
|
;; saved -- typically passwords to ftp, telnet, or somesuch.
|
|
|
|
|
;; Just enter m-x term-send-invisible and type in your line.
|
1994-10-13 06:30:49 +00:00
|
|
|
|
|
|
|
|
|
(defun term-read-noecho (prompt &optional stars)
|
1997-04-02 03:46:39 +00:00
|
|
|
|
"Read a single line of text from user without echoing, and return it.
|
1994-10-13 06:30:49 +00:00
|
|
|
|
Prompt with argument PROMPT, a string. Optional argument STARS causes
|
2015-11-17 23:28:50 +00:00
|
|
|
|
input to be echoed with `*' characters on the prompt line. Input ends with
|
1994-10-13 06:30:49 +00:00
|
|
|
|
RET, LFD, or ESC. DEL or C-h rubs out. C-u kills line. C-g aborts (if
|
|
|
|
|
`inhibit-quit' is set because e.g. this function was called from a process
|
|
|
|
|
filter and C-g is pressed, this function returns nil rather than a string).
|
|
|
|
|
|
|
|
|
|
Note that the keystrokes comprising the text can still be recovered
|
|
|
|
|
\(temporarily) with \\[view-lossage]. This may be a security bug for some
|
|
|
|
|
applications."
|
2018-07-30 01:10:31 +00:00
|
|
|
|
(declare (obsolete read-passwd "27.1"))
|
1994-10-13 06:30:49 +00:00
|
|
|
|
(let ((ans "")
|
|
|
|
|
(c 0)
|
|
|
|
|
(echo-keystrokes 0)
|
|
|
|
|
(cursor-in-echo-area t)
|
|
|
|
|
(done nil))
|
|
|
|
|
(while (not done)
|
|
|
|
|
(if stars
|
|
|
|
|
(message "%s%s" prompt (make-string (length ans) ?*))
|
1996-01-25 00:57:49 +00:00
|
|
|
|
(message "%s" prompt))
|
1994-10-13 06:30:49 +00:00
|
|
|
|
(setq c (read-char))
|
|
|
|
|
(cond ((= c ?\C-g)
|
|
|
|
|
;; This function may get called from a process filter, where
|
1997-04-02 03:46:39 +00:00
|
|
|
|
;; inhibit-quit is set. In later versions of Emacs read-char
|
1994-10-13 06:30:49 +00:00
|
|
|
|
;; may clear quit-flag itself and return C-g. That would make
|
|
|
|
|
;; it impossible to quit this loop in a simple way, so
|
|
|
|
|
;; re-enable it here (for backward-compatibility the check for
|
|
|
|
|
;; quit-flag below would still be necessary, so this seems
|
|
|
|
|
;; like the simplest way to do things).
|
|
|
|
|
(setq quit-flag t
|
|
|
|
|
done t))
|
|
|
|
|
((or (= c ?\r) (= c ?\n) (= c ?\e))
|
|
|
|
|
(setq done t))
|
|
|
|
|
((= c ?\C-u)
|
|
|
|
|
(setq ans ""))
|
|
|
|
|
((and (/= c ?\b) (/= c ?\177))
|
|
|
|
|
(setq ans (concat ans (char-to-string c))))
|
|
|
|
|
((> (length ans) 0)
|
|
|
|
|
(setq ans (substring ans 0 -1)))))
|
|
|
|
|
(if quit-flag
|
|
|
|
|
;; Emulate a true quit, except that we have to return a value.
|
|
|
|
|
(prog1
|
|
|
|
|
(setq quit-flag nil)
|
|
|
|
|
(message "Quit")
|
|
|
|
|
(beep t))
|
|
|
|
|
(message "")
|
|
|
|
|
ans)))
|
|
|
|
|
|
|
|
|
|
(defun term-send-invisible (str &optional proc)
|
|
|
|
|
"Read a string without echoing.
|
1997-04-02 03:46:39 +00:00
|
|
|
|
Then send it to the process running in the current buffer. A new-line
|
2018-02-15 00:09:50 +00:00
|
|
|
|
is additionally sent. String is not saved on term input history list."
|
1994-10-13 06:30:49 +00:00
|
|
|
|
(interactive "P") ; Defeat snooping via C-x esc
|
(term-if-xemacs, term-ifnot-xemacs): Delete, replace
uses with a simple test.
(term-set-escape-char, term-mode, term-check-kill-echo-list)
(term-send-raw-string, term-send-raw, term-mouse-paste)
(term-char-mode, term-line-mode, term-exec, term-sentinel)
(term-handle-exit, term-read-input-ring)
(term-previous-matching-input-string)
(term-previous-matching-input-string-position)
(term-previous-matching-input-from-input)
(term-replace-by-expanded-history, term-send-input)
(term-skip-prompt, term-bol, term-send-invisible)
(term-kill-input, term-delchar-or-maybe-eof)
(term-backward-matching-input, term-check-source)
(term-proc-query, term-emulate-terminal)
(term-handle-colors-array, term-process-pager, term-pager-line)
(term-pager-bob, term-unwrap-line, term-word)
(term-dynamic-complete-filename)
(term-dynamic-complete-as-filename)
(term-dynamic-simple-complete): Replace one arm ifs with whens or
unlesses.
2006-05-29 06:11:33 +00:00
|
|
|
|
(when (not (stringp str))
|
2018-02-15 00:09:50 +00:00
|
|
|
|
(setq str (read-passwd "Non-echoed text: ")))
|
(term-if-xemacs, term-ifnot-xemacs): Delete, replace
uses with a simple test.
(term-set-escape-char, term-mode, term-check-kill-echo-list)
(term-send-raw-string, term-send-raw, term-mouse-paste)
(term-char-mode, term-line-mode, term-exec, term-sentinel)
(term-handle-exit, term-read-input-ring)
(term-previous-matching-input-string)
(term-previous-matching-input-string-position)
(term-previous-matching-input-from-input)
(term-replace-by-expanded-history, term-send-input)
(term-skip-prompt, term-bol, term-send-invisible)
(term-kill-input, term-delchar-or-maybe-eof)
(term-backward-matching-input, term-check-source)
(term-proc-query, term-emulate-terminal)
(term-handle-colors-array, term-process-pager, term-pager-line)
(term-pager-bob, term-unwrap-line, term-word)
(term-dynamic-complete-filename)
(term-dynamic-complete-as-filename)
(term-dynamic-simple-complete): Replace one arm ifs with whens or
unlesses.
2006-05-29 06:11:33 +00:00
|
|
|
|
(when (not proc)
|
|
|
|
|
(setq proc (get-buffer-process (current-buffer))))
|
1994-10-13 06:30:49 +00:00
|
|
|
|
(if (not proc) (error "Current buffer has no process")
|
|
|
|
|
(setq term-kill-echo-list (nconc term-kill-echo-list
|
|
|
|
|
(cons str nil)))
|
|
|
|
|
(term-send-string proc str)
|
|
|
|
|
(term-send-string proc "\n")))
|
|
|
|
|
|
2018-02-15 00:09:50 +00:00
|
|
|
|
;; TODO: Maybe combine this with `comint-watch-for-password-prompt'.
|
|
|
|
|
(defun term-watch-for-password-prompt (string)
|
|
|
|
|
"Prompt in the minibuffer for password and send without echoing.
|
|
|
|
|
Checks if STRING contains a password prompt as defined by
|
|
|
|
|
`comint-password-prompt-regexp'."
|
|
|
|
|
(when (term-in-line-mode)
|
|
|
|
|
(when (let ((case-fold-search t))
|
|
|
|
|
(string-match comint-password-prompt-regexp string))
|
2021-10-18 13:24:54 +00:00
|
|
|
|
;; Use `run-at-time' in order not to pause execution of the
|
|
|
|
|
;; process filter with a minibuffer
|
|
|
|
|
(run-at-time
|
|
|
|
|
0 nil
|
|
|
|
|
(lambda (current-buf)
|
|
|
|
|
(with-current-buffer current-buf
|
|
|
|
|
(term-send-invisible (read-passwd string))))
|
|
|
|
|
(current-buffer)))))
|
2018-02-15 00:09:50 +00:00
|
|
|
|
|
1994-10-13 06:30:49 +00:00
|
|
|
|
|
|
|
|
|
;;; Low-level process communication
|
|
|
|
|
|
2011-02-17 05:13:17 +00:00
|
|
|
|
(defcustom term-input-chunk-size 512
|
|
|
|
|
"Long inputs send to term processes are broken up into chunks of this size.
|
|
|
|
|
If your process is choking on big inputs, try lowering the value."
|
|
|
|
|
:group 'term
|
2022-07-06 17:29:51 +00:00
|
|
|
|
:type 'natnum)
|
1994-10-13 06:30:49 +00:00
|
|
|
|
|
|
|
|
|
(defun term-send-string (proc str)
|
2005-06-10 00:43:13 +00:00
|
|
|
|
"Send to PROC the contents of STR as input.
|
(term-buffer-maximum-size, term-exec, term-escape-char, term-set-escape-char,
term-termcap-format, term-get-old-input-default, term-skip-prompt,
term-send-string, term-send-region, term-pager-page, term-pager-help):
Fix typos in docstrings.
2007-04-13 09:00:41 +00:00
|
|
|
|
This is equivalent to `process-send-string', except that long input strings
|
|
|
|
|
are broken up into chunks of size `term-input-chunk-size'. Processes
|
1997-04-02 03:46:39 +00:00
|
|
|
|
are given a chance to output between chunks. This can help prevent processes
|
1994-10-13 06:30:49 +00:00
|
|
|
|
from hanging when you send them long inputs on some OS's."
|
|
|
|
|
(let* ((len (length str))
|
|
|
|
|
(i (min len term-input-chunk-size)))
|
|
|
|
|
(process-send-string proc (substring str 0 i))
|
|
|
|
|
(while (< i len)
|
|
|
|
|
(let ((next-i (+ i term-input-chunk-size)))
|
|
|
|
|
(accept-process-output)
|
|
|
|
|
(process-send-string proc (substring str i (min len next-i)))
|
|
|
|
|
(setq i next-i)))))
|
|
|
|
|
|
|
|
|
|
(defun term-send-region (proc start end)
|
2005-06-10 00:43:13 +00:00
|
|
|
|
"Send to PROC the region delimited by START and END.
|
(term-buffer-maximum-size, term-exec, term-escape-char, term-set-escape-char,
term-termcap-format, term-get-old-input-default, term-skip-prompt,
term-send-string, term-send-region, term-pager-page, term-pager-help):
Fix typos in docstrings.
2007-04-13 09:00:41 +00:00
|
|
|
|
This is a replacement for `process-send-region' that tries to keep
|
2005-06-10 00:43:13 +00:00
|
|
|
|
your process from hanging on long inputs. See `term-send-string'."
|
1994-10-13 06:30:49 +00:00
|
|
|
|
(term-send-string proc (buffer-substring start end)))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;; Random input hackage
|
|
|
|
|
|
|
|
|
|
(defun term-kill-output ()
|
|
|
|
|
"Kill all output from interpreter since last input."
|
|
|
|
|
(interactive)
|
|
|
|
|
(let ((pmark (process-mark (get-buffer-process (current-buffer)))))
|
|
|
|
|
(kill-region term-last-input-end pmark)
|
1997-04-02 03:46:39 +00:00
|
|
|
|
(goto-char pmark)
|
1994-10-13 06:30:49 +00:00
|
|
|
|
(insert "*** output flushed ***\n")
|
|
|
|
|
(set-marker pmark (point))))
|
|
|
|
|
|
|
|
|
|
(defun term-show-output ()
|
|
|
|
|
"Display start of this batch of interpreter output at top of window.
|
|
|
|
|
Sets mark to the value of point when this command is run."
|
|
|
|
|
(interactive)
|
|
|
|
|
(goto-char term-last-input-end)
|
|
|
|
|
(backward-char)
|
|
|
|
|
(beginning-of-line)
|
|
|
|
|
(set-window-start (selected-window) (point))
|
|
|
|
|
(end-of-line))
|
|
|
|
|
|
|
|
|
|
(defun term-interrupt-subjob ()
|
|
|
|
|
"Interrupt the current subjob."
|
|
|
|
|
(interactive)
|
|
|
|
|
(interrupt-process nil term-ptyp))
|
|
|
|
|
|
|
|
|
|
(defun term-kill-subjob ()
|
|
|
|
|
"Send kill signal to the current subjob."
|
|
|
|
|
(interactive)
|
|
|
|
|
(kill-process nil term-ptyp))
|
|
|
|
|
|
|
|
|
|
(defun term-quit-subjob ()
|
|
|
|
|
"Send quit signal to the current subjob."
|
|
|
|
|
(interactive)
|
|
|
|
|
(quit-process nil term-ptyp))
|
|
|
|
|
|
|
|
|
|
(defun term-stop-subjob ()
|
|
|
|
|
"Stop the current subjob.
|
|
|
|
|
WARNING: if there is no current subjob, you can end up suspending
|
1997-04-02 03:46:39 +00:00
|
|
|
|
the top-level process running in the buffer. If you accidentally do
|
|
|
|
|
this, use \\[term-continue-subjob] to resume the process. (This
|
1994-10-13 06:30:49 +00:00
|
|
|
|
is not a problem with most shells, since they ignore this signal.)"
|
|
|
|
|
(interactive)
|
|
|
|
|
(stop-process nil term-ptyp))
|
|
|
|
|
|
|
|
|
|
(defun term-continue-subjob ()
|
|
|
|
|
"Send CONT signal to process buffer's process group.
|
|
|
|
|
Useful if you accidentally suspend the top-level process."
|
|
|
|
|
(interactive)
|
|
|
|
|
(continue-process nil term-ptyp))
|
|
|
|
|
|
|
|
|
|
(defun term-kill-input ()
|
|
|
|
|
"Kill all text from last stuff output by interpreter to point."
|
|
|
|
|
(interactive)
|
|
|
|
|
(let* ((pmark (process-mark (get-buffer-process (current-buffer))))
|
|
|
|
|
(p-pos (marker-position pmark)))
|
(term-if-xemacs, term-ifnot-xemacs): Delete, replace
uses with a simple test.
(term-set-escape-char, term-mode, term-check-kill-echo-list)
(term-send-raw-string, term-send-raw, term-mouse-paste)
(term-char-mode, term-line-mode, term-exec, term-sentinel)
(term-handle-exit, term-read-input-ring)
(term-previous-matching-input-string)
(term-previous-matching-input-string-position)
(term-previous-matching-input-from-input)
(term-replace-by-expanded-history, term-send-input)
(term-skip-prompt, term-bol, term-send-invisible)
(term-kill-input, term-delchar-or-maybe-eof)
(term-backward-matching-input, term-check-source)
(term-proc-query, term-emulate-terminal)
(term-handle-colors-array, term-process-pager, term-pager-line)
(term-pager-bob, term-unwrap-line, term-word)
(term-dynamic-complete-filename)
(term-dynamic-complete-as-filename)
(term-dynamic-simple-complete): Replace one arm ifs with whens or
unlesses.
2006-05-29 06:11:33 +00:00
|
|
|
|
(when (> (point) p-pos)
|
|
|
|
|
(kill-region pmark (point)))))
|
1994-10-13 06:30:49 +00:00
|
|
|
|
|
|
|
|
|
(defun term-delchar-or-maybe-eof (arg)
|
2021-09-22 18:26:40 +00:00
|
|
|
|
"Delete ARG characters forward, or send an EOF to process if at end of buffer."
|
1994-10-13 06:30:49 +00:00
|
|
|
|
(interactive "p")
|
|
|
|
|
(if (eobp)
|
|
|
|
|
(process-send-eof)
|
(term-if-xemacs, term-ifnot-xemacs): Delete, replace
uses with a simple test.
(term-set-escape-char, term-mode, term-check-kill-echo-list)
(term-send-raw-string, term-send-raw, term-mouse-paste)
(term-char-mode, term-line-mode, term-exec, term-sentinel)
(term-handle-exit, term-read-input-ring)
(term-previous-matching-input-string)
(term-previous-matching-input-string-position)
(term-previous-matching-input-from-input)
(term-replace-by-expanded-history, term-send-input)
(term-skip-prompt, term-bol, term-send-invisible)
(term-kill-input, term-delchar-or-maybe-eof)
(term-backward-matching-input, term-check-source)
(term-proc-query, term-emulate-terminal)
(term-handle-colors-array, term-process-pager, term-pager-line)
(term-pager-bob, term-unwrap-line, term-word)
(term-dynamic-complete-filename)
(term-dynamic-complete-as-filename)
(term-dynamic-simple-complete): Replace one arm ifs with whens or
unlesses.
2006-05-29 06:11:33 +00:00
|
|
|
|
(delete-char arg)))
|
1994-10-13 06:30:49 +00:00
|
|
|
|
|
|
|
|
|
(defun term-send-eof ()
|
|
|
|
|
"Send an EOF to the current buffer's process."
|
|
|
|
|
(interactive)
|
|
|
|
|
(process-send-eof))
|
|
|
|
|
|
2009-01-21 11:03:25 +00:00
|
|
|
|
(defun term-backward-matching-input (regexp n)
|
1994-10-13 06:30:49 +00:00
|
|
|
|
"Search backward through buffer for match for REGEXP.
|
|
|
|
|
Matches are searched for on lines that match `term-prompt-regexp'.
|
|
|
|
|
With prefix argument N, search for Nth previous match.
|
|
|
|
|
If N is negative, find the next or Nth next match."
|
|
|
|
|
(interactive (term-regexp-arg "Backward input matching (regexp): "))
|
|
|
|
|
(let* ((re (concat term-prompt-regexp ".*" regexp))
|
2009-01-21 11:03:25 +00:00
|
|
|
|
(pos (save-excursion (end-of-line (if (> n 0) 0 1))
|
|
|
|
|
(when (re-search-backward re nil t n)
|
(term-if-xemacs, term-ifnot-xemacs): Delete, replace
uses with a simple test.
(term-set-escape-char, term-mode, term-check-kill-echo-list)
(term-send-raw-string, term-send-raw, term-mouse-paste)
(term-char-mode, term-line-mode, term-exec, term-sentinel)
(term-handle-exit, term-read-input-ring)
(term-previous-matching-input-string)
(term-previous-matching-input-string-position)
(term-previous-matching-input-from-input)
(term-replace-by-expanded-history, term-send-input)
(term-skip-prompt, term-bol, term-send-invisible)
(term-kill-input, term-delchar-or-maybe-eof)
(term-backward-matching-input, term-check-source)
(term-proc-query, term-emulate-terminal)
(term-handle-colors-array, term-process-pager, term-pager-line)
(term-pager-bob, term-unwrap-line, term-word)
(term-dynamic-complete-filename)
(term-dynamic-complete-as-filename)
(term-dynamic-simple-complete): Replace one arm ifs with whens or
unlesses.
2006-05-29 06:11:33 +00:00
|
|
|
|
(point)))))
|
1994-10-13 06:30:49 +00:00
|
|
|
|
(if (null pos)
|
|
|
|
|
(progn (message "Not found")
|
|
|
|
|
(ding))
|
|
|
|
|
(goto-char pos)
|
|
|
|
|
(term-bol nil))))
|
|
|
|
|
|
2009-01-21 11:03:25 +00:00
|
|
|
|
(defun term-forward-matching-input (regexp n)
|
1994-10-13 06:30:49 +00:00
|
|
|
|
"Search forward through buffer for match for REGEXP.
|
|
|
|
|
Matches are searched for on lines that match `term-prompt-regexp'.
|
|
|
|
|
With prefix argument N, search for Nth following match.
|
|
|
|
|
If N is negative, find the previous or Nth previous match."
|
|
|
|
|
(interactive (term-regexp-arg "Forward input matching (regexp): "))
|
2009-01-21 11:03:25 +00:00
|
|
|
|
(term-backward-matching-input regexp (- n)))
|
1994-10-13 06:30:49 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defun term-next-prompt (n)
|
|
|
|
|
"Move to end of Nth next prompt in the buffer.
|
|
|
|
|
See `term-prompt-regexp'."
|
|
|
|
|
(interactive "p")
|
|
|
|
|
(let ((paragraph-start term-prompt-regexp))
|
|
|
|
|
(end-of-line (if (> n 0) 1 0))
|
|
|
|
|
(forward-paragraph n)
|
|
|
|
|
(term-skip-prompt)))
|
|
|
|
|
|
|
|
|
|
(defun term-previous-prompt (n)
|
|
|
|
|
"Move to end of Nth previous prompt in the buffer.
|
|
|
|
|
See `term-prompt-regexp'."
|
|
|
|
|
(interactive "p")
|
|
|
|
|
(term-next-prompt (- n)))
|
|
|
|
|
|
|
|
|
|
;;; Support for source-file processing commands.
|
2009-08-16 15:39:11 +00:00
|
|
|
|
;;============================================================================
|
|
|
|
|
;; Many command-interpreters (e.g., Lisp, Scheme, Soar) have
|
|
|
|
|
;; commands that process files of source text (e.g. loading or compiling
|
|
|
|
|
;; files). So the corresponding process-in-a-buffer modes have commands
|
|
|
|
|
;; for doing this (e.g., lisp-load-file). The functions below are useful
|
|
|
|
|
;; for defining these commands.
|
|
|
|
|
;;
|
|
|
|
|
;; Alas, these guys don't do exactly the right thing for Lisp, Scheme
|
|
|
|
|
;; and Soar, in that they don't know anything about file extensions.
|
|
|
|
|
;; So the compile/load interface gets the wrong default occasionally.
|
|
|
|
|
;; The load-file/compile-file default mechanism could be smarter -- it
|
|
|
|
|
;; doesn't know about the relationship between filename extensions and
|
|
|
|
|
;; whether the file is source or executable. If you compile foo.lisp
|
|
|
|
|
;; with compile-file, then the next load-file should use foo.bin for
|
|
|
|
|
;; the default, not foo.lisp. This is tricky to do right, particularly
|
|
|
|
|
;; because the extension for executable files varies so much (.o, .bin,
|
|
|
|
|
;; .lbin, .mo, .vo, .ao, ...).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;; TERM-SOURCE-DEFAULT -- determines defaults for source-file processing
|
|
|
|
|
;; commands.
|
|
|
|
|
;;
|
|
|
|
|
;; TERM-CHECK-SOURCE -- if FNAME is in a modified buffer, asks you if you
|
|
|
|
|
;; want to save the buffer before issuing any process requests to the command
|
|
|
|
|
;; interpreter.
|
|
|
|
|
;;
|
|
|
|
|
;; TERM-GET-SOURCE -- used by the source-file processing commands to prompt
|
|
|
|
|
;; for the file to process.
|
1994-10-13 06:30:49 +00:00
|
|
|
|
|
2009-08-16 15:39:11 +00:00
|
|
|
|
;; (TERM-SOURCE-DEFAULT previous-dir/file source-modes)
|
|
|
|
|
;;============================================================================
|
|
|
|
|
;; This function computes the defaults for the load-file and compile-file
|
|
|
|
|
;; commands for tea, soar, cmulisp, and cmuscheme modes.
|
|
|
|
|
;;
|
|
|
|
|
;; - PREVIOUS-DIR/FILE is a pair (directory . filename) from the last
|
|
|
|
|
;; source-file processing command, or nil if there hasn't been one yet.
|
|
|
|
|
;; - SOURCE-MODES is a list used to determine what buffers contain source
|
|
|
|
|
;; files: if the major mode of the buffer is in SOURCE-MODES, it's source.
|
|
|
|
|
;; Typically, (lisp-mode) or (scheme-mode).
|
|
|
|
|
;;
|
|
|
|
|
;; If the command is given while the cursor is inside a string, *and*
|
|
|
|
|
;; the string is an existing filename, *and* the filename is not a directory,
|
|
|
|
|
;; then the string is taken as default. This allows you to just position
|
|
|
|
|
;; your cursor over a string that's a filename and have it taken as default.
|
|
|
|
|
;;
|
|
|
|
|
;; If the command is given in a file buffer whose major mode is in
|
|
|
|
|
;; SOURCE-MODES, then the filename is the default file, and the
|
|
|
|
|
;; file's directory is the default directory.
|
|
|
|
|
;;
|
|
|
|
|
;; If the buffer isn't a source file buffer (e.g., it's the process buffer),
|
|
|
|
|
;; then the default directory & file are what was used in the last source-file
|
|
|
|
|
;; processing command (i.e., PREVIOUS-DIR/FILE). If this is the first time
|
|
|
|
|
;; the command has been run (PREVIOUS-DIR/FILE is nil), the default directory
|
|
|
|
|
;; is the cwd, with no default file. (\"no default file\" = nil)
|
|
|
|
|
;;
|
|
|
|
|
;; SOURCE-REGEXP is typically going to be something like (tea-mode)
|
|
|
|
|
;; for T programs, (lisp-mode) for Lisp programs, (soar-mode lisp-mode)
|
|
|
|
|
;; for Soar programs, etc.
|
|
|
|
|
;;
|
|
|
|
|
;; The function returns a pair: (default-directory . default-file).
|
1994-10-13 06:30:49 +00:00
|
|
|
|
|
|
|
|
|
(defun term-source-default (previous-dir/file source-modes)
|
|
|
|
|
(cond ((and buffer-file-name (memq major-mode source-modes))
|
|
|
|
|
(cons (file-name-directory buffer-file-name)
|
|
|
|
|
(file-name-nondirectory buffer-file-name)))
|
|
|
|
|
(previous-dir/file)
|
|
|
|
|
(t
|
|
|
|
|
(cons default-directory nil))))
|
|
|
|
|
|
|
|
|
|
|
2009-08-16 15:39:11 +00:00
|
|
|
|
;; (TERM-CHECK-SOURCE fname)
|
|
|
|
|
;;============================================================================
|
|
|
|
|
;; Prior to loading or compiling (or otherwise processing) a file (in the CMU
|
|
|
|
|
;; process-in-a-buffer modes), this function can be called on the filename.
|
|
|
|
|
;; If the file is loaded into a buffer, and the buffer is modified, the user
|
|
|
|
|
;; is queried to see if he wants to save the buffer before proceeding with
|
|
|
|
|
;; the load or compile.
|
1994-10-13 06:30:49 +00:00
|
|
|
|
|
|
|
|
|
(defun term-check-source (fname)
|
|
|
|
|
(let ((buff (get-file-buffer fname)))
|
(term-if-xemacs, term-ifnot-xemacs): Delete, replace
uses with a simple test.
(term-set-escape-char, term-mode, term-check-kill-echo-list)
(term-send-raw-string, term-send-raw, term-mouse-paste)
(term-char-mode, term-line-mode, term-exec, term-sentinel)
(term-handle-exit, term-read-input-ring)
(term-previous-matching-input-string)
(term-previous-matching-input-string-position)
(term-previous-matching-input-from-input)
(term-replace-by-expanded-history, term-send-input)
(term-skip-prompt, term-bol, term-send-invisible)
(term-kill-input, term-delchar-or-maybe-eof)
(term-backward-matching-input, term-check-source)
(term-proc-query, term-emulate-terminal)
(term-handle-colors-array, term-process-pager, term-pager-line)
(term-pager-bob, term-unwrap-line, term-word)
(term-dynamic-complete-filename)
(term-dynamic-complete-as-filename)
(term-dynamic-simple-complete): Replace one arm ifs with whens or
unlesses.
2006-05-29 06:11:33 +00:00
|
|
|
|
(when (and buff
|
|
|
|
|
(buffer-modified-p buff)
|
|
|
|
|
(y-or-n-p (format "Save buffer %s first? "
|
|
|
|
|
(buffer-name buff))))
|
|
|
|
|
;; save BUFF.
|
* x-dnd.el (x-dnd-maybe-call-test-function):
* window.el (split-window-vertically):
* whitespace.el (whitespace-help-on):
* vc-rcs.el (vc-rcs-consult-headers):
* userlock.el (ask-user-about-lock-help)
(ask-user-about-supersession-help):
* type-break.el (type-break-force-mode-line-update):
* time-stamp.el (time-stamp-conv-warn):
* terminal.el (te-set-output-log, te-more-break, te-filter)
(te-sentinel,terminal-emulator):
* term.el (make-term, term-exec, term-sentinel, term-read-input-ring)
(term-write-input-ring, term-check-source, term-start-output-log):
(term-display-buffer-line, term-dynamic-list-completions):
(term-ansi-make-term, serial-term):
* subr.el (selective-display):
* strokes.el (strokes-xpm-to-compressed-string, strokes-decode-buffer)
(strokes-encode-buffer, strokes-xpm-for-compressed-string):
* speedbar.el (speedbar-buffers-tail-notes, speedbar-buffers-item-info)
(speedbar-reconfigure-keymaps, speedbar-add-localized-speedbar-support)
(speedbar-remove-localized-speedbar-support)
(speedbar-set-mode-line-format, speedbar-create-tag-hierarchy)
(speedbar-update-special-contents, speedbar-buffer-buttons-engine)
(speedbar-buffers-line-directory):
* simple.el (shell-command-on-region, append-to-buffer)
(prepend-to-buffer):
* shadowfile.el (shadow-save-todo-file):
* scroll-bar.el (scroll-bar-set-window-start, scroll-bar-drag-1)
(scroll-bar-maybe-set-window-start):
* sb-image.el (speedbar-image-dump):
* saveplace.el (save-place-alist-to-file, save-places-to-alist)
(load-save-place-alist-from-file):
* ps-samp.el (ps-print-message-from-summary):
* ps-print.el (ps-flush-output, ps-insert-file, ps-get-boundingbox)
(ps-background-image, ps-begin-job, ps-do-despool):
* ps-bdf.el (bdf-find-file, bdf-read-font-info):
* printing.el (pr-interface, pr-ps-file-print, pr-find-buffer-visiting)
(pr-ps-message-from-summary, pr-lpr-message-from-summary):
(pr-call-process, pr-file-list, pr-interface-save):
* novice.el (disabled-command-function)
(enable-command, disable-command):
* mouse.el (mouse-buffer-menu-alist):
* mouse-copy.el (mouse-kill-preserving-secondary):
* macros.el (kbd-macro-query):
* ledit.el (ledit-go-to-lisp, ledit-go-to-liszt):
* informat.el (batch-info-validate):
* ido.el (ido-copy-current-word, ido-initiate-auto-merge):
* hippie-exp.el (try-expand-dabbrev-visible):
* help-mode.el (help-make-xrefs):
* help-fns.el (describe-variable):
* generic-x.el (bat-generic-mode-run-as-comint):
* finder.el (finder-mouse-select):
* find-dired.el (find-dired-sentinel):
* filesets.el (filesets-file-close):
* files.el (list-directory):
* faces.el (list-faces-display, describe-face):
* facemenu.el (list-colors-display):
* ezimage.el (ezimage-image-association-dump, ezimage-image-dump):
* epg.el (epg--process-filter, epg-cancel):
* epa.el (epa--marked-keys, epa--select-keys, epa-display-info)
(epa--read-signature-type):
* emerge.el (emerge-copy-as-kill-A, emerge-copy-as-kill-B)
(emerge-file-names):
* ehelp.el (electric-helpify):
* ediff.el (ediff-regions-wordwise, ediff-regions-linewise):
* ediff-vers.el (rcs-ediff-view-revision):
* ediff-util.el (ediff-setup):
* ediff-mult.el (ediff-append-custom-diff):
* ediff-diff.el (ediff-exec-process, ediff-process-sentinel)
(ediff-wordify):
* echistory.el (Electric-command-history-redo-expression):
* dos-w32.el (find-file-not-found-set-buffer-file-coding-system):
* disp-table.el (describe-display-table):
* dired.el (dired-find-buffer-nocreate):
* dired-aux.el (dired-rename-subdir, dired-dwim-target-directory):
* dabbrev.el (dabbrev--same-major-mode-p):
* chistory.el (list-command-history):
* apropos.el (apropos-documentation):
* allout.el (allout-obtain-passphrase):
(allout-copy-exposed-to-buffer):
(allout-verify-passphrase): Use with-current-buffer.
2009-11-13 22:19:45 +00:00
|
|
|
|
(with-current-buffer buff
|
|
|
|
|
(save-buffer)))))
|
1994-10-13 06:30:49 +00:00
|
|
|
|
|
|
|
|
|
|
2009-08-16 15:39:11 +00:00
|
|
|
|
;; (TERM-GET-SOURCE prompt prev-dir/file source-modes mustmatch-p)
|
|
|
|
|
;;============================================================================
|
|
|
|
|
;; TERM-GET-SOURCE is used to prompt for filenames in command-interpreter
|
|
|
|
|
;; commands that process source files (like loading or compiling a file).
|
|
|
|
|
;; It prompts for the filename, provides a default, if there is one,
|
|
|
|
|
;; and returns the result filename.
|
|
|
|
|
;;
|
|
|
|
|
;; See TERM-SOURCE-DEFAULT for more on determining defaults.
|
|
|
|
|
;;
|
|
|
|
|
;; PROMPT is the prompt string. PREV-DIR/FILE is the (directory . file) pair
|
|
|
|
|
;; from the last source processing command. SOURCE-MODES is a list of major
|
|
|
|
|
;; modes used to determine what file buffers contain source files. (These
|
|
|
|
|
;; two arguments are used for determining defaults). If MUSTMATCH-P is true,
|
|
|
|
|
;; then the filename reader will only accept a file that exists.
|
|
|
|
|
;;
|
|
|
|
|
;; A typical use:
|
Replace "(default %s)" with 'format-prompt'
* lisp/cmuscheme.el (scheme-load-file, scheme-compile-file):
* lisp/comint.el (comint-get-source):
* lisp/emulation/viper-cmd.el (viper-quote-region, viper-kill-buffer)
(viper-query-replace, viper-read-string-with-history):
* lisp/eshell/esh-mode.el (eshell-find-tag):
* lisp/gnus/gnus-sum.el (gnus-articles-to-read)
(gnus-summary-search-article-forward)
(gnus-summary-search-article-backward):
* lisp/international/mule-cmds.el (set-input-method, toggle-input-method)
(describe-input-method, set-language-environment)
(describe-language-environment):
* lisp/mh-e/mh-gnus.el (mh-mml-minibuffer-read-disposition):
* lisp/mh-e/mh-letter.el (mh-insert-letter):
* lisp/mh-e/mh-mime.el (mh-display-with-external-viewer)
(mh-mime-save-parts, mh-mh-forward-message)
(mh-mml-query-cryptographic-method, mh-minibuffer-read-type):
* lisp/mh-e/mh-seq.el (mh-read-seq, mh-read-range):
* lisp/mh-e/mh-utils.el (mh-prompt-for-folder):
* lisp/progmodes/etags.el (find-tag-tag):
(find-tag-noselect, find-tag, find-tag-other-window)
(find-tag-other-frame, find-tag-regexp):
* lisp/progmodes/idlwave.el (idlwave-find-module):
* lisp/progmodes/inf-lisp.el (lisp-load-file, lisp-compile-file):
* lisp/progmodes/tcl.el (tcl-load-file, tcl-restart-with-file):
* lisp/progmodes/xref.el (xref--read-identifier):
(xref-find-definitions, xref-find-definitions-other-window)
(xref-find-definitions-other-frame, xref-find-references):
* lisp/ses.el (ses-read-printer):
(ses-read-cell-printer, ses-read-column-printer)
(ses-read-default-printer, ses-define-local-printer):
* lisp/subr.el (read-number):
* lisp/term.el (term-get-source):
* src/minibuf.c (read-buffer): Remove prompt suffix and
use 'format-prompt'.
* lisp/minibuffer.el (format-prompt): Ignore DEFAULT empty strings
(bug#47286).
2021-03-24 09:31:31 +00:00
|
|
|
|
;; (interactive (term-get-source "Compile file" prev-lisp-dir/file
|
2009-08-16 15:39:11 +00:00
|
|
|
|
;; '(lisp-mode) t))
|
1994-10-13 06:30:49 +00:00
|
|
|
|
|
2009-08-16 15:39:11 +00:00
|
|
|
|
;; This is pretty stupid about strings. It decides we're in a string
|
|
|
|
|
;; if there's a quote on both sides of point on the current line.
|
1994-10-13 06:30:49 +00:00
|
|
|
|
(defun term-extract-string ()
|
2005-06-10 00:43:13 +00:00
|
|
|
|
"Return string around `point' that starts the current line or nil."
|
1994-10-13 06:30:49 +00:00
|
|
|
|
(save-excursion
|
|
|
|
|
(let* ((point (point))
|
Use line-end-position rather than end-of-line, etc.
* textmodes/texnfo-upd.el (texinfo-start-menu-description)
(texinfo-update-menu-region-beginning, texinfo-menu-first-node)
(texinfo-delete-existing-pointers, texinfo-find-pointer)
(texinfo-clean-up-node-line, texinfo-insert-node-lines)
(texinfo-multiple-files-update):
* textmodes/table.el (table--probe-cell-left-up)
(table--probe-cell-right-bottom):
* textmodes/picture.el (picture-tab-search):
* textmodes/page-ext.el (pages-copy-header-and-position)
(pages-directory-for-addresses):
* progmodes/vera-mode.el (vera-get-offset):
* progmodes/simula.el (simula-calculate-indent):
* progmodes/python.el (python-pdbtrack-overlay-arrow):
* progmodes/prolog.el (end-of-prolog-clause):
* progmodes/perl-mode.el (perl-calculate-indent, perl-indent-exp):
* progmodes/icon.el (indent-icon-exp):
* progmodes/etags.el (tag-re-match-p):
* progmodes/ebrowse.el (ebrowse-show-file-name-at-point):
* progmodes/ebnf2ps.el (ebnf-begin-file):
* progmodes/dcl-mode.el (dcl-back-to-indentation-1)
(dcl-save-local-variable):
* play/life.el (life-setup):
* play/gametree.el (gametree-looking-at-ply):
* nxml/nxml-maint.el (nxml-insert-target-repertoire-glyph-set):
* mail/sendmail.el (mail-mode-auto-fill):
* emacs-lisp/lisp-mode.el (calculate-lisp-indent):
* emacs-lisp/edebug.el (edebug-overlay-arrow):
* emacs-lisp/checkdoc.el (checkdoc-this-string-valid):
* woman.el (woman-parse-numeric-value, woman2-TH, woman2-SH)
(woman-tab-to-tab-stop, WoMan-warn-ignored):
* type-break.el (type-break-file-keystroke-count):
* term.el (term-replace-by-expanded-history-before-point)
(term-skip-prompt, term-extract-string):
* speedbar.el (speedbar-edit-line, speedbar-expand-line)
(speedbar-contract-line, speedbar-toggle-line-expansion)
(speedbar-parse-c-or-c++tag, speedbar-parse-tex-string)
(speedbar-buffer-revert-buffer, speedbar-highlight-one-tag-line):
* sort.el (sort-skip-fields):
* skeleton.el (skeleton-internal-list):
* simple.el (line-move-finish, line-move-to-column):
* shell.el (shell-forward-command):
* misc.el (copy-from-above-command):
* makesum.el (double-column):
* ebuff-menu.el (electric-buffer-update-highlight):
* dired.el (dired-move-to-end-of-filename):
* dframe.el (dframe-popup-kludge):
* bookmark.el (bookmark-kill-line, bookmark-bmenu-show-filenames):
* arc-mode.el (archive-get-lineno):
Use line-end-position and line-beginning-position.
* net/ange-ftp.el, progmodes/hideif.el, reposition.el:
Same, but only in comments.
2010-11-06 20:23:42 +00:00
|
|
|
|
(bol (line-beginning-position))
|
|
|
|
|
(eol (line-end-position))
|
|
|
|
|
(start (and (search-backward "\"" bol t)
|
|
|
|
|
(1+ (point))))
|
1994-10-13 06:30:49 +00:00
|
|
|
|
(end (progn (goto-char point)
|
|
|
|
|
(and (search-forward "\"" eol t)
|
|
|
|
|
(1- (point))))))
|
|
|
|
|
(and start end
|
|
|
|
|
(buffer-substring start end)))))
|
|
|
|
|
|
|
|
|
|
(defun term-get-source (prompt prev-dir/file source-modes mustmatch-p)
|
|
|
|
|
(let* ((def (term-source-default prev-dir/file source-modes))
|
|
|
|
|
(stringfile (term-extract-string))
|
|
|
|
|
(sfile-p (and stringfile
|
|
|
|
|
(condition-case ()
|
|
|
|
|
(file-exists-p stringfile)
|
|
|
|
|
(error nil))
|
|
|
|
|
(not (file-directory-p stringfile))))
|
|
|
|
|
(defdir (if sfile-p (file-name-directory stringfile)
|
|
|
|
|
(car def)))
|
|
|
|
|
(deffile (if sfile-p (file-name-nondirectory stringfile)
|
|
|
|
|
(cdr def)))
|
Replace "(default %s)" with 'format-prompt'
* lisp/cmuscheme.el (scheme-load-file, scheme-compile-file):
* lisp/comint.el (comint-get-source):
* lisp/emulation/viper-cmd.el (viper-quote-region, viper-kill-buffer)
(viper-query-replace, viper-read-string-with-history):
* lisp/eshell/esh-mode.el (eshell-find-tag):
* lisp/gnus/gnus-sum.el (gnus-articles-to-read)
(gnus-summary-search-article-forward)
(gnus-summary-search-article-backward):
* lisp/international/mule-cmds.el (set-input-method, toggle-input-method)
(describe-input-method, set-language-environment)
(describe-language-environment):
* lisp/mh-e/mh-gnus.el (mh-mml-minibuffer-read-disposition):
* lisp/mh-e/mh-letter.el (mh-insert-letter):
* lisp/mh-e/mh-mime.el (mh-display-with-external-viewer)
(mh-mime-save-parts, mh-mh-forward-message)
(mh-mml-query-cryptographic-method, mh-minibuffer-read-type):
* lisp/mh-e/mh-seq.el (mh-read-seq, mh-read-range):
* lisp/mh-e/mh-utils.el (mh-prompt-for-folder):
* lisp/progmodes/etags.el (find-tag-tag):
(find-tag-noselect, find-tag, find-tag-other-window)
(find-tag-other-frame, find-tag-regexp):
* lisp/progmodes/idlwave.el (idlwave-find-module):
* lisp/progmodes/inf-lisp.el (lisp-load-file, lisp-compile-file):
* lisp/progmodes/tcl.el (tcl-load-file, tcl-restart-with-file):
* lisp/progmodes/xref.el (xref--read-identifier):
(xref-find-definitions, xref-find-definitions-other-window)
(xref-find-definitions-other-frame, xref-find-references):
* lisp/ses.el (ses-read-printer):
(ses-read-cell-printer, ses-read-column-printer)
(ses-read-default-printer, ses-define-local-printer):
* lisp/subr.el (read-number):
* lisp/term.el (term-get-source):
* src/minibuf.c (read-buffer): Remove prompt suffix and
use 'format-prompt'.
* lisp/minibuffer.el (format-prompt): Ignore DEFAULT empty strings
(bug#47286).
2021-03-24 09:31:31 +00:00
|
|
|
|
(ans (read-file-name (format-prompt prompt deffile)
|
1994-10-13 06:30:49 +00:00
|
|
|
|
defdir
|
|
|
|
|
(concat defdir deffile)
|
|
|
|
|
mustmatch-p)))
|
|
|
|
|
(list (expand-file-name (substitute-in-file-name ans)))))
|
|
|
|
|
|
2009-08-16 15:39:11 +00:00
|
|
|
|
;; I am somewhat divided on this string-default feature. It seems
|
|
|
|
|
;; to violate the principle-of-least-astonishment, in that it makes
|
|
|
|
|
;; the default harder to predict, so you actually have to look and see
|
|
|
|
|
;; what the default really is before choosing it. This can trip you up.
|
|
|
|
|
;; On the other hand, it can be useful, I guess. I would appreciate feedback
|
|
|
|
|
;; on this.
|
|
|
|
|
;; -Olin
|
1994-10-13 06:30:49 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;; Simple process query facility.
|
2009-08-16 15:39:11 +00:00
|
|
|
|
;; ===========================================================================
|
|
|
|
|
;; This function is for commands that want to send a query to the process
|
|
|
|
|
;; and show the response to the user. For example, a command to get the
|
|
|
|
|
;; arglist for a Common Lisp function might send a "(arglist 'foo)" query
|
|
|
|
|
;; to an inferior Common Lisp process.
|
|
|
|
|
;;
|
|
|
|
|
;; This simple facility just sends strings to the inferior process and pops
|
|
|
|
|
;; up a window for the process buffer so you can see what the process
|
|
|
|
|
;; responds with. We don't do anything fancy like try to intercept what the
|
|
|
|
|
;; process responds with and put it in a pop-up window or on the message
|
|
|
|
|
;; line. We just display the buffer. Low tech. Simple. Works good.
|
|
|
|
|
|
|
|
|
|
;; Send to the inferior process PROC the string STR. Pop-up but do not select
|
|
|
|
|
;; a window for the inferior process so that its response can be seen.
|
1994-10-13 06:30:49 +00:00
|
|
|
|
(defun term-proc-query (proc str)
|
|
|
|
|
(let* ((proc-buf (process-buffer proc))
|
|
|
|
|
(proc-mark (process-mark proc)))
|
|
|
|
|
(display-buffer proc-buf)
|
|
|
|
|
(set-buffer proc-buf) ; but it's not the selected *window*
|
|
|
|
|
(let ((proc-win (get-buffer-window proc-buf))
|
|
|
|
|
(proc-pt (marker-position proc-mark)))
|
|
|
|
|
(term-send-string proc str) ; send the query
|
|
|
|
|
(accept-process-output proc) ; wait for some output
|
|
|
|
|
;; Try to position the proc window so you can see the answer.
|
1997-04-02 03:46:39 +00:00
|
|
|
|
;; This is bogus code. If you delete the (sit-for 0), it breaks.
|
|
|
|
|
;; I don't know why. Wizards invited to improve it.
|
(term-if-xemacs, term-ifnot-xemacs): Delete, replace
uses with a simple test.
(term-set-escape-char, term-mode, term-check-kill-echo-list)
(term-send-raw-string, term-send-raw, term-mouse-paste)
(term-char-mode, term-line-mode, term-exec, term-sentinel)
(term-handle-exit, term-read-input-ring)
(term-previous-matching-input-string)
(term-previous-matching-input-string-position)
(term-previous-matching-input-from-input)
(term-replace-by-expanded-history, term-send-input)
(term-skip-prompt, term-bol, term-send-invisible)
(term-kill-input, term-delchar-or-maybe-eof)
(term-backward-matching-input, term-check-source)
(term-proc-query, term-emulate-terminal)
(term-handle-colors-array, term-process-pager, term-pager-line)
(term-pager-bob, term-unwrap-line, term-word)
(term-dynamic-complete-filename)
(term-dynamic-complete-as-filename)
(term-dynamic-simple-complete): Replace one arm ifs with whens or
unlesses.
2006-05-29 06:11:33 +00:00
|
|
|
|
(when (not (pos-visible-in-window-p proc-pt proc-win))
|
|
|
|
|
(let ((opoint (window-point proc-win)))
|
|
|
|
|
(set-window-point proc-win proc-mark) (sit-for 0)
|
|
|
|
|
(if (not (pos-visible-in-window-p opoint proc-win))
|
|
|
|
|
(push-mark opoint)
|
|
|
|
|
(set-window-point proc-win opoint)))))))
|
1994-10-13 06:30:49 +00:00
|
|
|
|
|
2009-08-16 15:39:11 +00:00
|
|
|
|
;; Returns the current column in the current screen line.
|
|
|
|
|
;; Note: (current-column) yields column in buffer line.
|
1994-10-13 06:30:49 +00:00
|
|
|
|
|
|
|
|
|
(defun term-horizontal-column ()
|
|
|
|
|
(- (term-current-column) (term-start-line-column)))
|
|
|
|
|
|
2005-04-11 20:47:25 +00:00
|
|
|
|
;; Calls either vertical-motion or term-buffer-vertical-motion
|
1994-10-13 06:30:49 +00:00
|
|
|
|
(defmacro term-vertical-motion (count)
|
|
|
|
|
(list 'funcall 'term-vertical-motion count))
|
|
|
|
|
|
2009-08-16 15:39:11 +00:00
|
|
|
|
; An emulation of vertical-motion that is independent of having a window.
|
|
|
|
|
; Instead, it uses the term-width variable as the logical window width.
|
1994-10-13 06:30:49 +00:00
|
|
|
|
|
2005-04-11 20:47:25 +00:00
|
|
|
|
(defun term-buffer-vertical-motion (count)
|
1994-10-13 06:30:49 +00:00
|
|
|
|
(cond ((= count 0)
|
|
|
|
|
(move-to-column (* term-width (/ (current-column) term-width)))
|
|
|
|
|
0)
|
|
|
|
|
((> count 0)
|
|
|
|
|
(let ((H)
|
|
|
|
|
(todo (+ count (/ (current-column) term-width))))
|
|
|
|
|
(end-of-line)
|
1996-01-04 23:20:49 +00:00
|
|
|
|
;; The loop iterates over buffer lines;
|
1994-10-13 06:30:49 +00:00
|
|
|
|
;; H is the number of screen lines in the current line, i.e.
|
|
|
|
|
;; the ceiling of dividing the buffer line width by term-width.
|
|
|
|
|
(while (and (<= (setq H (max (/ (+ (current-column) term-width -1)
|
|
|
|
|
term-width)
|
|
|
|
|
1))
|
|
|
|
|
todo)
|
|
|
|
|
(not (eobp)))
|
|
|
|
|
(setq todo (- todo H))
|
|
|
|
|
(forward-char) ;; Move past the ?\n
|
|
|
|
|
(end-of-line)) ;; and on to the end of the next line.
|
|
|
|
|
(if (and (>= todo H) (> todo 0))
|
|
|
|
|
(+ (- count todo) H -1) ;; Hit end of buffer.
|
|
|
|
|
(move-to-column (* todo term-width))
|
|
|
|
|
count)))
|
|
|
|
|
(t ;; (< count 0) ;; Similar algorithm, but for upward motion.
|
|
|
|
|
(let ((H)
|
|
|
|
|
(todo (- count)))
|
|
|
|
|
(while (and (<= (setq H (max (/ (+ (current-column) term-width -1)
|
|
|
|
|
term-width)
|
|
|
|
|
1))
|
|
|
|
|
todo)
|
|
|
|
|
(progn (beginning-of-line)
|
|
|
|
|
(not (bobp))))
|
|
|
|
|
(setq todo (- todo H))
|
1996-01-04 23:20:49 +00:00
|
|
|
|
(backward-char)) ;; Move to end of previous line.
|
1994-10-13 06:30:49 +00:00
|
|
|
|
(if (and (>= todo H) (> todo 0))
|
|
|
|
|
(+ count todo (- 1 H)) ;; Hit beginning of buffer.
|
|
|
|
|
(move-to-column (* (- H todo 1) term-width))
|
|
|
|
|
count)))))
|
|
|
|
|
|
2009-08-16 15:39:11 +00:00
|
|
|
|
;; The term-start-line-column variable is used as a cache.
|
1994-10-13 06:30:49 +00:00
|
|
|
|
(defun term-start-line-column ()
|
|
|
|
|
(cond (term-start-line-column)
|
|
|
|
|
((let ((save-pos (point)))
|
|
|
|
|
(term-vertical-motion 0)
|
|
|
|
|
(setq term-start-line-column (current-column))
|
|
|
|
|
(goto-char save-pos)
|
|
|
|
|
term-start-line-column))))
|
|
|
|
|
|
2009-08-16 15:39:11 +00:00
|
|
|
|
;; Same as (current-column), but uses term-current-column as a cache.
|
1994-10-13 06:30:49 +00:00
|
|
|
|
(defun term-current-column ()
|
|
|
|
|
(cond (term-current-column)
|
|
|
|
|
((setq term-current-column (current-column)))))
|
|
|
|
|
|
2018-01-18 13:22:47 +00:00
|
|
|
|
(defun term-move-to-column (column)
|
|
|
|
|
(setq term-current-column column)
|
2022-08-23 02:54:57 +00:00
|
|
|
|
(let ((line-end-position (line-end-position)))
|
2005-03-26 22:32:43 +00:00
|
|
|
|
(move-to-column term-current-column t)
|
|
|
|
|
;; If move-to-column extends the current line it will use the face
|
|
|
|
|
;; from the last character on the line, set the face for the chars
|
|
|
|
|
;; to default.
|
2022-08-23 02:54:57 +00:00
|
|
|
|
(when (> (point) line-end-position)
|
|
|
|
|
(put-text-property line-end-position (point) 'font-lock-face 'default))))
|
1994-10-13 06:30:49 +00:00
|
|
|
|
|
2018-01-18 13:22:47 +00:00
|
|
|
|
;; Move DELTA column right (or left if delta < 0 limiting at column 0).
|
|
|
|
|
(defun term-move-columns (delta)
|
|
|
|
|
(term-move-to-column
|
|
|
|
|
(max 0 (+ (term-current-column) delta))))
|
|
|
|
|
|
1994-10-13 06:30:49 +00:00
|
|
|
|
;; Insert COUNT copies of CHAR in the default face.
|
|
|
|
|
(defun term-insert-char (char count)
|
|
|
|
|
(let ((old-point (point)))
|
|
|
|
|
(insert-char char count)
|
2012-06-20 09:21:06 +00:00
|
|
|
|
(put-text-property old-point (point) 'font-lock-face 'default)))
|
1994-10-13 06:30:49 +00:00
|
|
|
|
|
|
|
|
|
(defun term-current-row ()
|
|
|
|
|
(cond (term-current-row)
|
|
|
|
|
((setq term-current-row
|
|
|
|
|
(save-restriction
|
|
|
|
|
(save-excursion
|
|
|
|
|
(narrow-to-region term-home-marker (point-max))
|
|
|
|
|
(- (term-vertical-motion -9999))))))))
|
|
|
|
|
|
|
|
|
|
(defun term-adjust-current-row-cache (delta)
|
2004-10-02 18:23:27 +00:00
|
|
|
|
(when term-current-row
|
2005-06-10 00:43:13 +00:00
|
|
|
|
(setq term-current-row
|
2004-10-02 18:23:27 +00:00
|
|
|
|
(max 0 (+ term-current-row delta)))))
|
1994-10-13 06:30:49 +00:00
|
|
|
|
|
|
|
|
|
(defun term-terminal-pos ()
|
|
|
|
|
(save-excursion ; save-restriction
|
|
|
|
|
(let ((save-col (term-current-column))
|
1995-02-06 21:56:37 +00:00
|
|
|
|
x y)
|
1994-10-13 06:30:49 +00:00
|
|
|
|
(term-vertical-motion 0)
|
|
|
|
|
(setq x (- save-col (current-column)))
|
|
|
|
|
(setq y (term-vertical-motion term-height))
|
|
|
|
|
(cons x y))))
|
|
|
|
|
|
2009-08-16 15:39:11 +00:00
|
|
|
|
;;Function that handles term messages: code by rms (and you can see the
|
|
|
|
|
;;difference ;-) -mm
|
1997-04-02 03:46:39 +00:00
|
|
|
|
|
|
|
|
|
(defun term-handle-ansi-terminal-messages (message)
|
|
|
|
|
;; Is there a command here?
|
|
|
|
|
(while (string-match "\eAnSiT.+\n" message)
|
|
|
|
|
;; Extract the command code and the argument.
|
|
|
|
|
(let* ((start (match-beginning 0))
|
|
|
|
|
(command-code (aref message (+ start 6)))
|
|
|
|
|
(argument
|
|
|
|
|
(save-match-data
|
|
|
|
|
(substring message
|
|
|
|
|
(+ start 8)
|
|
|
|
|
(string-match "\r?\n" message
|
|
|
|
|
(+ start 8)))))
|
|
|
|
|
ignore)
|
|
|
|
|
;; Delete this command from MESSAGE.
|
|
|
|
|
(setq message (replace-match "" t t message))
|
|
|
|
|
|
|
|
|
|
;; If we recognize the type of command, set the appropriate variable.
|
|
|
|
|
(cond ((= command-code ?c)
|
|
|
|
|
(setq term-ansi-at-dir argument))
|
|
|
|
|
((= command-code ?h)
|
|
|
|
|
(setq term-ansi-at-host argument))
|
|
|
|
|
((= command-code ?u)
|
|
|
|
|
(setq term-ansi-at-user argument))
|
|
|
|
|
;; Otherwise ignore this one.
|
|
|
|
|
(t
|
|
|
|
|
(setq ignore t)))
|
|
|
|
|
|
|
|
|
|
;; Update default-directory based on the changes this command made.
|
|
|
|
|
(if ignore
|
|
|
|
|
nil
|
|
|
|
|
(setq default-directory
|
|
|
|
|
(file-name-as-directory
|
|
|
|
|
(if (and (string= term-ansi-at-host (system-name))
|
2018-05-03 13:29:42 +00:00
|
|
|
|
(string= term-ansi-at-user (user-real-login-name)))
|
1997-04-02 03:46:39 +00:00
|
|
|
|
(expand-file-name term-ansi-at-dir)
|
2018-05-03 13:29:42 +00:00
|
|
|
|
(concat "/-:" term-ansi-at-user "@" term-ansi-at-host ":"
|
|
|
|
|
term-ansi-at-dir))))
|
1997-04-02 03:46:39 +00:00
|
|
|
|
|
|
|
|
|
;; I'm not sure this is necessary,
|
|
|
|
|
;; but it's best to be on the safe side.
|
|
|
|
|
(if (string= term-ansi-at-host (system-name))
|
|
|
|
|
(progn
|
|
|
|
|
(setq ange-ftp-default-user term-ansi-at-save-user)
|
|
|
|
|
(setq ange-ftp-default-password term-ansi-at-save-pwd)
|
|
|
|
|
(setq ange-ftp-generate-anonymous-password term-ansi-at-save-anon))
|
|
|
|
|
(setq term-ansi-at-save-user ange-ftp-default-user)
|
|
|
|
|
(setq term-ansi-at-save-pwd ange-ftp-default-password)
|
|
|
|
|
(setq term-ansi-at-save-anon ange-ftp-generate-anonymous-password)
|
|
|
|
|
(setq ange-ftp-default-user nil)
|
|
|
|
|
(setq ange-ftp-default-password nil)
|
|
|
|
|
(setq ange-ftp-generate-anonymous-password nil)))))
|
|
|
|
|
message)
|
|
|
|
|
|
|
|
|
|
|
2009-08-16 15:39:11 +00:00
|
|
|
|
;; Terminal emulation
|
|
|
|
|
;; This is the standard process filter for term buffers.
|
|
|
|
|
;; It emulates (most of the features of) a VT100/ANSI-style terminal.
|
1994-10-13 06:30:49 +00:00
|
|
|
|
|
2018-01-18 13:22:47 +00:00
|
|
|
|
;; References:
|
|
|
|
|
;; [ctlseqs]: http://invisible-island.net/xterm/ctlseqs/ctlseqs.html
|
2020-10-24 18:22:33 +00:00
|
|
|
|
;; [ECMA-48]: https://www.ecma-international.org/publications/standards/Ecma-048.htm
|
2018-01-18 13:22:47 +00:00
|
|
|
|
;; [vt100]: https://vt100.net/docs/vt100-ug/chapter3.html
|
|
|
|
|
|
|
|
|
|
(defconst term-control-seq-regexp
|
|
|
|
|
(concat
|
|
|
|
|
;; A control character,
|
|
|
|
|
"\\(?:[\r\n\000\007\t\b\016\017]\\|"
|
|
|
|
|
;; some Emacs specific control sequences, implemented by
|
|
|
|
|
;; `term-command-hook',
|
2020-02-20 14:45:44 +00:00
|
|
|
|
"\032[^\n]+\n\\|"
|
2018-01-18 13:22:47 +00:00
|
|
|
|
;; a C1 escape coded character (see [ECMA-48] section 5.3 "Elements
|
|
|
|
|
;; of the C1 set"),
|
|
|
|
|
"\e\\(?:[DM78c]\\|"
|
|
|
|
|
;; another Emacs specific control sequence,
|
2020-02-20 14:45:44 +00:00
|
|
|
|
"AnSiT[^\n]+\n\\|"
|
2018-01-18 13:22:47 +00:00
|
|
|
|
;; or an escape sequence (section 5.4 "Control Sequences"),
|
|
|
|
|
"\\[\\([\x30-\x3F]*\\)[\x20-\x2F]*[\x40-\x7E]\\)\\)")
|
|
|
|
|
"Regexp matching control sequences handled by term.el.")
|
|
|
|
|
|
|
|
|
|
(defconst term-control-seq-prefix-regexp
|
|
|
|
|
"[\032\e]")
|
|
|
|
|
|
1994-10-13 06:30:49 +00:00
|
|
|
|
(defun term-emulate-terminal (proc str)
|
2021-02-05 09:13:23 +00:00
|
|
|
|
(when (buffer-live-p (process-buffer proc))
|
|
|
|
|
(with-current-buffer (process-buffer proc)
|
|
|
|
|
(let* ((i 0) funny
|
|
|
|
|
decoded-substring
|
|
|
|
|
save-point save-marker win
|
|
|
|
|
(inhibit-read-only t)
|
|
|
|
|
(buffer-undo-list t)
|
|
|
|
|
(selected (selected-window))
|
|
|
|
|
last-win
|
|
|
|
|
(str-length (length str)))
|
|
|
|
|
(save-selected-window
|
|
|
|
|
|
|
|
|
|
(when (marker-buffer term-pending-delete-marker)
|
|
|
|
|
;; Delete text following term-pending-delete-marker.
|
|
|
|
|
(delete-region term-pending-delete-marker (process-mark proc))
|
|
|
|
|
(set-marker term-pending-delete-marker nil))
|
|
|
|
|
|
|
|
|
|
(when (/= (point) (process-mark proc))
|
|
|
|
|
(setq save-point (point-marker)))
|
|
|
|
|
|
|
|
|
|
(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
|
|
|
|
|
;; If the buffer is in line mode, and there is a partial
|
|
|
|
|
;; input line, save the line (by narrowing to leave it
|
|
|
|
|
;; outside the restriction ) until we're done with output.
|
|
|
|
|
(when (and (> (point-max) (process-mark proc))
|
|
|
|
|
(term-in-line-mode))
|
|
|
|
|
(narrow-to-region (point-min) (process-mark proc)))
|
|
|
|
|
|
|
|
|
|
(when term-log-buffer
|
|
|
|
|
(princ str term-log-buffer))
|
|
|
|
|
(when term-terminal-undecoded-bytes
|
|
|
|
|
(setq str (concat term-terminal-undecoded-bytes str))
|
|
|
|
|
(setq str-length (length str))
|
|
|
|
|
(setq term-terminal-undecoded-bytes nil))
|
|
|
|
|
|
|
|
|
|
(while (< i str-length)
|
|
|
|
|
(setq funny (string-match term-control-seq-regexp str i))
|
|
|
|
|
(let ((ctl-params (and funny (match-string 1 str)))
|
|
|
|
|
(ctl-params-end (and funny (match-end 1)))
|
|
|
|
|
(ctl-end (if funny (match-end 0)
|
|
|
|
|
(setq funny (string-match term-control-seq-prefix-regexp str i))
|
|
|
|
|
(if funny
|
|
|
|
|
(setq term-terminal-undecoded-bytes
|
|
|
|
|
(substring str funny))
|
|
|
|
|
(setq funny str-length))
|
|
|
|
|
;; The control sequence ends somewhere
|
|
|
|
|
;; past the end of this string.
|
|
|
|
|
(1+ str-length))))
|
|
|
|
|
(when (> funny i)
|
|
|
|
|
(when term-do-line-wrapping
|
|
|
|
|
(term-down 1 t)
|
|
|
|
|
(term-move-to-column 0)
|
|
|
|
|
(setq term-do-line-wrapping nil))
|
|
|
|
|
;; Handle non-control data. Decode the string before
|
|
|
|
|
;; counting characters, to avoid garbling of certain
|
|
|
|
|
;; multibyte characters (bug#1006).
|
|
|
|
|
(setq decoded-substring
|
|
|
|
|
(decode-coding-string
|
|
|
|
|
(substring str i funny)
|
|
|
|
|
locale-coding-system t))
|
|
|
|
|
;; Check for multibyte characters that ends
|
|
|
|
|
;; before end of string, and save it for
|
|
|
|
|
;; next time.
|
|
|
|
|
(when (= funny str-length)
|
|
|
|
|
(let ((partial 0)
|
|
|
|
|
(count (length decoded-substring)))
|
|
|
|
|
(while (and (< partial count)
|
|
|
|
|
(eq (char-charset (aref decoded-substring
|
|
|
|
|
(- count 1 partial)))
|
|
|
|
|
'eight-bit))
|
|
|
|
|
(cl-incf partial))
|
|
|
|
|
(when (> count partial 0)
|
2018-01-18 13:22:47 +00:00
|
|
|
|
(setq term-terminal-undecoded-bytes
|
2021-02-05 09:13:23 +00:00
|
|
|
|
(substring decoded-substring (- partial)))
|
|
|
|
|
(setq decoded-substring
|
|
|
|
|
(substring decoded-substring 0 (- partial)))
|
|
|
|
|
(cl-decf str-length partial)
|
|
|
|
|
(cl-decf funny partial))))
|
|
|
|
|
|
|
|
|
|
;; Insert a string, check how many columns
|
|
|
|
|
;; we moved, then delete that many columns
|
|
|
|
|
;; following point if not eob nor insert-mode.
|
|
|
|
|
(let ((old-column (term-horizontal-column))
|
|
|
|
|
(old-point (point))
|
|
|
|
|
columns)
|
|
|
|
|
(unless term-suppress-hard-newline
|
|
|
|
|
(while (> (+ (length decoded-substring) old-column)
|
|
|
|
|
term-width)
|
|
|
|
|
(insert (substring decoded-substring 0
|
|
|
|
|
(- term-width old-column)))
|
|
|
|
|
;; Since we've enough text to fill the whole line,
|
|
|
|
|
;; delete previous text regardless of
|
|
|
|
|
;; `term-insert-mode's value.
|
|
|
|
|
(delete-region (point) (line-end-position))
|
|
|
|
|
(term-down 1 t)
|
|
|
|
|
(term-move-columns (- (term-current-column)))
|
|
|
|
|
(add-text-properties (1- (point)) (point)
|
|
|
|
|
'(term-line-wrap t rear-nonsticky t))
|
|
|
|
|
(setq decoded-substring
|
|
|
|
|
(substring decoded-substring (- term-width old-column)))
|
|
|
|
|
(setq old-column 0)))
|
|
|
|
|
(insert decoded-substring)
|
|
|
|
|
(setq term-current-column (current-column)
|
|
|
|
|
columns (- term-current-column old-column))
|
|
|
|
|
(when (not (or (eobp) term-insert-mode))
|
|
|
|
|
(let ((pos (point)))
|
|
|
|
|
(term-move-columns columns)
|
|
|
|
|
(delete-region pos (point))
|
|
|
|
|
(setq term-current-column nil)))
|
|
|
|
|
;; In insert mode if the current line
|
|
|
|
|
;; has become too long it needs to be
|
|
|
|
|
;; chopped off.
|
|
|
|
|
(when term-insert-mode
|
|
|
|
|
(let ((pos (point)))
|
|
|
|
|
(end-of-line)
|
|
|
|
|
(when (> (current-column) term-width)
|
|
|
|
|
(delete-region (- (point) (- (current-column) term-width))
|
|
|
|
|
(point)))
|
|
|
|
|
(goto-char pos)))
|
|
|
|
|
|
|
|
|
|
(put-text-property old-point (point)
|
|
|
|
|
'font-lock-face term-current-face))
|
|
|
|
|
;; If the last char was written in last column,
|
|
|
|
|
;; back up one column, but remember we did so.
|
|
|
|
|
;; Thus we emulate xterm/vt100-style line-wrapping.
|
|
|
|
|
(when (eq (term-current-column) term-width)
|
|
|
|
|
(term-move-columns -1)
|
|
|
|
|
;; We check after ctrl sequence handling if point
|
|
|
|
|
;; was moved (and leave line-wrapping state if so).
|
|
|
|
|
(setq term-do-line-wrapping (point)))
|
|
|
|
|
(setq term-current-column nil)
|
|
|
|
|
(setq i funny))
|
|
|
|
|
(pcase-exhaustive (and (<= ctl-end str-length) (aref str i))
|
|
|
|
|
(?\t ;; TAB (terminfo: ht)
|
|
|
|
|
;; The line cannot exceed term-width. TAB at
|
|
|
|
|
;; the end of a line should not cause wrapping.
|
|
|
|
|
(let ((col (term-current-column)))
|
|
|
|
|
(term-move-to-column
|
|
|
|
|
(min (1- term-width)
|
|
|
|
|
(+ col 8 (- (mod col 8)))))))
|
|
|
|
|
(?\r ;; (terminfo: cr)
|
|
|
|
|
(term-vertical-motion 0)
|
|
|
|
|
(setq term-current-column term-start-line-column))
|
|
|
|
|
(?\n ;; (terminfo: cud1, ind)
|
|
|
|
|
(unless (and term-kill-echo-list
|
|
|
|
|
(term-check-kill-echo-list))
|
|
|
|
|
(term-down 1 t)))
|
|
|
|
|
(?\b ;; (terminfo: cub1)
|
|
|
|
|
(term-move-columns -1))
|
|
|
|
|
(?\C-g ;; (terminfo: bel)
|
|
|
|
|
(beep t))
|
|
|
|
|
(?\032 ; Emacs specific control sequence.
|
|
|
|
|
(funcall term-command-function
|
|
|
|
|
(decode-coding-string
|
|
|
|
|
(substring str (1+ i)
|
|
|
|
|
(- ctl-end
|
|
|
|
|
(if (eq (aref str (- ctl-end 2)) ?\r)
|
|
|
|
|
2 1)))
|
|
|
|
|
locale-coding-system t)))
|
|
|
|
|
(?\e
|
|
|
|
|
(pcase (aref str (1+ i))
|
|
|
|
|
(?\[
|
|
|
|
|
;; We only handle control sequences with a single
|
|
|
|
|
;; "Final" byte (see [ECMA-48] section 5.4).
|
|
|
|
|
(when (eq ctl-params-end (1- ctl-end))
|
|
|
|
|
(term-handle-ansi-escape
|
|
|
|
|
proc
|
|
|
|
|
(mapcar ;; We don't distinguish empty params
|
|
|
|
|
;; from 0 (according to [ECMA-48] we
|
|
|
|
|
;; should, but all commands we support
|
|
|
|
|
;; default to 0 values anyway).
|
|
|
|
|
#'string-to-number
|
|
|
|
|
(split-string ctl-params ";"))
|
|
|
|
|
(aref str (1- ctl-end)))))
|
|
|
|
|
(?D ;; Scroll forward (apparently not documented in
|
|
|
|
|
;; [ECMA-48], [ctlseqs] mentions it as C1
|
|
|
|
|
;; character "Index" though).
|
|
|
|
|
(term-handle-deferred-scroll)
|
|
|
|
|
(term-down 1 t))
|
|
|
|
|
(?M ;; Scroll reversed (terminfo: ri, ECMA-48
|
|
|
|
|
;; "Reverse Linefeed").
|
|
|
|
|
(if (or (< (term-current-row) term-scroll-start)
|
|
|
|
|
(>= (1- (term-current-row))
|
|
|
|
|
term-scroll-start))
|
|
|
|
|
;; Scrolling up will not move outside
|
|
|
|
|
;; the scroll region.
|
|
|
|
|
(term-down -1)
|
|
|
|
|
;; Scrolling the scroll region is needed.
|
|
|
|
|
(term-down -1 t)))
|
|
|
|
|
(?7 ;; Save cursor (terminfo: sc, not in [ECMA-48],
|
|
|
|
|
;; [ctlseqs] has it as "DECSC").
|
|
|
|
|
(term-handle-deferred-scroll)
|
|
|
|
|
(setq term-saved-cursor
|
|
|
|
|
(list (term-current-row)
|
|
|
|
|
(term-horizontal-column)
|
|
|
|
|
term-ansi-current-bg-color
|
|
|
|
|
term-ansi-current-bold
|
2021-09-27 13:15:57 +00:00
|
|
|
|
term-ansi-current-faint
|
|
|
|
|
term-ansi-current-italic
|
|
|
|
|
term-ansi-current-underline
|
|
|
|
|
term-ansi-current-slow-blink
|
|
|
|
|
term-ansi-current-fast-blink
|
2021-02-05 09:13:23 +00:00
|
|
|
|
term-ansi-current-color
|
|
|
|
|
term-ansi-current-invisible
|
|
|
|
|
term-ansi-current-reverse
|
|
|
|
|
term-current-face)))
|
|
|
|
|
(?8 ;; Restore cursor (terminfo: rc, [ctlseqs]
|
|
|
|
|
;; "DECRC").
|
|
|
|
|
(when term-saved-cursor
|
|
|
|
|
(term-goto (nth 0 term-saved-cursor)
|
|
|
|
|
(nth 1 term-saved-cursor))
|
2021-09-27 13:15:57 +00:00
|
|
|
|
(pcase-setq
|
|
|
|
|
`( ,_ ,_
|
|
|
|
|
,term-ansi-current-bg-color
|
|
|
|
|
,term-ansi-current-bold
|
|
|
|
|
,term-ansi-current-faint
|
|
|
|
|
,term-ansi-current-italic
|
|
|
|
|
,term-ansi-current-underline
|
|
|
|
|
,term-ansi-current-slow-blink
|
|
|
|
|
,term-ansi-current-fast-blink
|
|
|
|
|
,term-ansi-current-color
|
|
|
|
|
,term-ansi-current-invisible
|
|
|
|
|
,term-ansi-current-reverse
|
|
|
|
|
,term-current-face)
|
|
|
|
|
term-saved-cursor)))
|
2021-02-05 09:13:23 +00:00
|
|
|
|
(?c ;; \Ec - Reset (terminfo: rs1, [ctlseqs] "RIS").
|
|
|
|
|
;; This is used by the "clear" program.
|
|
|
|
|
(term-reset-terminal))
|
|
|
|
|
(?A ;; An \eAnSiT sequence (Emacs specific).
|
|
|
|
|
(term-handle-ansi-terminal-messages
|
|
|
|
|
(substring str i ctl-end)))))
|
|
|
|
|
;; Ignore NUL, Shift Out, Shift In.
|
|
|
|
|
((or ?\0 #xE #xF 'nil) nil))
|
|
|
|
|
;; Leave line-wrapping state if point was moved.
|
|
|
|
|
(unless (eq term-do-line-wrapping (point))
|
|
|
|
|
(setq term-do-line-wrapping nil))
|
|
|
|
|
(if (term-handling-pager)
|
|
|
|
|
(progn
|
|
|
|
|
;; Finish stuff to get ready to handle PAGER.
|
|
|
|
|
(if (> (% (current-column) term-width) 0)
|
2018-01-18 13:22:47 +00:00
|
|
|
|
(setq term-terminal-undecoded-bytes
|
2021-02-05 09:13:23 +00:00
|
|
|
|
(substring str i))
|
|
|
|
|
;; We're at column 0. Goto end of buffer; to compensate,
|
|
|
|
|
;; prepend a ?\r for later. This looks more consistent.
|
|
|
|
|
(if (zerop i)
|
|
|
|
|
(setq term-terminal-undecoded-bytes
|
|
|
|
|
(concat "\r" (substring str i)))
|
|
|
|
|
(setq term-terminal-undecoded-bytes (substring str (1- i)))
|
|
|
|
|
(aset term-terminal-undecoded-bytes 0 ?\r))
|
|
|
|
|
(goto-char (point-max)))
|
|
|
|
|
;; FIXME: Use (add-function :override (process-filter proc)
|
|
|
|
|
(setq-local term-pager-old-filter (process-filter proc))
|
|
|
|
|
;; FIXME: Where is `term-pager-filter' set to a function?!
|
|
|
|
|
(set-process-filter proc term-pager-filter)
|
|
|
|
|
(setq i str-length))
|
|
|
|
|
(setq i ctl-end)))))
|
|
|
|
|
|
|
|
|
|
(when (>= (term-current-row) term-height)
|
|
|
|
|
(term-handle-deferred-scroll))
|
|
|
|
|
|
|
|
|
|
(set-marker (process-mark proc) (point))
|
|
|
|
|
(when (stringp decoded-substring)
|
|
|
|
|
(term-watch-for-password-prompt decoded-substring))
|
|
|
|
|
(when save-point
|
|
|
|
|
(goto-char save-point)
|
|
|
|
|
(set-marker save-point nil))
|
|
|
|
|
|
|
|
|
|
;; Check for a pending filename-and-line number to display.
|
|
|
|
|
;; We do this before scrolling, because we might create a new window.
|
|
|
|
|
(when (and term-pending-frame
|
|
|
|
|
(eq (window-buffer selected) (current-buffer)))
|
|
|
|
|
(term-display-line (car term-pending-frame)
|
|
|
|
|
(cdr term-pending-frame))
|
|
|
|
|
(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.
|
|
|
|
|
(setq win selected)
|
|
|
|
|
;; Avoid infinite loop in strange case where minibuffer window
|
|
|
|
|
;; is selected but not active.
|
|
|
|
|
(while (window-minibuffer-p win)
|
|
|
|
|
(setq win (next-window win nil t)))
|
|
|
|
|
(setq last-win win)
|
|
|
|
|
(while (progn
|
|
|
|
|
(setq win (next-window win nil t))
|
|
|
|
|
(when (eq (window-buffer win) (process-buffer proc))
|
|
|
|
|
(let ((scroll term-scroll-to-bottom-on-output))
|
2021-09-17 16:37:51 +00:00
|
|
|
|
(select-window win t)
|
2021-02-05 09:13:23 +00:00
|
|
|
|
(when (or (= (point) save-marker)
|
|
|
|
|
(eq scroll t) (eq scroll 'all)
|
|
|
|
|
;; Maybe user wants point to jump to the end.
|
|
|
|
|
(and (eq selected win)
|
|
|
|
|
(or (eq scroll 'this) (not save-point)))
|
|
|
|
|
(and (eq scroll 'others)
|
|
|
|
|
(not (eq selected win))))
|
|
|
|
|
(when term-scroll-snap-to-bottom
|
|
|
|
|
(goto-char term-home-marker)
|
|
|
|
|
(recenter 0))
|
|
|
|
|
(goto-char (process-mark proc))
|
|
|
|
|
(if (not (pos-visible-in-window-p (point) win))
|
|
|
|
|
(recenter -1)))
|
|
|
|
|
;; Optionally scroll so that the text
|
|
|
|
|
;; ends at the bottom of the window.
|
|
|
|
|
(when (and term-scroll-show-maximum-output
|
|
|
|
|
(>= (point) (process-mark proc))
|
|
|
|
|
(or term-scroll-snap-to-bottom
|
|
|
|
|
(not (pos-visible-in-window-p
|
|
|
|
|
(point-max) win))))
|
|
|
|
|
(save-excursion
|
|
|
|
|
(goto-char (point-max))
|
|
|
|
|
(recenter -1)))))
|
|
|
|
|
(not (eq win last-win))))
|
|
|
|
|
|
|
|
|
|
;; Stolen from comint.el and adapted -mm
|
|
|
|
|
(when (> term-buffer-maximum-size 0)
|
|
|
|
|
(save-excursion
|
|
|
|
|
(goto-char (process-mark (get-buffer-process (current-buffer))))
|
|
|
|
|
(forward-line (- term-buffer-maximum-size))
|
|
|
|
|
(beginning-of-line)
|
|
|
|
|
(delete-region (point-min) (point))))
|
|
|
|
|
(set-marker save-marker nil)))
|
|
|
|
|
;; This might be expensive, but we need it to handle something
|
|
|
|
|
;; like `sleep 5 | less -c' in more-or-less real time.
|
|
|
|
|
(when (get-buffer-window (current-buffer))
|
|
|
|
|
(redisplay)))))
|
1994-10-13 06:30:49 +00:00
|
|
|
|
|
2017-10-21 08:17:56 +00:00
|
|
|
|
(defvar-local term-goto-process-mark t
|
|
|
|
|
"Whether to reset point to the current process mark after this command.
|
|
|
|
|
|
|
|
|
|
Set in `pre-command-hook' in char mode by `term-set-goto-process-mark'.")
|
|
|
|
|
|
|
|
|
|
(defun term-set-goto-process-mark ()
|
2021-09-22 18:26:40 +00:00
|
|
|
|
"Set `term-goto-process-mark'.
|
2017-10-21 08:17:56 +00:00
|
|
|
|
|
|
|
|
|
Always set to nil if `term-char-mode-point-at-process-mark' is nil.
|
|
|
|
|
|
|
|
|
|
Called as a buffer-local `pre-command-hook' function in
|
|
|
|
|
`term-char-mode' so that when point is equal to the process mark
|
|
|
|
|
at the pre-command stage, we know to restore point to the process
|
|
|
|
|
mark at the post-command stage.
|
|
|
|
|
|
|
|
|
|
See also `term-goto-process-mark-maybe'."
|
|
|
|
|
(setq term-goto-process-mark
|
|
|
|
|
(and term-char-mode-point-at-process-mark
|
|
|
|
|
(eq (point) (marker-position (term-process-mark))))))
|
|
|
|
|
|
|
|
|
|
(defun term-goto-process-mark-maybe ()
|
|
|
|
|
"Move point to the term buffer's process mark upon keyboard input.
|
|
|
|
|
|
|
|
|
|
Called as a buffer-local `post-command-hook' function in
|
|
|
|
|
`term-char-mode' to prevent commands from putting the buffer into
|
|
|
|
|
an inconsistent state by unexpectedly moving point.
|
|
|
|
|
|
2021-12-27 09:55:23 +00:00
|
|
|
|
Mouse and wheel events are ignored so that mouse selection and
|
2021-12-28 18:09:42 +00:00
|
|
|
|
mouse wheel scrolling are unimpeded.
|
2017-10-21 08:17:56 +00:00
|
|
|
|
|
|
|
|
|
Only acts when the pre-command position of point was equal to the
|
|
|
|
|
process mark, and the `term-char-mode-point-at-process-mark'
|
|
|
|
|
option is enabled. See `term-set-goto-process-mark'."
|
|
|
|
|
(when term-goto-process-mark
|
2021-12-27 09:55:23 +00:00
|
|
|
|
(unless (or (mouse-event-p last-command-event)
|
|
|
|
|
(memq (event-basic-type last-command-event)
|
|
|
|
|
'(wheel-down wheel-up)))
|
2017-10-21 08:17:56 +00:00
|
|
|
|
(goto-char (term-process-mark)))))
|
|
|
|
|
|
|
|
|
|
(defun term-process-mark ()
|
|
|
|
|
"The current `process-mark' for the term buffer process."
|
|
|
|
|
(process-mark (get-buffer-process (current-buffer))))
|
|
|
|
|
|
1995-06-14 22:30:16 +00:00
|
|
|
|
(defun term-handle-deferred-scroll ()
|
|
|
|
|
(let ((count (- (term-current-row) term-height)))
|
(term-if-xemacs, term-ifnot-xemacs): Delete, replace
uses with a simple test.
(term-set-escape-char, term-mode, term-check-kill-echo-list)
(term-send-raw-string, term-send-raw, term-mouse-paste)
(term-char-mode, term-line-mode, term-exec, term-sentinel)
(term-handle-exit, term-read-input-ring)
(term-previous-matching-input-string)
(term-previous-matching-input-string-position)
(term-previous-matching-input-from-input)
(term-replace-by-expanded-history, term-send-input)
(term-skip-prompt, term-bol, term-send-invisible)
(term-kill-input, term-delchar-or-maybe-eof)
(term-backward-matching-input, term-check-source)
(term-proc-query, term-emulate-terminal)
(term-handle-colors-array, term-process-pager, term-pager-line)
(term-pager-bob, term-unwrap-line, term-word)
(term-dynamic-complete-filename)
(term-dynamic-complete-as-filename)
(term-dynamic-simple-complete): Replace one arm ifs with whens or
unlesses.
2006-05-29 06:11:33 +00:00
|
|
|
|
(when (>= count 0)
|
|
|
|
|
(save-excursion
|
|
|
|
|
(goto-char term-home-marker)
|
|
|
|
|
(term-vertical-motion (1+ count))
|
|
|
|
|
(set-marker term-home-marker (point))
|
2019-04-29 17:53:38 +00:00
|
|
|
|
(setq term-current-row (term--last-line))))))
|
1995-06-14 22:30:16 +00:00
|
|
|
|
|
2004-12-11 21:05:19 +00:00
|
|
|
|
(defun term-reset-terminal ()
|
2009-08-16 15:39:11 +00:00
|
|
|
|
"Reset the terminal, delete all the content and set the face to the default one."
|
2004-12-11 21:05:19 +00:00
|
|
|
|
(erase-buffer)
|
2009-09-24 02:04:25 +00:00
|
|
|
|
(term-ansi-reset)
|
2005-03-26 22:32:43 +00:00
|
|
|
|
(setq term-current-row 0)
|
2004-12-11 21:05:19 +00:00
|
|
|
|
(setq term-current-column 1)
|
2019-04-29 17:53:38 +00:00
|
|
|
|
(term--reset-scroll-region)
|
2021-09-25 21:28:08 +00:00
|
|
|
|
(setq term-insert-mode nil))
|
|
|
|
|
|
|
|
|
|
(defun term--color-as-hex (for-foreground)
|
|
|
|
|
"Return the current ANSI color as a hexadecimal color string.
|
|
|
|
|
Use the current background color if FOR-FOREGROUND is nil,
|
|
|
|
|
otherwise use the current foreground color."
|
|
|
|
|
(let ((color (if for-foreground term-ansi-current-color
|
|
|
|
|
term-ansi-current-bg-color)))
|
|
|
|
|
(or (ansi-color--code-as-hex (1- color))
|
|
|
|
|
(progn
|
|
|
|
|
(and ansi-color-bold-is-bright term-ansi-current-bold
|
|
|
|
|
(<= 1 color 8)
|
|
|
|
|
(setq color (+ color 8)))
|
|
|
|
|
(if for-foreground
|
|
|
|
|
(face-foreground (elt ansi-term-color-vector color)
|
|
|
|
|
nil 'default)
|
|
|
|
|
(face-background (elt ansi-term-color-vector color)
|
|
|
|
|
nil 'default))))))
|
Add support for "bright" ANSI colors in term-mode
* list/term.el (ansi-term-color-vector): Add new faces.
(term-color-black, term-color-red, term-color-green, term-color-yellow)
(term-color-blue, term-color-magenta, term-color-cyan, term-color-white):
Inherit from 'ansi-color-COLOR'.
(term-color-bright-black, term-color-bright-red, term-color-bright-green)
(term-color-bright-yellow, term-color-bright-blue)
(term-color-bright-magenta, term-color-bright-cyan)
(term-color-bright-white): New faces.
(term--maybe-brighten-color): New function.
(term-handle-colors-array): Handle bright colors.
* test/lisp/term-tests.el (term-colors, term-colors-bold-is-bright):
New functions.
2021-09-23 01:39:52 +00:00
|
|
|
|
|
2009-08-16 15:39:11 +00:00
|
|
|
|
;; New function to deal with ansi colorized output, as you can see you can
|
|
|
|
|
;; have any bold/underline/fg/bg/reverse combination. -mm
|
1997-04-02 03:46:39 +00:00
|
|
|
|
|
|
|
|
|
(defun term-handle-colors-array (parameter)
|
2021-10-05 09:14:22 +00:00
|
|
|
|
(declare (obsolete term--handle-colors-list "29.1"))
|
2021-09-25 21:28:08 +00:00
|
|
|
|
(term--handle-colors-list (list parameter)))
|
|
|
|
|
|
|
|
|
|
(defun term--handle-colors-list (parameters)
|
|
|
|
|
(while parameters
|
|
|
|
|
(pcase (pop parameters)
|
|
|
|
|
(1 (setq term-ansi-current-bold t)) ; (terminfo: bold)
|
2021-09-27 13:15:57 +00:00
|
|
|
|
(2 (setq term-ansi-current-faint t)) ; (terminfo: dim)
|
|
|
|
|
(3 (setq term-ansi-current-italic t)) ; (terminfo: sitm)
|
2021-09-25 21:28:08 +00:00
|
|
|
|
(4 (setq term-ansi-current-underline t)) ; (terminfo: smul)
|
2021-09-27 13:15:57 +00:00
|
|
|
|
(5 (setq term-ansi-current-slow-blink t)) ; (terminfo: blink)
|
|
|
|
|
(6 (setq term-ansi-current-fast-blink t))
|
2021-09-25 21:28:08 +00:00
|
|
|
|
(7 (setq term-ansi-current-reverse t)) ; (terminfo: smso, rev)
|
|
|
|
|
(8 (setq term-ansi-current-invisible t)) ; (terminfo: invis)
|
2021-09-27 13:15:57 +00:00
|
|
|
|
(21 (setq term-ansi-current-bold nil))
|
|
|
|
|
(22 (setq term-ansi-current-bold nil)
|
|
|
|
|
(setq term-ansi-current-faint nil))
|
|
|
|
|
(23 (setq term-ansi-current-italic nil)) ; (terminfo: ritm)
|
2021-09-25 21:28:08 +00:00
|
|
|
|
(24 (setq term-ansi-current-underline nil)) ; (terminfo: rmul)
|
2021-09-27 13:15:57 +00:00
|
|
|
|
(25 (setq term-ansi-current-slow-blink nil)
|
|
|
|
|
(setq term-ansi-current-fast-blink nil))
|
2021-09-25 21:28:08 +00:00
|
|
|
|
(27 (setq term-ansi-current-reverse nil)) ; (terminfo: rmso)
|
|
|
|
|
|
|
|
|
|
;; Foreground (terminfo: setaf)
|
|
|
|
|
((and param (guard (<= 30 param 37)))
|
|
|
|
|
(setq term-ansi-current-color (- param 29)))
|
|
|
|
|
|
|
|
|
|
;; Bright foreground (terminfo: setaf)
|
|
|
|
|
((and param (guard (<= 90 param 97)))
|
|
|
|
|
(setq term-ansi-current-color (- param 81)))
|
|
|
|
|
|
|
|
|
|
;; Extended foreground (terminfo: setaf)
|
|
|
|
|
(38
|
|
|
|
|
(pcase (pop parameters)
|
|
|
|
|
;; 256 color
|
|
|
|
|
(5 (if (setq term-ansi-current-color (pop parameters))
|
|
|
|
|
(cl-incf term-ansi-current-color)
|
|
|
|
|
(term-ansi-reset)))
|
|
|
|
|
;; Full 24-bit color
|
|
|
|
|
(2 (cl-loop with color = (1+ 256) ; Base
|
|
|
|
|
for i from 16 downto 0 by 8
|
|
|
|
|
if (pop parameters)
|
|
|
|
|
do (setq color (+ color (ash it i)))
|
|
|
|
|
else return (term-ansi-reset)
|
|
|
|
|
finally
|
|
|
|
|
(if (> color (+ 1 256 #xFFFFFF))
|
|
|
|
|
(term-ansi-reset)
|
|
|
|
|
(setq term-ansi-current-color color))))
|
|
|
|
|
(_ (term-ansi-reset))))
|
|
|
|
|
|
|
|
|
|
;; Reset foreground (terminfo: op)
|
|
|
|
|
(39 (setq term-ansi-current-color 0))
|
|
|
|
|
|
|
|
|
|
;; Background (terminfo: setab)
|
|
|
|
|
((and param (guard (<= 40 param 47)))
|
|
|
|
|
(setq term-ansi-current-bg-color (- param 39)))
|
|
|
|
|
|
|
|
|
|
;; Bright background (terminfo: setab)
|
|
|
|
|
((and param (guard (<= 100 param 107)))
|
|
|
|
|
(setq term-ansi-current-bg-color (- param 91)))
|
|
|
|
|
|
|
|
|
|
;; Extended background (terminfo: setab)
|
|
|
|
|
(48
|
|
|
|
|
(pcase (pop parameters)
|
|
|
|
|
;; 256 color
|
|
|
|
|
(5 (if (setq term-ansi-current-bg-color (pop parameters))
|
|
|
|
|
(cl-incf term-ansi-current-bg-color)
|
|
|
|
|
(term-ansi-reset)))
|
|
|
|
|
;; Full 24-bit color
|
|
|
|
|
(2 (cl-loop with color = (1+ 256) ; Base
|
|
|
|
|
for i from 16 downto 0 by 8
|
|
|
|
|
if (pop parameters)
|
|
|
|
|
do (setq color (+ color (ash it i)))
|
|
|
|
|
else return (term-ansi-reset)
|
|
|
|
|
finally
|
|
|
|
|
(if (> color (+ 1 256 #xFFFFFF))
|
|
|
|
|
(term-ansi-reset)
|
|
|
|
|
(setq term-ansi-current-bg-color color))))
|
|
|
|
|
(_ (term-ansi-reset))))
|
|
|
|
|
|
|
|
|
|
;; Reset background (terminfo: op)
|
|
|
|
|
(49 (setq term-ansi-current-bg-color 0))
|
|
|
|
|
|
|
|
|
|
;; 0 (Reset) (terminfo: sgr0) or unknown (reset anyway)
|
|
|
|
|
(_ (term-ansi-reset))))
|
|
|
|
|
|
|
|
|
|
(let (fg bg)
|
|
|
|
|
(if term-ansi-current-invisible
|
|
|
|
|
(setq bg (term--color-as-hex term-ansi-current-reverse)
|
|
|
|
|
fg bg)
|
|
|
|
|
(setq fg (term--color-as-hex t)
|
|
|
|
|
bg (term--color-as-hex nil)))
|
|
|
|
|
(setq term-current-face
|
|
|
|
|
`( :foreground ,fg
|
|
|
|
|
:background ,bg
|
|
|
|
|
,@(unless term-ansi-current-invisible
|
|
|
|
|
(list :inverse-video term-ansi-current-reverse)))))
|
|
|
|
|
|
2021-09-27 13:15:57 +00:00
|
|
|
|
(setq term-current-face
|
|
|
|
|
`(,term-current-face
|
|
|
|
|
,@(when term-ansi-current-bold
|
|
|
|
|
'(term-bold))
|
|
|
|
|
,@(when term-ansi-current-faint
|
|
|
|
|
'(term-faint))
|
|
|
|
|
,@(when term-ansi-current-italic
|
|
|
|
|
'(term-italic))
|
|
|
|
|
,@(when term-ansi-current-underline
|
|
|
|
|
'(term-underline))
|
|
|
|
|
,@(when term-ansi-current-slow-blink
|
|
|
|
|
'(term-slow-blink))
|
|
|
|
|
,@(when term-ansi-current-fast-blink
|
|
|
|
|
'(term-fast-blink)))))
|
1997-04-02 03:46:39 +00:00
|
|
|
|
|
|
|
|
|
|
2009-08-16 15:39:11 +00:00
|
|
|
|
;; Handle a character assuming (eq terminal-state 2) -
|
|
|
|
|
;; i.e. we have previously seen Escape followed by ?[.
|
1994-10-13 06:30:49 +00:00
|
|
|
|
|
2018-01-18 13:22:47 +00:00
|
|
|
|
(defun term-handle-ansi-escape (proc params char)
|
1994-10-13 06:30:49 +00:00
|
|
|
|
(cond
|
2006-01-15 19:36:10 +00:00
|
|
|
|
((or (eq char ?H) ;; cursor motion (terminfo: cup,home)
|
|
|
|
|
;; (eq char ?f) ;; xterm seems to handle this sequence too, not
|
2004-10-02 18:23:27 +00:00
|
|
|
|
;; needed for now
|
2005-06-10 00:43:13 +00:00
|
|
|
|
)
|
1994-10-13 06:30:49 +00:00
|
|
|
|
(term-goto
|
2018-01-18 13:22:47 +00:00
|
|
|
|
(1- (max 1 (min (or (nth 0 params) 0) term-height)))
|
|
|
|
|
(1- (max 1 (min (or (nth 1 params) 0) term-width)))))
|
2004-10-02 18:23:27 +00:00
|
|
|
|
;; \E[A - cursor up (terminfo: cuu, cuu1)
|
1994-10-13 06:30:49 +00:00
|
|
|
|
((eq char ?A)
|
1995-06-14 22:30:16 +00:00
|
|
|
|
(term-handle-deferred-scroll)
|
2018-01-18 13:22:47 +00:00
|
|
|
|
(let ((tcr (term-current-row))
|
|
|
|
|
(scroll-amount (car params)))
|
(term-buffer-maximum-size, term-exec, term-escape-char, term-set-escape-char,
term-termcap-format, term-get-old-input-default, term-skip-prompt,
term-send-string, term-send-region, term-pager-page, term-pager-help):
Fix typos in docstrings.
2007-04-13 09:00:41 +00:00
|
|
|
|
(term-down
|
2018-01-18 13:22:47 +00:00
|
|
|
|
(if (< (- tcr scroll-amount) term-scroll-start)
|
2006-01-15 19:36:10 +00:00
|
|
|
|
;; If the amount to move is before scroll start, move
|
|
|
|
|
;; to scroll start.
|
|
|
|
|
(- term-scroll-start tcr)
|
2018-01-18 13:22:47 +00:00
|
|
|
|
(if (>= scroll-amount tcr)
|
2006-01-15 19:36:10 +00:00
|
|
|
|
(- tcr)
|
2018-01-18 13:22:47 +00:00
|
|
|
|
(- (max 1 scroll-amount))))
|
|
|
|
|
t)))
|
2004-10-02 18:23:27 +00:00
|
|
|
|
;; \E[B - cursor down (terminfo: cud)
|
1994-10-13 06:30:49 +00:00
|
|
|
|
((eq char ?B)
|
2018-01-18 13:22:47 +00:00
|
|
|
|
(let ((tcr (term-current-row))
|
|
|
|
|
(scroll-amount (car params)))
|
2018-06-02 19:57:33 +00:00
|
|
|
|
(unless (>= tcr term-scroll-end)
|
(term-buffer-maximum-size, term-exec, term-escape-char, term-set-escape-char,
term-termcap-format, term-get-old-input-default, term-skip-prompt,
term-send-string, term-send-region, term-pager-page, term-pager-help):
Fix typos in docstrings.
2007-04-13 09:00:41 +00:00
|
|
|
|
(term-down
|
2018-06-10 22:47:27 +00:00
|
|
|
|
(min (- term-scroll-end tcr) (max 1 scroll-amount))
|
2018-01-18 13:22:47 +00:00
|
|
|
|
t))))
|
2005-10-26 18:57:45 +00:00
|
|
|
|
;; \E[C - cursor right (terminfo: cuf, cuf1)
|
1994-10-13 06:30:49 +00:00
|
|
|
|
((eq char ?C)
|
2005-06-10 00:43:13 +00:00
|
|
|
|
(term-move-columns
|
|
|
|
|
(max 1
|
2018-01-18 13:22:47 +00:00
|
|
|
|
(if (>= (+ (car params) (term-current-column)) term-width)
|
2004-10-02 18:23:27 +00:00
|
|
|
|
(- term-width (term-current-column) 1)
|
2018-01-18 13:22:47 +00:00
|
|
|
|
(car params)))))
|
2004-10-02 18:23:27 +00:00
|
|
|
|
;; \E[D - cursor left (terminfo: cub)
|
1994-10-13 06:30:49 +00:00
|
|
|
|
((eq char ?D)
|
2018-01-18 13:22:47 +00:00
|
|
|
|
(term-move-columns (- (max 1 (car params)))))
|
2016-04-21 15:59:37 +00:00
|
|
|
|
;; \E[G - cursor motion to absolute column (terminfo: hpa)
|
|
|
|
|
((eq char ?G)
|
2018-01-18 13:22:47 +00:00
|
|
|
|
(term-move-columns (- (max 0 (min term-width (car params)))
|
2016-04-21 15:59:37 +00:00
|
|
|
|
(term-current-column))))
|
2004-09-26 18:39:10 +00:00
|
|
|
|
;; \E[J - clear to end of screen (terminfo: ed, clear)
|
1994-10-13 06:30:49 +00:00
|
|
|
|
((eq char ?J)
|
2018-01-18 13:22:47 +00:00
|
|
|
|
(term-erase-in-display (car params)))
|
2004-09-26 18:39:10 +00:00
|
|
|
|
;; \E[K - clear to end of line (terminfo: el, el1)
|
1994-10-13 06:30:49 +00:00
|
|
|
|
((eq char ?K)
|
2018-01-18 13:22:47 +00:00
|
|
|
|
(term-erase-in-line (car params)))
|
2004-09-26 18:39:10 +00:00
|
|
|
|
;; \E[L - insert lines (terminfo: il, il1)
|
1994-10-13 06:30:49 +00:00
|
|
|
|
((eq char ?L)
|
2018-01-18 13:22:47 +00:00
|
|
|
|
(term-insert-lines (max 1 (car params))))
|
2005-10-26 18:57:45 +00:00
|
|
|
|
;; \E[M - delete lines (terminfo: dl, dl1)
|
1994-10-13 06:30:49 +00:00
|
|
|
|
((eq char ?M)
|
2018-01-18 13:22:47 +00:00
|
|
|
|
(term-delete-lines (max 1 (car params))))
|
2005-10-26 18:57:45 +00:00
|
|
|
|
;; \E[P - delete chars (terminfo: dch, dch1)
|
1994-10-13 06:30:49 +00:00
|
|
|
|
((eq char ?P)
|
2018-01-18 13:22:47 +00:00
|
|
|
|
(term-delete-chars (max 1 (car params))))
|
2005-10-26 18:57:45 +00:00
|
|
|
|
;; \E[@ - insert spaces (terminfo: ich)
|
|
|
|
|
((eq char ?@)
|
2018-01-18 13:22:47 +00:00
|
|
|
|
(term-insert-spaces (max 1 (car params))))
|
1994-10-13 06:30:49 +00:00
|
|
|
|
;; \E[?h - DEC Private Mode Set
|
|
|
|
|
((eq char ?h)
|
2018-01-18 13:22:47 +00:00
|
|
|
|
(cond ((eq (car params) 4) ;; (terminfo: smir)
|
1994-10-13 06:30:49 +00:00
|
|
|
|
(setq term-insert-mode t))
|
2022-01-23 20:13:24 +00:00
|
|
|
|
((eq (car params) 47) ;; (terminfo: smcup)
|
|
|
|
|
(term-switch-to-alternate-sub-buffer t))))
|
1994-11-22 10:47:06 +00:00
|
|
|
|
;; \E[?l - DEC Private Mode Reset
|
1994-10-13 06:30:49 +00:00
|
|
|
|
((eq char ?l)
|
2018-01-18 13:22:47 +00:00
|
|
|
|
(cond ((eq (car params) 4) ;; (terminfo: rmir)
|
1994-10-13 06:30:49 +00:00
|
|
|
|
(setq term-insert-mode nil))
|
2022-01-23 20:13:24 +00:00
|
|
|
|
((eq (car params) 47) ;; (terminfo: rmcup)
|
|
|
|
|
(term-switch-to-alternate-sub-buffer nil))))
|
1997-04-02 03:46:39 +00:00
|
|
|
|
|
2009-08-16 15:39:11 +00:00
|
|
|
|
;; Modified to allow ansi coloring -mm
|
2005-06-10 00:43:13 +00:00
|
|
|
|
;; \E[m - Set/reset modes, set bg/fg
|
2021-09-27 13:15:57 +00:00
|
|
|
|
;;(terminfo: smso,rmso,smul,rmul,rev,bold,dim,sitm,ritm,blink,sgr0,invis,op,setab,setaf)
|
1994-10-13 06:30:49 +00:00
|
|
|
|
((eq char ?m)
|
2021-09-25 21:28:08 +00:00
|
|
|
|
(term--handle-colors-list params))
|
1997-04-02 03:46:39 +00:00
|
|
|
|
|
2009-08-07 07:04:02 +00:00
|
|
|
|
;; \E[6n - Report cursor position (terminfo: u7)
|
1995-02-06 21:56:37 +00:00
|
|
|
|
((eq char ?n)
|
1995-06-14 22:30:16 +00:00
|
|
|
|
(term-handle-deferred-scroll)
|
1995-02-06 21:56:37 +00:00
|
|
|
|
(process-send-string proc
|
2009-08-07 07:04:02 +00:00
|
|
|
|
;; (terminfo: u6)
|
1995-02-06 21:56:37 +00:00
|
|
|
|
(format "\e[%s;%sR"
|
|
|
|
|
(1+ (term-current-row))
|
|
|
|
|
(1+ (term-horizontal-column)))))
|
2006-01-15 19:36:10 +00:00
|
|
|
|
;; \E[r - Set scrolling region (terminfo: csr)
|
|
|
|
|
((eq char ?r)
|
|
|
|
|
(term-set-scroll-region
|
2018-01-18 13:22:47 +00:00
|
|
|
|
(1- (or (nth 0 params) 0))
|
|
|
|
|
(1- (or (nth 1 params) 0))))
|
1994-10-13 06:30:49 +00:00
|
|
|
|
(t)))
|
|
|
|
|
|
2019-04-29 17:53:38 +00:00
|
|
|
|
(defun term--reset-scroll-region ()
|
2021-09-22 18:26:40 +00:00
|
|
|
|
"Set the scroll region to the full height of the terminal."
|
2019-04-29 17:53:38 +00:00
|
|
|
|
(term-set-scroll-region 0 (term--last-line)))
|
|
|
|
|
|
2006-01-15 19:36:10 +00:00
|
|
|
|
(defun term-set-scroll-region (top bottom)
|
1994-10-13 06:30:49 +00:00
|
|
|
|
"Set scrolling region.
|
|
|
|
|
TOP is the top-most line (inclusive) of the new scrolling region,
|
1996-01-04 23:20:49 +00:00
|
|
|
|
while BOTTOM is the line following the new scrolling region (e.g. exclusive).
|
1994-10-13 06:30:49 +00:00
|
|
|
|
The top-most line is line 0."
|
|
|
|
|
(setq term-scroll-start
|
|
|
|
|
(if (or (< top 0) (>= top term-height))
|
|
|
|
|
0
|
|
|
|
|
top))
|
|
|
|
|
(setq term-scroll-end
|
2019-04-29 17:53:38 +00:00
|
|
|
|
(if (or (<= bottom term-scroll-start) (> bottom (term--last-line)))
|
|
|
|
|
(term--last-line)
|
1994-10-13 06:30:49 +00:00
|
|
|
|
bottom))
|
|
|
|
|
(setq term-scroll-with-delete
|
|
|
|
|
(or (term-using-alternate-sub-buffer)
|
|
|
|
|
(not (and (= term-scroll-start 0)
|
2019-04-29 17:53:38 +00:00
|
|
|
|
(= term-scroll-end (term--last-line))))))
|
2009-09-24 18:10:44 +00:00
|
|
|
|
(term-move-columns (- (term-current-column)))
|
|
|
|
|
(term-goto 0 0))
|
1994-10-13 06:30:49 +00:00
|
|
|
|
|
2022-01-23 20:13:24 +00:00
|
|
|
|
(defun term-switch-to-alternate-sub-buffer (set)
|
|
|
|
|
;; If asked to switch to (from) the alternate sub-buffer, and already (not)
|
|
|
|
|
;; using it, do nothing. This test is needed for some programs (including
|
|
|
|
|
;; Emacs) that emit the ti termcap string twice, for unknown reason.
|
|
|
|
|
(term-handle-deferred-scroll)
|
|
|
|
|
(when (eq set (not (term-using-alternate-sub-buffer)))
|
|
|
|
|
(cond
|
|
|
|
|
(set
|
|
|
|
|
(goto-char (point-max))
|
|
|
|
|
(if (not (eq (preceding-char) ?\n))
|
|
|
|
|
(term-insert-char ?\n 1))
|
|
|
|
|
(setq term-scroll-with-delete t)
|
|
|
|
|
(setq term-saved-home-marker (copy-marker term-home-marker))
|
|
|
|
|
(set-marker term-home-marker (point)))
|
|
|
|
|
(t
|
|
|
|
|
(setq term-scroll-with-delete
|
|
|
|
|
(not (and (= term-scroll-start 0)
|
|
|
|
|
(= term-scroll-end (term--last-line)))))
|
|
|
|
|
(goto-char (point-max))
|
|
|
|
|
(when term-clear-full-screen-programs
|
|
|
|
|
(delete-region term-home-marker (point))
|
|
|
|
|
(set-marker term-home-marker term-saved-home-marker))
|
|
|
|
|
(set-marker term-saved-home-marker nil)
|
|
|
|
|
(setq term-saved-home-marker nil)))
|
|
|
|
|
|
|
|
|
|
(setq term-start-line-column nil)
|
|
|
|
|
(setq term-current-column nil)
|
|
|
|
|
(setq term-current-row nil)
|
|
|
|
|
(term-handle-deferred-scroll)))
|
1994-10-13 06:30:49 +00:00
|
|
|
|
|
2019-02-24 21:19:59 +00:00
|
|
|
|
;; Default value for the symbol term-command-function.
|
1994-10-13 06:30:49 +00:00
|
|
|
|
|
|
|
|
|
(defun term-command-hook (string)
|
2003-02-04 11:43:01 +00:00
|
|
|
|
(cond ((equal string "")
|
|
|
|
|
t)
|
|
|
|
|
((= (aref string 0) ?\032)
|
1994-10-13 06:30:49 +00:00
|
|
|
|
;; gdb (when invoked with -fullname) prints:
|
|
|
|
|
;; \032\032FULLFILENAME:LINENUMBER:CHARPOS:BEG_OR_MIDDLE:PC\n
|
Use string-search instead of string-match[-p]
`string-search` is easier to understand, less error-prone, much
faster, does not pollute the regexp cache, and does not mutate global
state. Use it where applicable and obviously safe (erring on the
conservative side).
* admin/authors.el (authors-canonical-file-name)
(authors-scan-change-log):
* lisp/apropos.el (apropos-command)
(apropos-documentation-property, apropos-symbols-internal):
* lisp/arc-mode.el (archive-arc-summarize)
(archive-zoo-summarize):
* lisp/calc/calc-aent.el (math-read-factor):
* lisp/calc/calc-ext.el (math-read-big-expr)
(math-format-nice-expr, math-format-number-fancy):
* lisp/calc/calc-forms.el (math-read-angle-brackets):
* lisp/calc/calc-graph.el (calc-graph-set-range):
* lisp/calc/calc-keypd.el (calc-keypad-press):
* lisp/calc/calc-lang.el (tex, latex, math-read-big-rec):
* lisp/calc/calc-prog.el (calc-fix-token-name)
(calc-user-define-permanent, math-define-exp):
* lisp/calc/calc.el (calc-record, calcDigit-key)
(calc-count-lines):
* lisp/calc/calcalg2.el (calc-solve-for, calc-poly-roots)
(math-do-integral):
* lisp/calc/calcalg3.el (calc-find-root, calc-find-minimum)
(calc-get-fit-variables):
* lisp/cedet/ede/speedbar.el (ede-tag-expand):
* lisp/cedet/semantic/java.el (semantic-java-expand-tag):
* lisp/cedet/semantic/sb.el (semantic-sb-show-extra)
(semantic-sb-expand-group):
* lisp/cedet/semantic/wisent/python.el
(semantic-python-instance-variable-p):
* lisp/cus-edit.el (get):
* lisp/descr-text.el (describe-text-sexp):
* lisp/dired-aux.el (dired-compress-file):
* lisp/dired-x.el (dired-make-relative-symlink):
* lisp/dired.el (dired-glob-regexp):
* lisp/dos-fns.el (dos-convert-standard-filename, dos-8+3-filename):
* lisp/edmacro.el (edmacro-format-keys):
* lisp/emacs-lisp/eieio-opt.el (eieio-sb-expand):
* lisp/emacs-lisp/eieio-speedbar.el (eieio-speedbar-object-expand):
* lisp/emacs-lisp/lisp-mnt.el (lm-keywords-list):
* lisp/emacs-lisp/warnings.el (display-warning):
* lisp/emulation/viper-ex.el (viper-ex-read-file-name)
(ex-print-display-lines):
* lisp/env.el (read-envvar-name, setenv):
* lisp/epa-mail.el (epa-mail-encrypt):
* lisp/epg.el (epg--start):
* lisp/erc/erc-backend.el (erc-parse-server-response):
* lisp/erc/erc-dcc.el (erc-dcc-member):
* lisp/erc/erc-speedbar.el (erc-speedbar-expand-server)
(erc-speedbar-expand-channel, erc-speedbar-expand-user):
* lisp/erc/erc.el (erc-send-input):
* lisp/eshell/em-glob.el (eshell-glob-entries):
* lisp/eshell/esh-proc.el (eshell-needs-pipe-p):
* lisp/eshell/esh-util.el (eshell-convert):
* lisp/eshell/esh-var.el (eshell-envvar-names):
* lisp/faces.el (x-resolve-font-name):
* lisp/ffap.el (ffap-file-at-point):
* lisp/files.el (wildcard-to-regexp, shell-quote-wildcard-pattern):
* lisp/forms.el (forms--update):
* lisp/frameset.el (frameset-filter-unshelve-param):
* lisp/gnus/gnus-art.el (article-decode-charset):
* lisp/gnus/gnus-kill.el (gnus-kill-parse-rn-kill-file):
* lisp/gnus/gnus-mlspl.el (gnus-group-split-fancy):
* lisp/gnus/gnus-msg.el (gnus-summary-resend-message-insert-gcc)
(gnus-inews-insert-gcc):
* lisp/gnus/gnus-rfc1843.el (rfc1843-decode-article-body):
* lisp/gnus/gnus-search.el (gnus-search-indexed-parse-output)
(gnus-search--complete-key-data):
* lisp/gnus/gnus-spec.el (gnus-parse-simple-format):
* lisp/gnus/gnus-sum.el (gnus-summary-refer-article):
* lisp/gnus/gnus-util.el (gnus-extract-address-components)
(gnus-newsgroup-directory-form):
* lisp/gnus/gnus-uu.el (gnus-uu-grab-view):
* lisp/gnus/gnus.el (gnus-group-native-p, gnus-short-group-name):
* lisp/gnus/message.el (message-check-news-header-syntax)
(message-make-message-id, message-user-mail-address)
(message-make-fqdn, message-get-reply-headers, message-followup):
* lisp/gnus/mm-decode.el (mm-dissect-buffer):
* lisp/gnus/nnheader.el (nnheader-insert):
* lisp/gnus/nnimap.el (nnimap-process-quirk)
(nnimap-imap-ranges-to-gnus-ranges):
* lisp/gnus/nnmaildir.el (nnmaildir--ensure-suffix):
* lisp/gnus/nnmairix.el (nnmairix-determine-original-group-from-path):
* lisp/gnus/nnrss.el (nnrss-match-macro):
* lisp/gnus/nntp.el (nntp-find-group-and-number):
* lisp/help-fns.el (help--symbol-completion-table-affixation):
* lisp/help.el (help-function-arglist):
* lisp/hippie-exp.el (he-concat-directory-file-name):
* lisp/htmlfontify.el (hfy-relstub):
* lisp/ido.el (ido-make-prompt, ido-complete, ido-copy-current-word)
(ido-exhibit):
* lisp/image/image-converter.el (image-convert-p):
* lisp/info-xref.el (info-xref-docstrings):
* lisp/info.el (Info-toc-build, Info-follow-reference)
(Info-backward-node, Info-finder-find-node)
(Info-speedbar-expand-node):
* lisp/international/mule-diag.el (print-fontset-element):
* lisp/language/korea-util.el (default-korean-keyboard):
* lisp/linum.el (linum-after-change):
* lisp/mail/ietf-drums.el (ietf-drums-parse-address):
* lisp/mail/mail-utils.el (mail-dont-reply-to):
* lisp/mail/rfc2047.el (rfc2047-encode-1, rfc2047-decode-string):
* lisp/mail/rfc2231.el (rfc2231-parse-string):
* lisp/mail/rmailkwd.el (rmail-set-label):
* lisp/mail/rmailsum.el (rmail-header-summary):
* lisp/mail/smtpmail.el (smtpmail-maybe-append-domain)
(smtpmail-user-mail-address):
* lisp/mail/uce.el (uce-reply-to-uce):
* lisp/man.el (Man-default-man-entry):
* lisp/mh-e/mh-alias.el (mh-alias-gecos-name)
(mh-alias-minibuffer-confirm-address):
* lisp/mh-e/mh-comp.el (mh-forwarded-letter-subject):
* lisp/mh-e/mh-speed.el (mh-speed-parse-flists-output):
* lisp/mh-e/mh-utils.el (mh-collect-folder-names-filter)
(mh-folder-completion-function):
* lisp/minibuffer.el (completion--make-envvar-table)
(completion-file-name-table, completion-flex-try-completion)
(completion-flex-all-completions):
* lisp/mpc.el (mpc--proc-quote-string, mpc-cmd-special-tag-p)
(mpc-constraints-tag-lookup):
* lisp/net/ange-ftp.el (ange-ftp-send-cmd)
(ange-ftp-allow-child-lookup):
* lisp/net/mailcap.el (mailcap-mime-types):
* lisp/net/mairix.el (mairix-search-thread-this-article):
* lisp/net/pop3.el (pop3-open-server):
* lisp/net/soap-client.el (soap-decode-xs-complex-type):
* lisp/net/socks.el (socks-filter):
* lisp/nxml/nxml-outln.el (nxml-highlighted-qname):
* lisp/nxml/rng-cmpct.el (rng-c-expand-name, rng-c-expand-datatype):
* lisp/nxml/rng-uri.el (rng-uri-file-name-1):
* lisp/obsolete/complete.el (partial-completion-mode)
(PC-do-completion):
* lisp/obsolete/longlines.el (longlines-encode-string):
* lisp/obsolete/nnir.el (nnir-compose-result):
* lisp/obsolete/terminal.el (te-quote-arg-for-sh):
* lisp/obsolete/tpu-edt.el (tpu-check-search-case):
* lisp/obsolete/url-ns.el (isPlainHostName):
* lisp/pcmpl-unix.el (pcomplete/scp):
* lisp/play/dunnet.el (dun-listify-string2, dun-get-path)
(dun-unix-parse, dun-doassign, dun-cat, dun-batch-unix-interface):
* lisp/progmodes/ebnf2ps.el: (ebnf-eps-header-footer-comment):
* lisp/progmodes/gdb-mi.el (gdb-var-delete)
(gdb-speedbar-expand-node, gdbmi-bnf-incomplete-record-result):
* lisp/progmodes/gud.el (gud-find-expr):
* lisp/progmodes/idlw-help.el (idlwave-do-context-help1):
* lisp/progmodes/idlw-shell.el (idlwave-shell-mode)
(idlwave-shell-filter-hidden-output, idlwave-shell-filter):
* lisp/progmodes/idlwave.el (idlwave-skip-label-or-case)
(idlwave-routine-info):
* lisp/progmodes/octave.el (inferior-octave-completion-at-point):
* lisp/progmodes/sh-script.el (sh-add-completer):
* lisp/progmodes/sql.el (defun):
* lisp/progmodes/xscheme.el (xscheme-process-filter):
* lisp/replace.el (query-replace-compile-replacement)
(map-query-replace-regexp):
* lisp/shell.el (shell--command-completion-data)
(shell-environment-variable-completion):
* lisp/simple.el (display-message-or-buffer):
* lisp/speedbar.el (speedbar-dired, speedbar-tag-file)
(speedbar-tag-expand):
* lisp/subr.el (split-string-and-unquote):
* lisp/tar-mode.el (tar-extract):
* lisp/term.el (term-command-hook, serial-read-name):
* lisp/textmodes/bibtex.el (bibtex-print-help-message):
* lisp/textmodes/ispell.el (ispell-lookup-words, ispell-filter)
(ispell-parse-output, ispell-buffer-local-parsing):
* lisp/textmodes/reftex-cite.el (reftex-do-citation):
* lisp/textmodes/reftex-parse.el (reftex-notice-new):
* lisp/textmodes/reftex-ref.el (reftex-show-entry):
* lisp/textmodes/reftex.el (reftex-compile-variables):
* lisp/textmodes/tex-mode.el (tex-send-command)
(tex-start-tex, tex-append):
* lisp/thingatpt.el (thing-at-point-url-at-point):
* lisp/tmm.el (tmm-add-one-shortcut):
* lisp/transient.el (transient-format-key):
* lisp/url/url-auth.el (url-basic-auth)
(url-digest-auth-directory-id-assoc):
* lisp/url/url-news.el (url-news):
* lisp/url/url-util.el (url-parse-query-string):
* lisp/vc/vc-cvs.el (vc-cvs-parse-entry):
* lisp/wid-browse.el (widget-browse-sexp):
* lisp/woman.el (woman-parse-colon-path, woman-mini-help)
(WoMan-getpage-in-background, woman-negative-vertical-space):
* lisp/xml.el:
* test/lisp/emacs-lisp/check-declare-tests.el
(check-declare-tests-warn):
* test/lisp/files-tests.el
(files-tests-file-name-non-special-dired-compress-handler):
* test/lisp/net/network-stream-tests.el (server-process-filter):
* test/src/coding-tests.el (ert-test-unibyte-buffer-dos-eol-decode):
Use `string-search` instead of `string-match` and `string-match-p`.
2021-08-09 09:20:00 +00:00
|
|
|
|
(let* ((first-colon (string-search ":" string 1))
|
1994-10-13 06:30:49 +00:00
|
|
|
|
(second-colon
|
Use string-search instead of string-match[-p]
`string-search` is easier to understand, less error-prone, much
faster, does not pollute the regexp cache, and does not mutate global
state. Use it where applicable and obviously safe (erring on the
conservative side).
* admin/authors.el (authors-canonical-file-name)
(authors-scan-change-log):
* lisp/apropos.el (apropos-command)
(apropos-documentation-property, apropos-symbols-internal):
* lisp/arc-mode.el (archive-arc-summarize)
(archive-zoo-summarize):
* lisp/calc/calc-aent.el (math-read-factor):
* lisp/calc/calc-ext.el (math-read-big-expr)
(math-format-nice-expr, math-format-number-fancy):
* lisp/calc/calc-forms.el (math-read-angle-brackets):
* lisp/calc/calc-graph.el (calc-graph-set-range):
* lisp/calc/calc-keypd.el (calc-keypad-press):
* lisp/calc/calc-lang.el (tex, latex, math-read-big-rec):
* lisp/calc/calc-prog.el (calc-fix-token-name)
(calc-user-define-permanent, math-define-exp):
* lisp/calc/calc.el (calc-record, calcDigit-key)
(calc-count-lines):
* lisp/calc/calcalg2.el (calc-solve-for, calc-poly-roots)
(math-do-integral):
* lisp/calc/calcalg3.el (calc-find-root, calc-find-minimum)
(calc-get-fit-variables):
* lisp/cedet/ede/speedbar.el (ede-tag-expand):
* lisp/cedet/semantic/java.el (semantic-java-expand-tag):
* lisp/cedet/semantic/sb.el (semantic-sb-show-extra)
(semantic-sb-expand-group):
* lisp/cedet/semantic/wisent/python.el
(semantic-python-instance-variable-p):
* lisp/cus-edit.el (get):
* lisp/descr-text.el (describe-text-sexp):
* lisp/dired-aux.el (dired-compress-file):
* lisp/dired-x.el (dired-make-relative-symlink):
* lisp/dired.el (dired-glob-regexp):
* lisp/dos-fns.el (dos-convert-standard-filename, dos-8+3-filename):
* lisp/edmacro.el (edmacro-format-keys):
* lisp/emacs-lisp/eieio-opt.el (eieio-sb-expand):
* lisp/emacs-lisp/eieio-speedbar.el (eieio-speedbar-object-expand):
* lisp/emacs-lisp/lisp-mnt.el (lm-keywords-list):
* lisp/emacs-lisp/warnings.el (display-warning):
* lisp/emulation/viper-ex.el (viper-ex-read-file-name)
(ex-print-display-lines):
* lisp/env.el (read-envvar-name, setenv):
* lisp/epa-mail.el (epa-mail-encrypt):
* lisp/epg.el (epg--start):
* lisp/erc/erc-backend.el (erc-parse-server-response):
* lisp/erc/erc-dcc.el (erc-dcc-member):
* lisp/erc/erc-speedbar.el (erc-speedbar-expand-server)
(erc-speedbar-expand-channel, erc-speedbar-expand-user):
* lisp/erc/erc.el (erc-send-input):
* lisp/eshell/em-glob.el (eshell-glob-entries):
* lisp/eshell/esh-proc.el (eshell-needs-pipe-p):
* lisp/eshell/esh-util.el (eshell-convert):
* lisp/eshell/esh-var.el (eshell-envvar-names):
* lisp/faces.el (x-resolve-font-name):
* lisp/ffap.el (ffap-file-at-point):
* lisp/files.el (wildcard-to-regexp, shell-quote-wildcard-pattern):
* lisp/forms.el (forms--update):
* lisp/frameset.el (frameset-filter-unshelve-param):
* lisp/gnus/gnus-art.el (article-decode-charset):
* lisp/gnus/gnus-kill.el (gnus-kill-parse-rn-kill-file):
* lisp/gnus/gnus-mlspl.el (gnus-group-split-fancy):
* lisp/gnus/gnus-msg.el (gnus-summary-resend-message-insert-gcc)
(gnus-inews-insert-gcc):
* lisp/gnus/gnus-rfc1843.el (rfc1843-decode-article-body):
* lisp/gnus/gnus-search.el (gnus-search-indexed-parse-output)
(gnus-search--complete-key-data):
* lisp/gnus/gnus-spec.el (gnus-parse-simple-format):
* lisp/gnus/gnus-sum.el (gnus-summary-refer-article):
* lisp/gnus/gnus-util.el (gnus-extract-address-components)
(gnus-newsgroup-directory-form):
* lisp/gnus/gnus-uu.el (gnus-uu-grab-view):
* lisp/gnus/gnus.el (gnus-group-native-p, gnus-short-group-name):
* lisp/gnus/message.el (message-check-news-header-syntax)
(message-make-message-id, message-user-mail-address)
(message-make-fqdn, message-get-reply-headers, message-followup):
* lisp/gnus/mm-decode.el (mm-dissect-buffer):
* lisp/gnus/nnheader.el (nnheader-insert):
* lisp/gnus/nnimap.el (nnimap-process-quirk)
(nnimap-imap-ranges-to-gnus-ranges):
* lisp/gnus/nnmaildir.el (nnmaildir--ensure-suffix):
* lisp/gnus/nnmairix.el (nnmairix-determine-original-group-from-path):
* lisp/gnus/nnrss.el (nnrss-match-macro):
* lisp/gnus/nntp.el (nntp-find-group-and-number):
* lisp/help-fns.el (help--symbol-completion-table-affixation):
* lisp/help.el (help-function-arglist):
* lisp/hippie-exp.el (he-concat-directory-file-name):
* lisp/htmlfontify.el (hfy-relstub):
* lisp/ido.el (ido-make-prompt, ido-complete, ido-copy-current-word)
(ido-exhibit):
* lisp/image/image-converter.el (image-convert-p):
* lisp/info-xref.el (info-xref-docstrings):
* lisp/info.el (Info-toc-build, Info-follow-reference)
(Info-backward-node, Info-finder-find-node)
(Info-speedbar-expand-node):
* lisp/international/mule-diag.el (print-fontset-element):
* lisp/language/korea-util.el (default-korean-keyboard):
* lisp/linum.el (linum-after-change):
* lisp/mail/ietf-drums.el (ietf-drums-parse-address):
* lisp/mail/mail-utils.el (mail-dont-reply-to):
* lisp/mail/rfc2047.el (rfc2047-encode-1, rfc2047-decode-string):
* lisp/mail/rfc2231.el (rfc2231-parse-string):
* lisp/mail/rmailkwd.el (rmail-set-label):
* lisp/mail/rmailsum.el (rmail-header-summary):
* lisp/mail/smtpmail.el (smtpmail-maybe-append-domain)
(smtpmail-user-mail-address):
* lisp/mail/uce.el (uce-reply-to-uce):
* lisp/man.el (Man-default-man-entry):
* lisp/mh-e/mh-alias.el (mh-alias-gecos-name)
(mh-alias-minibuffer-confirm-address):
* lisp/mh-e/mh-comp.el (mh-forwarded-letter-subject):
* lisp/mh-e/mh-speed.el (mh-speed-parse-flists-output):
* lisp/mh-e/mh-utils.el (mh-collect-folder-names-filter)
(mh-folder-completion-function):
* lisp/minibuffer.el (completion--make-envvar-table)
(completion-file-name-table, completion-flex-try-completion)
(completion-flex-all-completions):
* lisp/mpc.el (mpc--proc-quote-string, mpc-cmd-special-tag-p)
(mpc-constraints-tag-lookup):
* lisp/net/ange-ftp.el (ange-ftp-send-cmd)
(ange-ftp-allow-child-lookup):
* lisp/net/mailcap.el (mailcap-mime-types):
* lisp/net/mairix.el (mairix-search-thread-this-article):
* lisp/net/pop3.el (pop3-open-server):
* lisp/net/soap-client.el (soap-decode-xs-complex-type):
* lisp/net/socks.el (socks-filter):
* lisp/nxml/nxml-outln.el (nxml-highlighted-qname):
* lisp/nxml/rng-cmpct.el (rng-c-expand-name, rng-c-expand-datatype):
* lisp/nxml/rng-uri.el (rng-uri-file-name-1):
* lisp/obsolete/complete.el (partial-completion-mode)
(PC-do-completion):
* lisp/obsolete/longlines.el (longlines-encode-string):
* lisp/obsolete/nnir.el (nnir-compose-result):
* lisp/obsolete/terminal.el (te-quote-arg-for-sh):
* lisp/obsolete/tpu-edt.el (tpu-check-search-case):
* lisp/obsolete/url-ns.el (isPlainHostName):
* lisp/pcmpl-unix.el (pcomplete/scp):
* lisp/play/dunnet.el (dun-listify-string2, dun-get-path)
(dun-unix-parse, dun-doassign, dun-cat, dun-batch-unix-interface):
* lisp/progmodes/ebnf2ps.el: (ebnf-eps-header-footer-comment):
* lisp/progmodes/gdb-mi.el (gdb-var-delete)
(gdb-speedbar-expand-node, gdbmi-bnf-incomplete-record-result):
* lisp/progmodes/gud.el (gud-find-expr):
* lisp/progmodes/idlw-help.el (idlwave-do-context-help1):
* lisp/progmodes/idlw-shell.el (idlwave-shell-mode)
(idlwave-shell-filter-hidden-output, idlwave-shell-filter):
* lisp/progmodes/idlwave.el (idlwave-skip-label-or-case)
(idlwave-routine-info):
* lisp/progmodes/octave.el (inferior-octave-completion-at-point):
* lisp/progmodes/sh-script.el (sh-add-completer):
* lisp/progmodes/sql.el (defun):
* lisp/progmodes/xscheme.el (xscheme-process-filter):
* lisp/replace.el (query-replace-compile-replacement)
(map-query-replace-regexp):
* lisp/shell.el (shell--command-completion-data)
(shell-environment-variable-completion):
* lisp/simple.el (display-message-or-buffer):
* lisp/speedbar.el (speedbar-dired, speedbar-tag-file)
(speedbar-tag-expand):
* lisp/subr.el (split-string-and-unquote):
* lisp/tar-mode.el (tar-extract):
* lisp/term.el (term-command-hook, serial-read-name):
* lisp/textmodes/bibtex.el (bibtex-print-help-message):
* lisp/textmodes/ispell.el (ispell-lookup-words, ispell-filter)
(ispell-parse-output, ispell-buffer-local-parsing):
* lisp/textmodes/reftex-cite.el (reftex-do-citation):
* lisp/textmodes/reftex-parse.el (reftex-notice-new):
* lisp/textmodes/reftex-ref.el (reftex-show-entry):
* lisp/textmodes/reftex.el (reftex-compile-variables):
* lisp/textmodes/tex-mode.el (tex-send-command)
(tex-start-tex, tex-append):
* lisp/thingatpt.el (thing-at-point-url-at-point):
* lisp/tmm.el (tmm-add-one-shortcut):
* lisp/transient.el (transient-format-key):
* lisp/url/url-auth.el (url-basic-auth)
(url-digest-auth-directory-id-assoc):
* lisp/url/url-news.el (url-news):
* lisp/url/url-util.el (url-parse-query-string):
* lisp/vc/vc-cvs.el (vc-cvs-parse-entry):
* lisp/wid-browse.el (widget-browse-sexp):
* lisp/woman.el (woman-parse-colon-path, woman-mini-help)
(WoMan-getpage-in-background, woman-negative-vertical-space):
* lisp/xml.el:
* test/lisp/emacs-lisp/check-declare-tests.el
(check-declare-tests-warn):
* test/lisp/files-tests.el
(files-tests-file-name-non-special-dired-compress-handler):
* test/lisp/net/network-stream-tests.el (server-process-filter):
* test/src/coding-tests.el (ert-test-unibyte-buffer-dos-eol-decode):
Use `string-search` instead of `string-match` and `string-match-p`.
2021-08-09 09:20:00 +00:00
|
|
|
|
(string-search ":" string (1+ first-colon)))
|
1994-10-13 06:30:49 +00:00
|
|
|
|
(filename (substring string 1 first-colon))
|
2005-05-16 11:34:49 +00:00
|
|
|
|
(fileline (string-to-number
|
1994-10-13 06:30:49 +00:00
|
|
|
|
(substring string (1+ first-colon) second-colon))))
|
|
|
|
|
(setq term-pending-frame (cons filename fileline))))
|
|
|
|
|
((= (aref string 0) ?/)
|
|
|
|
|
(cd (substring string 1)))
|
1997-04-02 03:46:39 +00:00
|
|
|
|
;; Allowing the inferior to call functions in Emacs is
|
1995-01-22 02:21:32 +00:00
|
|
|
|
;; probably too big a security hole.
|
|
|
|
|
;; ((= (aref string 0) ?!)
|
|
|
|
|
;; (eval (car (read-from-string string 1))))
|
1994-10-13 06:30:49 +00:00
|
|
|
|
(t)));; Otherwise ignore it
|
|
|
|
|
|
|
|
|
|
;; Make sure the file named TRUE-FILE is in a buffer that appears on the screen
|
|
|
|
|
;; and that its line LINE is visible.
|
|
|
|
|
;; Put the overlay-arrow on the line LINE in that buffer.
|
|
|
|
|
;; This is mainly used by gdb.
|
|
|
|
|
|
|
|
|
|
(defun term-display-line (true-file line)
|
|
|
|
|
(term-display-buffer-line (find-file-noselect true-file) line))
|
|
|
|
|
|
|
|
|
|
(defun term-display-buffer-line (buffer line)
|
|
|
|
|
(let* ((window (display-buffer buffer t))
|
|
|
|
|
(pos))
|
* x-dnd.el (x-dnd-maybe-call-test-function):
* window.el (split-window-vertically):
* whitespace.el (whitespace-help-on):
* vc-rcs.el (vc-rcs-consult-headers):
* userlock.el (ask-user-about-lock-help)
(ask-user-about-supersession-help):
* type-break.el (type-break-force-mode-line-update):
* time-stamp.el (time-stamp-conv-warn):
* terminal.el (te-set-output-log, te-more-break, te-filter)
(te-sentinel,terminal-emulator):
* term.el (make-term, term-exec, term-sentinel, term-read-input-ring)
(term-write-input-ring, term-check-source, term-start-output-log):
(term-display-buffer-line, term-dynamic-list-completions):
(term-ansi-make-term, serial-term):
* subr.el (selective-display):
* strokes.el (strokes-xpm-to-compressed-string, strokes-decode-buffer)
(strokes-encode-buffer, strokes-xpm-for-compressed-string):
* speedbar.el (speedbar-buffers-tail-notes, speedbar-buffers-item-info)
(speedbar-reconfigure-keymaps, speedbar-add-localized-speedbar-support)
(speedbar-remove-localized-speedbar-support)
(speedbar-set-mode-line-format, speedbar-create-tag-hierarchy)
(speedbar-update-special-contents, speedbar-buffer-buttons-engine)
(speedbar-buffers-line-directory):
* simple.el (shell-command-on-region, append-to-buffer)
(prepend-to-buffer):
* shadowfile.el (shadow-save-todo-file):
* scroll-bar.el (scroll-bar-set-window-start, scroll-bar-drag-1)
(scroll-bar-maybe-set-window-start):
* sb-image.el (speedbar-image-dump):
* saveplace.el (save-place-alist-to-file, save-places-to-alist)
(load-save-place-alist-from-file):
* ps-samp.el (ps-print-message-from-summary):
* ps-print.el (ps-flush-output, ps-insert-file, ps-get-boundingbox)
(ps-background-image, ps-begin-job, ps-do-despool):
* ps-bdf.el (bdf-find-file, bdf-read-font-info):
* printing.el (pr-interface, pr-ps-file-print, pr-find-buffer-visiting)
(pr-ps-message-from-summary, pr-lpr-message-from-summary):
(pr-call-process, pr-file-list, pr-interface-save):
* novice.el (disabled-command-function)
(enable-command, disable-command):
* mouse.el (mouse-buffer-menu-alist):
* mouse-copy.el (mouse-kill-preserving-secondary):
* macros.el (kbd-macro-query):
* ledit.el (ledit-go-to-lisp, ledit-go-to-liszt):
* informat.el (batch-info-validate):
* ido.el (ido-copy-current-word, ido-initiate-auto-merge):
* hippie-exp.el (try-expand-dabbrev-visible):
* help-mode.el (help-make-xrefs):
* help-fns.el (describe-variable):
* generic-x.el (bat-generic-mode-run-as-comint):
* finder.el (finder-mouse-select):
* find-dired.el (find-dired-sentinel):
* filesets.el (filesets-file-close):
* files.el (list-directory):
* faces.el (list-faces-display, describe-face):
* facemenu.el (list-colors-display):
* ezimage.el (ezimage-image-association-dump, ezimage-image-dump):
* epg.el (epg--process-filter, epg-cancel):
* epa.el (epa--marked-keys, epa--select-keys, epa-display-info)
(epa--read-signature-type):
* emerge.el (emerge-copy-as-kill-A, emerge-copy-as-kill-B)
(emerge-file-names):
* ehelp.el (electric-helpify):
* ediff.el (ediff-regions-wordwise, ediff-regions-linewise):
* ediff-vers.el (rcs-ediff-view-revision):
* ediff-util.el (ediff-setup):
* ediff-mult.el (ediff-append-custom-diff):
* ediff-diff.el (ediff-exec-process, ediff-process-sentinel)
(ediff-wordify):
* echistory.el (Electric-command-history-redo-expression):
* dos-w32.el (find-file-not-found-set-buffer-file-coding-system):
* disp-table.el (describe-display-table):
* dired.el (dired-find-buffer-nocreate):
* dired-aux.el (dired-rename-subdir, dired-dwim-target-directory):
* dabbrev.el (dabbrev--same-major-mode-p):
* chistory.el (list-command-history):
* apropos.el (apropos-documentation):
* allout.el (allout-obtain-passphrase):
(allout-copy-exposed-to-buffer):
(allout-verify-passphrase): Use with-current-buffer.
2009-11-13 22:19:45 +00:00
|
|
|
|
(with-current-buffer buffer
|
1994-10-13 06:30:49 +00:00
|
|
|
|
(save-restriction
|
|
|
|
|
(widen)
|
2009-08-22 19:29:18 +00:00
|
|
|
|
(goto-char (point-min))
|
|
|
|
|
(forward-line (1- line))
|
1994-10-13 06:30:49 +00:00
|
|
|
|
(setq pos (point))
|
|
|
|
|
(setq overlay-arrow-string "=>")
|
|
|
|
|
(or overlay-arrow-position
|
|
|
|
|
(setq overlay-arrow-position (make-marker)))
|
|
|
|
|
(set-marker overlay-arrow-position (point) (current-buffer)))
|
|
|
|
|
(cond ((or (< pos (point-min)) (> pos (point-max)))
|
|
|
|
|
(widen)
|
|
|
|
|
(goto-char pos))))
|
|
|
|
|
(set-window-point window overlay-arrow-position)))
|
|
|
|
|
|
2009-08-16 15:39:11 +00:00
|
|
|
|
;; The buffer-local marker term-home-marker defines the "home position"
|
|
|
|
|
;; (in terms of cursor motion). However, we move the term-home-marker
|
|
|
|
|
;; "down" as needed so that is no more that a window-full above (point-max).
|
1994-10-13 06:30:49 +00:00
|
|
|
|
|
|
|
|
|
(defun term-goto-home ()
|
1995-06-14 22:30:16 +00:00
|
|
|
|
(term-handle-deferred-scroll)
|
1994-10-13 06:30:49 +00:00
|
|
|
|
(goto-char term-home-marker)
|
|
|
|
|
(setq term-current-row 0)
|
|
|
|
|
(setq term-current-column (current-column))
|
|
|
|
|
(setq term-start-line-column term-current-column))
|
|
|
|
|
|
|
|
|
|
(defun term-goto (row col)
|
1995-06-14 22:30:16 +00:00
|
|
|
|
(term-handle-deferred-scroll)
|
|
|
|
|
(cond ((and term-current-row (>= row term-current-row))
|
|
|
|
|
;; I assume this is a worthwhile optimization.
|
|
|
|
|
(term-vertical-motion 0)
|
|
|
|
|
(setq term-current-column term-start-line-column)
|
|
|
|
|
(setq row (- row term-current-row)))
|
|
|
|
|
(t
|
|
|
|
|
(term-goto-home)))
|
|
|
|
|
(term-down row)
|
|
|
|
|
(term-move-columns col))
|
1994-10-13 06:30:49 +00:00
|
|
|
|
|
2009-08-16 15:39:11 +00:00
|
|
|
|
;; The page is full, so enter "pager" mode, and wait for input.
|
1994-10-13 06:30:49 +00:00
|
|
|
|
|
|
|
|
|
(defun term-process-pager ()
|
2009-08-16 15:39:11 +00:00
|
|
|
|
;; (let ((process (get-buffer-process (current-buffer))))
|
|
|
|
|
;; (stop-process process))
|
1994-10-13 06:30:49 +00:00
|
|
|
|
(setq term-pager-old-local-map (current-local-map))
|
|
|
|
|
(use-local-map term-pager-break-map)
|
2020-12-08 07:52:57 +00:00
|
|
|
|
(setq-local term-old-mode-line-format mode-line-format)
|
1994-10-13 06:30:49 +00:00
|
|
|
|
(setq mode-line-format
|
|
|
|
|
(list "-- **MORE** "
|
|
|
|
|
mode-line-buffer-identification
|
|
|
|
|
" [Type ? for help] "
|
1995-01-22 02:21:32 +00:00
|
|
|
|
"%-"))
|
1995-04-25 22:25:25 +00:00
|
|
|
|
(force-mode-line-update))
|
1994-10-13 06:30:49 +00:00
|
|
|
|
|
|
|
|
|
(defun term-pager-line (lines)
|
|
|
|
|
(interactive "p")
|
|
|
|
|
(let* ((moved (vertical-motion (1+ lines)))
|
|
|
|
|
(deficit (- lines moved)))
|
(term-if-xemacs, term-ifnot-xemacs): Delete, replace
uses with a simple test.
(term-set-escape-char, term-mode, term-check-kill-echo-list)
(term-send-raw-string, term-send-raw, term-mouse-paste)
(term-char-mode, term-line-mode, term-exec, term-sentinel)
(term-handle-exit, term-read-input-ring)
(term-previous-matching-input-string)
(term-previous-matching-input-string-position)
(term-previous-matching-input-from-input)
(term-replace-by-expanded-history, term-send-input)
(term-skip-prompt, term-bol, term-send-invisible)
(term-kill-input, term-delchar-or-maybe-eof)
(term-backward-matching-input, term-check-source)
(term-proc-query, term-emulate-terminal)
(term-handle-colors-array, term-process-pager, term-pager-line)
(term-pager-bob, term-unwrap-line, term-word)
(term-dynamic-complete-filename)
(term-dynamic-complete-as-filename)
(term-dynamic-simple-complete): Replace one arm ifs with whens or
unlesses.
2006-05-29 06:11:33 +00:00
|
|
|
|
(when (> moved lines)
|
|
|
|
|
(backward-char))
|
1994-10-13 06:30:49 +00:00
|
|
|
|
(cond ((<= deficit 0) ;; OK, had enough in the buffer for request.
|
2019-04-29 17:53:38 +00:00
|
|
|
|
(recenter (term--last-line)))
|
1994-10-13 06:30:49 +00:00
|
|
|
|
((term-pager-continue deficit)))))
|
|
|
|
|
|
|
|
|
|
(defun term-pager-page (arg)
|
(term-buffer-maximum-size, term-exec, term-escape-char, term-set-escape-char,
term-termcap-format, term-get-old-input-default, term-skip-prompt,
term-send-string, term-send-region, term-pager-page, term-pager-help):
Fix typos in docstrings.
2007-04-13 09:00:41 +00:00
|
|
|
|
"Proceed past the **MORE** break, allowing the next page of output to appear."
|
1994-10-13 06:30:49 +00:00
|
|
|
|
(interactive "p")
|
|
|
|
|
(term-pager-line (* arg term-height)))
|
|
|
|
|
|
2009-08-16 15:39:11 +00:00
|
|
|
|
;; Pager mode command to go to beginning of buffer.
|
1994-10-13 06:30:49 +00:00
|
|
|
|
(defun term-pager-bob ()
|
|
|
|
|
(interactive)
|
|
|
|
|
(goto-char (point-min))
|
(term-if-xemacs, term-ifnot-xemacs): Delete, replace
uses with a simple test.
(term-set-escape-char, term-mode, term-check-kill-echo-list)
(term-send-raw-string, term-send-raw, term-mouse-paste)
(term-char-mode, term-line-mode, term-exec, term-sentinel)
(term-handle-exit, term-read-input-ring)
(term-previous-matching-input-string)
(term-previous-matching-input-string-position)
(term-previous-matching-input-from-input)
(term-replace-by-expanded-history, term-send-input)
(term-skip-prompt, term-bol, term-send-invisible)
(term-kill-input, term-delchar-or-maybe-eof)
(term-backward-matching-input, term-check-source)
(term-proc-query, term-emulate-terminal)
(term-handle-colors-array, term-process-pager, term-pager-line)
(term-pager-bob, term-unwrap-line, term-word)
(term-dynamic-complete-filename)
(term-dynamic-complete-as-filename)
(term-dynamic-simple-complete): Replace one arm ifs with whens or
unlesses.
2006-05-29 06:11:33 +00:00
|
|
|
|
(when (= (vertical-motion term-height) term-height)
|
|
|
|
|
(backward-char))
|
2019-04-29 17:53:38 +00:00
|
|
|
|
(recenter (term--last-line)))
|
1994-10-13 06:30:49 +00:00
|
|
|
|
|
2009-08-16 15:39:11 +00:00
|
|
|
|
;; Pager mode command to go to end of buffer.
|
1994-10-13 06:30:49 +00:00
|
|
|
|
(defun term-pager-eob ()
|
|
|
|
|
(interactive)
|
|
|
|
|
(goto-char term-home-marker)
|
|
|
|
|
(recenter 0)
|
|
|
|
|
(goto-char (process-mark (get-buffer-process (current-buffer)))))
|
|
|
|
|
|
|
|
|
|
(defun term-pager-back-line (lines)
|
|
|
|
|
(interactive "p")
|
|
|
|
|
(vertical-motion (- 1 lines))
|
|
|
|
|
(if (not (bobp))
|
|
|
|
|
(backward-char)
|
|
|
|
|
(beep)
|
|
|
|
|
;; Move cursor to end of window.
|
|
|
|
|
(vertical-motion term-height)
|
|
|
|
|
(backward-char))
|
2019-04-29 17:53:38 +00:00
|
|
|
|
(recenter (term--last-line)))
|
1994-10-13 06:30:49 +00:00
|
|
|
|
|
|
|
|
|
(defun term-pager-back-page (arg)
|
|
|
|
|
(interactive "p")
|
|
|
|
|
(term-pager-back-line (* arg term-height)))
|
|
|
|
|
|
|
|
|
|
(defun term-pager-discard ()
|
|
|
|
|
(interactive)
|
2018-01-18 13:22:47 +00:00
|
|
|
|
(setq term-terminal-undecoded-bytes "")
|
1994-10-13 06:30:49 +00:00
|
|
|
|
(interrupt-process nil t)
|
|
|
|
|
(term-pager-continue term-height))
|
|
|
|
|
|
2009-08-16 15:39:11 +00:00
|
|
|
|
;; Disable pager processing.
|
|
|
|
|
;; Only callable while in pager mode. (Contrast term-disable-pager.)
|
1994-10-13 06:30:49 +00:00
|
|
|
|
(defun term-pager-disable ()
|
|
|
|
|
(interactive)
|
|
|
|
|
(if (term-handling-pager)
|
|
|
|
|
(term-pager-continue nil)
|
1995-02-06 21:56:37 +00:00
|
|
|
|
(setq term-pager-count nil))
|
|
|
|
|
(term-update-mode-line))
|
1997-04-02 03:46:39 +00:00
|
|
|
|
|
2009-08-16 15:39:11 +00:00
|
|
|
|
;; Enable pager processing.
|
1994-10-13 06:30:49 +00:00
|
|
|
|
(defun term-pager-enable ()
|
|
|
|
|
(interactive)
|
1995-02-06 21:56:37 +00:00
|
|
|
|
(or (term-pager-enabled)
|
|
|
|
|
(setq term-pager-count 0)) ;; Or maybe set to (term-current-row) ??
|
|
|
|
|
(term-update-mode-line))
|
1994-10-13 06:30:49 +00:00
|
|
|
|
|
1995-01-22 02:21:32 +00:00
|
|
|
|
(defun term-pager-toggle ()
|
|
|
|
|
(interactive)
|
1995-02-06 21:56:37 +00:00
|
|
|
|
(if (term-pager-enabled) (term-pager-disable) (term-pager-enable)))
|
1995-01-22 02:21:32 +00:00
|
|
|
|
|
1994-10-13 06:30:49 +00:00
|
|
|
|
(defun term-pager-help ()
|
(term-buffer-maximum-size, term-exec, term-escape-char, term-set-escape-char,
term-termcap-format, term-get-old-input-default, term-skip-prompt,
term-send-string, term-send-region, term-pager-page, term-pager-help):
Fix typos in docstrings.
2007-04-13 09:00:41 +00:00
|
|
|
|
"Provide help on commands available in a terminal-emulator **MORE** break."
|
1994-10-13 06:30:49 +00:00
|
|
|
|
(interactive)
|
|
|
|
|
(message "Terminal-emulator pager break help...")
|
|
|
|
|
(sit-for 0)
|
|
|
|
|
(with-electric-help
|
2020-09-30 14:18:50 +00:00
|
|
|
|
(lambda ()
|
|
|
|
|
(princ (substitute-command-keys
|
1994-10-13 06:30:49 +00:00
|
|
|
|
"\\<term-pager-break-map>\
|
|
|
|
|
Terminal-emulator MORE break.\n\
|
|
|
|
|
Type one of the following keys:\n\n\
|
|
|
|
|
\\[term-pager-page]\t\tMove forward one page.\n\
|
|
|
|
|
\\[term-pager-line]\t\tMove forward one line.\n\
|
|
|
|
|
\\[universal-argument] N \\[term-pager-page]\tMove N pages forward.\n\
|
|
|
|
|
\\[universal-argument] N \\[term-pager-line]\tMove N lines forward.\n\
|
|
|
|
|
\\[universal-argument] N \\[term-pager-back-line]\tMove N lines back.\n\
|
|
|
|
|
\\[universal-argument] N \\[term-pager-back-page]\t\tMove N pages back.\n\
|
|
|
|
|
\\[term-pager-bob]\t\tMove to the beginning of the buffer.\n\
|
|
|
|
|
\\[term-pager-eob]\t\tMove to the end of the buffer.\n\
|
|
|
|
|
\\[term-pager-discard]\t\tKill pending output and kill process.\n\
|
|
|
|
|
\\[term-pager-disable]\t\tDisable PAGER handling.\n\n\
|
|
|
|
|
\\{term-pager-break-map}\n\
|
|
|
|
|
Any other key is passed through to the program
|
|
|
|
|
running under the terminal emulator and disables pager processing until
|
|
|
|
|
all pending output has been dealt with."))
|
2020-09-30 14:18:50 +00:00
|
|
|
|
nil)))
|
1994-10-13 06:30:49 +00:00
|
|
|
|
|
|
|
|
|
(defun term-pager-continue (new-count)
|
|
|
|
|
(let ((process (get-buffer-process (current-buffer))))
|
|
|
|
|
(use-local-map term-pager-old-local-map)
|
|
|
|
|
(setq term-pager-old-local-map nil)
|
|
|
|
|
(setq mode-line-format term-old-mode-line-format)
|
1995-04-25 22:25:25 +00:00
|
|
|
|
(force-mode-line-update)
|
1994-10-13 06:30:49 +00:00
|
|
|
|
(setq term-pager-count new-count)
|
|
|
|
|
(set-process-filter process term-pager-old-filter)
|
|
|
|
|
(funcall term-pager-old-filter process "")
|
|
|
|
|
(continue-process process)))
|
|
|
|
|
|
|
|
|
|
;; Make sure there are DOWN blank lines below the current one.
|
|
|
|
|
;; Return 0 if we're unable (because of PAGER handling), else return DOWN.
|
|
|
|
|
|
|
|
|
|
(defun term-handle-scroll (down)
|
|
|
|
|
(let ((scroll-needed
|
(term-buffer-maximum-size, term-exec, term-escape-char, term-set-escape-char,
term-termcap-format, term-get-old-input-default, term-skip-prompt,
term-send-string, term-send-region, term-pager-page, term-pager-help):
Fix typos in docstrings.
2007-04-13 09:00:41 +00:00
|
|
|
|
(- (+ (term-current-row) down)
|
2006-01-15 19:36:10 +00:00
|
|
|
|
(if (< down 0) term-scroll-start term-scroll-end))))
|
(term-buffer-maximum-size, term-exec, term-escape-char, term-set-escape-char,
term-termcap-format, term-get-old-input-default, term-skip-prompt,
term-send-string, term-send-region, term-pager-page, term-pager-help):
Fix typos in docstrings.
2007-04-13 09:00:41 +00:00
|
|
|
|
(when (or (and (< down 0) (< scroll-needed 0))
|
(term-if-xemacs, term-ifnot-xemacs): Delete, replace
uses with a simple test.
(term-set-escape-char, term-mode, term-check-kill-echo-list)
(term-send-raw-string, term-send-raw, term-mouse-paste)
(term-char-mode, term-line-mode, term-exec, term-sentinel)
(term-handle-exit, term-read-input-ring)
(term-previous-matching-input-string)
(term-previous-matching-input-string-position)
(term-previous-matching-input-from-input)
(term-replace-by-expanded-history, term-send-input)
(term-skip-prompt, term-bol, term-send-invisible)
(term-kill-input, term-delchar-or-maybe-eof)
(term-backward-matching-input, term-check-source)
(term-proc-query, term-emulate-terminal)
(term-handle-colors-array, term-process-pager, term-pager-line)
(term-pager-bob, term-unwrap-line, term-word)
(term-dynamic-complete-filename)
(term-dynamic-complete-as-filename)
(term-dynamic-simple-complete): Replace one arm ifs with whens or
unlesses.
2006-05-29 06:11:33 +00:00
|
|
|
|
(and (> down 0) (> scroll-needed 0)))
|
2014-06-22 05:43:58 +00:00
|
|
|
|
(let ((save-point (point-marker)) (save-top))
|
(term-if-xemacs, term-ifnot-xemacs): Delete, replace
uses with a simple test.
(term-set-escape-char, term-mode, term-check-kill-echo-list)
(term-send-raw-string, term-send-raw, term-mouse-paste)
(term-char-mode, term-line-mode, term-exec, term-sentinel)
(term-handle-exit, term-read-input-ring)
(term-previous-matching-input-string)
(term-previous-matching-input-string-position)
(term-previous-matching-input-from-input)
(term-replace-by-expanded-history, term-send-input)
(term-skip-prompt, term-bol, term-send-invisible)
(term-kill-input, term-delchar-or-maybe-eof)
(term-backward-matching-input, term-check-source)
(term-proc-query, term-emulate-terminal)
(term-handle-colors-array, term-process-pager, term-pager-line)
(term-pager-bob, term-unwrap-line, term-word)
(term-dynamic-complete-filename)
(term-dynamic-complete-as-filename)
(term-dynamic-simple-complete): Replace one arm ifs with whens or
unlesses.
2006-05-29 06:11:33 +00:00
|
|
|
|
(goto-char term-home-marker)
|
|
|
|
|
(cond (term-scroll-with-delete
|
|
|
|
|
(if (< down 0)
|
|
|
|
|
(progn
|
|
|
|
|
;; Delete scroll-needed lines at term-scroll-end,
|
|
|
|
|
;; then insert scroll-needed lines.
|
2006-06-15 22:58:10 +00:00
|
|
|
|
(term-vertical-motion term-scroll-end)
|
(term-if-xemacs, term-ifnot-xemacs): Delete, replace
uses with a simple test.
(term-set-escape-char, term-mode, term-check-kill-echo-list)
(term-send-raw-string, term-send-raw, term-mouse-paste)
(term-char-mode, term-line-mode, term-exec, term-sentinel)
(term-handle-exit, term-read-input-ring)
(term-previous-matching-input-string)
(term-previous-matching-input-string-position)
(term-previous-matching-input-from-input)
(term-replace-by-expanded-history, term-send-input)
(term-skip-prompt, term-bol, term-send-invisible)
(term-kill-input, term-delchar-or-maybe-eof)
(term-backward-matching-input, term-check-source)
(term-proc-query, term-emulate-terminal)
(term-handle-colors-array, term-process-pager, term-pager-line)
(term-pager-bob, term-unwrap-line, term-word)
(term-dynamic-complete-filename)
(term-dynamic-complete-as-filename)
(term-dynamic-simple-complete): Replace one arm ifs with whens or
unlesses.
2006-05-29 06:11:33 +00:00
|
|
|
|
(end-of-line)
|
|
|
|
|
(setq save-top (point))
|
|
|
|
|
(term-vertical-motion scroll-needed)
|
|
|
|
|
(end-of-line)
|
|
|
|
|
(delete-region save-top (point))
|
|
|
|
|
(goto-char save-point)
|
|
|
|
|
(setq down (- scroll-needed down))
|
|
|
|
|
(term-vertical-motion down))
|
|
|
|
|
;; Delete scroll-needed lines at term-scroll-start.
|
|
|
|
|
(term-vertical-motion term-scroll-start)
|
|
|
|
|
(setq save-top (point))
|
1994-10-13 06:30:49 +00:00
|
|
|
|
(term-vertical-motion scroll-needed)
|
(term-if-xemacs, term-ifnot-xemacs): Delete, replace
uses with a simple test.
(term-set-escape-char, term-mode, term-check-kill-echo-list)
(term-send-raw-string, term-send-raw, term-mouse-paste)
(term-char-mode, term-line-mode, term-exec, term-sentinel)
(term-handle-exit, term-read-input-ring)
(term-previous-matching-input-string)
(term-previous-matching-input-string-position)
(term-previous-matching-input-from-input)
(term-replace-by-expanded-history, term-send-input)
(term-skip-prompt, term-bol, term-send-invisible)
(term-kill-input, term-delchar-or-maybe-eof)
(term-backward-matching-input, term-check-source)
(term-proc-query, term-emulate-terminal)
(term-handle-colors-array, term-process-pager, term-pager-line)
(term-pager-bob, term-unwrap-line, term-word)
(term-dynamic-complete-filename)
(term-dynamic-complete-as-filename)
(term-dynamic-simple-complete): Replace one arm ifs with whens or
unlesses.
2006-05-29 06:11:33 +00:00
|
|
|
|
(delete-region save-top (point))
|
|
|
|
|
(goto-char save-point)
|
|
|
|
|
(term-vertical-motion down)
|
|
|
|
|
(term-adjust-current-row-cache (- scroll-needed)))
|
|
|
|
|
(setq term-current-column nil)
|
|
|
|
|
(term-insert-char ?\n (abs scroll-needed)))
|
|
|
|
|
((and (numberp term-pager-count)
|
|
|
|
|
(< (setq term-pager-count (- term-pager-count down))
|
|
|
|
|
0))
|
|
|
|
|
(setq down 0)
|
|
|
|
|
(term-process-pager))
|
|
|
|
|
(t
|
|
|
|
|
(term-adjust-current-row-cache (- scroll-needed))
|
|
|
|
|
(term-vertical-motion scroll-needed)
|
|
|
|
|
(set-marker term-home-marker (point))))
|
|
|
|
|
(goto-char save-point)
|
|
|
|
|
(set-marker save-point nil))))
|
1994-10-13 06:30:49 +00:00
|
|
|
|
down)
|
|
|
|
|
|
1995-06-14 22:30:16 +00:00
|
|
|
|
(defun term-down (down &optional check-for-scroll)
|
|
|
|
|
"Move down DOWN screen lines vertically."
|
1994-10-13 06:30:49 +00:00
|
|
|
|
(let ((start-column (term-horizontal-column)))
|
2005-11-15 17:13:22 +00:00
|
|
|
|
(when (and check-for-scroll (or term-scroll-with-delete term-pager-count))
|
|
|
|
|
(setq down (term-handle-scroll down)))
|
2018-04-17 23:17:18 +00:00
|
|
|
|
(unless (and (= (term-current-row) 0) (< down 0))
|
2005-11-15 17:13:22 +00:00
|
|
|
|
(term-adjust-current-row-cache down)
|
|
|
|
|
(when (or (/= (point) (point-max)) (< down 0))
|
|
|
|
|
(setq down (- down (term-vertical-motion down)))))
|
2006-01-15 19:36:10 +00:00
|
|
|
|
(cond ((>= down 0)
|
2005-11-15 17:13:22 +00:00
|
|
|
|
;; Extend buffer with extra blank lines if needed.
|
1995-06-14 22:30:16 +00:00
|
|
|
|
(term-insert-char ?\n down)
|
|
|
|
|
(setq term-current-column 0)
|
|
|
|
|
(setq term-start-line-column 0))
|
|
|
|
|
(t
|
2018-04-17 23:17:18 +00:00
|
|
|
|
(when (= (term-current-row) 0)
|
2005-11-15 17:13:22 +00:00
|
|
|
|
;; Insert lines if at the beginning.
|
|
|
|
|
(save-excursion (term-insert-char ?\n (- down)))
|
|
|
|
|
(save-excursion
|
|
|
|
|
(let (p)
|
|
|
|
|
;; Delete lines from the end.
|
|
|
|
|
(forward-line term-height)
|
|
|
|
|
(setq p (point))
|
|
|
|
|
(forward-line (- down))
|
|
|
|
|
(delete-region p (point)))))
|
|
|
|
|
(setq term-current-column 0)
|
1995-06-14 22:30:16 +00:00
|
|
|
|
(setq term-start-line-column (current-column))))
|
2005-11-15 17:13:22 +00:00
|
|
|
|
(when start-column
|
|
|
|
|
(term-move-columns start-column))))
|
1994-10-13 06:30:49 +00:00
|
|
|
|
|
|
|
|
|
;; Assuming point is at the beginning of a screen line,
|
|
|
|
|
;; if the line above point wraps around, add a ?\n to undo the wrapping.
|
|
|
|
|
;; FIXME: Probably should be called more than it is.
|
|
|
|
|
(defun term-unwrap-line ()
|
2019-01-21 00:08:17 +00:00
|
|
|
|
(when (not (bolp))
|
|
|
|
|
(let ((old-point (point)))
|
|
|
|
|
(insert-before-markers ?\n)
|
2019-04-28 19:59:50 +00:00
|
|
|
|
(add-text-properties old-point (point)
|
|
|
|
|
'(term-line-wrap t rear-nonsticky t)))))
|
1994-10-13 06:30:49 +00:00
|
|
|
|
|
|
|
|
|
(defun term-erase-in-line (kind)
|
(term-if-xemacs, term-ifnot-xemacs): Delete, replace
uses with a simple test.
(term-set-escape-char, term-mode, term-check-kill-echo-list)
(term-send-raw-string, term-send-raw, term-mouse-paste)
(term-char-mode, term-line-mode, term-exec, term-sentinel)
(term-handle-exit, term-read-input-ring)
(term-previous-matching-input-string)
(term-previous-matching-input-string-position)
(term-previous-matching-input-from-input)
(term-replace-by-expanded-history, term-send-input)
(term-skip-prompt, term-bol, term-send-invisible)
(term-kill-input, term-delchar-or-maybe-eof)
(term-backward-matching-input, term-check-source)
(term-proc-query, term-emulate-terminal)
(term-handle-colors-array, term-process-pager, term-pager-line)
(term-pager-bob, term-unwrap-line, term-word)
(term-dynamic-complete-filename)
(term-dynamic-complete-as-filename)
(term-dynamic-simple-complete): Replace one arm ifs with whens or
unlesses.
2006-05-29 06:11:33 +00:00
|
|
|
|
(when (= kind 1) ;; erase left of point
|
|
|
|
|
(let ((cols (term-horizontal-column)) (saved-point (point)))
|
|
|
|
|
(term-vertical-motion 0)
|
|
|
|
|
(delete-region (point) saved-point)
|
|
|
|
|
(term-insert-char ? cols)))
|
|
|
|
|
(when (not (eq kind 1)) ;; erase right of point
|
|
|
|
|
(let ((saved-point (point))
|
|
|
|
|
(wrapped (and (zerop (term-horizontal-column))
|
|
|
|
|
(not (zerop (term-current-column))))))
|
|
|
|
|
(term-vertical-motion 1)
|
|
|
|
|
(delete-region saved-point (point))
|
|
|
|
|
;; wrapped is true if we're at the beginning of screen line,
|
|
|
|
|
;; but not a buffer line. If we delete the current screen line
|
|
|
|
|
;; that will make the previous line no longer wrap, and (because
|
|
|
|
|
;; of the way Emacs display works) point will be at the end of
|
|
|
|
|
;; the previous screen line rather then the beginning of the
|
|
|
|
|
;; current one. To avoid that, we make sure that current line
|
|
|
|
|
;; contain a space, to force the previous line to continue to wrap.
|
|
|
|
|
;; We could do this always, but it seems preferable to not add the
|
|
|
|
|
;; extra space when wrapped is false.
|
(term-buffer-maximum-size, term-exec, term-escape-char, term-set-escape-char,
term-termcap-format, term-get-old-input-default, term-skip-prompt,
term-send-string, term-send-region, term-pager-page, term-pager-help):
Fix typos in docstrings.
2007-04-13 09:00:41 +00:00
|
|
|
|
(when wrapped
|
(term-if-xemacs, term-ifnot-xemacs): Delete, replace
uses with a simple test.
(term-set-escape-char, term-mode, term-check-kill-echo-list)
(term-send-raw-string, term-send-raw, term-mouse-paste)
(term-char-mode, term-line-mode, term-exec, term-sentinel)
(term-handle-exit, term-read-input-ring)
(term-previous-matching-input-string)
(term-previous-matching-input-string-position)
(term-previous-matching-input-from-input)
(term-replace-by-expanded-history, term-send-input)
(term-skip-prompt, term-bol, term-send-invisible)
(term-kill-input, term-delchar-or-maybe-eof)
(term-backward-matching-input, term-check-source)
(term-proc-query, term-emulate-terminal)
(term-handle-colors-array, term-process-pager, term-pager-line)
(term-pager-bob, term-unwrap-line, term-word)
(term-dynamic-complete-filename)
(term-dynamic-complete-as-filename)
(term-dynamic-simple-complete): Replace one arm ifs with whens or
unlesses.
2006-05-29 06:11:33 +00:00
|
|
|
|
(insert ? ))
|
|
|
|
|
(insert ?\n)
|
2012-06-20 09:21:06 +00:00
|
|
|
|
(put-text-property saved-point (point) 'font-lock-face 'default)
|
(term-if-xemacs, term-ifnot-xemacs): Delete, replace
uses with a simple test.
(term-set-escape-char, term-mode, term-check-kill-echo-list)
(term-send-raw-string, term-send-raw, term-mouse-paste)
(term-char-mode, term-line-mode, term-exec, term-sentinel)
(term-handle-exit, term-read-input-ring)
(term-previous-matching-input-string)
(term-previous-matching-input-string-position)
(term-previous-matching-input-from-input)
(term-replace-by-expanded-history, term-send-input)
(term-skip-prompt, term-bol, term-send-invisible)
(term-kill-input, term-delchar-or-maybe-eof)
(term-backward-matching-input, term-check-source)
(term-proc-query, term-emulate-terminal)
(term-handle-colors-array, term-process-pager, term-pager-line)
(term-pager-bob, term-unwrap-line, term-word)
(term-dynamic-complete-filename)
(term-dynamic-complete-as-filename)
(term-dynamic-simple-complete): Replace one arm ifs with whens or
unlesses.
2006-05-29 06:11:33 +00:00
|
|
|
|
(goto-char saved-point))))
|
1994-10-13 06:30:49 +00:00
|
|
|
|
|
|
|
|
|
(defun term-erase-in-display (kind)
|
2010-08-02 04:14:26 +00:00
|
|
|
|
"Erase (that is blank out) part of the window.
|
2021-09-22 18:26:40 +00:00
|
|
|
|
If KIND is 0, erase from point to point-max;
|
2007-08-03 10:49:56 +00:00
|
|
|
|
if KIND is 1, erase from home to point; else erase from home to point-max."
|
1995-06-14 22:30:16 +00:00
|
|
|
|
(term-handle-deferred-scroll)
|
2018-01-18 13:22:47 +00:00
|
|
|
|
(cond ((eq kind 0)
|
2007-08-03 10:49:56 +00:00
|
|
|
|
(let ((need-unwrap (bolp)))
|
|
|
|
|
(delete-region (point) (point-max))
|
|
|
|
|
(when need-unwrap (term-unwrap-line))))
|
1994-10-13 06:30:49 +00:00
|
|
|
|
((let ((row (term-current-row))
|
|
|
|
|
(col (term-horizontal-column))
|
|
|
|
|
(start-region term-home-marker)
|
|
|
|
|
(end-region (if (eq kind 1) (point) (point-max))))
|
|
|
|
|
(delete-region start-region end-region)
|
|
|
|
|
(term-unwrap-line)
|
2004-10-02 18:23:27 +00:00
|
|
|
|
(when (eq kind 1)
|
|
|
|
|
(term-insert-char ?\n row))
|
1994-10-13 06:30:49 +00:00
|
|
|
|
(setq term-current-column nil)
|
|
|
|
|
(setq term-current-row nil)
|
|
|
|
|
(term-goto row col)))))
|
|
|
|
|
|
|
|
|
|
(defun term-delete-chars (count)
|
|
|
|
|
(let ((save-point (point)))
|
|
|
|
|
(term-vertical-motion 1)
|
|
|
|
|
(term-unwrap-line)
|
|
|
|
|
(goto-char save-point)
|
|
|
|
|
(move-to-column (+ (term-current-column) count) t)
|
|
|
|
|
(delete-region save-point (point))))
|
|
|
|
|
|
2009-08-16 15:39:11 +00:00
|
|
|
|
;; Insert COUNT spaces after point, but do not change any of
|
|
|
|
|
;; following screen lines. Hence we may have to delete characters
|
|
|
|
|
;; at the end of this screen line to make room.
|
1995-06-14 22:30:16 +00:00
|
|
|
|
|
1994-10-13 06:30:49 +00:00
|
|
|
|
(defun term-insert-spaces (count)
|
2006-01-15 19:36:10 +00:00
|
|
|
|
(let ((save-point (point)) (save-eol) (pnt-at-eol))
|
1994-10-13 06:30:49 +00:00
|
|
|
|
(term-vertical-motion 1)
|
2006-01-15 19:36:10 +00:00
|
|
|
|
(when (bolp)
|
|
|
|
|
(backward-char))
|
Replace still more end-of-line etc with line-end-position, etc.
* lisp/gnus/nnbabyl.el (nnbabyl-request-move-article, nnbabyl-delete-mail)
(nnbabyl-check-mbox): Use point-at-bol.
* lisp/cedet/semantic/lex.el (semantic-lex-ignore-comments, semantic-flex):
* lisp/cedet/semantic/grammar.el (semantic-grammar-epilogue):
* lisp/cedet/ede/speedbar.el (ede-find-nearest-file-line):
* lisp/cedet/ede/pmake.el (ede-proj-makefile-insert-dist-rules):
* lisp/cedet/ede/autoconf-edit.el (autoconf-delete-parameter):
Use point-at-bol and point-at-eol.
* lisp/vc/emerge.el (emerge-line-number-in-buf):
* lisp/textmodes/ispell.el (ispell-region):
* lisp/textmodes/fill.el (current-fill-column):
* lisp/progmodes/xscheme.el (xscheme-send-current-line):
* lisp/progmodes/vhdl-mode.el (vhdl-current-line, vhdl-line-copy):
* lisp/progmodes/tcl.el (tcl-hairy-scan-for-comment):
* lisp/progmodes/sh-script.el (sh-handle-prev-do):
* lisp/progmodes/meta-mode.el (meta-indent-line):
* lisp/progmodes/idlwave.el (idlwave-goto-comment, idlwave-fill-paragraph)
(idlwave-in-quote):
* lisp/progmodes/idlw-shell.el (idlwave-shell-current-frame)
(idlwave-shell-update-bp-overlays, idlwave-shell-sources-filter):
* lisp/progmodes/fortran.el (fortran-looking-at-if-then):
* lisp/progmodes/etags.el (find-tag-in-order, etags-snarf-tag):
* lisp/progmodes/cperl-mode.el (cperl-sniff-for-indent)
(cperl-find-pods-heres):
* lisp/progmodes/ada-mode.el (ada-get-current-indent, ada-narrow-to-defun):
* lisp/net/quickurl.el (quickurl-list-insert):
* lisp/net/ldap.el (ldap-search-internal):
* lisp/net/eudc.el (eudc-expand-inline):
* lisp/mail/sendmail.el (sendmail-send-it):
* lisp/mail/mspools.el (mspools-visit-spool, mspools-get-spool-name):
* lisp/emulation/viper-cmd.el (viper-paren-match, viper-backward-indent)
(viper-brac-function):
* lisp/calc/calc-yank.el (calc-do-grab-region):
* lisp/calc/calc-keypd.el (calc-keypad-press):
* lisp/term.el (term-move-columns, term-insert-spaces):
* lisp/speedbar.el (speedbar-highlight-one-tag-line):
* lisp/simple.el (current-word):
* lisp/mouse-drag.el (mouse-drag-should-do-col-scrolling):
* lisp/info.el (Info-find-node-in-buffer-1, Info-follow-reference)
(Info-scroll-down):
* lisp/hippie-exp.el (he-line-beg):
* lisp/epa.el (epa--marked-keys):
* lisp/dired-aux.el (dired-kill-line, dired-do-kill-lines)
(dired-update-file-line, dired-add-entry, dired-remove-entry)
(dired-relist-entry):
* lisp/buff-menu.el (Buffer-menu-buffer):
* lisp/array.el (current-line):
* lisp/allout.el (allout-resolve-xref)
(allout-latex-verbatim-quote-curr-line):
Replace yet more uses of end-of-line etc with line-end-position.
2010-11-09 05:33:07 +00:00
|
|
|
|
(setq save-eol (point)
|
|
|
|
|
pnt-at-eol (line-end-position))
|
1994-10-13 06:30:49 +00:00
|
|
|
|
(move-to-column (+ (term-start-line-column) (- term-width count)) t)
|
2005-03-26 22:32:43 +00:00
|
|
|
|
;; If move-to-column extends the current line it will use the face
|
|
|
|
|
;; from the last character on the line, set the face for the chars
|
|
|
|
|
;; to default.
|
2006-01-15 19:36:10 +00:00
|
|
|
|
(when (>= (point) pnt-at-eol)
|
2012-06-20 09:21:06 +00:00
|
|
|
|
(put-text-property pnt-at-eol (point) 'font-lock-face 'default))
|
2006-01-15 19:36:10 +00:00
|
|
|
|
(when (> save-eol (point))
|
|
|
|
|
(delete-region (point) save-eol))
|
1994-10-13 06:30:49 +00:00
|
|
|
|
(goto-char save-point)
|
|
|
|
|
(term-insert-char ? count)
|
|
|
|
|
(goto-char save-point)))
|
|
|
|
|
|
|
|
|
|
(defun term-delete-lines (lines)
|
|
|
|
|
(let ((start (point))
|
|
|
|
|
(save-current-column term-current-column)
|
|
|
|
|
(save-start-line-column term-start-line-column)
|
|
|
|
|
(save-current-row (term-current-row)))
|
2006-06-15 22:58:10 +00:00
|
|
|
|
;; The number of inserted lines shouldn't exceed the scroll region end.
|
2006-06-20 18:12:23 +00:00
|
|
|
|
;; The `term-scroll-end' line is part of the scrolling region, so
|
|
|
|
|
;; we need to go one line past it in order to ensure correct
|
|
|
|
|
;; scrolling.
|
2006-06-15 22:58:10 +00:00
|
|
|
|
(when (> (+ save-current-row lines) (1+ term-scroll-end))
|
|
|
|
|
(setq lines (- lines (- (+ save-current-row lines) (1+ term-scroll-end)))))
|
1995-06-14 22:30:16 +00:00
|
|
|
|
(term-down lines)
|
1994-10-13 06:30:49 +00:00
|
|
|
|
(delete-region start (point))
|
2006-06-15 22:58:10 +00:00
|
|
|
|
(term-down (- (1+ term-scroll-end) save-current-row lines))
|
1994-10-13 06:30:49 +00:00
|
|
|
|
(term-insert-char ?\n lines)
|
|
|
|
|
(setq term-current-column save-current-column)
|
|
|
|
|
(setq term-start-line-column save-start-line-column)
|
|
|
|
|
(setq term-current-row save-current-row)
|
|
|
|
|
(goto-char start)))
|
|
|
|
|
|
|
|
|
|
(defun term-insert-lines (lines)
|
|
|
|
|
(let ((start (point))
|
|
|
|
|
(start-deleted)
|
|
|
|
|
(save-current-column term-current-column)
|
|
|
|
|
(save-start-line-column term-start-line-column)
|
|
|
|
|
(save-current-row (term-current-row)))
|
2006-01-15 19:36:10 +00:00
|
|
|
|
;; Inserting lines should take into account the scroll region.
|
2006-06-20 18:12:23 +00:00
|
|
|
|
;; The `term-scroll-end' line is part of the scrolling region, so
|
|
|
|
|
;; we need to go one line past it in order to ensure correct
|
|
|
|
|
;; scrolling.
|
2006-01-15 19:36:10 +00:00
|
|
|
|
(if (< save-current-row term-scroll-start)
|
(term-buffer-maximum-size, term-exec, term-escape-char, term-set-escape-char,
term-termcap-format, term-get-old-input-default, term-skip-prompt,
term-send-string, term-send-region, term-pager-page, term-pager-help):
Fix typos in docstrings.
2007-04-13 09:00:41 +00:00
|
|
|
|
;; If point is before scroll start,
|
|
|
|
|
(progn
|
2006-01-15 19:36:10 +00:00
|
|
|
|
(setq lines (- lines (- term-scroll-start save-current-row)))
|
|
|
|
|
(term-down (- term-scroll-start save-current-row))
|
|
|
|
|
(setq start (point)))
|
|
|
|
|
;; The number of inserted lines shouldn't exceed the scroll region end.
|
2006-06-15 22:58:10 +00:00
|
|
|
|
(when (> (+ save-current-row lines) (1+ term-scroll-end))
|
|
|
|
|
(setq lines (- lines (- (+ save-current-row lines)(1+ term-scroll-end)))))
|
|
|
|
|
(term-down (- (1+ term-scroll-end) save-current-row lines)))
|
1994-10-13 06:30:49 +00:00
|
|
|
|
(setq start-deleted (point))
|
1995-06-14 22:30:16 +00:00
|
|
|
|
(term-down lines)
|
1994-10-13 06:30:49 +00:00
|
|
|
|
(delete-region start-deleted (point))
|
|
|
|
|
(goto-char start)
|
|
|
|
|
(setq term-current-column save-current-column)
|
|
|
|
|
(setq term-start-line-column save-start-line-column)
|
|
|
|
|
(setq term-current-row save-current-row)
|
|
|
|
|
(term-insert-char ?\n lines)
|
|
|
|
|
(goto-char start)))
|
|
|
|
|
|
2004-09-26 18:39:10 +00:00
|
|
|
|
(defun term-start-output-log (name)
|
1994-10-13 06:30:49 +00:00
|
|
|
|
"Record raw inferior process output in a buffer."
|
|
|
|
|
(interactive (list (if term-log-buffer
|
|
|
|
|
nil
|
|
|
|
|
(read-buffer "Record output in buffer: "
|
|
|
|
|
(format "%s output-log"
|
|
|
|
|
(buffer-name (current-buffer)))
|
|
|
|
|
nil))))
|
|
|
|
|
(if (or (null name) (equal name ""))
|
|
|
|
|
(progn (setq term-log-buffer nil)
|
|
|
|
|
(message "Output logging off."))
|
|
|
|
|
(if (get-buffer name)
|
|
|
|
|
nil
|
* x-dnd.el (x-dnd-maybe-call-test-function):
* window.el (split-window-vertically):
* whitespace.el (whitespace-help-on):
* vc-rcs.el (vc-rcs-consult-headers):
* userlock.el (ask-user-about-lock-help)
(ask-user-about-supersession-help):
* type-break.el (type-break-force-mode-line-update):
* time-stamp.el (time-stamp-conv-warn):
* terminal.el (te-set-output-log, te-more-break, te-filter)
(te-sentinel,terminal-emulator):
* term.el (make-term, term-exec, term-sentinel, term-read-input-ring)
(term-write-input-ring, term-check-source, term-start-output-log):
(term-display-buffer-line, term-dynamic-list-completions):
(term-ansi-make-term, serial-term):
* subr.el (selective-display):
* strokes.el (strokes-xpm-to-compressed-string, strokes-decode-buffer)
(strokes-encode-buffer, strokes-xpm-for-compressed-string):
* speedbar.el (speedbar-buffers-tail-notes, speedbar-buffers-item-info)
(speedbar-reconfigure-keymaps, speedbar-add-localized-speedbar-support)
(speedbar-remove-localized-speedbar-support)
(speedbar-set-mode-line-format, speedbar-create-tag-hierarchy)
(speedbar-update-special-contents, speedbar-buffer-buttons-engine)
(speedbar-buffers-line-directory):
* simple.el (shell-command-on-region, append-to-buffer)
(prepend-to-buffer):
* shadowfile.el (shadow-save-todo-file):
* scroll-bar.el (scroll-bar-set-window-start, scroll-bar-drag-1)
(scroll-bar-maybe-set-window-start):
* sb-image.el (speedbar-image-dump):
* saveplace.el (save-place-alist-to-file, save-places-to-alist)
(load-save-place-alist-from-file):
* ps-samp.el (ps-print-message-from-summary):
* ps-print.el (ps-flush-output, ps-insert-file, ps-get-boundingbox)
(ps-background-image, ps-begin-job, ps-do-despool):
* ps-bdf.el (bdf-find-file, bdf-read-font-info):
* printing.el (pr-interface, pr-ps-file-print, pr-find-buffer-visiting)
(pr-ps-message-from-summary, pr-lpr-message-from-summary):
(pr-call-process, pr-file-list, pr-interface-save):
* novice.el (disabled-command-function)
(enable-command, disable-command):
* mouse.el (mouse-buffer-menu-alist):
* mouse-copy.el (mouse-kill-preserving-secondary):
* macros.el (kbd-macro-query):
* ledit.el (ledit-go-to-lisp, ledit-go-to-liszt):
* informat.el (batch-info-validate):
* ido.el (ido-copy-current-word, ido-initiate-auto-merge):
* hippie-exp.el (try-expand-dabbrev-visible):
* help-mode.el (help-make-xrefs):
* help-fns.el (describe-variable):
* generic-x.el (bat-generic-mode-run-as-comint):
* finder.el (finder-mouse-select):
* find-dired.el (find-dired-sentinel):
* filesets.el (filesets-file-close):
* files.el (list-directory):
* faces.el (list-faces-display, describe-face):
* facemenu.el (list-colors-display):
* ezimage.el (ezimage-image-association-dump, ezimage-image-dump):
* epg.el (epg--process-filter, epg-cancel):
* epa.el (epa--marked-keys, epa--select-keys, epa-display-info)
(epa--read-signature-type):
* emerge.el (emerge-copy-as-kill-A, emerge-copy-as-kill-B)
(emerge-file-names):
* ehelp.el (electric-helpify):
* ediff.el (ediff-regions-wordwise, ediff-regions-linewise):
* ediff-vers.el (rcs-ediff-view-revision):
* ediff-util.el (ediff-setup):
* ediff-mult.el (ediff-append-custom-diff):
* ediff-diff.el (ediff-exec-process, ediff-process-sentinel)
(ediff-wordify):
* echistory.el (Electric-command-history-redo-expression):
* dos-w32.el (find-file-not-found-set-buffer-file-coding-system):
* disp-table.el (describe-display-table):
* dired.el (dired-find-buffer-nocreate):
* dired-aux.el (dired-rename-subdir, dired-dwim-target-directory):
* dabbrev.el (dabbrev--same-major-mode-p):
* chistory.el (list-command-history):
* apropos.el (apropos-documentation):
* allout.el (allout-obtain-passphrase):
(allout-copy-exposed-to-buffer):
(allout-verify-passphrase): Use with-current-buffer.
2009-11-13 22:19:45 +00:00
|
|
|
|
(with-current-buffer (get-buffer-create name)
|
1994-10-13 06:30:49 +00:00
|
|
|
|
(fundamental-mode)
|
|
|
|
|
(buffer-disable-undo (current-buffer))
|
|
|
|
|
(erase-buffer)))
|
|
|
|
|
(setq term-log-buffer (get-buffer name))
|
|
|
|
|
(message "Recording terminal emulator output into buffer \"%s\""
|
|
|
|
|
(buffer-name term-log-buffer))))
|
|
|
|
|
|
2004-09-26 18:39:10 +00:00
|
|
|
|
(defun term-stop-output-log ()
|
1994-10-13 06:30:49 +00:00
|
|
|
|
"Discontinue raw inferior process logging."
|
|
|
|
|
(interactive)
|
2004-09-26 18:39:10 +00:00
|
|
|
|
(term-start-output-log nil))
|
1994-10-13 06:30:49 +00:00
|
|
|
|
|
|
|
|
|
(defun term-show-maximum-output ()
|
|
|
|
|
"Put the end of the buffer at the bottom of the window."
|
|
|
|
|
(interactive)
|
|
|
|
|
(goto-char (point-max))
|
|
|
|
|
(recenter -1))
|
|
|
|
|
|
2011-11-20 02:29:42 +00:00
|
|
|
|
;;; Do the user's customization...
|
1994-10-13 06:30:49 +00:00
|
|
|
|
|
|
|
|
|
(defvar term-load-hook nil
|
|
|
|
|
"This hook is run when term is loaded in.
|
|
|
|
|
This is a good place to put keybindings.")
|
1997-04-02 03:46:39 +00:00
|
|
|
|
|
1994-10-13 06:30:49 +00:00
|
|
|
|
(run-hooks 'term-load-hook)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;; Filename/command/history completion in a buffer
|
2009-08-16 15:39:11 +00:00
|
|
|
|
;; ===========================================================================
|
|
|
|
|
;; Useful completion functions, courtesy of the Ergo group.
|
|
|
|
|
|
|
|
|
|
;; Six commands:
|
|
|
|
|
;; term-dynamic-complete Complete or expand command, filename,
|
|
|
|
|
;; history at point.
|
|
|
|
|
;; term-dynamic-complete-filename Complete filename at point.
|
|
|
|
|
;; term-dynamic-list-filename-completions List completions in help buffer.
|
|
|
|
|
;; term-replace-by-expanded-filename Expand and complete filename at point;
|
|
|
|
|
;; replace with expanded/completed name.
|
|
|
|
|
|
|
|
|
|
;; These are not installed in the term-mode keymap. But they are
|
|
|
|
|
;; available for people who want them. Shell-mode installs them:
|
|
|
|
|
;; (define-key shell-mode-map "\t" 'term-dynamic-complete)
|
|
|
|
|
;; (define-key shell-mode-map "\M-?"
|
|
|
|
|
;; 'term-dynamic-list-filename-completions)))
|
|
|
|
|
;;
|
|
|
|
|
;; Commands like this are fine things to put in load hooks if you
|
|
|
|
|
;; want them present in specific modes.
|
1994-10-13 06:30:49 +00:00
|
|
|
|
|
2011-02-17 05:13:17 +00:00
|
|
|
|
(defcustom term-completion-autolist nil
|
|
|
|
|
"If non-nil, automatically list possibilities on partial completion.
|
|
|
|
|
This mirrors the optional behavior of tcsh."
|
|
|
|
|
:group 'term
|
|
|
|
|
:type 'boolean)
|
1994-10-13 06:30:49 +00:00
|
|
|
|
|
2011-02-17 05:13:17 +00:00
|
|
|
|
(defcustom term-completion-addsuffix t
|
|
|
|
|
"If non-nil, add a `/' to completed directories, ` ' to file names.
|
1997-03-12 00:23:49 +00:00
|
|
|
|
If a cons pair, it should be of the form (DIRSUFFIX . FILESUFFIX) where
|
|
|
|
|
DIRSUFFIX and FILESUFFIX are strings added on unambiguous or exact
|
2011-02-17 05:13:17 +00:00
|
|
|
|
completion. This mirrors the optional behavior of tcsh."
|
|
|
|
|
:group 'term
|
|
|
|
|
:type '(choice (const :tag "No suffix" nil)
|
|
|
|
|
(cons (string :tag "dirsuffix") (string :tag "filesuffix"))
|
|
|
|
|
(other :tag "Suffix" t)))
|
1994-10-13 06:30:49 +00:00
|
|
|
|
|
2011-02-17 05:13:17 +00:00
|
|
|
|
(defcustom term-completion-recexact nil
|
|
|
|
|
"If non-nil, use shortest completion if characters cannot be added.
|
1994-10-13 06:30:49 +00:00
|
|
|
|
This mirrors the optional behavior of tcsh.
|
|
|
|
|
|
2011-02-17 05:13:17 +00:00
|
|
|
|
A non-nil value is useful if `term-completion-autolist' is non-nil too."
|
|
|
|
|
:group 'term
|
|
|
|
|
:type 'boolean)
|
1994-10-13 06:30:49 +00:00
|
|
|
|
|
2011-02-17 05:13:17 +00:00
|
|
|
|
(defcustom term-completion-fignore nil
|
|
|
|
|
"List of suffixes to be disregarded during file completion.
|
1994-10-13 06:30:49 +00:00
|
|
|
|
This mirrors the optional behavior of bash and tcsh.
|
|
|
|
|
|
2011-02-17 05:13:17 +00:00
|
|
|
|
Note that this applies to `term-dynamic-complete-filename' only."
|
|
|
|
|
:group 'term
|
|
|
|
|
:type '(choice (const nil)
|
|
|
|
|
(repeat :tag "List of suffixes" string)))
|
1994-10-13 06:30:49 +00:00
|
|
|
|
|
|
|
|
|
(defvar term-file-name-prefix ""
|
|
|
|
|
"Prefix prepended to absolute file names taken from process input.
|
|
|
|
|
This is used by term's and shell's completion functions, and by shell's
|
|
|
|
|
directory tracking functions.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defun term-directory (directory)
|
|
|
|
|
;; Return expanded DIRECTORY, with `term-file-name-prefix' if absolute.
|
|
|
|
|
(expand-file-name (if (file-name-absolute-p directory)
|
|
|
|
|
(concat term-file-name-prefix directory)
|
|
|
|
|
directory)))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defun term-word (word-chars)
|
2005-06-10 00:43:13 +00:00
|
|
|
|
"Return the word of WORD-CHARS at point, or nil if none is found.
|
1994-10-13 06:30:49 +00:00
|
|
|
|
Word constituents are considered to be those in WORD-CHARS, which is like the
|
|
|
|
|
inside of a \"[...]\" (see `skip-chars-forward')."
|
|
|
|
|
(save-excursion
|
|
|
|
|
(let ((limit (point))
|
|
|
|
|
(word (concat "[" word-chars "]"))
|
|
|
|
|
(non-word (concat "[^" word-chars "]")))
|
(term-if-xemacs, term-ifnot-xemacs): Delete, replace
uses with a simple test.
(term-set-escape-char, term-mode, term-check-kill-echo-list)
(term-send-raw-string, term-send-raw, term-mouse-paste)
(term-char-mode, term-line-mode, term-exec, term-sentinel)
(term-handle-exit, term-read-input-ring)
(term-previous-matching-input-string)
(term-previous-matching-input-string-position)
(term-previous-matching-input-from-input)
(term-replace-by-expanded-history, term-send-input)
(term-skip-prompt, term-bol, term-send-invisible)
(term-kill-input, term-delchar-or-maybe-eof)
(term-backward-matching-input, term-check-source)
(term-proc-query, term-emulate-terminal)
(term-handle-colors-array, term-process-pager, term-pager-line)
(term-pager-bob, term-unwrap-line, term-word)
(term-dynamic-complete-filename)
(term-dynamic-complete-as-filename)
(term-dynamic-simple-complete): Replace one arm ifs with whens or
unlesses.
2006-05-29 06:11:33 +00:00
|
|
|
|
(when (re-search-backward non-word nil 'move)
|
|
|
|
|
(forward-char 1))
|
1994-10-13 06:30:49 +00:00
|
|
|
|
;; Anchor the search forwards.
|
|
|
|
|
(if (or (eolp) (looking-at non-word))
|
|
|
|
|
nil
|
|
|
|
|
(re-search-forward (concat word "+") limit)
|
|
|
|
|
(buffer-substring (match-beginning 0) (match-end 0))))))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defun term-match-partial-filename ()
|
2005-06-10 00:43:13 +00:00
|
|
|
|
"Return the filename at point, or nil if none is found.
|
1994-10-13 06:30:49 +00:00
|
|
|
|
Environment variables are substituted. See `term-word'."
|
|
|
|
|
(let ((filename (term-word "~/A-Za-z0-9+@:_.$#,={}-")))
|
|
|
|
|
(and filename (substitute-in-file-name filename))))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defun term-dynamic-complete ()
|
|
|
|
|
"Dynamically perform completion at point.
|
|
|
|
|
Calls the functions in `term-dynamic-complete-functions' to perform
|
|
|
|
|
completion until a function returns non-nil, at which point completion is
|
|
|
|
|
assumed to have occurred."
|
|
|
|
|
(interactive)
|
2019-02-24 21:19:59 +00:00
|
|
|
|
(run-hook-with-args-until-success 'term-dynamic-complete-functions))
|
1994-10-13 06:30:49 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defun term-dynamic-complete-filename ()
|
|
|
|
|
"Dynamically complete the filename at point.
|
|
|
|
|
Completes if after a filename. See `term-match-partial-filename' and
|
|
|
|
|
`term-dynamic-complete-as-filename'.
|
|
|
|
|
This function is similar to `term-replace-by-expanded-filename', except that
|
|
|
|
|
it won't change parts of the filename already entered in the buffer; it just
|
|
|
|
|
adds completion characters to the end of the filename. A completions listing
|
|
|
|
|
may be shown in a help buffer if completion is ambiguous.
|
|
|
|
|
|
|
|
|
|
Completion is dependent on the value of `term-completion-addsuffix',
|
|
|
|
|
`term-completion-recexact' and `term-completion-fignore', and the timing of
|
|
|
|
|
completions listing is dependent on the value of `term-completion-autolist'.
|
|
|
|
|
|
|
|
|
|
Returns t if successful."
|
|
|
|
|
(interactive)
|
(term-if-xemacs, term-ifnot-xemacs): Delete, replace
uses with a simple test.
(term-set-escape-char, term-mode, term-check-kill-echo-list)
(term-send-raw-string, term-send-raw, term-mouse-paste)
(term-char-mode, term-line-mode, term-exec, term-sentinel)
(term-handle-exit, term-read-input-ring)
(term-previous-matching-input-string)
(term-previous-matching-input-string-position)
(term-previous-matching-input-from-input)
(term-replace-by-expanded-history, term-send-input)
(term-skip-prompt, term-bol, term-send-invisible)
(term-kill-input, term-delchar-or-maybe-eof)
(term-backward-matching-input, term-check-source)
(term-proc-query, term-emulate-terminal)
(term-handle-colors-array, term-process-pager, term-pager-line)
(term-pager-bob, term-unwrap-line, term-word)
(term-dynamic-complete-filename)
(term-dynamic-complete-as-filename)
(term-dynamic-simple-complete): Replace one arm ifs with whens or
unlesses.
2006-05-29 06:11:33 +00:00
|
|
|
|
(when (term-match-partial-filename)
|
|
|
|
|
(prog2 (or (eq (selected-window) (minibuffer-window))
|
|
|
|
|
(message "Completing file name..."))
|
|
|
|
|
(term-dynamic-complete-as-filename))))
|
1994-10-13 06:30:49 +00:00
|
|
|
|
|
|
|
|
|
(defun term-dynamic-complete-as-filename ()
|
|
|
|
|
"Dynamically complete at point as a filename.
|
|
|
|
|
See `term-dynamic-complete-filename'. Returns t if successful."
|
|
|
|
|
(let* ((completion-ignore-case nil)
|
|
|
|
|
(completion-ignored-extensions term-completion-fignore)
|
|
|
|
|
(success t)
|
1997-03-12 00:23:49 +00:00
|
|
|
|
(dirsuffix (cond ((not term-completion-addsuffix) "")
|
|
|
|
|
((not (consp term-completion-addsuffix)) "/")
|
|
|
|
|
(t (car term-completion-addsuffix))))
|
|
|
|
|
(filesuffix (cond ((not term-completion-addsuffix) "")
|
|
|
|
|
((not (consp term-completion-addsuffix)) " ")
|
2003-02-04 12:29:42 +00:00
|
|
|
|
(t (cdr term-completion-addsuffix))))
|
1994-10-13 06:30:49 +00:00
|
|
|
|
(filename (or (term-match-partial-filename) ""))
|
|
|
|
|
(pathdir (file-name-directory filename))
|
|
|
|
|
(pathnondir (file-name-nondirectory filename))
|
|
|
|
|
(directory (if pathdir (term-directory pathdir) default-directory))
|
|
|
|
|
(completion (file-name-completion pathnondir directory))
|
|
|
|
|
(mini-flag (eq (selected-window) (minibuffer-window))))
|
|
|
|
|
(cond ((null completion)
|
|
|
|
|
(message "No completions of %s" filename)
|
|
|
|
|
(setq success nil))
|
|
|
|
|
((eq completion t) ; Means already completed "file".
|
(term-if-xemacs, term-ifnot-xemacs): Delete, replace
uses with a simple test.
(term-set-escape-char, term-mode, term-check-kill-echo-list)
(term-send-raw-string, term-send-raw, term-mouse-paste)
(term-char-mode, term-line-mode, term-exec, term-sentinel)
(term-handle-exit, term-read-input-ring)
(term-previous-matching-input-string)
(term-previous-matching-input-string-position)
(term-previous-matching-input-from-input)
(term-replace-by-expanded-history, term-send-input)
(term-skip-prompt, term-bol, term-send-invisible)
(term-kill-input, term-delchar-or-maybe-eof)
(term-backward-matching-input, term-check-source)
(term-proc-query, term-emulate-terminal)
(term-handle-colors-array, term-process-pager, term-pager-line)
(term-pager-bob, term-unwrap-line, term-word)
(term-dynamic-complete-filename)
(term-dynamic-complete-as-filename)
(term-dynamic-simple-complete): Replace one arm ifs with whens or
unlesses.
2006-05-29 06:11:33 +00:00
|
|
|
|
(when term-completion-addsuffix (insert " "))
|
1994-10-13 06:30:49 +00:00
|
|
|
|
(or mini-flag (message "Sole completion")))
|
|
|
|
|
((string-equal completion "") ; Means completion on "directory/".
|
|
|
|
|
(term-dynamic-list-filename-completions))
|
|
|
|
|
(t ; Completion string returned.
|
|
|
|
|
(let ((file (concat (file-name-as-directory directory) completion)))
|
|
|
|
|
(insert (substring (directory-file-name completion)
|
|
|
|
|
(length pathnondir)))
|
|
|
|
|
(cond ((symbolp (file-name-completion completion directory))
|
|
|
|
|
;; We inserted a unique completion.
|
1997-03-12 00:23:49 +00:00
|
|
|
|
(insert (if (file-directory-p file) dirsuffix filesuffix))
|
1994-10-13 06:30:49 +00:00
|
|
|
|
(or mini-flag (message "Completed")))
|
|
|
|
|
((and term-completion-recexact term-completion-addsuffix
|
|
|
|
|
(string-equal pathnondir completion)
|
|
|
|
|
(file-exists-p file))
|
|
|
|
|
;; It's not unique, but user wants shortest match.
|
1997-03-12 00:23:49 +00:00
|
|
|
|
(insert (if (file-directory-p file) dirsuffix filesuffix))
|
1994-10-13 06:30:49 +00:00
|
|
|
|
(or mini-flag (message "Completed shortest")))
|
|
|
|
|
((or term-completion-autolist
|
|
|
|
|
(string-equal pathnondir completion))
|
|
|
|
|
;; It's not unique, list possible completions.
|
|
|
|
|
(term-dynamic-list-filename-completions))
|
|
|
|
|
(t
|
|
|
|
|
(or mini-flag (message "Partially completed")))))))
|
|
|
|
|
success))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defun term-replace-by-expanded-filename ()
|
|
|
|
|
"Dynamically expand and complete the filename at point.
|
2005-06-16 16:11:46 +00:00
|
|
|
|
Replace the filename with an expanded, canonicalized and completed replacement.
|
1994-10-13 06:30:49 +00:00
|
|
|
|
\"Expanded\" means environment variables (e.g., $HOME) and `~'s are replaced
|
2005-06-16 16:11:46 +00:00
|
|
|
|
with the corresponding directories. \"Canonicalized\" means `..' and `.' are
|
1994-10-13 06:30:49 +00:00
|
|
|
|
removed, and the filename is made absolute instead of relative. For expansion
|
|
|
|
|
see `expand-file-name' and `substitute-in-file-name'. For completion see
|
|
|
|
|
`term-dynamic-complete-filename'."
|
|
|
|
|
(interactive)
|
|
|
|
|
(replace-match (expand-file-name (term-match-partial-filename)) t t)
|
|
|
|
|
(term-dynamic-complete-filename))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defun term-dynamic-list-filename-completions ()
|
|
|
|
|
"List in help buffer possible completions of the filename at point."
|
|
|
|
|
(interactive)
|
|
|
|
|
(let* ((completion-ignore-case nil)
|
|
|
|
|
(filename (or (term-match-partial-filename) ""))
|
|
|
|
|
(pathdir (file-name-directory filename))
|
|
|
|
|
(pathnondir (file-name-nondirectory filename))
|
|
|
|
|
(directory (if pathdir (term-directory pathdir) default-directory))
|
|
|
|
|
(completions (file-name-all-completions pathnondir directory)))
|
|
|
|
|
(if completions
|
|
|
|
|
(term-dynamic-list-completions completions)
|
|
|
|
|
(message "No completions of %s" filename))))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defun term-dynamic-list-completions (completions)
|
|
|
|
|
"List in help buffer sorted COMPLETIONS.
|
|
|
|
|
Typing SPC flushes the help buffer."
|
|
|
|
|
(let ((conf (current-window-configuration)))
|
|
|
|
|
(with-output-to-temp-buffer "*Completions*"
|
|
|
|
|
(display-completion-list (sort completions 'string-lessp)))
|
|
|
|
|
(message "Hit space to flush")
|
|
|
|
|
(let (key first)
|
* x-dnd.el (x-dnd-maybe-call-test-function):
* window.el (split-window-vertically):
* whitespace.el (whitespace-help-on):
* vc-rcs.el (vc-rcs-consult-headers):
* userlock.el (ask-user-about-lock-help)
(ask-user-about-supersession-help):
* type-break.el (type-break-force-mode-line-update):
* time-stamp.el (time-stamp-conv-warn):
* terminal.el (te-set-output-log, te-more-break, te-filter)
(te-sentinel,terminal-emulator):
* term.el (make-term, term-exec, term-sentinel, term-read-input-ring)
(term-write-input-ring, term-check-source, term-start-output-log):
(term-display-buffer-line, term-dynamic-list-completions):
(term-ansi-make-term, serial-term):
* subr.el (selective-display):
* strokes.el (strokes-xpm-to-compressed-string, strokes-decode-buffer)
(strokes-encode-buffer, strokes-xpm-for-compressed-string):
* speedbar.el (speedbar-buffers-tail-notes, speedbar-buffers-item-info)
(speedbar-reconfigure-keymaps, speedbar-add-localized-speedbar-support)
(speedbar-remove-localized-speedbar-support)
(speedbar-set-mode-line-format, speedbar-create-tag-hierarchy)
(speedbar-update-special-contents, speedbar-buffer-buttons-engine)
(speedbar-buffers-line-directory):
* simple.el (shell-command-on-region, append-to-buffer)
(prepend-to-buffer):
* shadowfile.el (shadow-save-todo-file):
* scroll-bar.el (scroll-bar-set-window-start, scroll-bar-drag-1)
(scroll-bar-maybe-set-window-start):
* sb-image.el (speedbar-image-dump):
* saveplace.el (save-place-alist-to-file, save-places-to-alist)
(load-save-place-alist-from-file):
* ps-samp.el (ps-print-message-from-summary):
* ps-print.el (ps-flush-output, ps-insert-file, ps-get-boundingbox)
(ps-background-image, ps-begin-job, ps-do-despool):
* ps-bdf.el (bdf-find-file, bdf-read-font-info):
* printing.el (pr-interface, pr-ps-file-print, pr-find-buffer-visiting)
(pr-ps-message-from-summary, pr-lpr-message-from-summary):
(pr-call-process, pr-file-list, pr-interface-save):
* novice.el (disabled-command-function)
(enable-command, disable-command):
* mouse.el (mouse-buffer-menu-alist):
* mouse-copy.el (mouse-kill-preserving-secondary):
* macros.el (kbd-macro-query):
* ledit.el (ledit-go-to-lisp, ledit-go-to-liszt):
* informat.el (batch-info-validate):
* ido.el (ido-copy-current-word, ido-initiate-auto-merge):
* hippie-exp.el (try-expand-dabbrev-visible):
* help-mode.el (help-make-xrefs):
* help-fns.el (describe-variable):
* generic-x.el (bat-generic-mode-run-as-comint):
* finder.el (finder-mouse-select):
* find-dired.el (find-dired-sentinel):
* filesets.el (filesets-file-close):
* files.el (list-directory):
* faces.el (list-faces-display, describe-face):
* facemenu.el (list-colors-display):
* ezimage.el (ezimage-image-association-dump, ezimage-image-dump):
* epg.el (epg--process-filter, epg-cancel):
* epa.el (epa--marked-keys, epa--select-keys, epa-display-info)
(epa--read-signature-type):
* emerge.el (emerge-copy-as-kill-A, emerge-copy-as-kill-B)
(emerge-file-names):
* ehelp.el (electric-helpify):
* ediff.el (ediff-regions-wordwise, ediff-regions-linewise):
* ediff-vers.el (rcs-ediff-view-revision):
* ediff-util.el (ediff-setup):
* ediff-mult.el (ediff-append-custom-diff):
* ediff-diff.el (ediff-exec-process, ediff-process-sentinel)
(ediff-wordify):
* echistory.el (Electric-command-history-redo-expression):
* dos-w32.el (find-file-not-found-set-buffer-file-coding-system):
* disp-table.el (describe-display-table):
* dired.el (dired-find-buffer-nocreate):
* dired-aux.el (dired-rename-subdir, dired-dwim-target-directory):
* dabbrev.el (dabbrev--same-major-mode-p):
* chistory.el (list-command-history):
* apropos.el (apropos-documentation):
* allout.el (allout-obtain-passphrase):
(allout-copy-exposed-to-buffer):
(allout-verify-passphrase): Use with-current-buffer.
2009-11-13 22:19:45 +00:00
|
|
|
|
(if (with-current-buffer (get-buffer "*Completions*")
|
1994-10-13 06:30:49 +00:00
|
|
|
|
(setq key (read-key-sequence nil)
|
|
|
|
|
first (aref key 0))
|
|
|
|
|
(and (consp first)
|
|
|
|
|
(eq (window-buffer (posn-window (event-start first)))
|
|
|
|
|
(get-buffer "*Completions*"))
|
2014-04-23 02:22:06 +00:00
|
|
|
|
(memq (key-binding key)
|
2020-08-24 01:28:48 +00:00
|
|
|
|
'(choose-completion))))
|
2014-04-23 02:22:06 +00:00
|
|
|
|
;; If the user does choose-completion with the mouse,
|
1994-10-13 06:30:49 +00:00
|
|
|
|
;; execute the command, then delete the completion window.
|
|
|
|
|
(progn
|
2009-10-24 03:49:44 +00:00
|
|
|
|
(choose-completion first)
|
1994-10-13 06:30:49 +00:00
|
|
|
|
(set-window-configuration conf))
|
2005-07-04 02:35:55 +00:00
|
|
|
|
(if (eq first ?\s)
|
1994-10-13 06:30:49 +00:00
|
|
|
|
(set-window-configuration conf)
|
2015-07-25 16:54:42 +00:00
|
|
|
|
(setq unread-command-events
|
|
|
|
|
(nconc (listify-key-sequence key)
|
|
|
|
|
unread-command-events)))))))
|
1997-04-02 03:46:39 +00:00
|
|
|
|
|
2009-08-16 15:39:11 +00:00
|
|
|
|
;; I need a make-term that doesn't surround with *s -mm
|
1997-04-02 03:46:39 +00:00
|
|
|
|
(defun term-ansi-make-term (name program &optional startfile &rest switches)
|
2010-08-02 04:14:26 +00:00
|
|
|
|
"Make a term process NAME in a buffer, running PROGRAM.
|
1997-04-02 03:46:39 +00:00
|
|
|
|
The name of the buffer is NAME.
|
|
|
|
|
If there is already a running process in that buffer, it is not restarted.
|
|
|
|
|
Optional third arg STARTFILE is the name of a file to send the contents of to
|
|
|
|
|
the process. Any more args are arguments to PROGRAM."
|
|
|
|
|
(let ((buffer (get-buffer-create name )))
|
|
|
|
|
;; If no process, or nuked process, crank up a new one and put buffer in
|
|
|
|
|
;; term mode. Otherwise, leave buffer and existing process alone.
|
|
|
|
|
(cond ((not (term-check-proc buffer))
|
* x-dnd.el (x-dnd-maybe-call-test-function):
* window.el (split-window-vertically):
* whitespace.el (whitespace-help-on):
* vc-rcs.el (vc-rcs-consult-headers):
* userlock.el (ask-user-about-lock-help)
(ask-user-about-supersession-help):
* type-break.el (type-break-force-mode-line-update):
* time-stamp.el (time-stamp-conv-warn):
* terminal.el (te-set-output-log, te-more-break, te-filter)
(te-sentinel,terminal-emulator):
* term.el (make-term, term-exec, term-sentinel, term-read-input-ring)
(term-write-input-ring, term-check-source, term-start-output-log):
(term-display-buffer-line, term-dynamic-list-completions):
(term-ansi-make-term, serial-term):
* subr.el (selective-display):
* strokes.el (strokes-xpm-to-compressed-string, strokes-decode-buffer)
(strokes-encode-buffer, strokes-xpm-for-compressed-string):
* speedbar.el (speedbar-buffers-tail-notes, speedbar-buffers-item-info)
(speedbar-reconfigure-keymaps, speedbar-add-localized-speedbar-support)
(speedbar-remove-localized-speedbar-support)
(speedbar-set-mode-line-format, speedbar-create-tag-hierarchy)
(speedbar-update-special-contents, speedbar-buffer-buttons-engine)
(speedbar-buffers-line-directory):
* simple.el (shell-command-on-region, append-to-buffer)
(prepend-to-buffer):
* shadowfile.el (shadow-save-todo-file):
* scroll-bar.el (scroll-bar-set-window-start, scroll-bar-drag-1)
(scroll-bar-maybe-set-window-start):
* sb-image.el (speedbar-image-dump):
* saveplace.el (save-place-alist-to-file, save-places-to-alist)
(load-save-place-alist-from-file):
* ps-samp.el (ps-print-message-from-summary):
* ps-print.el (ps-flush-output, ps-insert-file, ps-get-boundingbox)
(ps-background-image, ps-begin-job, ps-do-despool):
* ps-bdf.el (bdf-find-file, bdf-read-font-info):
* printing.el (pr-interface, pr-ps-file-print, pr-find-buffer-visiting)
(pr-ps-message-from-summary, pr-lpr-message-from-summary):
(pr-call-process, pr-file-list, pr-interface-save):
* novice.el (disabled-command-function)
(enable-command, disable-command):
* mouse.el (mouse-buffer-menu-alist):
* mouse-copy.el (mouse-kill-preserving-secondary):
* macros.el (kbd-macro-query):
* ledit.el (ledit-go-to-lisp, ledit-go-to-liszt):
* informat.el (batch-info-validate):
* ido.el (ido-copy-current-word, ido-initiate-auto-merge):
* hippie-exp.el (try-expand-dabbrev-visible):
* help-mode.el (help-make-xrefs):
* help-fns.el (describe-variable):
* generic-x.el (bat-generic-mode-run-as-comint):
* finder.el (finder-mouse-select):
* find-dired.el (find-dired-sentinel):
* filesets.el (filesets-file-close):
* files.el (list-directory):
* faces.el (list-faces-display, describe-face):
* facemenu.el (list-colors-display):
* ezimage.el (ezimage-image-association-dump, ezimage-image-dump):
* epg.el (epg--process-filter, epg-cancel):
* epa.el (epa--marked-keys, epa--select-keys, epa-display-info)
(epa--read-signature-type):
* emerge.el (emerge-copy-as-kill-A, emerge-copy-as-kill-B)
(emerge-file-names):
* ehelp.el (electric-helpify):
* ediff.el (ediff-regions-wordwise, ediff-regions-linewise):
* ediff-vers.el (rcs-ediff-view-revision):
* ediff-util.el (ediff-setup):
* ediff-mult.el (ediff-append-custom-diff):
* ediff-diff.el (ediff-exec-process, ediff-process-sentinel)
(ediff-wordify):
* echistory.el (Electric-command-history-redo-expression):
* dos-w32.el (find-file-not-found-set-buffer-file-coding-system):
* disp-table.el (describe-display-table):
* dired.el (dired-find-buffer-nocreate):
* dired-aux.el (dired-rename-subdir, dired-dwim-target-directory):
* dabbrev.el (dabbrev--same-major-mode-p):
* chistory.el (list-command-history):
* apropos.el (apropos-documentation):
* allout.el (allout-obtain-passphrase):
(allout-copy-exposed-to-buffer):
(allout-verify-passphrase): Use with-current-buffer.
2009-11-13 22:19:45 +00:00
|
|
|
|
(with-current-buffer buffer
|
1997-04-02 03:46:39 +00:00
|
|
|
|
(term-mode)) ; Install local vars, mode, keymap, ...
|
|
|
|
|
(term-exec buffer name program startfile switches)))
|
|
|
|
|
buffer))
|
|
|
|
|
|
|
|
|
|
(defvar term-ansi-buffer-name nil)
|
|
|
|
|
(defvar term-ansi-default-program nil)
|
|
|
|
|
(defvar term-ansi-buffer-base-name nil)
|
|
|
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
|
(defun ansi-term (program &optional new-buffer-name)
|
2018-01-29 01:17:43 +00:00
|
|
|
|
"Start a terminal-emulator in a new buffer.
|
|
|
|
|
This is almost the same as `term' apart from always creating a new buffer,
|
2022-07-03 15:35:53 +00:00
|
|
|
|
and \\`C-x' being marked as a `term-escape-char'."
|
1997-04-02 03:46:39 +00:00
|
|
|
|
(interactive (list (read-from-minibuffer "Run program: "
|
|
|
|
|
(or explicit-shell-file-name
|
|
|
|
|
(getenv "ESHELL")
|
2017-08-04 04:05:00 +00:00
|
|
|
|
shell-file-name))))
|
1997-04-02 03:46:39 +00:00
|
|
|
|
|
|
|
|
|
;; Pick the name of the new buffer.
|
|
|
|
|
(setq term-ansi-buffer-name
|
|
|
|
|
(if new-buffer-name
|
|
|
|
|
new-buffer-name
|
|
|
|
|
(if term-ansi-buffer-base-name
|
|
|
|
|
(if (eq term-ansi-buffer-base-name t)
|
|
|
|
|
(file-name-nondirectory program)
|
|
|
|
|
term-ansi-buffer-base-name)
|
|
|
|
|
"ansi-term")))
|
|
|
|
|
|
|
|
|
|
(setq term-ansi-buffer-name (concat "*" term-ansi-buffer-name "*"))
|
|
|
|
|
|
|
|
|
|
;; In order to have more than one term active at a time
|
|
|
|
|
;; I'd like to have the term names have the *term-ansi-term<?>* form,
|
|
|
|
|
;; for now they have the *term-ansi-term*<?> form but we'll see...
|
|
|
|
|
|
|
|
|
|
(setq term-ansi-buffer-name (generate-new-buffer-name term-ansi-buffer-name))
|
2022-05-11 15:10:30 +00:00
|
|
|
|
(let ((prog (split-string-shell-command program)))
|
|
|
|
|
(setq term-ansi-buffer-name
|
|
|
|
|
(apply #'term-ansi-make-term term-ansi-buffer-name (car prog)
|
|
|
|
|
nil (cdr prog))))
|
1997-04-02 03:46:39 +00:00
|
|
|
|
|
|
|
|
|
(set-buffer term-ansi-buffer-name)
|
|
|
|
|
(term-mode)
|
|
|
|
|
(term-char-mode)
|
|
|
|
|
|
2012-11-15 06:17:56 +00:00
|
|
|
|
;; Historical baggage. A call to term-set-escape-char used to not
|
|
|
|
|
;; undo any previous call to t-s-e-c. Because of this, ansi-term
|
|
|
|
|
;; ended up with both C-x and C-c as escape chars. Who knows what
|
|
|
|
|
;; the original intention was, but people could have become used to
|
|
|
|
|
;; either. (Bug#12842)
|
|
|
|
|
(let (term-escape-char)
|
|
|
|
|
;; I wanna have find-file on C-x C-f -mm
|
|
|
|
|
;; your mileage may definitely vary, maybe it's better to put this in your
|
|
|
|
|
;; .emacs ...
|
|
|
|
|
(term-set-escape-char ?\C-x))
|
1997-04-02 03:46:39 +00:00
|
|
|
|
|
2016-06-26 16:51:22 +00:00
|
|
|
|
(switch-to-buffer term-ansi-buffer-name))
|
1997-04-02 03:46:39 +00:00
|
|
|
|
|
2008-06-13 08:04:56 +00:00
|
|
|
|
|
|
|
|
|
;;; Serial terminals
|
2009-08-16 15:39:11 +00:00
|
|
|
|
;; ===========================================================================
|
2008-06-13 08:04:56 +00:00
|
|
|
|
(defun serial-port-is-file-p ()
|
|
|
|
|
"Guess whether serial ports are files on this system.
|
|
|
|
|
Return t if this is a Unix-based system, where serial ports are
|
|
|
|
|
files, such as /dev/ttyS0.
|
|
|
|
|
Return nil if this is Windows or DOS, where serial ports have
|
|
|
|
|
special identifiers such as COM1."
|
2010-11-10 04:24:47 +00:00
|
|
|
|
(not (memq system-type '(windows-nt cygwin ms-dos))))
|
2008-06-13 08:04:56 +00:00
|
|
|
|
|
|
|
|
|
(defvar serial-name-history
|
|
|
|
|
(if (serial-port-is-file-p)
|
|
|
|
|
(or (when (file-exists-p "/dev/ttys0") (list "/dev/ttys0"))
|
|
|
|
|
(when (file-exists-p "/dev/ttyS0") (list "/dev/ttyS0")))
|
|
|
|
|
(list "COM1"))
|
|
|
|
|
"History of serial ports used by `serial-read-name'.")
|
|
|
|
|
|
|
|
|
|
(defvar serial-speed-history
|
2011-11-13 07:48:23 +00:00
|
|
|
|
;; Initialized with reasonable values for newbies.
|
2008-06-13 08:04:56 +00:00
|
|
|
|
(list "9600" ;; Given twice because 9600 b/s is the most common speed
|
|
|
|
|
"1200" "2400" "4800" "9600" "14400" "19200"
|
|
|
|
|
"28800" "38400" "57600" "115200")
|
|
|
|
|
"History of serial port speeds used by `serial-read-speed'.")
|
|
|
|
|
|
|
|
|
|
(defun serial-nice-speed-history ()
|
|
|
|
|
"Return `serial-speed-history' cleaned up for a mouse-menu."
|
|
|
|
|
(let ((x) (y))
|
|
|
|
|
(setq x
|
|
|
|
|
(sort
|
|
|
|
|
(copy-sequence serial-speed-history)
|
2011-05-23 17:57:17 +00:00
|
|
|
|
(lambda (a b) (when (and (stringp a) (stringp b))
|
|
|
|
|
(> (string-to-number a) (string-to-number b))))))
|
2008-06-13 08:04:56 +00:00
|
|
|
|
(dolist (i x) (when (not (equal i (car y))) (push i y)))
|
|
|
|
|
y))
|
|
|
|
|
|
|
|
|
|
(defconst serial-no-speed "nil"
|
|
|
|
|
"String for `serial-read-speed' for special serial ports.
|
|
|
|
|
If `serial-read-speed' reads this string from the user, it
|
|
|
|
|
returns nil, which is recognized by `serial-process-configure'
|
|
|
|
|
for special serial ports that cannot be configured.")
|
|
|
|
|
|
|
|
|
|
(defun serial-supported-or-barf ()
|
2010-08-02 04:14:26 +00:00
|
|
|
|
"Signal an error if serial processes are not supported."
|
2008-06-13 08:04:56 +00:00
|
|
|
|
(unless (fboundp 'make-serial-process)
|
|
|
|
|
(error "Serial processes are not supported on this system")))
|
|
|
|
|
|
|
|
|
|
(defun serial-read-name ()
|
|
|
|
|
"Read a serial port name from the user.
|
|
|
|
|
Try to be nice by providing useful defaults and history.
|
|
|
|
|
On Windows, prepend \\.\ to the port name unless it already
|
|
|
|
|
contains a backslash. This handles the legacy ports COM1-COM9 as
|
|
|
|
|
well as the newer ports COM10 and higher."
|
|
|
|
|
(serial-supported-or-barf)
|
|
|
|
|
(let* ((file-name-history serial-name-history)
|
|
|
|
|
(h (car file-name-history))
|
|
|
|
|
(x (if (serial-port-is-file-p)
|
|
|
|
|
(read-file-name
|
|
|
|
|
;; `prompt': The most recently used port is provided as
|
|
|
|
|
;; the default value, which is used when the user
|
|
|
|
|
;; simply presses return.
|
Use `format-prompt' when prompting with default values
* lisp/woman.el (woman-file-name):
* lisp/wid-edit.el (widget-file-prompt-value)
(widget-coding-system-prompt-value):
* lisp/w32-fns.el (w32-set-system-coding-system):
* lisp/vc/vc.el (vc-print-root-log):
* lisp/vc/vc-annotate.el (vc-annotate):
* lisp/vc/emerge.el (emerge-read-file-name):
* lisp/vc/ediff.el (ediff-directories)
(ediff-directory-revisions, ediff-directories3)
(ediff-merge-directories, )
(ediff-merge-directories-with-ancestor)
(ediff-merge-directory-revisions)
(ediff-merge-directory-revisions-with-ancestor)
(ediff-merge-revisions, ediff-merge-revisions-with-ancestor)
(ediff-revision):
* lisp/vc/ediff-util.el (ediff-toggle-regexp-match):
* lisp/vc/ediff-mult.el (ediff-filegroup-action):
* lisp/vc/add-log.el (prompt-for-change-log-name):
* lisp/textmodes/table.el (table-insert-row-column)
(table-span-cell, table-split-cell-horizontally)
(table-split-cell, table-justify, table-generate-source)
(table-insert-sequence, table-capture)
(table--read-from-minibuffer, table--query-justification):
* lisp/textmodes/sgml-mode.el (sgml-tag, sgml-tag-help):
* lisp/textmodes/reftex-ref.el (reftex-goto-label):
* lisp/textmodes/refer.el (refer-get-bib-files):
* lisp/textmodes/css-mode.el (css-lookup-symbol):
* lisp/term.el (serial-read-name, serial-read-speed):
* lisp/speedbar.el (speedbar-change-initial-expansion-list):
* lisp/simple.el (previous-matching-history-element)
(set-variable):
* lisp/ses.el (ses-read-cell, ses-set-column-width):
* lisp/replace.el (query-replace-read-from)
(occur-read-primary-args):
* lisp/rect.el (string-rectangle, string-insert-rectangle):
* lisp/progmodes/tcl.el (tcl-help-on-word):
* lisp/progmodes/sh-script.el (sh-set-shell):
* lisp/progmodes/python.el (python-eldoc-at-point):
* lisp/progmodes/octave.el (octave-completing-read)
(octave-update-function-file-comment, octave-insert-defun):
* lisp/progmodes/inf-lisp.el (lisp-symprompt):
* lisp/progmodes/cperl-mode.el (cperl-info-on-command)
(cperl-perldoc):
* lisp/progmodes/compile.el (compilation-find-file):
* lisp/net/rcirc.el (rcirc-prompt-for-encryption):
* lisp/net/eww.el (eww):
* lisp/net/browse-url.el (browse-url-with-browser-kind):
* lisp/man.el (man):
* lisp/mail/sendmail.el (sendmail-query-user-about-smtp):
* lisp/mail/mailalias.el (build-mail-aliases):
* lisp/mail/mailabbrev.el (merge-mail-abbrevs)
(rebuild-mail-abbrevs):
* lisp/locate.el (locate-prompt-for-search-string):
* lisp/isearch.el (isearch-occur):
* lisp/international/ogonek.el (ogonek-read-encoding)
(ogonek-read-prefix):
* lisp/international/mule.el (read-buffer-file-coding-system)
(set-terminal-coding-system, set-keyboard-coding-system)
(set-next-selection-coding-system, recode-region):
* lisp/international/mule-cmds.el ()
(universal-coding-system-argument, search-unencodable-char)
(select-safe-coding-system-interactively):
* lisp/info.el (Info-search, Info-search-backward, Info-menu):
* lisp/info-look.el (info-lookup-interactive-arguments):
* lisp/imenu.el (imenu--completion-buffer):
* lisp/ibuf-ext.el (mode, used-mode, ibuffer-mark-by-mode):
* lisp/hi-lock.el (hi-lock-unface-buffer)
(hi-lock-read-face-name):
* lisp/help.el (view-emacs-news, where-is):
* lisp/help-fns.el (describe-variable, describe-symbol)
(describe-keymap):
* lisp/gnus/mm-decode.el (mm-save-part):
* lisp/gnus/gnus-sum.el (gnus-summary-browse-url):
* lisp/gnus/gnus-group.el (gnus-group--read-bug-ids)
(gnus-group-set-current-level):
* lisp/frame.el (make-frame-on-monitor)
(close-display-connection, select-frame-by-name):
* lisp/format.el (format-encode-buffer, format-encode-region):
* lisp/files.el (recode-file-name):
* lisp/files-x.el (read-file-local-variable)
(read-file-local-variable-value, )
(read-file-local-variable-mode):
* lisp/ffap.el (ffap-menu-ask):
* lisp/faces.el (face-read-string):
* lisp/facemenu.el (facemenu-set-charset):
* lisp/erc/erc-dcc.el (erc-dcc-do-GET-command):
* lisp/emulation/edt-mapper.el (edt-mapper):
* lisp/emacs-lisp/trace.el (trace--read-args)
(trace-function-foreground, trace-function-background):
* lisp/emacs-lisp/smie.el (smie-config-set-indent):
* lisp/emacs-lisp/re-builder.el (reb-change-syntax):
* lisp/emacs-lisp/package.el (describe-package):
* lisp/emacs-lisp/find-func.el (read-library-name)
(find-function-read):
* lisp/emacs-lisp/ert.el (ert-read-test-name)
(ert-run-tests-interactively):
* lisp/emacs-lisp/disass.el (disassemble):
* lisp/emacs-lisp/debug.el (debug-on-entry)
(debug-on-variable-change):
* lisp/emacs-lisp/advice.el (ad-read-advised-function)
(ad-read-advice-class, ad-read-advice-name, ad-read-regexp):
* lisp/dired-x.el (dired--mark-suffix-interactive-spec):
* lisp/dired-aux.el (dired-diff):
* lisp/cus-edit.el (custom-variable-prompt, customize-mode)
(customize-changed-options):
* lisp/completion.el (interactive-completion-string-reader):
* lisp/calendar/timeclock.el (timeclock-ask-for-project):
* lisp/calc/calcalg3.el (calc-get-fit-variables):
* lisp/calc/calc-store.el (calc-edit-variable):
* lisp/calc/calc-bin.el (calc-word-size):
* lisp/bookmark.el (bookmark-set-internal):
* lisp/abbrev.el (read-abbrev-file): Use `format-prompt' for
prompting (bug#12443).
2020-09-06 14:56:44 +00:00
|
|
|
|
(format-prompt "Serial port" h)
|
2008-06-13 08:04:56 +00:00
|
|
|
|
;; `directory': Most systems have their serial ports
|
|
|
|
|
;; in the same directory, so start in the directory
|
|
|
|
|
;; of the most recently used port, or in a reasonable
|
|
|
|
|
;; default directory.
|
|
|
|
|
(or (and h (file-name-directory h))
|
|
|
|
|
(and (file-exists-p "/dev/") "/dev/")
|
|
|
|
|
(and (file-exists-p "/") "/"))
|
|
|
|
|
;; `default': This causes (read-file-name) to return
|
|
|
|
|
;; the empty string if he user simply presses return.
|
|
|
|
|
;; Using nil here may result in a default directory
|
|
|
|
|
;; of the current buffer, which is not useful for
|
|
|
|
|
;; serial port.
|
|
|
|
|
"")
|
|
|
|
|
(read-from-minibuffer
|
Use `format-prompt' when prompting with default values
* lisp/woman.el (woman-file-name):
* lisp/wid-edit.el (widget-file-prompt-value)
(widget-coding-system-prompt-value):
* lisp/w32-fns.el (w32-set-system-coding-system):
* lisp/vc/vc.el (vc-print-root-log):
* lisp/vc/vc-annotate.el (vc-annotate):
* lisp/vc/emerge.el (emerge-read-file-name):
* lisp/vc/ediff.el (ediff-directories)
(ediff-directory-revisions, ediff-directories3)
(ediff-merge-directories, )
(ediff-merge-directories-with-ancestor)
(ediff-merge-directory-revisions)
(ediff-merge-directory-revisions-with-ancestor)
(ediff-merge-revisions, ediff-merge-revisions-with-ancestor)
(ediff-revision):
* lisp/vc/ediff-util.el (ediff-toggle-regexp-match):
* lisp/vc/ediff-mult.el (ediff-filegroup-action):
* lisp/vc/add-log.el (prompt-for-change-log-name):
* lisp/textmodes/table.el (table-insert-row-column)
(table-span-cell, table-split-cell-horizontally)
(table-split-cell, table-justify, table-generate-source)
(table-insert-sequence, table-capture)
(table--read-from-minibuffer, table--query-justification):
* lisp/textmodes/sgml-mode.el (sgml-tag, sgml-tag-help):
* lisp/textmodes/reftex-ref.el (reftex-goto-label):
* lisp/textmodes/refer.el (refer-get-bib-files):
* lisp/textmodes/css-mode.el (css-lookup-symbol):
* lisp/term.el (serial-read-name, serial-read-speed):
* lisp/speedbar.el (speedbar-change-initial-expansion-list):
* lisp/simple.el (previous-matching-history-element)
(set-variable):
* lisp/ses.el (ses-read-cell, ses-set-column-width):
* lisp/replace.el (query-replace-read-from)
(occur-read-primary-args):
* lisp/rect.el (string-rectangle, string-insert-rectangle):
* lisp/progmodes/tcl.el (tcl-help-on-word):
* lisp/progmodes/sh-script.el (sh-set-shell):
* lisp/progmodes/python.el (python-eldoc-at-point):
* lisp/progmodes/octave.el (octave-completing-read)
(octave-update-function-file-comment, octave-insert-defun):
* lisp/progmodes/inf-lisp.el (lisp-symprompt):
* lisp/progmodes/cperl-mode.el (cperl-info-on-command)
(cperl-perldoc):
* lisp/progmodes/compile.el (compilation-find-file):
* lisp/net/rcirc.el (rcirc-prompt-for-encryption):
* lisp/net/eww.el (eww):
* lisp/net/browse-url.el (browse-url-with-browser-kind):
* lisp/man.el (man):
* lisp/mail/sendmail.el (sendmail-query-user-about-smtp):
* lisp/mail/mailalias.el (build-mail-aliases):
* lisp/mail/mailabbrev.el (merge-mail-abbrevs)
(rebuild-mail-abbrevs):
* lisp/locate.el (locate-prompt-for-search-string):
* lisp/isearch.el (isearch-occur):
* lisp/international/ogonek.el (ogonek-read-encoding)
(ogonek-read-prefix):
* lisp/international/mule.el (read-buffer-file-coding-system)
(set-terminal-coding-system, set-keyboard-coding-system)
(set-next-selection-coding-system, recode-region):
* lisp/international/mule-cmds.el ()
(universal-coding-system-argument, search-unencodable-char)
(select-safe-coding-system-interactively):
* lisp/info.el (Info-search, Info-search-backward, Info-menu):
* lisp/info-look.el (info-lookup-interactive-arguments):
* lisp/imenu.el (imenu--completion-buffer):
* lisp/ibuf-ext.el (mode, used-mode, ibuffer-mark-by-mode):
* lisp/hi-lock.el (hi-lock-unface-buffer)
(hi-lock-read-face-name):
* lisp/help.el (view-emacs-news, where-is):
* lisp/help-fns.el (describe-variable, describe-symbol)
(describe-keymap):
* lisp/gnus/mm-decode.el (mm-save-part):
* lisp/gnus/gnus-sum.el (gnus-summary-browse-url):
* lisp/gnus/gnus-group.el (gnus-group--read-bug-ids)
(gnus-group-set-current-level):
* lisp/frame.el (make-frame-on-monitor)
(close-display-connection, select-frame-by-name):
* lisp/format.el (format-encode-buffer, format-encode-region):
* lisp/files.el (recode-file-name):
* lisp/files-x.el (read-file-local-variable)
(read-file-local-variable-value, )
(read-file-local-variable-mode):
* lisp/ffap.el (ffap-menu-ask):
* lisp/faces.el (face-read-string):
* lisp/facemenu.el (facemenu-set-charset):
* lisp/erc/erc-dcc.el (erc-dcc-do-GET-command):
* lisp/emulation/edt-mapper.el (edt-mapper):
* lisp/emacs-lisp/trace.el (trace--read-args)
(trace-function-foreground, trace-function-background):
* lisp/emacs-lisp/smie.el (smie-config-set-indent):
* lisp/emacs-lisp/re-builder.el (reb-change-syntax):
* lisp/emacs-lisp/package.el (describe-package):
* lisp/emacs-lisp/find-func.el (read-library-name)
(find-function-read):
* lisp/emacs-lisp/ert.el (ert-read-test-name)
(ert-run-tests-interactively):
* lisp/emacs-lisp/disass.el (disassemble):
* lisp/emacs-lisp/debug.el (debug-on-entry)
(debug-on-variable-change):
* lisp/emacs-lisp/advice.el (ad-read-advised-function)
(ad-read-advice-class, ad-read-advice-name, ad-read-regexp):
* lisp/dired-x.el (dired--mark-suffix-interactive-spec):
* lisp/dired-aux.el (dired-diff):
* lisp/cus-edit.el (custom-variable-prompt, customize-mode)
(customize-changed-options):
* lisp/completion.el (interactive-completion-string-reader):
* lisp/calendar/timeclock.el (timeclock-ask-for-project):
* lisp/calc/calcalg3.el (calc-get-fit-variables):
* lisp/calc/calc-store.el (calc-edit-variable):
* lisp/calc/calc-bin.el (calc-word-size):
* lisp/bookmark.el (bookmark-set-internal):
* lisp/abbrev.el (read-abbrev-file): Use `format-prompt' for
prompting (bug#12443).
2020-09-06 14:56:44 +00:00
|
|
|
|
(format-prompt "Serial port" h)
|
2008-06-13 08:04:56 +00:00
|
|
|
|
nil nil nil '(file-name-history . 1) nil nil))))
|
|
|
|
|
(if (or (null x) (and (stringp x) (zerop (length x))))
|
|
|
|
|
(setq x h)
|
|
|
|
|
(setq serial-name-history file-name-history))
|
|
|
|
|
(when (or (null x) (and (stringp x) (zerop (length x))))
|
|
|
|
|
(error "No serial port selected"))
|
2019-02-24 21:19:59 +00:00
|
|
|
|
(when (not (or (serial-port-is-file-p)
|
Use string-search instead of string-match[-p]
`string-search` is easier to understand, less error-prone, much
faster, does not pollute the regexp cache, and does not mutate global
state. Use it where applicable and obviously safe (erring on the
conservative side).
* admin/authors.el (authors-canonical-file-name)
(authors-scan-change-log):
* lisp/apropos.el (apropos-command)
(apropos-documentation-property, apropos-symbols-internal):
* lisp/arc-mode.el (archive-arc-summarize)
(archive-zoo-summarize):
* lisp/calc/calc-aent.el (math-read-factor):
* lisp/calc/calc-ext.el (math-read-big-expr)
(math-format-nice-expr, math-format-number-fancy):
* lisp/calc/calc-forms.el (math-read-angle-brackets):
* lisp/calc/calc-graph.el (calc-graph-set-range):
* lisp/calc/calc-keypd.el (calc-keypad-press):
* lisp/calc/calc-lang.el (tex, latex, math-read-big-rec):
* lisp/calc/calc-prog.el (calc-fix-token-name)
(calc-user-define-permanent, math-define-exp):
* lisp/calc/calc.el (calc-record, calcDigit-key)
(calc-count-lines):
* lisp/calc/calcalg2.el (calc-solve-for, calc-poly-roots)
(math-do-integral):
* lisp/calc/calcalg3.el (calc-find-root, calc-find-minimum)
(calc-get-fit-variables):
* lisp/cedet/ede/speedbar.el (ede-tag-expand):
* lisp/cedet/semantic/java.el (semantic-java-expand-tag):
* lisp/cedet/semantic/sb.el (semantic-sb-show-extra)
(semantic-sb-expand-group):
* lisp/cedet/semantic/wisent/python.el
(semantic-python-instance-variable-p):
* lisp/cus-edit.el (get):
* lisp/descr-text.el (describe-text-sexp):
* lisp/dired-aux.el (dired-compress-file):
* lisp/dired-x.el (dired-make-relative-symlink):
* lisp/dired.el (dired-glob-regexp):
* lisp/dos-fns.el (dos-convert-standard-filename, dos-8+3-filename):
* lisp/edmacro.el (edmacro-format-keys):
* lisp/emacs-lisp/eieio-opt.el (eieio-sb-expand):
* lisp/emacs-lisp/eieio-speedbar.el (eieio-speedbar-object-expand):
* lisp/emacs-lisp/lisp-mnt.el (lm-keywords-list):
* lisp/emacs-lisp/warnings.el (display-warning):
* lisp/emulation/viper-ex.el (viper-ex-read-file-name)
(ex-print-display-lines):
* lisp/env.el (read-envvar-name, setenv):
* lisp/epa-mail.el (epa-mail-encrypt):
* lisp/epg.el (epg--start):
* lisp/erc/erc-backend.el (erc-parse-server-response):
* lisp/erc/erc-dcc.el (erc-dcc-member):
* lisp/erc/erc-speedbar.el (erc-speedbar-expand-server)
(erc-speedbar-expand-channel, erc-speedbar-expand-user):
* lisp/erc/erc.el (erc-send-input):
* lisp/eshell/em-glob.el (eshell-glob-entries):
* lisp/eshell/esh-proc.el (eshell-needs-pipe-p):
* lisp/eshell/esh-util.el (eshell-convert):
* lisp/eshell/esh-var.el (eshell-envvar-names):
* lisp/faces.el (x-resolve-font-name):
* lisp/ffap.el (ffap-file-at-point):
* lisp/files.el (wildcard-to-regexp, shell-quote-wildcard-pattern):
* lisp/forms.el (forms--update):
* lisp/frameset.el (frameset-filter-unshelve-param):
* lisp/gnus/gnus-art.el (article-decode-charset):
* lisp/gnus/gnus-kill.el (gnus-kill-parse-rn-kill-file):
* lisp/gnus/gnus-mlspl.el (gnus-group-split-fancy):
* lisp/gnus/gnus-msg.el (gnus-summary-resend-message-insert-gcc)
(gnus-inews-insert-gcc):
* lisp/gnus/gnus-rfc1843.el (rfc1843-decode-article-body):
* lisp/gnus/gnus-search.el (gnus-search-indexed-parse-output)
(gnus-search--complete-key-data):
* lisp/gnus/gnus-spec.el (gnus-parse-simple-format):
* lisp/gnus/gnus-sum.el (gnus-summary-refer-article):
* lisp/gnus/gnus-util.el (gnus-extract-address-components)
(gnus-newsgroup-directory-form):
* lisp/gnus/gnus-uu.el (gnus-uu-grab-view):
* lisp/gnus/gnus.el (gnus-group-native-p, gnus-short-group-name):
* lisp/gnus/message.el (message-check-news-header-syntax)
(message-make-message-id, message-user-mail-address)
(message-make-fqdn, message-get-reply-headers, message-followup):
* lisp/gnus/mm-decode.el (mm-dissect-buffer):
* lisp/gnus/nnheader.el (nnheader-insert):
* lisp/gnus/nnimap.el (nnimap-process-quirk)
(nnimap-imap-ranges-to-gnus-ranges):
* lisp/gnus/nnmaildir.el (nnmaildir--ensure-suffix):
* lisp/gnus/nnmairix.el (nnmairix-determine-original-group-from-path):
* lisp/gnus/nnrss.el (nnrss-match-macro):
* lisp/gnus/nntp.el (nntp-find-group-and-number):
* lisp/help-fns.el (help--symbol-completion-table-affixation):
* lisp/help.el (help-function-arglist):
* lisp/hippie-exp.el (he-concat-directory-file-name):
* lisp/htmlfontify.el (hfy-relstub):
* lisp/ido.el (ido-make-prompt, ido-complete, ido-copy-current-word)
(ido-exhibit):
* lisp/image/image-converter.el (image-convert-p):
* lisp/info-xref.el (info-xref-docstrings):
* lisp/info.el (Info-toc-build, Info-follow-reference)
(Info-backward-node, Info-finder-find-node)
(Info-speedbar-expand-node):
* lisp/international/mule-diag.el (print-fontset-element):
* lisp/language/korea-util.el (default-korean-keyboard):
* lisp/linum.el (linum-after-change):
* lisp/mail/ietf-drums.el (ietf-drums-parse-address):
* lisp/mail/mail-utils.el (mail-dont-reply-to):
* lisp/mail/rfc2047.el (rfc2047-encode-1, rfc2047-decode-string):
* lisp/mail/rfc2231.el (rfc2231-parse-string):
* lisp/mail/rmailkwd.el (rmail-set-label):
* lisp/mail/rmailsum.el (rmail-header-summary):
* lisp/mail/smtpmail.el (smtpmail-maybe-append-domain)
(smtpmail-user-mail-address):
* lisp/mail/uce.el (uce-reply-to-uce):
* lisp/man.el (Man-default-man-entry):
* lisp/mh-e/mh-alias.el (mh-alias-gecos-name)
(mh-alias-minibuffer-confirm-address):
* lisp/mh-e/mh-comp.el (mh-forwarded-letter-subject):
* lisp/mh-e/mh-speed.el (mh-speed-parse-flists-output):
* lisp/mh-e/mh-utils.el (mh-collect-folder-names-filter)
(mh-folder-completion-function):
* lisp/minibuffer.el (completion--make-envvar-table)
(completion-file-name-table, completion-flex-try-completion)
(completion-flex-all-completions):
* lisp/mpc.el (mpc--proc-quote-string, mpc-cmd-special-tag-p)
(mpc-constraints-tag-lookup):
* lisp/net/ange-ftp.el (ange-ftp-send-cmd)
(ange-ftp-allow-child-lookup):
* lisp/net/mailcap.el (mailcap-mime-types):
* lisp/net/mairix.el (mairix-search-thread-this-article):
* lisp/net/pop3.el (pop3-open-server):
* lisp/net/soap-client.el (soap-decode-xs-complex-type):
* lisp/net/socks.el (socks-filter):
* lisp/nxml/nxml-outln.el (nxml-highlighted-qname):
* lisp/nxml/rng-cmpct.el (rng-c-expand-name, rng-c-expand-datatype):
* lisp/nxml/rng-uri.el (rng-uri-file-name-1):
* lisp/obsolete/complete.el (partial-completion-mode)
(PC-do-completion):
* lisp/obsolete/longlines.el (longlines-encode-string):
* lisp/obsolete/nnir.el (nnir-compose-result):
* lisp/obsolete/terminal.el (te-quote-arg-for-sh):
* lisp/obsolete/tpu-edt.el (tpu-check-search-case):
* lisp/obsolete/url-ns.el (isPlainHostName):
* lisp/pcmpl-unix.el (pcomplete/scp):
* lisp/play/dunnet.el (dun-listify-string2, dun-get-path)
(dun-unix-parse, dun-doassign, dun-cat, dun-batch-unix-interface):
* lisp/progmodes/ebnf2ps.el: (ebnf-eps-header-footer-comment):
* lisp/progmodes/gdb-mi.el (gdb-var-delete)
(gdb-speedbar-expand-node, gdbmi-bnf-incomplete-record-result):
* lisp/progmodes/gud.el (gud-find-expr):
* lisp/progmodes/idlw-help.el (idlwave-do-context-help1):
* lisp/progmodes/idlw-shell.el (idlwave-shell-mode)
(idlwave-shell-filter-hidden-output, idlwave-shell-filter):
* lisp/progmodes/idlwave.el (idlwave-skip-label-or-case)
(idlwave-routine-info):
* lisp/progmodes/octave.el (inferior-octave-completion-at-point):
* lisp/progmodes/sh-script.el (sh-add-completer):
* lisp/progmodes/sql.el (defun):
* lisp/progmodes/xscheme.el (xscheme-process-filter):
* lisp/replace.el (query-replace-compile-replacement)
(map-query-replace-regexp):
* lisp/shell.el (shell--command-completion-data)
(shell-environment-variable-completion):
* lisp/simple.el (display-message-or-buffer):
* lisp/speedbar.el (speedbar-dired, speedbar-tag-file)
(speedbar-tag-expand):
* lisp/subr.el (split-string-and-unquote):
* lisp/tar-mode.el (tar-extract):
* lisp/term.el (term-command-hook, serial-read-name):
* lisp/textmodes/bibtex.el (bibtex-print-help-message):
* lisp/textmodes/ispell.el (ispell-lookup-words, ispell-filter)
(ispell-parse-output, ispell-buffer-local-parsing):
* lisp/textmodes/reftex-cite.el (reftex-do-citation):
* lisp/textmodes/reftex-parse.el (reftex-notice-new):
* lisp/textmodes/reftex-ref.el (reftex-show-entry):
* lisp/textmodes/reftex.el (reftex-compile-variables):
* lisp/textmodes/tex-mode.el (tex-send-command)
(tex-start-tex, tex-append):
* lisp/thingatpt.el (thing-at-point-url-at-point):
* lisp/tmm.el (tmm-add-one-shortcut):
* lisp/transient.el (transient-format-key):
* lisp/url/url-auth.el (url-basic-auth)
(url-digest-auth-directory-id-assoc):
* lisp/url/url-news.el (url-news):
* lisp/url/url-util.el (url-parse-query-string):
* lisp/vc/vc-cvs.el (vc-cvs-parse-entry):
* lisp/wid-browse.el (widget-browse-sexp):
* lisp/woman.el (woman-parse-colon-path, woman-mini-help)
(WoMan-getpage-in-background, woman-negative-vertical-space):
* lisp/xml.el:
* test/lisp/emacs-lisp/check-declare-tests.el
(check-declare-tests-warn):
* test/lisp/files-tests.el
(files-tests-file-name-non-special-dired-compress-handler):
* test/lisp/net/network-stream-tests.el (server-process-filter):
* test/src/coding-tests.el (ert-test-unibyte-buffer-dos-eol-decode):
Use `string-search` instead of `string-match` and `string-match-p`.
2021-08-09 09:20:00 +00:00
|
|
|
|
(string-search "\\" x)))
|
2019-02-24 21:19:59 +00:00
|
|
|
|
(setq x (concat "\\\\.\\" x)))
|
2008-06-13 08:04:56 +00:00
|
|
|
|
x))
|
|
|
|
|
|
|
|
|
|
(defun serial-read-speed ()
|
|
|
|
|
"Read a serial port speed (in bits per second) from the user.
|
|
|
|
|
Try to be nice by providing useful defaults and history."
|
|
|
|
|
(serial-supported-or-barf)
|
|
|
|
|
(let* ((history serial-speed-history)
|
|
|
|
|
(h (car history))
|
|
|
|
|
(x (read-from-minibuffer
|
|
|
|
|
(cond ((string= h serial-no-speed)
|
|
|
|
|
"Speed (default nil = set by port): ")
|
|
|
|
|
(h
|
Use `format-prompt' when prompting with default values
* lisp/woman.el (woman-file-name):
* lisp/wid-edit.el (widget-file-prompt-value)
(widget-coding-system-prompt-value):
* lisp/w32-fns.el (w32-set-system-coding-system):
* lisp/vc/vc.el (vc-print-root-log):
* lisp/vc/vc-annotate.el (vc-annotate):
* lisp/vc/emerge.el (emerge-read-file-name):
* lisp/vc/ediff.el (ediff-directories)
(ediff-directory-revisions, ediff-directories3)
(ediff-merge-directories, )
(ediff-merge-directories-with-ancestor)
(ediff-merge-directory-revisions)
(ediff-merge-directory-revisions-with-ancestor)
(ediff-merge-revisions, ediff-merge-revisions-with-ancestor)
(ediff-revision):
* lisp/vc/ediff-util.el (ediff-toggle-regexp-match):
* lisp/vc/ediff-mult.el (ediff-filegroup-action):
* lisp/vc/add-log.el (prompt-for-change-log-name):
* lisp/textmodes/table.el (table-insert-row-column)
(table-span-cell, table-split-cell-horizontally)
(table-split-cell, table-justify, table-generate-source)
(table-insert-sequence, table-capture)
(table--read-from-minibuffer, table--query-justification):
* lisp/textmodes/sgml-mode.el (sgml-tag, sgml-tag-help):
* lisp/textmodes/reftex-ref.el (reftex-goto-label):
* lisp/textmodes/refer.el (refer-get-bib-files):
* lisp/textmodes/css-mode.el (css-lookup-symbol):
* lisp/term.el (serial-read-name, serial-read-speed):
* lisp/speedbar.el (speedbar-change-initial-expansion-list):
* lisp/simple.el (previous-matching-history-element)
(set-variable):
* lisp/ses.el (ses-read-cell, ses-set-column-width):
* lisp/replace.el (query-replace-read-from)
(occur-read-primary-args):
* lisp/rect.el (string-rectangle, string-insert-rectangle):
* lisp/progmodes/tcl.el (tcl-help-on-word):
* lisp/progmodes/sh-script.el (sh-set-shell):
* lisp/progmodes/python.el (python-eldoc-at-point):
* lisp/progmodes/octave.el (octave-completing-read)
(octave-update-function-file-comment, octave-insert-defun):
* lisp/progmodes/inf-lisp.el (lisp-symprompt):
* lisp/progmodes/cperl-mode.el (cperl-info-on-command)
(cperl-perldoc):
* lisp/progmodes/compile.el (compilation-find-file):
* lisp/net/rcirc.el (rcirc-prompt-for-encryption):
* lisp/net/eww.el (eww):
* lisp/net/browse-url.el (browse-url-with-browser-kind):
* lisp/man.el (man):
* lisp/mail/sendmail.el (sendmail-query-user-about-smtp):
* lisp/mail/mailalias.el (build-mail-aliases):
* lisp/mail/mailabbrev.el (merge-mail-abbrevs)
(rebuild-mail-abbrevs):
* lisp/locate.el (locate-prompt-for-search-string):
* lisp/isearch.el (isearch-occur):
* lisp/international/ogonek.el (ogonek-read-encoding)
(ogonek-read-prefix):
* lisp/international/mule.el (read-buffer-file-coding-system)
(set-terminal-coding-system, set-keyboard-coding-system)
(set-next-selection-coding-system, recode-region):
* lisp/international/mule-cmds.el ()
(universal-coding-system-argument, search-unencodable-char)
(select-safe-coding-system-interactively):
* lisp/info.el (Info-search, Info-search-backward, Info-menu):
* lisp/info-look.el (info-lookup-interactive-arguments):
* lisp/imenu.el (imenu--completion-buffer):
* lisp/ibuf-ext.el (mode, used-mode, ibuffer-mark-by-mode):
* lisp/hi-lock.el (hi-lock-unface-buffer)
(hi-lock-read-face-name):
* lisp/help.el (view-emacs-news, where-is):
* lisp/help-fns.el (describe-variable, describe-symbol)
(describe-keymap):
* lisp/gnus/mm-decode.el (mm-save-part):
* lisp/gnus/gnus-sum.el (gnus-summary-browse-url):
* lisp/gnus/gnus-group.el (gnus-group--read-bug-ids)
(gnus-group-set-current-level):
* lisp/frame.el (make-frame-on-monitor)
(close-display-connection, select-frame-by-name):
* lisp/format.el (format-encode-buffer, format-encode-region):
* lisp/files.el (recode-file-name):
* lisp/files-x.el (read-file-local-variable)
(read-file-local-variable-value, )
(read-file-local-variable-mode):
* lisp/ffap.el (ffap-menu-ask):
* lisp/faces.el (face-read-string):
* lisp/facemenu.el (facemenu-set-charset):
* lisp/erc/erc-dcc.el (erc-dcc-do-GET-command):
* lisp/emulation/edt-mapper.el (edt-mapper):
* lisp/emacs-lisp/trace.el (trace--read-args)
(trace-function-foreground, trace-function-background):
* lisp/emacs-lisp/smie.el (smie-config-set-indent):
* lisp/emacs-lisp/re-builder.el (reb-change-syntax):
* lisp/emacs-lisp/package.el (describe-package):
* lisp/emacs-lisp/find-func.el (read-library-name)
(find-function-read):
* lisp/emacs-lisp/ert.el (ert-read-test-name)
(ert-run-tests-interactively):
* lisp/emacs-lisp/disass.el (disassemble):
* lisp/emacs-lisp/debug.el (debug-on-entry)
(debug-on-variable-change):
* lisp/emacs-lisp/advice.el (ad-read-advised-function)
(ad-read-advice-class, ad-read-advice-name, ad-read-regexp):
* lisp/dired-x.el (dired--mark-suffix-interactive-spec):
* lisp/dired-aux.el (dired-diff):
* lisp/cus-edit.el (custom-variable-prompt, customize-mode)
(customize-changed-options):
* lisp/completion.el (interactive-completion-string-reader):
* lisp/calendar/timeclock.el (timeclock-ask-for-project):
* lisp/calc/calcalg3.el (calc-get-fit-variables):
* lisp/calc/calc-store.el (calc-edit-variable):
* lisp/calc/calc-bin.el (calc-word-size):
* lisp/bookmark.el (bookmark-set-internal):
* lisp/abbrev.el (read-abbrev-file): Use `format-prompt' for
prompting (bug#12443).
2020-09-06 14:56:44 +00:00
|
|
|
|
(format-prompt "Speed" (format "%s b/s" h)))
|
2021-09-21 15:52:53 +00:00
|
|
|
|
(t "Speed (b/s): "))
|
2008-06-13 08:04:56 +00:00
|
|
|
|
nil nil nil '(history . 1) nil nil)))
|
|
|
|
|
(when (or (null x) (and (stringp x) (zerop (length x))))
|
|
|
|
|
(setq x h))
|
|
|
|
|
(when (or (null x) (not (stringp x)) (zerop (length x)))
|
|
|
|
|
(error "Invalid speed"))
|
|
|
|
|
(if (string= x serial-no-speed)
|
|
|
|
|
(setq x nil)
|
|
|
|
|
(setq x (string-to-number x))
|
|
|
|
|
(when (or (null x) (not (integerp x)) (<= x 0))
|
|
|
|
|
(error "Invalid speed")))
|
|
|
|
|
(setq serial-speed-history history)
|
|
|
|
|
x))
|
|
|
|
|
|
|
|
|
|
;;;###autoload
|
2019-07-27 12:18:27 +00:00
|
|
|
|
(defun serial-term (port speed &optional line-mode)
|
2008-06-13 08:04:56 +00:00
|
|
|
|
"Start a terminal-emulator for a serial port in a new buffer.
|
|
|
|
|
PORT is the path or name of the serial port. For example, this
|
|
|
|
|
could be \"/dev/ttyS0\" on Unix. On Windows, this could be
|
|
|
|
|
\"COM1\" or \"\\\\.\\COM10\".
|
2019-07-27 12:18:27 +00:00
|
|
|
|
|
2008-06-13 08:04:56 +00:00
|
|
|
|
SPEED is the speed of the serial port in bits per second. 9600
|
|
|
|
|
is a common value. SPEED can be nil, see
|
|
|
|
|
`serial-process-configure' for details.
|
2019-07-27 12:18:27 +00:00
|
|
|
|
|
|
|
|
|
Usually `term-char-mode' is used, but if LINE-MODE (the prefix
|
|
|
|
|
when used interactively) is non-nil, `term-line-mode' is used
|
|
|
|
|
instead.
|
|
|
|
|
|
2008-06-13 08:04:56 +00:00
|
|
|
|
The buffer is in Term mode; see `term-mode' for the commands to
|
|
|
|
|
use in that buffer.
|
2019-07-27 12:18:27 +00:00
|
|
|
|
|
2008-06-13 08:04:56 +00:00
|
|
|
|
\\<term-raw-map>Type \\[switch-to-buffer] to switch to another buffer."
|
2019-07-27 12:18:27 +00:00
|
|
|
|
(interactive (list (serial-read-name) (serial-read-speed)
|
|
|
|
|
current-prefix-arg))
|
2008-06-13 08:04:56 +00:00
|
|
|
|
(serial-supported-or-barf)
|
|
|
|
|
(let* ((process (make-serial-process
|
|
|
|
|
:port port
|
|
|
|
|
:speed speed
|
|
|
|
|
:coding 'no-conversion
|
|
|
|
|
:noquery t))
|
|
|
|
|
(buffer (process-buffer process)))
|
* x-dnd.el (x-dnd-maybe-call-test-function):
* window.el (split-window-vertically):
* whitespace.el (whitespace-help-on):
* vc-rcs.el (vc-rcs-consult-headers):
* userlock.el (ask-user-about-lock-help)
(ask-user-about-supersession-help):
* type-break.el (type-break-force-mode-line-update):
* time-stamp.el (time-stamp-conv-warn):
* terminal.el (te-set-output-log, te-more-break, te-filter)
(te-sentinel,terminal-emulator):
* term.el (make-term, term-exec, term-sentinel, term-read-input-ring)
(term-write-input-ring, term-check-source, term-start-output-log):
(term-display-buffer-line, term-dynamic-list-completions):
(term-ansi-make-term, serial-term):
* subr.el (selective-display):
* strokes.el (strokes-xpm-to-compressed-string, strokes-decode-buffer)
(strokes-encode-buffer, strokes-xpm-for-compressed-string):
* speedbar.el (speedbar-buffers-tail-notes, speedbar-buffers-item-info)
(speedbar-reconfigure-keymaps, speedbar-add-localized-speedbar-support)
(speedbar-remove-localized-speedbar-support)
(speedbar-set-mode-line-format, speedbar-create-tag-hierarchy)
(speedbar-update-special-contents, speedbar-buffer-buttons-engine)
(speedbar-buffers-line-directory):
* simple.el (shell-command-on-region, append-to-buffer)
(prepend-to-buffer):
* shadowfile.el (shadow-save-todo-file):
* scroll-bar.el (scroll-bar-set-window-start, scroll-bar-drag-1)
(scroll-bar-maybe-set-window-start):
* sb-image.el (speedbar-image-dump):
* saveplace.el (save-place-alist-to-file, save-places-to-alist)
(load-save-place-alist-from-file):
* ps-samp.el (ps-print-message-from-summary):
* ps-print.el (ps-flush-output, ps-insert-file, ps-get-boundingbox)
(ps-background-image, ps-begin-job, ps-do-despool):
* ps-bdf.el (bdf-find-file, bdf-read-font-info):
* printing.el (pr-interface, pr-ps-file-print, pr-find-buffer-visiting)
(pr-ps-message-from-summary, pr-lpr-message-from-summary):
(pr-call-process, pr-file-list, pr-interface-save):
* novice.el (disabled-command-function)
(enable-command, disable-command):
* mouse.el (mouse-buffer-menu-alist):
* mouse-copy.el (mouse-kill-preserving-secondary):
* macros.el (kbd-macro-query):
* ledit.el (ledit-go-to-lisp, ledit-go-to-liszt):
* informat.el (batch-info-validate):
* ido.el (ido-copy-current-word, ido-initiate-auto-merge):
* hippie-exp.el (try-expand-dabbrev-visible):
* help-mode.el (help-make-xrefs):
* help-fns.el (describe-variable):
* generic-x.el (bat-generic-mode-run-as-comint):
* finder.el (finder-mouse-select):
* find-dired.el (find-dired-sentinel):
* filesets.el (filesets-file-close):
* files.el (list-directory):
* faces.el (list-faces-display, describe-face):
* facemenu.el (list-colors-display):
* ezimage.el (ezimage-image-association-dump, ezimage-image-dump):
* epg.el (epg--process-filter, epg-cancel):
* epa.el (epa--marked-keys, epa--select-keys, epa-display-info)
(epa--read-signature-type):
* emerge.el (emerge-copy-as-kill-A, emerge-copy-as-kill-B)
(emerge-file-names):
* ehelp.el (electric-helpify):
* ediff.el (ediff-regions-wordwise, ediff-regions-linewise):
* ediff-vers.el (rcs-ediff-view-revision):
* ediff-util.el (ediff-setup):
* ediff-mult.el (ediff-append-custom-diff):
* ediff-diff.el (ediff-exec-process, ediff-process-sentinel)
(ediff-wordify):
* echistory.el (Electric-command-history-redo-expression):
* dos-w32.el (find-file-not-found-set-buffer-file-coding-system):
* disp-table.el (describe-display-table):
* dired.el (dired-find-buffer-nocreate):
* dired-aux.el (dired-rename-subdir, dired-dwim-target-directory):
* dabbrev.el (dabbrev--same-major-mode-p):
* chistory.el (list-command-history):
* apropos.el (apropos-documentation):
* allout.el (allout-obtain-passphrase):
(allout-copy-exposed-to-buffer):
(allout-verify-passphrase): Use with-current-buffer.
2009-11-13 22:19:45 +00:00
|
|
|
|
(with-current-buffer buffer
|
2008-06-13 08:04:56 +00:00
|
|
|
|
(term-mode)
|
2019-07-27 12:18:27 +00:00
|
|
|
|
(unless line-mode
|
|
|
|
|
(term-char-mode))
|
2008-06-13 08:04:56 +00:00
|
|
|
|
(goto-char (point-max))
|
|
|
|
|
(set-marker (process-mark process) (point))
|
2019-02-24 21:19:59 +00:00
|
|
|
|
(set-process-filter process #'term-emulate-terminal)
|
|
|
|
|
(set-process-sentinel process #'term-sentinel))
|
2008-06-13 08:04:56 +00:00
|
|
|
|
(switch-to-buffer buffer)
|
|
|
|
|
buffer))
|
|
|
|
|
|
|
|
|
|
(defvar serial-mode-line-speed-menu nil)
|
|
|
|
|
(defvar serial-mode-line-config-menu nil)
|
|
|
|
|
|
|
|
|
|
(defun serial-speed ()
|
|
|
|
|
"Return the speed of the serial port of the current buffer's process.
|
|
|
|
|
The return value may be nil for a special serial port."
|
|
|
|
|
(process-contact (get-buffer-process (current-buffer)) :speed))
|
|
|
|
|
|
|
|
|
|
(defun serial-mode-line-speed-menu-1 (event)
|
|
|
|
|
(interactive "e")
|
|
|
|
|
(save-selected-window
|
|
|
|
|
(select-window (posn-window (event-start event)))
|
|
|
|
|
(serial-update-speed-menu)
|
|
|
|
|
(let* ((selection (serial-mode-line-speed-menu event))
|
|
|
|
|
(binding (and selection (lookup-key serial-mode-line-speed-menu
|
|
|
|
|
(vector (car selection))))))
|
|
|
|
|
(when binding (call-interactively binding)))))
|
|
|
|
|
|
|
|
|
|
(defun serial-mode-line-speed-menu (event)
|
|
|
|
|
(x-popup-menu event serial-mode-line-speed-menu))
|
|
|
|
|
|
|
|
|
|
(defun serial-update-speed-menu ()
|
|
|
|
|
(setq serial-mode-line-speed-menu (make-sparse-keymap "Speed (b/s)"))
|
|
|
|
|
(define-key serial-mode-line-speed-menu [serial-mode-line-speed-menu-other]
|
|
|
|
|
'(menu-item "Other..."
|
|
|
|
|
(lambda (event) (interactive "e")
|
|
|
|
|
(let ((speed (serial-read-speed)))
|
|
|
|
|
(serial-process-configure :speed speed)
|
|
|
|
|
(term-update-mode-line)
|
|
|
|
|
(message "Speed set to %d b/s" speed)))))
|
|
|
|
|
(dolist (str (serial-nice-speed-history))
|
|
|
|
|
(let ((num (or (and (stringp str) (string-to-number str)) 0)))
|
|
|
|
|
(define-key
|
|
|
|
|
serial-mode-line-speed-menu
|
|
|
|
|
(vector (make-symbol (format "serial-mode-line-speed-menu-%s" str)))
|
|
|
|
|
`(menu-item
|
|
|
|
|
,str
|
|
|
|
|
(lambda (event) (interactive "e")
|
|
|
|
|
(serial-process-configure :speed ,num)
|
|
|
|
|
(term-update-mode-line)
|
|
|
|
|
(message "Speed set to %d b/s" ,num))
|
|
|
|
|
:button (:toggle . (= (serial-speed) ,num)))))))
|
|
|
|
|
|
|
|
|
|
(defun serial-mode-line-config-menu-1 (event)
|
|
|
|
|
(interactive "e")
|
|
|
|
|
(save-selected-window
|
|
|
|
|
(select-window (posn-window (event-start event)))
|
|
|
|
|
(serial-update-config-menu)
|
|
|
|
|
(let* ((selection (serial-mode-line-config-menu event))
|
|
|
|
|
(binding (and selection (lookup-key serial-mode-line-config-menu
|
|
|
|
|
(vector (car selection))))))
|
|
|
|
|
(when binding (call-interactively binding)))))
|
|
|
|
|
|
|
|
|
|
(defun serial-mode-line-config-menu (event)
|
|
|
|
|
(x-popup-menu event serial-mode-line-config-menu))
|
|
|
|
|
|
|
|
|
|
(defun serial-update-config-menu ()
|
|
|
|
|
(setq serial-mode-line-config-menu (make-sparse-keymap "Configuration"))
|
|
|
|
|
(let ((config (process-contact
|
2009-12-04 04:39:21 +00:00
|
|
|
|
(get-buffer-process (current-buffer)) t)))
|
2008-06-13 08:04:56 +00:00
|
|
|
|
(dolist (y '((:flowcontrol hw "Hardware flowcontrol (RTS/CTS)")
|
|
|
|
|
(:flowcontrol sw "Software flowcontrol (XON/XOFF)")
|
|
|
|
|
(:flowcontrol nil "No flowcontrol")
|
|
|
|
|
(:stopbits 2 "2 stopbits")
|
|
|
|
|
(:stopbits 1 "1 stopbit")
|
|
|
|
|
(:parity odd "Odd parity")
|
|
|
|
|
(:parity even "Even parity")
|
|
|
|
|
(:parity nil "No parity")
|
|
|
|
|
(:bytesize 7 "7 bits per byte")
|
|
|
|
|
(:bytesize 8 "8 bits per byte")))
|
|
|
|
|
(define-key serial-mode-line-config-menu
|
|
|
|
|
(vector (make-symbol (format "%s-%s" (nth 0 y) (nth 1 y))))
|
|
|
|
|
`(menu-item
|
|
|
|
|
,(nth 2 y)
|
|
|
|
|
(lambda (event) (interactive "e")
|
|
|
|
|
(serial-process-configure ,(nth 0 y) ',(nth 1 y))
|
|
|
|
|
(term-update-mode-line)
|
|
|
|
|
(message "%s" ,(nth 2 y)))
|
|
|
|
|
;; Use :toggle instead of :radio because a non-standard port
|
|
|
|
|
;; configuration may not match any menu items.
|
|
|
|
|
:button (:toggle . ,(equal (plist-get config (nth 0 y))
|
|
|
|
|
(nth 1 y))))))))
|
|
|
|
|
|
1994-10-13 06:30:49 +00:00
|
|
|
|
|
|
|
|
|
;;; Converting process modes to use term mode
|
2009-08-16 15:39:11 +00:00
|
|
|
|
;; ===========================================================================
|
|
|
|
|
;; Renaming variables
|
|
|
|
|
;; Most of the work is renaming variables and functions. These are the common
|
|
|
|
|
;; ones:
|
|
|
|
|
;; Local variables:
|
|
|
|
|
;; last-input-start term-last-input-start
|
|
|
|
|
;; last-input-end term-last-input-end
|
|
|
|
|
;; shell-prompt-pattern term-prompt-regexp
|
|
|
|
|
;; shell-set-directory-error-hook <no equivalent>
|
|
|
|
|
;; Miscellaneous:
|
|
|
|
|
;; shell-set-directory <unnecessary>
|
|
|
|
|
;; shell-mode-map term-mode-map
|
|
|
|
|
;; Commands:
|
|
|
|
|
;; shell-send-input term-send-input
|
|
|
|
|
;; shell-send-eof term-delchar-or-maybe-eof
|
|
|
|
|
;; kill-shell-input term-kill-input
|
|
|
|
|
;; interrupt-shell-subjob term-interrupt-subjob
|
|
|
|
|
;; stop-shell-subjob term-stop-subjob
|
|
|
|
|
;; quit-shell-subjob term-quit-subjob
|
|
|
|
|
;; kill-shell-subjob term-kill-subjob
|
|
|
|
|
;; kill-output-from-shell term-kill-output
|
|
|
|
|
;; show-output-from-shell term-show-output
|
|
|
|
|
;; copy-last-shell-input Use term-previous-input/term-next-input
|
|
|
|
|
;;
|
|
|
|
|
;; SHELL-SET-DIRECTORY is gone, its functionality taken over by
|
|
|
|
|
;; SHELL-DIRECTORY-TRACKER, the shell mode's term-input-filter-functions.
|
|
|
|
|
;; Term mode does not provide functionality equivalent to
|
|
|
|
|
;; shell-set-directory-error-hook; it is gone.
|
|
|
|
|
;;
|
|
|
|
|
;; term-last-input-start is provided for modes which want to munge
|
|
|
|
|
;; the buffer after input is sent, perhaps because the inferior
|
|
|
|
|
;; insists on echoing the input. The LAST-INPUT-START variable in
|
|
|
|
|
;; the old shell package was used to implement a history mechanism,
|
|
|
|
|
;; but you should think twice before using term-last-input-start
|
|
|
|
|
;; for this; the input history ring often does the job better.
|
|
|
|
|
;;
|
|
|
|
|
;; If you are implementing some process-in-a-buffer mode, called foo-mode, do
|
|
|
|
|
;; *not* create the term-mode local variables in your foo-mode function.
|
|
|
|
|
;; This is not modular. Instead, call term-mode, and let *it* create the
|
|
|
|
|
;; necessary term-specific local variables. Then create the
|
|
|
|
|
;; foo-mode-specific local variables in foo-mode. Set the buffer's keymap to
|
|
|
|
|
;; be foo-mode-map, and its mode to be foo-mode. Set the term-mode hooks
|
|
|
|
|
;; (term-{prompt-regexp, input-filter, input-filter-functions,
|
|
|
|
|
;; get-old-input) that need to be different from the defaults. Call
|
|
|
|
|
;; foo-mode-hook, and you're done. Don't run the term-mode hook yourself;
|
|
|
|
|
;; term-mode will take care of it. The following example, from shell.el,
|
|
|
|
|
;; is typical:
|
|
|
|
|
;;
|
2019-02-24 21:19:59 +00:00
|
|
|
|
;; (defvar shell-mode-map
|
|
|
|
|
;; (let ((map (make-sparse-keymap)))
|
|
|
|
|
;; (define-key map "\C-c\C-f" 'shell-forward-command)
|
|
|
|
|
;; (define-key map "\C-c\C-b" 'shell-backward-command)
|
|
|
|
|
;; (define-key map "\t" 'term-dynamic-complete)
|
|
|
|
|
;; (define-key map "\M-?"
|
|
|
|
|
;; 'term-dynamic-list-filename-completions)))
|
2009-08-16 15:39:11 +00:00
|
|
|
|
;;
|
2019-02-24 21:19:59 +00:00
|
|
|
|
;; (define-derived-mode shell-mode term-mode "Shell"
|
|
|
|
|
;; "A shell mode."
|
|
|
|
|
;; (setq-local term-prompt-regexp shell-prompt-pattern)
|
|
|
|
|
;; (setq-local shell-directory-stack nil)
|
|
|
|
|
;; (add-hook 'term-input-filter-functions #'shell-directory-tracker nil t))
|
2009-08-16 15:39:11 +00:00
|
|
|
|
;;
|
|
|
|
|
;; Completion for term-mode users
|
|
|
|
|
;;
|
|
|
|
|
;; For modes that use term-mode, term-dynamic-complete-functions is the
|
|
|
|
|
;; hook to add completion functions to. Functions on this list should return
|
|
|
|
|
;; non-nil if completion occurs (i.e., further completion should not occur).
|
2009-12-04 04:39:21 +00:00
|
|
|
|
;; You could use completion-in-region to do the bulk of the
|
2009-08-16 15:39:11 +00:00
|
|
|
|
;; completion job.
|
1994-10-13 06:30:49 +00:00
|
|
|
|
|
|
|
|
|
(provide 'term)
|
|
|
|
|
|
|
|
|
|
;;; term.el ends here
|