unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#50929: Add slurp-sexp and barf-sexp
@ 2021-10-01  7:43 Philip Kaludercic
  2021-10-01  8:12 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 18+ messages in thread
From: Philip Kaludercic @ 2021-10-01  7:43 UTC (permalink / raw)
  To: 50929

[-- Attachment #1: Type: text/plain, Size: 767 bytes --]

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'


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Add-slurp-sexp-and-barf-sexp.patch --]
[-- Type: text/patch, Size: 1679 bytes --]

From 90ca9317f524359786f6427f6d5a109abee2211c Mon Sep 17 00:00:00 2001
From: Philip Kaludercic <philipk@posteo.net>
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


[-- Attachment #3: Type: text/plain, Size: 16 bytes --]


-- 
	Philip K.

^ permalink raw reply related	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2021-11-14 17:32 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-01  7:43 bug#50929: Add slurp-sexp and barf-sexp Philip Kaludercic
2021-10-01  8:12 ` Lars Ingebrigtsen
2021-10-01  8:31   ` Philip Kaludercic
2021-11-05  3:04     ` Lars Ingebrigtsen
2021-11-06 18:53       ` Juri Linkov
2021-11-08  3:08       ` Richard Stallman
2021-11-08 15:23         ` Philip Kaludercic
2021-11-09 11:38           ` Richard Stallman
2021-11-09 12:13             ` Philip Kaludercic
2021-11-09 16:26               ` bug#50929: [External] : " Drew Adams
2021-11-09 18:44                 ` Philip Kaludercic
2021-11-09 19:15                   ` Drew Adams
2021-11-09 22:17                     ` Drew Adams
2021-11-11  3:39                       ` Richard Stallman
2021-11-14  0:05                     ` Philip Kaludercic
2021-11-14 17:32                       ` Drew Adams
2021-11-09 22:14               ` Rudolf Adamkovič via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-11-11  3:39                 ` Richard Stallman

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).