From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Samer Masterson Newsgroups: gmane.emacs.devel Subject: Re: [PATCH] Proposal: new syntax for eshell-buffer-shorthand (related: bug#19391) Date: Sat, 16 May 2015 01:05:36 -0700 Message-ID: <87pp619cbz.fsf@f-box.i-did-not-set--mail-host-address--so-tickle-me> References: <1425543601.2108.0@mail.samertm.com> <87r3qh2pof.fsf@f-box.i-did-not-set--mail-host-address--so-tickle-me> <83a8x5gf3c.fsf@gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1431763571 16911 80.91.229.3 (16 May 2015 08:06:11 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 16 May 2015 08:06:11 +0000 (UTC) Cc: emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat May 16 10:06:02 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 1YtX6g-0007iF-Av for ged-emacs-devel@m.gmane.org; Sat, 16 May 2015 10:06:02 +0200 Original-Received: from localhost ([::1]:33912 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YtX6f-00058u-F8 for ged-emacs-devel@m.gmane.org; Sat, 16 May 2015 04:06:01 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:42084) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YtX6R-00058n-Vj for emacs-devel@gnu.org; Sat, 16 May 2015 04:05:49 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YtX6Q-0002h6-N7 for emacs-devel@gnu.org; Sat, 16 May 2015 04:05:47 -0400 Original-Received: from mx2.mailbox.org ([80.241.60.215]:40244) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YtX6M-0002gJ-Lc; Sat, 16 May 2015 04:05:42 -0400 Original-Received: from smtp1.mailbox.org (smtp1.mailbox.org [80.241.60.240]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx2.mailbox.org (Postfix) with ESMTPS id E69434004B; Sat, 16 May 2015 10:05:41 +0200 (CEST) X-Virus-Scanned: amavisd-new at heinlein-support.de Original-Received: from smtp1.mailbox.org ([80.241.60.240]) by hefe.heinlein-support.de (hefe.heinlein-support.de [91.198.250.172]) (amavisd-new, port 10030) with ESMTP id KH1i7x056o9G; Sat, 16 May 2015 10:05:40 +0200 (CEST) In-Reply-To: <83a8x5gf3c.fsf@gnu.org> User-Agent: Notmuch/0.19 (http://notmuchmail.org) Emacs/25.0.50.1 (x86_64-unknown-linux-gnu) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 80.241.60.215 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:186525 Archived-At: Eli Zaretskii writes: > Could you please send the patch in the form equivalent to "diff -w" (I > hope Git allows that)? It's hard to read a large patch where most of > the lines "changed" just due to whitespace. My bad, I've attached the diff with whitespace ignored. What's the process for getting write access to the Emacs repository? If it's easier, I can install the change after you review it. Thanks for the review. -s Diff below: diff --git a/etc/NEWS b/etc/NEWS index 48c3a2a5..9c9f13f 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -659,6 +659,12 @@ command line's password prompt. *** 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. +*** New buffer syntax '#', which is equivalent to +'#'. This shorthand makes interacting with +buffers from eshell more convenient. Custom variable +`eshell-buffer-shorthand', which has been broken for a while, has been +removed. + ** Browse-url *** Support for the Conkeror web browser. diff --git a/lisp/eshell/esh-arg.el b/lisp/eshell/esh-arg.el index a5f697f..49ba727 100644 --- a/lisp/eshell/esh-arg.el +++ b/lisp/eshell/esh-arg.el @@ -357,22 +357,31 @@ after are both returned." (goto-char (1+ end))))))) (defun eshell-parse-special-reference () - "Parse a special syntax reference, of the form '#'." - (if (and (not eshell-current-argument) + "Parse a special syntax reference, of the form '#'. + +args := `type' `whitespace' `arbitrary-args' | `arbitrary-args' +type := \"buffer\" or \"process\" +arbitrary-args := any string of characters. + +If the form has no 'type', the syntax is parsed as if 'type' were +\"buffer\"." + (when (and (not eshell-current-argument) (not eshell-current-quoted) - (looking-at "#<\\(buffer\\|process\\)\\s-")) + (looking-at "#<\\(\\(buffer\\|process\\)\\s-\\)?")) (let ((here (point))) - (goto-char (match-end 0)) - (let* ((buffer-p (string= (match-string 1) "buffer")) + (goto-char (match-end 0)) ;; Go to the end of the match. + (let ((buffer-p (if (match-string 1) + (string= (match-string 2) "buffer") + t)) ;; buffer-p is non-nil by default. (end (eshell-find-delimiter ?\< ?\>))) - (if (not end) - (throw 'eshell-incomplete ?\<) + (when (not end) + (throw 'eshell-incomplete ?\<)) (if (eshell-arg-delimiter (1+ end)) (prog1 (list (if buffer-p 'get-buffer-create 'get-process) (buffer-substring-no-properties (point) end)) (goto-char (1+ end))) - (ignore (goto-char here)))))))) + (ignore (goto-char here))))))) (defun eshell-parse-delimiter () "Parse an argument delimiter, which is essentially a command operator." diff --git a/lisp/eshell/esh-io.el b/lisp/eshell/esh-io.el index 7dfc39f..dc731bc 100644 --- a/lisp/eshell/esh-io.el +++ b/lisp/eshell/esh-io.el @@ -31,6 +31,18 @@ ;; consistent with most shells. Therefore, only unique features are ;; mentioned here. ;; +;;;_* Redirect to a Buffer or Process +;; +;; Buffers and processes can be named with '#' and +;; '#', respectively. As a shorthand, +;; '#' without the explicit "buffer" arg is equivalent to +;; '#'. +;; +;; echo hello > # # Overwrite '*scratch*' with 'hello'. +;; echo hello > #<*scratch*> # Same as the command above. +;; +;; echo hello > # # Pipe "hello" into the shell process. +;; ;;;_* Insertion ;; ;; To insert at the location of point in a buffer, use '>>>': @@ -98,19 +110,6 @@ other buffers) ." :type 'integer :group 'eshell-io) -(defcustom eshell-buffer-shorthand nil - "If non-nil, a symbol name can be used for a buffer in redirection. -If nil, redirecting to a buffer requires buffer name syntax. If this -variable is set, redirection directly to Lisp symbols will be -impossible. - -Example: - - echo hello > '*scratch* ; works if `eshell-buffer-shorthand' is t - echo hello > # ; always works" - :type 'boolean - :group 'eshell-io) - (defcustom eshell-print-queue-size 5 "The size of the print queue, for doing buffered printing. This is basically a speed enhancement, to avoid blocking the Lisp code @@ -355,21 +354,14 @@ it defaults to `insert'." (goto-char (point-max)))) (point-marker)))))) - ((or (bufferp target) - (and (boundp 'eshell-buffer-shorthand) - (symbol-value 'eshell-buffer-shorthand) - (symbolp target) - (not (memq target '(t nil))))) - (let ((buf (if (bufferp target) - target - (get-buffer-create - (symbol-name target))))) - (with-current-buffer buf + + ((bufferp target) + (with-current-buffer target (cond ((eq mode 'overwrite) (erase-buffer)) ((eq mode 'append) (goto-char (point-max)))) - (point-marker)))) + (point-marker))) ((functionp target) nil)