From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: vibhavp@gmail.com Newsgroups: gmane.emacs.devel Subject: Re: Add function eshell/clear to clear current eshell buffer Date: Sun, 19 Apr 2015 09:56:45 +0530 Message-ID: <87383wspyy.fsf@gmail.com> References: <874mpwhxml.fsf@gmail.com> <83lhj7lcgn.fsf@gnu.org> <87y4n7e1bn.fsf@gmail.com> <831tkz6yh1.fsf@gnu.org> <87oao23dbb.fsf@gmail.com> <20150309101126.GA11863@boo.workgroup> <83twxu5fh5.fsf@gnu.org> <87y4lpofl5.fsf@lifelogs.com> <83vbgt7gqw.fsf@gnu.org> <87d231o954.fsf@lifelogs.com> <83r3rh7dsb.fsf@gnu.org> <87mw25sbvx.fsf@gmail.com> <83lhhp795h.fsf@gnu.org> <87fv7xi48y.fsf@gmail.com> <87pp71m3y3.fsf@lifelogs.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: ger.gmane.org 1429417621 3738 80.91.229.3 (19 Apr 2015 04:27:01 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 19 Apr 2015 04:27:01 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Apr 19 06:27:01 2015 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Yjgou-0002LB-0D for ged-emacs-devel@m.gmane.org; Sun, 19 Apr 2015 06:27:00 +0200 Original-Received: from localhost ([::1]:47509 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yjgos-00013M-Q8 for ged-emacs-devel@m.gmane.org; Sun, 19 Apr 2015 00:26:58 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:39879) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yjgop-000130-2P for emacs-devel@gnu.org; Sun, 19 Apr 2015 00:26:55 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Yjgol-0005N5-TQ for emacs-devel@gnu.org; Sun, 19 Apr 2015 00:26:55 -0400 Original-Received: from mail-pa0-x236.google.com ([2607:f8b0:400e:c03::236]:35351) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yjgol-0005My-Lt for emacs-devel@gnu.org; Sun, 19 Apr 2015 00:26:51 -0400 Original-Received: by pabtp1 with SMTP id tp1so170354766pab.2 for ; Sat, 18 Apr 2015 21:26:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:references:date:in-reply-to:message-id:user-agent :mime-version:content-type; bh=fsUV8bn6LtvCEsmA3/aaHeCWBWUtRn5Fns3LUwiHCS4=; b=P23XN/AoePaGOlZxpSeHvNPo2E+bkpk3pJmhS/OxlR4J4yEFyqS6kHngSI5mIaXoSL f6elukVdNGjbpdmIoB86I95QKbFyZwDcqINXkfNEvyhnXnRuexwTOu19dwm9VdpZhRf/ vSVIZQVhLnSzdfEg76xm0gfa9SFwTGWMv85Rx0J3RrmtYDdAC0z9COJ7ov6aOgDfFWH7 C/MEA+ybl/ZVWuSw5w7spxnsiG7gebTdE48knBjbD3rEIdCseJHSZ6RqWh2UtXY6VQi6 GwdHkra/YhgbYUNxXEeOY/upqkLcTCmaNHMpIacOYTc31OJS4qygGVa4WM/bVZeskEDs zJdw== X-Received: by 10.68.225.99 with SMTP id rj3mr18054484pbc.54.1429417610617; Sat, 18 Apr 2015 21:26:50 -0700 (PDT) Original-Received: from lenovog410 ([117.214.173.142]) by mx.google.com with ESMTPSA id km11sm14220340pbd.90.2015.04.18.21.26.48 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 18 Apr 2015 21:26:49 -0700 (PDT) In-Reply-To: <87pp71m3y3.fsf@lifelogs.com> (Ted Zlatanov's message of "Sat, 18 Apr 2015 19:06:44 -0400") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:400e:c03::236 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:185654 Archived-At: --=-=-= Content-Type: text/plain Ted Zlatanov writes: > That looks great. Could you also make it available through > `C-u M-x eshell/clear'? Attached Patch. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=esh-clear-scrollback.patch diff --git a/etc/NEWS b/etc/NEWS index 5e312ed..5bb84e1 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -610,6 +610,7 @@ command line's password prompt. ** Eshell *** The new built-in command `clear' can scroll window contents out of sight. +If provided with an optional non-nil argument, the scrollback contents will be cleared. ** Browse-url diff --git a/lisp/eshell/esh-mode.el b/lisp/eshell/esh-mode.el index 15120cb..54e52b9 100644 --- a/lisp/eshell/esh-mode.el +++ b/lisp/eshell/esh-mode.el @@ -871,12 +871,20 @@ 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 scollback contents." (interactive) - (let ((number-newlines (count-lines (window-start) (point)))) - (insert (make-string number-newlines ?\n))) - (eshell-send-input)) + (if scrollback + (eshell/clear-scrollback) + (let ((number-newlines (count-lines (window-start) (point)))) + (insert (make-string number-newlines ?\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." --=-=-= Content-Type: text/plain -- Vibhav Pant vibhavp@gmail.com --=-=-=--