]> code.delx.au - gnu-emacs/blobdiff - lisp/eshell/esh-mode.el
Merge from origin/emacs-25
[gnu-emacs] / lisp / eshell / esh-mode.el
index 15120cb61d4ba65ced923739ff44cd458f363da2..074b94cc75d7668a59dda815b6edf3e9f10a0de4 100644 (file)
@@ -1,6 +1,6 @@
 ;;; esh-mode.el --- user interface  -*- lexical-binding:t -*-
 
-;; Copyright (C) 1999-2015 Free Software Foundation, Inc.
+;; Copyright (C) 1999-2016 Free Software Foundation, Inc.
 
 ;; Author: John Wiegley <johnw@gnu.org>
 
@@ -206,7 +206,7 @@ This is used by `eshell-watch-for-password-prompt'."
 
 ;; Internal Variables:
 
-;; these are only set to `nil' initially for the sake of the
+;; these are only set to nil initially for the sake of the
 ;; byte-compiler, when compiling other files which `require' this one
 (defvar eshell-mode nil)
 (defvar eshell-mode-map nil)
@@ -296,7 +296,7 @@ and the hook `eshell-exit-hook'."
   (run-hooks 'eshell-exit-hook))
 
 ;;;###autoload
-(define-derived-mode eshell-mode fundamental-mode "EShell"
+(define-derived-mode eshell-mode fundamental-mode "Eshell"
   "Emacs shell interactive mode."
   (setq-local eshell-mode t)
 
@@ -344,7 +344,6 @@ and the hook `eshell-exit-hook'."
 
   (setq local-abbrev-table eshell-mode-abbrev-table)
 
-  (set (make-local-variable 'dired-directory) default-directory)
   (set (make-local-variable 'list-buffers-directory)
        (expand-file-name default-directory))
 
@@ -628,10 +627,11 @@ newline."
   (let ((proc-running-p (and (eshell-interactive-process)
                             (not queue-p)))
        (inhibit-point-motion-hooks t)
-       after-change-functions)
+       (inhibit-modification-hooks t))
     (unless (and proc-running-p
                 (not (eq (process-status
-                          (eshell-interactive-process)) 'run)))
+                          (eshell-interactive-process))
+                          'run)))
       (if (or proc-running-p
              (>= (point) eshell-last-output-end))
          (goto-char (point-max))
@@ -698,7 +698,7 @@ This is done after all necessary filtering has been done."
   (let ((oprocbuf (if process (process-buffer process)
                    (current-buffer)))
        (inhibit-point-motion-hooks t)
-       after-change-functions)
+       (inhibit-modification-hooks t))
     (let ((functions eshell-preoutput-filter-functions))
       (while (and functions string)
        (setq string (funcall (car functions) string))
@@ -871,12 +871,19 @@ When run interactively, widen the buffer first."
   (goto-char (point-max))
   (recenter -1))
 
-(defun eshell/clear ()
-  "Scroll contents of eshell window out of sight, leaving a blank window."
+(defun eshell/clear (&optional scrollback)
+  "Scroll contents of eshell window out of sight, leaving a blank window.
+If SCROLLBACK is non-nil, clear the scrollback contents."
   (interactive)
-  (let ((number-newlines (count-lines (window-start) (point))))
-    (insert (make-string number-newlines ?\n)))
-    (eshell-send-input))
+  (if scrollback
+      (eshell/clear-scrollback)
+    (insert (make-string (window-size) ?\n))
+    (eshell-send-input)))
+
+(defun eshell/clear-scrollback ()
+  "Clear the scrollback content of the eshell window."
+  (let ((inhibit-read-only t))
+    (erase-buffer)))
 
 (defun eshell-get-old-input (&optional use-current-region)
   "Return the command input on the current line."