From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Matthew Bauer Newsgroups: gmane.emacs.devel Subject: [PATCH] Add more rebind functions to em-rebind.el Date: Fri, 14 Jul 2017 10:05:32 -0700 Message-ID: <5968fc78.8243630a.fed3c.2be5@mx.google.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Trace: blaine.gmane.org 1500052724 10432 195.159.176.226 (14 Jul 2017 17:18:44 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 14 Jul 2017 17:18:44 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Jul 14 19:18:41 2017 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dW4Ei-0002Dy-Pe for ged-emacs-devel@m.gmane.org; Fri, 14 Jul 2017 19:18:40 +0200 Original-Received: from localhost ([::1]:39137 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dW4Ek-0003ug-Mi for ged-emacs-devel@m.gmane.org; Fri, 14 Jul 2017 13:18:42 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:36477) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dW4Ct-0002kO-GZ for emacs-devel@gnu.org; Fri, 14 Jul 2017 13:16:48 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dW4Co-0006XO-Ia for emacs-devel@gnu.org; Fri, 14 Jul 2017 13:16:47 -0400 Original-Received: from mail-pg0-x22b.google.com ([2607:f8b0:400e:c05::22b]:32875) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dW4Co-0006X8-DC for emacs-devel@gnu.org; Fri, 14 Jul 2017 13:16:42 -0400 Original-Received: by mail-pg0-x22b.google.com with SMTP id k14so48740846pgr.0 for ; Fri, 14 Jul 2017 10:16:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:from:date:subject:mime-version:content-transfer-encoding :to; bh=4jAjOCk65frDvsp5d2Om5jxGzA2Q+eEJqIoil3BWmsg=; b=DdZD60GgXSjNPotL4n9HNFZbyVYMOZebnWooAVyPLrV78HVBcX/rr3eniDWQtnVR+j QD1CWfpYS2T8xSgLyOkUdoCB7f07i9t704Gy91xN5uIE+SeMtTDm3GBZQ979rMjhd8Ud kN1Jo8BYZCEBVKyw0WWHj1F4wh/k9TaRC0pjI9tOoiLZ0gaIwH7yIfnFNx7th/m/S2z7 wfAJQwlWpjFAktgba8LcI/s3NuOQ202Xh5bhQ7uPzi0KQCKTkKx5N6eCPKmGyyxP1YFB 68zLy51q9Q6HE4Zk/xd+DWYc26pJ4O+04B0HIxMUVF+FzKfNBfvFQHV2BMv//jAX2ZQG Utng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:from:date:subject:mime-version :content-transfer-encoding:to; bh=4jAjOCk65frDvsp5d2Om5jxGzA2Q+eEJqIoil3BWmsg=; b=i/QulKAJyG94RTS3Zl9IAjojTkFxG+CuZecMMA/YQ+mfDGo9OWFiuGKM4nPErUhZCc mu19pzb05C/5lo8c5D1W+K9c1vnB66FuFhER9cwyF6qGbsyap0Cg0Xomt1xBRC5uvM77 LmpBd96pUtAcPCO9cV9twRFI5iV6NnZZtFoTPyE9Pjft7bHSlXdJyJ4RC5s5IvK98cVG yvAaVUvbVC6FaASQ7/K9KeTxvuYa7J1yRegCsySTZAcOyRT8hKfGT6OUGZFH8/wJfyEa gJmv7KZnoveqzYNVERgbR3VgmGt0QGbiQr8LRSPr9ZcWZBi9LKCNCbfVvvmiX5EraElt Ny5A== X-Gm-Message-State: AIVw113v8Ih4RCxKalwB8qkBR5y8zvEJcWDiLeJhj1NLnOoBfEFjrHlU JbNOl6rGnw4ckdKt57A= X-Received: by 10.98.217.23 with SMTP id s23mr6372171pfg.204.1500052601190; Fri, 14 Jul 2017 10:16:41 -0700 (PDT) Original-Received: from localhost ([216.64.167.154]) by smtp.gmail.com with ESMTPSA id q124sm15969373pga.8.2017.07.14.10.16.39 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 14 Jul 2017 10:16:40 -0700 (PDT) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::22b X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 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" Xref: news.gmane.org gmane.emacs.devel:216654 Archived-At: This adds two new functions for em-rebind to handle "killing" without messing up the prompt: - eshell-kill-whole-line - eshell-backward-kill-word They are roughly the same as ‘kill-whole-line’ and ‘backward-kill-word’ respectively. In addition, the default values for ‘eshell-rebind-keys-alist’ have been updated to use these new commands over the defaults. --- lisp/eshell/em-rebind.el | 37 ++++++++++++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/lisp/eshell/em-rebind.el b/lisp/eshell/em-rebind.el index a1f9054dae..c34c0cf9c3 100644 --- a/lisp/eshell/em-rebind.el +++ b/lisp/eshell/em-rebind.el @@ -55,8 +55,13 @@ the behavior of normal shells while the user editing new input text." ([(control ?d)] . eshell-delchar-or-maybe-eof) ([backspace] . eshell-delete-backward-char) ([delete] . eshell-delete-backward-char) - ([(control ?w)] . backward-kill-word) - ([(control ?u)] . eshell-kill-input)) + ([(control ?u)] . eshell-kill-input) + ([(control ?w)] . eshell-backward-kill-word) + ([(control backspace)] . eshell-backward-kill-word) + ([(meta backspace)] . eshell-backward-kill-word) + ([(control delete)] . eshell-backward-kill-word) + ([(meta delete)] . eshell-backward-kill-word) + ([(control shift backspace)] . eshell-kill-whole-line)) "Bind some keys differently if point is in input text." :type '(repeat (cons (vector :tag "Keys to bind" (repeat :inline t sexp)) @@ -222,7 +227,12 @@ lock it at that." "Delete the last character, unless it's part of the output." (interactive "P") (let ((count (prefix-numeric-value n))) - (if (eshell-point-within-input-p (- (point) count)) + (if (or (eshell-point-within-input-p (- (point) count)) + (and (use-region-p) + delete-active-region + (= count 1) + (eshell-point-within-input-p (region-beginning)) + (eshell-point-within-input-p (region-end)))) (delete-backward-char count n) (beep)))) @@ -242,6 +252,27 @@ input." (eshell-life-is-too-much))) (eshell-delete-backward-char (- arg))))) +(defun eshell-kill-whole-line () + "Kill the whole line except for the eshell prompt." + (interactive) + (kill-region (point) (save-excursion + (eshell-bol) + (point)))) + +(defun eshell-backward-kill-word (arg) + "Delete the last word, or else everything until the beginning of line. +ARG number of words to kill." + (interactive "p") + (let ((word-point (save-excursion + (forward-word (- arg)) + (point)))) + (if (eshell-point-within-input-p word-point) + (backward-kill-word arg) + (kill-region (point) (save-excursion + (eshell-bol) + (point))) + (beep)))) + (provide 'em-rebind) ;; Local Variables: -- 2.13.2