;;; term.el --- general command interpreter in a window stuff
-;; Copyright (C) 1988, 1990, 1992, 1994, 1995, 2001, 2002, 2003,
-;; 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
+;; Copyright (C) 1988, 1990, 1992, 1994-1995, 2001-2012
+;; Free Software Foundation, Inc.
;; Author: Per Bothner <per@bothner.com>
;; Maintainer: Dan Nicolaescu <dann@ics.uci.edu>, Per Bothner <per@bothner.com>
;; --------------------------------------
;;
;; While the message passing and the colorization surely introduce some
-;; overhead this has became so small that IMHO is surely outweighted by
-;; the benefits you get but, as usual, YMMV
+;; overhead this has became so small that IMHO it is surely outweighed by
+;; the benefits you get but, as usual, YMMV.
;;
-;; Important caveat, when deciding the cursor/'grey keys' keycodes I had to
+;; Important caveat, when deciding the cursor/'gray keys' keycodes I had to
;; make a choice: on my Linux box this choice allows me to run all the
;; ncurses applications without problems but make these keys
-;; uncomprehensible to all the cursesX programs. Your mileage may vary so
+;; incomprehensible to all the cursesX programs. Your mileage may vary so
;; you may consider changing the default 'emulation'. Just search for this
;; piece of code and modify it as you like:
;;
;; # Notice that the ^[ character is an ESC, not two chars. You can
;; # get it in various ways, for example by typing
;; # echo -e '\033' > escape.file
-;; # or by using your favourite editor
+;; # or by using your favorite editor
;;
;; foreach temp (cd pushd)
;; alias $temp "$temp \!* ; echo '\eAnSiTc' $cwd_hack"
:type 'hook
:group 'term)
+(defvar term-signals-menu
+ (let ((map (make-sparse-keymap "Signals")))
+ (define-key map [eof]
+ '(menu-item "EOF" term-send-eof
+ :help "Send an EOF to the current buffer's process"))
+ (define-key map [kill]
+ '(menu-item "KILL" term-kill-subjob
+ :help "Send kill signal to the current subjob"))
+ (define-key map [quit]
+ '(menu-item "QUIT" term-quit-subjob
+ :help "Send quit signal to the current subjob."))
+ (define-key map [cont]
+ '(menu-item "CONT" term-continue-subjob
+ :help "Send CONT signal to process buffer's process group"))
+ (define-key map [stop]
+ '(menu-item "STOP" term-stop-subjob
+ :help "Stop the current subjob"))
+ (define-key map [brk]
+ '(menu-item "BREAK" term-interrupt-subjob
+ :help "Interrupt the current subjob"))
+ (cons "Signals" map)))
+
(defvar term-mode-map
(let ((map (make-sparse-keymap)))
(define-key map "\ep" 'term-previous-input)
(define-key map "\C-c\C-j" 'term-line-mode)
(define-key map "\C-c\C-q" 'term-pager-toggle)
- ;; ;; completion:
- ;; (define-key map [menu-bar completion]
- ;; (cons "Complete" (make-sparse-keymap "Complete")))
- ;; (define-key map [menu-bar completion complete-expand]
- ;; '("Expand File Name" . term-replace-by-expanded-filename))
- ;; (define-key map [menu-bar completion complete-listing]
- ;; '("File Completion Listing" . term-dynamic-list-filename-completions))
- ;; (define-key map [menu-bar completion complete-file]
- ;; '("Complete File Name" . term-dynamic-complete-filename))
- ;; (define-key map [menu-bar completion complete]
- ;; '("Complete Before Point" . term-dynamic-complete))
- ;; ;; Put them in the menu bar:
- ;; (setq menu-bar-final-items (append '(terminal completion inout signals)
- ;; menu-bar-final-items))
+ ;; completion: (line mode only)
+ (let ((completion-menu (make-sparse-keymap "Complete")))
+ (define-key map [menu-bar completion]
+ (cons "Complete" completion-menu))
+ (define-key completion-menu [complete-expand]
+ '("Expand File Name" . term-replace-by-expanded-filename))
+ (define-key completion-menu [complete-listing]
+ '("File Completion Listing" . term-dynamic-list-filename-completions))
+ (define-key completion-menu [complete-file]
+ '("Complete File Name" . term-dynamic-complete-filename))
+ (define-key completion-menu [complete]
+ '("Complete Before Point" . term-dynamic-complete)))
+
+ ;; Input history: (line mode only)
+ (let ((inout-menu (make-sparse-keymap "In/Out")))
+ (define-key map [menu-bar inout]
+ (cons "In/Out" inout-menu))
+ (define-key inout-menu [kill-output]
+ '("Kill Current Output Group" . term-kill-output))
+ (define-key inout-menu [next-prompt]
+ '("Forward Output Group" . term-next-prompt))
+ (define-key inout-menu [previous-prompt]
+ '("Backward Output Group" . term-previous-prompt))
+ (define-key inout-menu [show-maximum-output]
+ '("Show Maximum Output" . term-show-maximum-output))
+ (define-key inout-menu [show-output]
+ '("Show Current Output Group" . term-show-output))
+ (define-key inout-menu [kill-input]
+ '("Kill Current Input" . term-kill-input))
+ (define-key inout-menu [copy-input]
+ '("Copy Old Input" . term-copy-old-input))
+ (define-key inout-menu [forward-matching-history]
+ '("Forward Matching Input..." . term-forward-matching-input))
+ (define-key inout-menu [backward-matching-history]
+ '("Backward Matching Input..." . term-backward-matching-input))
+ (define-key inout-menu [next-matching-history]
+ '("Next Matching Input..." . term-next-matching-input))
+ (define-key inout-menu [previous-matching-history]
+ '("Previous Matching Input..." . term-previous-matching-input))
+ (define-key inout-menu [next-matching-history-from-input]
+ '("Next Matching Current Input" . term-next-matching-input-from-input))
+ (define-key inout-menu [previous-matching-history-from-input]
+ '("Previous Matching Current Input" .
+ term-previous-matching-input-from-input))
+ (define-key inout-menu [next-history]
+ '("Next Input" . term-next-input))
+ (define-key inout-menu [previous-history]
+ '("Previous Input" . term-previous-input))
+ (define-key inout-menu [list-history]
+ '("List Input History" . term-dynamic-list-input-ring))
+ (define-key inout-menu [expand-history]
+ '("Expand History Before Point" . term-replace-by-expanded-history)))
+
+ (define-key map [menu-bar signals] term-signals-menu)
+
map))
-(defvar term-raw-map nil
- "Keyboard map for sending characters directly to the inferior process.")
(defvar term-escape-char nil
"Escape character for char sub-mode of term mode.
Do not change it directly; use `term-set-escape-char' instead.")
-(defvar term-raw-escape-map nil)
(defvar term-pager-break-map nil)
(defmacro term-handling-pager () 'term-pager-old-local-map)
(defmacro term-using-alternate-sub-buffer () 'term-saved-home-marker)
-(defvar term-signals-menu)
-(defvar term-terminal-menu)
-
;; Let's silence the byte-compiler -mm
(defvar term-ansi-at-host nil)
(defvar term-ansi-at-dir nil)
"magenta3" "cyan3" "white"])
;; Inspiration came from comint.el -mm
-(defvar term-buffer-maximum-size 2048
- "*The maximum size in lines for term buffers.
+(defcustom term-buffer-maximum-size 2048
+ "The maximum size in lines for term buffers.
Term buffers are truncated from the top to be no greater than this number.
Notice that a setting of 0 means \"don't truncate anything\". This variable
-is buffer-local.")
+is buffer-local."
+ :group 'term
+ :type 'integer)
\f
-(when (featurep 'xemacs)
- (defvar term-terminal-menu
- '("Terminal"
- [ "Character mode" term-char-mode (term-in-line-mode)]
- [ "Line mode" term-line-mode (term-in-char-mode)]
- [ "Enable paging" term-pager-toggle (not term-pager-count)]
- [ "Disable paging" term-pager-toggle term-pager-count])))
-
-;; Menu bars:
-(unless (featurep 'xemacs)
- ;; terminal:
- (let (newmap)
- (setq newmap (make-sparse-keymap "Terminal"))
- (define-key newmap [terminal-pager-enable]
- '(menu-item "Enable paging" term-fake-pager-enable
- :help "Enable paging feature"))
- (define-key newmap [terminal-pager-disable]
- '(menu-item "Disable paging" term-fake-pager-disable
- :help "Disable paging feature"))
- (define-key newmap [terminal-char-mode]
- '(menu-item "Character mode" term-char-mode
- :help "Switch to char (raw) sub-mode of term mode"))
- (define-key newmap [terminal-line-mode]
- '(menu-item "Line mode" term-line-mode
- :help "Switch to line (cooked) sub-mode of term mode"))
- (setq term-terminal-menu (cons "Terminal" newmap))
-
- ;; completion: (line mode only)
- (defvar term-completion-menu (make-sparse-keymap "Complete"))
- (define-key term-mode-map [menu-bar completion]
- (cons "Complete" term-completion-menu))
- (define-key term-completion-menu [complete-expand]
- '("Expand File Name" . term-replace-by-expanded-filename))
- (define-key term-completion-menu [complete-listing]
- '("File Completion Listing" . term-dynamic-list-filename-completions))
- (define-key term-completion-menu [menu-bar completion complete-file]
- '("Complete File Name" . term-dynamic-complete-filename))
- (define-key term-completion-menu [menu-bar completion complete]
- '("Complete Before Point" . term-dynamic-complete))
-
- ;; Input history: (line mode only)
- (defvar term-inout-menu (make-sparse-keymap "In/Out"))
- (define-key term-mode-map [menu-bar inout]
- (cons "In/Out" term-inout-menu))
- (define-key term-inout-menu [kill-output]
- '("Kill Current Output Group" . term-kill-output))
- (define-key term-inout-menu [next-prompt]
- '("Forward Output Group" . term-next-prompt))
- (define-key term-inout-menu [previous-prompt]
- '("Backward Output Group" . term-previous-prompt))
- (define-key term-inout-menu [show-maximum-output]
- '("Show Maximum Output" . term-show-maximum-output))
- (define-key term-inout-menu [show-output]
- '("Show Current Output Group" . term-show-output))
- (define-key term-inout-menu [kill-input]
- '("Kill Current Input" . term-kill-input))
- (define-key term-inout-menu [copy-input]
- '("Copy Old Input" . term-copy-old-input))
- (define-key term-inout-menu [forward-matching-history]
- '("Forward Matching Input..." . term-forward-matching-input))
- (define-key term-inout-menu [backward-matching-history]
- '("Backward Matching Input..." . term-backward-matching-input))
- (define-key term-inout-menu [next-matching-history]
- '("Next Matching Input..." . term-next-matching-input))
- (define-key term-inout-menu [previous-matching-history]
- '("Previous Matching Input..." . term-previous-matching-input))
- (define-key term-inout-menu [next-matching-history-from-input]
- '("Next Matching Current Input" . term-next-matching-input-from-input))
- (define-key term-inout-menu [previous-matching-history-from-input]
- '("Previous Matching Current Input" .
- term-previous-matching-input-from-input))
- (define-key term-inout-menu [next-history]
- '("Next Input" . term-next-input))
- (define-key term-inout-menu [previous-history]
- '("Previous Input" . term-previous-input))
- (define-key term-inout-menu [list-history]
- '("List Input History" . term-dynamic-list-input-ring))
- (define-key term-inout-menu [expand-history]
- '("Expand History Before Point" . term-replace-by-expanded-history))
-
- ;; Signals
- (setq newmap (make-sparse-keymap "Signals"))
- (define-key term-mode-map [menu-bar signals]
- (setq term-signals-menu (cons "Signals" newmap)))
- (define-key newmap [eof]
- '(menu-item "EOF" term-send-eof
- :help "Send an EOF to the current buffer's process"))
- (define-key newmap [kill]
- '(menu-item "KILL" term-kill-subjob
- :help "Send kill signal to the current subjob"))
- (define-key newmap [quit]
- '(menu-item "QUIT" term-quit-subjob
- :help "Send quit signal to the current subjob."))
- (define-key newmap [cont]
- '(menu-item "CONT" term-continue-subjob
- :help "Send CONT signal to process buffer's process group"))
- (define-key newmap [stop]
- '(menu-item "STOP" term-stop-subjob
- :help "Stop the current subjob"))
- (define-key newmap [brk]
- '(menu-item "BREAK" term-interrupt-subjob
- :help "Interrupt the current subjob"))
- ))
+(defvar term-terminal-menu
+ (if (featurep 'xemacs)
+ '("Terminal"
+ [ "Character mode" term-char-mode (term-in-line-mode)]
+ [ "Line mode" term-line-mode (term-in-char-mode)]
+ [ "Enable paging" term-pager-toggle (not term-pager-count)]
+ [ "Disable paging" term-pager-toggle term-pager-count])
+ (let ((map (make-sparse-keymap "Terminal")))
+ (define-key map [terminal-pager-enable]
+ '(menu-item "Enable paging" term-fake-pager-enable
+ :help "Enable paging feature"))
+ (define-key map [terminal-pager-disable]
+ '(menu-item "Disable paging" term-fake-pager-disable
+ :help "Disable paging feature"))
+ (define-key map [terminal-char-mode]
+ '(menu-item "Character mode" term-char-mode
+ :help "Switch to char (raw) sub-mode of term mode"))
+ (define-key map [terminal-line-mode]
+ '(menu-item "Line mode" term-line-mode
+ :help "Switch to line (cooked) sub-mode of term mode"))
+ (cons "Terminal" map))))
\f
;; Set up term-raw-map, etc.
-(defun term-set-escape-char (c)
+(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
+
+ (if (featurep 'xemacs)
+ (define-key map [button2] 'term-mouse-paste)
+ (define-key map [mouse-2] 'term-mouse-paste)
+ (define-key map [menu-bar terminal] term-terminal-menu)
+ (define-key map [menu-bar signals] term-signals-menu))
+ (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)
+ (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)
+ map)
+ "Keyboard map for sending characters directly to the inferior process.")
+
+(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))
+
+(defun term-set-escape-char (key)
"Change `term-escape-char' and keymaps that depend on it."
(when term-escape-char
+ ;; Undo previous term-set-escape-char.
(define-key term-raw-map term-escape-char 'term-send-raw))
- (setq c (make-string 1 c))
- (define-key term-raw-map c term-raw-escape-map)
- ;; Define standard bindings in term-raw-escape-map
- (define-key term-raw-escape-map "\C-v"
- (lookup-key (current-global-map) "\C-v"))
- (define-key term-raw-escape-map "\C-u"
- (lookup-key (current-global-map) "\C-u"))
- (define-key term-raw-escape-map c 'term-send-raw)
- (define-key term-raw-escape-map "\C-q" 'term-pager-toggle)
- ;; The keybinding for term-char-mode is needed by the menubar code.
- (define-key term-raw-escape-map "\C-k" 'term-char-mode)
- (define-key term-raw-escape-map "\C-j" 'term-line-mode)
- ;; It's convenient to have execute-extended-command here.
- (define-key term-raw-escape-map [?\M-x] 'execute-extended-command))
-
-(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)
- (setq term-raw-map map)
- (setq term-raw-escape-map
- (copy-keymap (lookup-key (current-global-map) "\C-x")))
-
- ;; Added nearly all the 'grey keys' -mm
+ (setq term-escape-char (vector key))
+ (define-key term-raw-map term-escape-char term-raw-escape-map)
+ ;; FIXME: If we later call term-set-escape-char again with another key,
+ ;; we should undo this binding.
+ (define-key term-raw-escape-map term-escape-char 'term-send-raw))
- (if (featurep 'xemacs)
- (define-key term-raw-map [button2] 'term-mouse-paste)
- (define-key term-raw-map [mouse-2] 'term-mouse-paste)
- (define-key term-raw-map [menu-bar terminal] term-terminal-menu)
- (define-key term-raw-map [menu-bar signals] term-signals-menu))
- (define-key term-raw-map [up] 'term-send-up)
- (define-key term-raw-map [down] 'term-send-down)
- (define-key term-raw-map [right] 'term-send-right)
- (define-key term-raw-map [left] 'term-send-left)
- (define-key term-raw-map [delete] 'term-send-del)
- (define-key term-raw-map [deletechar] 'term-send-del)
- (define-key term-raw-map [backspace] 'term-send-backspace)
- (define-key term-raw-map [home] 'term-send-home)
- (define-key term-raw-map [end] 'term-send-end)
- (define-key term-raw-map [insert] 'term-send-insert)
- (define-key term-raw-map [S-prior] 'scroll-down)
- (define-key term-raw-map [S-next] 'scroll-up)
- (define-key term-raw-map [S-insert] 'term-paste)
- (define-key term-raw-map [prior] 'term-send-prior)
- (define-key term-raw-map [next] 'term-send-next))
-
-(term-set-escape-char ?\C-c)
+(term-set-escape-char (or term-escape-char ?\C-c))
(defvar overflow-newline-into-fringe)
(make-string 1 char)
(format "\e%c" char)))))
-(defun term-mouse-paste (click arg)
- "Insert the last stretch of killed text at the position clicked on."
- (interactive "e\nP")
+(defun term-mouse-paste (click)
+ "Insert the primary selection at the position clicked on."
+ (interactive "e")
(if (featurep 'xemacs)
(term-send-raw-string
(or (condition-case () (x-get-selection) (error ()))
(run-hooks 'mouse-leave-buffer-hook)
(setq this-command 'yank)
(mouse-set-point click)
- (term-send-raw-string (current-kill (cond
- ((listp arg) 0)
- ((eq arg '-) -1)
- (t (1- arg)))))))
+ (term-send-raw-string
+ (or (cond ; From `mouse-yank-primary':
+ ((eq system-type 'windows-nt)
+ (or (x-get-selection 'PRIMARY)
+ (x-get-selection-value)))
+ ((fboundp 'x-get-selection-value)
+ (or (x-get-selection-value)
+ (x-get-selection 'PRIMARY)))
+ (t
+ (x-get-selection 'PRIMARY)))
+ (error "No selection is available")))))
(defun term-paste ()
"Insert the last stretch of killed text at point."
(message "Cannot read history file %s"
term-input-ring-file-name)))
(t
- (let ((history-buf (get-buffer-create " *temp*"))
- (file term-input-ring-file-name)
+ (let ((file term-input-ring-file-name)
(count 0)
(ring (make-ring term-input-ring-size)))
- (unwind-protect
- (with-current-buffer history-buf
- (widen)
- (erase-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))))
- (kill-buffer history-buf))
+ (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))))
(setq term-input-ring ring
term-input-ring-index nil)))))
"Expand directory stack reference before point.
See `term-replace-by-expanded-history'. Returns t if successful."
(save-excursion
- (let ((toend (- (save-excursion (end-of-line nil) (point)) (point)))
+ (let ((toend (- (line-end-position) (point)))
(start (progn (term-bol nil) (point))))
(while (progn
- (skip-chars-forward "^!^"
- (save-excursion
- (end-of-line nil) (- (point) toend)))
- (< (point)
- (save-excursion
- (end-of-line nil) (- (point) toend))))
+ (skip-chars-forward "^!^" (- (line-end-position) toend))
+ (< (point) (- (line-end-position) toend)))
;; 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
(defun term-skip-prompt ()
"Skip past the text matching regexp `term-prompt-regexp'.
If this takes us past the end of the current line, don't skip at all."
- (let ((eol (save-excursion (end-of-line) (point))))
+ (let ((eol (line-end-position)))
(when (and (looking-at term-prompt-regexp)
(<= (match-end 0) eol))
(goto-char (match-end 0)))))
"Is point after the process output marker?"
;; Since output could come into the buffer after we looked at the point
;; but before we looked at the process marker's value, we explicitly
- ;; serialise. This is just because I don't know whether or not Emacs
+ ;; serialize. This is just because I don't know whether or not Emacs
;; services input during execution of lisp commands.
(let ((proc-pos (marker-position
(process-mark (get-buffer-process (current-buffer))))))
\f
;;; Low-level process communication
-(defvar 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.")
+(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
+ :type 'integer)
(defun term-send-string (proc str)
"Send to PROC the contents of STR as input.
"Return string around `point' that starts the current line or nil."
(save-excursion
(let* ((point (point))
- (bol (progn (beginning-of-line) (point)))
- (eol (progn (end-of-line) (point)))
- (start (progn (goto-char point)
- (and (search-backward "\"" bol t)
- (1+ (point)))))
+ (bol (line-beginning-position))
+ (eol (line-end-position))
+ (start (and (search-backward "\"" bol t)
+ (1+ (point))))
(end (progn (goto-char point)
(and (search-forward "\"" eol t)
(1- (point))))))
(defun term-move-columns (delta)
(setq term-current-column (max 0 (+ (term-current-column) delta)))
- (let (point-at-eol)
- (save-excursion
- (end-of-line)
- (setq point-at-eol (point)))
+ (let ((point-at-eol (line-end-position)))
(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
(term-vertical-motion 1)
(when (bolp)
(backward-char))
- (setq save-eol (point))
- (save-excursion
- (end-of-line)
- (setq pnt-at-eol (point)))
+ (setq save-eol (point)
+ pnt-at-eol (line-end-position))
(move-to-column (+ (term-start-line-column) (- term-width count)) 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
(goto-char (point-max))
(recenter -1))
\f
-;;; Do the user's customisation...
+;;; Do the user's customization...
(defvar term-load-hook nil
"This hook is run when term is loaded in.
;; Commands like this are fine things to put in load hooks if you
;; want them present in specific modes.
-(defvar term-completion-autolist nil
- "*If non-nil, automatically list possibilities on partial completion.
-This mirrors the optional behavior of tcsh.")
+(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)
-(defvar term-completion-addsuffix t
- "*If non-nil, add a `/' to completed directories, ` ' to file names.
+(defcustom term-completion-addsuffix t
+ "If non-nil, add a `/' to completed directories, ` ' to file names.
If a cons pair, it should be of the form (DIRSUFFIX . FILESUFFIX) where
DIRSUFFIX and FILESUFFIX are strings added on unambiguous or exact
-completion. This mirrors the optional behavior of tcsh.")
+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)))
-(defvar term-completion-recexact nil
- "*If non-nil, use shortest completion if characters cannot be added.
+(defcustom term-completion-recexact nil
+ "If non-nil, use shortest completion if characters cannot be added.
This mirrors the optional behavior of tcsh.
-A non-nil value is useful if `term-completion-autolist' is non-nil too.")
+A non-nil value is useful if `term-completion-autolist' is non-nil too."
+ :group 'term
+ :type 'boolean)
-(defvar term-completion-fignore nil
- "*List of suffixes to be disregarded during file completion.
+(defcustom term-completion-fignore nil
+ "List of suffixes to be disregarded during file completion.
This mirrors the optional behavior of bash and tcsh.
-Note that this applies to `term-dynamic-complete-filename' only.")
+Note that this applies to `term-dynamic-complete-filename' only."
+ :group 'term
+ :type '(choice (const nil)
+ (repeat :tag "List of suffixes" string)))
(defvar term-file-name-prefix ""
"Prefix prepended to absolute file names taken from process input.
files, such as /dev/ttyS0.
Return nil if this is Windows or DOS, where serial ports have
special identifiers such as COM1."
- (not (member system-type (list 'windows-nt 'cygwin 'ms-dos))))
+ (not (memq system-type '(windows-nt cygwin ms-dos))))
(defvar serial-name-history
(if (serial-port-is-file-p)
"History of serial ports used by `serial-read-name'.")
(defvar serial-speed-history
- ;; Initialised with reasonable values for newbies.
+ ;; Initialized with reasonable values for newbies.
(list "9600" ;; Given twice because 9600 b/s is the most common speed
"1200" "2400" "4800" "9600" "14400" "19200"
"28800" "38400" "57600" "115200")
(setq x
(sort
(copy-sequence serial-speed-history)
- '(lambda (a b) (when (and (stringp a) (stringp b))
- (> (string-to-number a) (string-to-number b))))))
+ (lambda (a b) (when (and (stringp a) (stringp b))
+ (> (string-to-number a) (string-to-number b))))))
(dolist (i x) (when (not (equal i (car y))) (push i y)))
y))
\f
(provide 'term)
-;; arch-tag: eee16bc8-2cd7-4147-9534-a5694752f716
;;; term.el ends here