From c07cfbaacc00a3374de519cc073b2364662f0023 Mon Sep 17 00:00:00 2001 From: Andreas Roehler Date: Fri, 29 May 2009 09:21:59 +0200 Subject: [PATCH] peel-list Peeling a list means: remove list at point, but preserve inner lists. Whatever is part of a list at the beginning and end of the present i.e. sourrounding list should be deleted. Must be called from the part of list to remove. --- code/elbb-misc-utils.el | 42 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/code/elbb-misc-utils.el b/code/elbb-misc-utils.el index faaf98b..8e16048 100644 --- a/code/elbb-misc-utils.el +++ b/code/elbb-misc-utils.el @@ -15,7 +15,6 @@ ;; You should have received a copy of the GNU General Public License ;; along with GNU Emacs. If not, see . - ;; Copyright (C) 2009 by Andreas Roehler ;; Author Andreas Roehler @@ -88,4 +87,45 @@ Stepps through region if activated, otherwise takes the whole buffer." (delete-char 1) (insert cn))) +(require 'thing-at-point-utils) +;; thing-at-point-utils are available at +;; https://code.launchpad.net/s-x-emacs-werkstatt/ +(defun peel-list-atpt () + "Remove list at point, preserve inner lists. +Whatever is part of a list at the +beginning and end of the present i.e. sourrounding list +will be deleted. +Must be called from the part of list to remove." + (interactive "*") + (save-excursion + (let* ((bounds (bounds-of-list-atpt)) + (beg (car bounds)) + (end (cdr bounds))) + (down-list) + (let* ((bounds (bounds-of-list-atpt)) + (inner-beg (car bounds)) + (inner-end (cdr bounds))) + (delete-region inner-end end) + (goto-char beg) + (delete-region beg inner-beg))))) + +;; re-implemented here to run without `thing-at-point-utils' +(require 'thingatpt) +(defun peel-list-at-point () + "Remove list at point, preserve inner lists. +Whatever is part of a list at the +beginning and end of the present i.e. sourrounding list +will be deleted. +Must be called from the part of list to remove." + (interactive "*") + (save-excursion + (let ((beg (save-excursion (progn (beginning-of-thing 'list) (point)))) + (end (save-excursion (progn (end-of-thing 'list) (point))))) + (down-list) + (let ((inner-beg (save-excursion (progn (beginning-of-thing 'list) (point)))) + (inner-end (save-excursion (progn (end-of-thing 'list) (point))))) + (delete-region inner-end end) + (goto-char beg) + (delete-region beg inner-beg))))) + ;; elbb-misc-utils.el ends here -- 2.11.4.GIT