From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Philip Kaludercic Newsgroups: gmane.emacs.bugs Subject: bug#50929: Add slurp-sexp and barf-sexp Date: Fri, 01 Oct 2021 07:43:49 +0000 Message-ID: <87czop2nre.fsf@posteo.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="9927"; mail-complaints-to="usenet@ciao.gmane.io" To: 50929@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Oct 01 09:45:56 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mWDEw-0002JU-AT for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 01 Oct 2021 09:45:54 +0200 Original-Received: from localhost ([::1]:59908 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mWDEv-0002Sp-78 for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 01 Oct 2021 03:45:53 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:42342) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mWDE6-0002SX-MK for bug-gnu-emacs@gnu.org; Fri, 01 Oct 2021 03:45:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:43054) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mWDE6-0006oR-E9 for bug-gnu-emacs@gnu.org; Fri, 01 Oct 2021 03:45:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mWDE6-0005BU-AG for bug-gnu-emacs@gnu.org; Fri, 01 Oct 2021 03:45:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Philip Kaludercic Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 01 Oct 2021 07:45:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 50929 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.163307424219827 (code B ref -1); Fri, 01 Oct 2021 07:45:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 1 Oct 2021 07:44:02 +0000 Original-Received: from localhost ([127.0.0.1]:54597 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mWDD8-00059g-6t for submit@debbugs.gnu.org; Fri, 01 Oct 2021 03:44:02 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:35058) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mWDD3-00059B-AI for submit@debbugs.gnu.org; Fri, 01 Oct 2021 03:44:00 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:42218) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mWDD3-0002Mo-2f for bug-gnu-emacs@gnu.org; Fri, 01 Oct 2021 03:43:57 -0400 Original-Received: from mout01.posteo.de ([185.67.36.65]:37711) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mWDCz-0005q9-KA for bug-gnu-emacs@gnu.org; Fri, 01 Oct 2021 03:43:56 -0400 Original-Received: from submission (posteo.de [89.146.220.130]) by mout01.posteo.de (Postfix) with ESMTPS id 3BD79240028 for ; Fri, 1 Oct 2021 09:43:51 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1633074231; bh=edyTJS3dHgo4ZKtZ32srN7N49PvZRUPja4yFFm84Wcs=; h=From:To:Subject:Autocrypt:Date:From; b=YVf83ZK3PCwiLIB0+nknCxTbht8fr2YPiIUzwABSDeFyrQPcwqKm3GAAOPZKCzNNM fojP+dnZdT83DOkPeXx1piHNdYpRIbePu75h7wNCDGnirviDWnbnbrcEl6bxU+AYMs bD4ZoT7DlNDPZ03mbRwrQUIFp+R2ASF26H3j3twYG2+P7jJOWVckTvc0sMHMtH6DQI grt4UCEWJl9iNPZXBD57VBOnS0iEuUK9TpI0CdChbqXzZtLMiQoRqxaGe8YS8u47TX b94+YX7RGSPJFRFen1GaD0eeXe599SIL5wWroITcyNvRfJAgRGkXa7EzXipdJlX1WA 9OaYc37nWR61A== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4HLMYf42tZz9rxK for ; Fri, 1 Oct 2021 09:43:50 +0200 (CEST) Autocrypt: addr=philipk@posteo.net; prefer-encrypt=nopreference; keydata= mDMEYHHqUhYJKwYBBAHaRw8BAQdAp3GdmYJ6tm5McweY6dEvIYIiry+Oz9rU4MH6NHWK0Ee0QlBo aWxpcCBLYWx1ZGVyY2ljIChnZW5lcmF0ZWQgYnkgYXV0b2NyeXB0LmVsKSA8cGhpbGlwa0Bwb3N0 ZW8ubmV0PoiQBBMWCAA4FiEEDM2H44ZoPt9Ms0eHtVrAHPRh1FwFAmBx6lICGwMFCwkIBwIGFQoJ CAsCBBYCAwECHgECF4AACgkQtVrAHPRh1FyTkgEAjlbGPxFchvMbxzAES3r8QLuZgCxeAXunM9gh io0ePtUBALVhh9G6wIoZhl0gUCbQpoN/UJHI08Gm1qDob5zDxnIHuDgEYHHqUhIKKwYBBAGXVQEF AQEHQNcRB+MUimTMqoxxMMUERpOR+Q4b1KgncDZkhrO2ql1tAwEIB4h4BBgWCAAgFiEEDM2H44Zo Pt9Ms0eHtVrAHPRh1FwFAmBx6lICGwwACgkQtVrAHPRh1Fw1JwD/Qo7kvtib8jy7puyWrSv0MeTS g8qIxgoRWJE/KKdkCLEA/jb9b9/g8nnX+UcwHf/4VfKsjExlnND3FrBviXUW6NcB Received-SPF: pass client-ip=185.67.36.65; envelope-from=philipk@posteo.net; helo=mout01.posteo.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:216011 Archived-At: --=-=-= Content-Type: text/plain Tags: patch Hi, I'd like to suggest adding the command slurp-sexp and barf-sexp to lisp.el (perhaps after changing the names). These commands were popularized by structural editing packages like Paredit, and allow the user to quickly pull or push s-expressions into the current list. In GNU Emacs 28.0.50 (build 5, x86_64-pc-linux-gnu, X toolkit, cairo version 1.16.0, Xaw scroll bars) of 2021-09-30 built on icterid Repository revision: a1789fd67b2dd67d891b6c7181aee885a9ab9447 Repository branch: master Windowing system distributor 'The X.Org Foundation', version 11.0.12011000 System Description: Debian GNU/Linux 11 (bullseye) Configured using: 'configure --with-native-compilation --with-x-toolkit=athena 'CFLAGS=-Os -march=native -pipe' LDFLAGS=-flto' --=-=-= Content-Type: text/patch Content-Disposition: attachment; filename=0001-Add-slurp-sexp-and-barf-sexp.patch >From 90ca9317f524359786f6427f6d5a109abee2211c Mon Sep 17 00:00:00 2001 From: Philip Kaludercic Date: Fri, 1 Oct 2021 09:25:43 +0200 Subject: [PATCH] Add slurp-sexp and barf-sexp * lisp.el (slurp-sexp): Add function (barf-sexp): Add function --- lisp/emacs-lisp/lisp.el | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/lisp/emacs-lisp/lisp.el b/lisp/emacs-lisp/lisp.el index 9b38d86e2c..e49893303c 100644 --- a/lisp/emacs-lisp/lisp.el +++ b/lisp/emacs-lisp/lisp.el @@ -867,6 +867,33 @@ raise-sexp (delete-region (point) (save-excursion (forward-sexp 1) (point))) (save-excursion (insert s)))) +(defun slurp-sexp (&optional arg) + "Pull the next ARG sexps into the current list." + (interactive "p") + (save-excursion + (up-list 1) + (let ((start (point))) + (forward-sexp arg) + (let ((copy (delete-and-extract-region start (point)))) + (down-list -1) + (insert copy))) + (let ((bounds (bounds-of-thing-at-point 'sexp))) + (indent-region (car bounds) (cdr bounds))))) + +(defun barf-sexp (&optional arg) + "Push the last ARG sexps out of the current list." + (interactive "p") + (save-excursion + (up-list 1) + (down-list -1) + (let ((start (point))) + (backward-sexp arg) + (let ((copy (delete-and-extract-region (point) start))) + (move-past-close-and-reindent) + (insert copy))) + (let ((bounds (bounds-of-thing-at-point 'sexp))) + (indent-region (car bounds) (cdr bounds))))) + (defun move-past-close-and-reindent () "Move past next `)', delete indentation before it, then indent after it." (interactive) -- 2.30.2 --=-=-= Content-Type: text/plain -- Philip K. --=-=-=--