From mboxrd@z Thu Jan 1 00:00:00 1970 From: marvin doyley Subject: Converting paragraph to plain lis Date: Tue, 15 Dec 2015 19:27:42 -0500 Message-ID: <542BCA5A-1AC1-454B-8292-C6F196BB57BB@gmail.com> Mime-Version: 1.0 (Mac OS X Mail 9.2 \(3112\)) Content-Type: multipart/alternative; boundary="Apple-Mail=_B5C49EE6-1AC6-4FED-9FE7-C4C3AB77C48A" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:50774) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a8zwd-0004a4-6R for emacs-orgmode@gnu.org; Tue, 15 Dec 2015 19:27:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a8zwY-0006nZ-1c for emacs-orgmode@gnu.org; Tue, 15 Dec 2015 19:27:50 -0500 Received: from mail-qk0-x22e.google.com ([2607:f8b0:400d:c09::22e]:36821) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a8zwX-0006nK-TE for emacs-orgmode@gnu.org; Tue, 15 Dec 2015 19:27:45 -0500 Received: by mail-qk0-x22e.google.com with SMTP id t125so40906716qkh.3 for ; Tue, 15 Dec 2015 16:27:45 -0800 (PST) Received: from [10.0.1.14] (cpe-45-46-209-35.rochester.res.rr.com. [45.46.209.35]) by smtp.gmail.com with ESMTPSA id w14sm1582000qge.24.2015.12.15.16.27.43 for (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 15 Dec 2015 16:27:44 -0800 (PST) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org --Apple-Mail=_B5C49EE6-1AC6-4FED-9FE7-C4C3AB77C48A Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii Hi there, Does anybody know how to convert a paragraph to a plain list, and vice = versa. For example, I would like to convert=20 Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse = viverra consectetur euismod. Donec non tempor turpis.=20 to=20 1. Lorem ipsum dolor sit amet, consectetur adipiscing elit.=20 2. Suspendisse viverra consectetur euismod. 3. Donec non tempor turpis.=20 In one key stroke, this would speed up my brain storming process. Thanks, M= --Apple-Mail=_B5C49EE6-1AC6-4FED-9FE7-C4C3AB77C48A Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=us-ascii Hi there,

Does anybody know how to convert a paragraph to a plain list, = and vice versa. For example, I would like to convert 

Lorem = ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse viverra = consectetur euismod. Donec non tempor turpis. 

to 

1. Lorem ipsum dolor sit = amet, consectetur adipiscing elit. 
 2.  Suspendisse viverra = consectetur euismod.
3.  Donec non tempor = turpis. 

In one key = stroke, this would speed up my brain storming = process.

Thanks,
M
= --Apple-Mail=_B5C49EE6-1AC6-4FED-9FE7-C4C3AB77C48A-- From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marcin Borkowski Subject: Re: Converting paragraph to plain lis Date: Wed, 16 Dec 2015 09:22:56 +0100 Message-ID: <87k2oeajkv.fsf@mbork.pl> References: <542BCA5A-1AC1-454B-8292-C6F196BB57BB@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:39837) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a97Mc-00023D-1W for emacs-orgmode@gnu.org; Wed, 16 Dec 2015 03:23:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a97MY-0002uc-RC for emacs-orgmode@gnu.org; Wed, 16 Dec 2015 03:23:09 -0500 Received: from mail.mojserwer.eu ([2a01:5e00:2:52::8]:44430) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a97MY-0002uS-Kn for emacs-orgmode@gnu.org; Wed, 16 Dec 2015 03:23:06 -0500 In-reply-to: <542BCA5A-1AC1-454B-8292-C6F196BB57BB@gmail.com> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: marvin doyley Cc: emacs-orgmode@gnu.org On 2015-12-16, at 01:27, marvin doyley wrote: > Hi there, > > Does anybody know how to convert a paragraph to a plain list, and vice versa. For example, I would like to convert > > Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse viverra consectetur euismod. Donec non tempor turpis. > > to > > 1. Lorem ipsum dolor sit amet, consectetur adipiscing elit. > 2. Suspendisse viverra consectetur euismod. > 3. Donec non tempor turpis. > > In one key stroke, this would speed up my brain storming process. 1. A keyboard macro, or 2. Some elisp involving =forward-sentence=. I don't have time to write this now (I have a lecture soon), but I might e.g. in the afternoon, if there's still demand. > Thanks, > M Hth, -- Marcin Borkowski http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski Faculty of Mathematics and Computer Science Adam Mickiewicz University From mboxrd@z Thu Jan 1 00:00:00 1970 From: John Kitchin Subject: Re: Converting paragraph to plain lis Date: Wed, 16 Dec 2015 06:38:51 -0500 Message-ID: References: <542BCA5A-1AC1-454B-8292-C6F196BB57BB@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:50625) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a9AQ9-00084z-UW for emacs-orgmode@gnu.org; Wed, 16 Dec 2015 06:39:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a9AQ4-0004kY-PX for emacs-orgmode@gnu.org; Wed, 16 Dec 2015 06:39:01 -0500 Received: from mail-qg0-x22e.google.com ([2607:f8b0:400d:c04::22e]:36660) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a9AQ4-0004kU-LJ for emacs-orgmode@gnu.org; Wed, 16 Dec 2015 06:38:56 -0500 Received: by mail-qg0-x22e.google.com with SMTP id 103so31184381qgi.3 for ; Wed, 16 Dec 2015 03:38:56 -0800 (PST) In-reply-to: <542BCA5A-1AC1-454B-8292-C6F196BB57BB@gmail.com> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: marvin doyley Cc: emacs-orgmode@gnu.org Here is a solution that works on your paragraph. #+BEGIN_SRC emacs-lisp (defun explode-paragraph () (interactive) (let (start end) ;; narrow to paragraph (backward-paragraph) (forward-line) (setq start (point)) (forward-paragraph) (previous-line) (setq end (point)) ;; now move by sentence, insert number and \n. at the end go to beginning ;; insert a number and use C-cC-c to renumber the list. (save-restriction (narrow-to-region start end) (goto-char (point-min)) (while (< (point) (point-max)) (forward-sentence) (insert "\n1. ")) (goto-char (point-min)) (insert "1. ") (org-ctrl-c-ctrl-c)))) (defun unfill-paragraph () "Unfill paragraph at or after point." (interactive "*") (let ((fill-column most-positive-fixnum)) (fill-paragraph nil (region-active-p)))) (defun list-to-paragraph () "Convert list at point to a paragraph." (interactive) ;; make sure we are at the beginning of the list (beginning-of-line) (let ((element (org-element-context)) contents) (when (eq 'item (car element)) (setq element (org-element-property :parent (org-element-context))) (goto-char (org-element-property :begin element))) ;; collect each sentence, minus the numbers. (setq contents (loop for node in (org-element-property :structure element) collect ;; remove number and space (replace-regexp-in-string (regexp-quote (nth 2 node)) "" (buffer-substring (nth 0 node) (nth 6 node))))) ;; replace the list, and then unfill the paragraph. (setf (buffer-substring (org-element-property :begin element) (- (org-element-property :end element) 1)) (mapconcat 'identity contents "")) (goto-char (org-element-property :begin element)) (unfill-paragraph))) #+END_SRC marvin doyley writes: > Hi there, > > Does anybody know how to convert a paragraph to a plain list, and vice versa. For example, I would like to convert > > Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse viverra consectetur euismod. Donec non tempor turpis. > > to > > 1. Lorem ipsum dolor sit amet, consectetur adipiscing elit. > 2. Suspendisse viverra consectetur euismod. > 3. Donec non tempor turpis. > > In one key stroke, this would speed up my brain storming process. > > Thanks, > M -- Professor John Kitchin Doherty Hall A207F Department of Chemical Engineering Carnegie Mellon University Pittsburgh, PA 15213 412-268-7803 @johnkitchin http://kitchingroup.cheme.cmu.edu From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Doyley, Marvin M." Subject: Fwd: Converting paragraph to plain lis Date: Wed, 16 Dec 2015 14:15:42 +0000 Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="_000_B6C0FC2E9E4944E5944719E0EFB5F009urrochesteredu_" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:50908) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a9EK0-0001YA-0h for emacs-orgmode@gnu.org; Wed, 16 Dec 2015 10:48:57 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a9EJw-0006Al-Fh for emacs-orgmode@gnu.org; Wed, 16 Dec 2015 10:48:55 -0500 Received: from mail-bn1bn0108.outbound.protection.outlook.com ([157.56.110.108]:55808 helo=na01-bn1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a9EJv-0006AX-RZ for emacs-orgmode@gnu.org; Wed, 16 Dec 2015 10:48:52 -0500 Content-Language: en-US List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: "emacs-orgmode@gnu.org" --_000_B6C0FC2E9E4944E5944719E0EFB5F009urrochesteredu_ Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hi John, I really appreciate this. Cheers, M --- Begin forwarded message: From: John Kitchin = > Date: December 16, 2015 at 6:38:51 AM EST To: marvin doyley > Cc: emacs-orgmode@gnu.org Subject: Re: [O] Converting paragraph to plain lis Here is a solution that works on your paragraph. #+BEGIN_SRC emacs-lisp (defun explode-paragraph () (interactive) (let (start end) ;; narrow to paragraph (backward-paragraph) (forward-line) (setq start (point)) (forward-paragraph) (previous-line) (setq end (point)) ;; now move by sentence, insert number and \n. at the end go to beginnin= g ;; insert a number and use C-cC-c to renumber the list. (save-restriction (narrow-to-region start end) (goto-char (point-min)) (while (< (point) (point-max)) (forward-sentence) (insert "\n1. ")) (goto-char (point-min)) (insert "1. ") (org-ctrl-c-ctrl-c)))) (defun unfill-paragraph () "Unfill paragraph at or after point." (interactive "*") (let ((fill-column most-positive-fixnum)) (fill-paragraph nil (region-active-p)))) (defun list-to-paragraph () "Convert list at point to a paragraph." (interactive) ;; make sure we are at the beginning of the list (beginning-of-line) (let ((element (org-element-context)) contents) (when (eq 'item (car element)) (setq element (org-element-property :parent (org-element-context))) (goto-char (org-element-property :begin element))) ;; collect each sentence, minus the numbers. (setq contents (loop for node in (org-element-property :structure element) collect ;; remove number and space (replace-regexp-in-string (regexp-quote (nth 2 node)) "" (buffer-substring (nth 0 node) (nth 6 node))))) ;; replace the list, and then unfill the paragraph. (setf (buffer-substring (org-element-property :begin element) (- (org-element-property :end element) 1)) (mapconcat 'identity contents "")) (goto-char (org-element-property :begin element)) (unfill-paragraph))) #+END_SRC marvin doyley writes: Hi there, Does anybody know how to convert a paragraph to a plain list, and vice vers= a. For example, I would like to convert Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse viverr= a consectetur euismod. Donec non tempor turpis. to 1. Lorem ipsum dolor sit amet, consectetur adipiscing elit. 2. Suspendisse viverra consectetur euismod. 3. Donec non tempor turpis. In one key stroke, this would speed up my brain storming process. Thanks, M -- Professor John Kitchin Doherty Hall A207F Department of Chemical Engineering Carnegie Mellon University Pittsburgh, PA 15213 412-268-7803 @johnkitchin http://kitchingroup.cheme.cmu.edu --_000_B6C0FC2E9E4944E5944719E0EFB5F009urrochesteredu_ Content-Type: text/html; charset="us-ascii" Content-ID: <2FDF366FB5A843479DBA64602A3FEC6E@namprd07.prod.outlook.com> Content-Transfer-Encoding: quoted-printable Hi John,
I really appreciate this.
Cheers,
M
---





Begin forwarded message:

From: John Kitchin <jkitchin@andrew.cmu.edu>
Date: December 16, 2015 at 6:38:51 AM EST
To: marvin doyley <marvinpas@gmail.com>
Subject: Re: [O] Converting paragr= aph to plain lis

Here is a solution that works on your paragraph.

#+BEGIN_SRC emacs-lisp
(defun explode-paragraph ()
 (interactive)
 (let (start end)
   ;; narrow to paragraph
   (backward-paragraph) (forward-line)
   (setq start (point))
   (forward-paragraph) (previous-line)
   (setq end (point))

   ;; now move by sentence, insert number and \n. at the end= go to beginning
   ;; insert a number and use C-cC-c to renumber the list.    (save-restriction
     (narrow-to-region start end)
     (goto-char (point-min))
     (while (< (point) (point-max))
       (forward-sentence)
       (insert "\n1. "))
     (goto-char (point-min))
     (insert "1. ")
     (org-ctrl-c-ctrl-c))))

(defun unfill-paragraph ()
 "Unfill paragraph at or after point."
 (interactive "*")
 (let ((fill-column most-positive-fixnum))
   (fill-paragraph nil (region-active-p))))

(defun list-to-paragraph ()
 "Convert list at point to a paragraph."
 (interactive)
 ;; make sure we are at the beginning of the list
 (beginning-of-line)
 (let ((element (org-element-context))
       contents)
   (when (eq 'item (car element))
     (setq element (org-element-property :parent (= org-element-context)))
     (goto-char
      (org-element-property
       :begin
       element)))
   ;; collect each sentence, minus the numbers.
   (setq contents (loop for node in
            &nb= sp;           (org-e= lement-property :structure element)
            &nb= sp;           collec= t
            &nb= sp;           ;; rem= ove number and space
            &nb= sp;           (repla= ce-regexp-in-string
            &nb= sp;            = (regexp-quote (nth 2 node)) ""
            &nb= sp;            = (buffer-substring (nth 0 node)
            &nb= sp;            =             &nb= sp;     (nth 6 node)))))
   ;; replace the list, and then unfill the paragraph.
   (setf (buffer-substring (org-element-property :begin elem= ent)
            &nb= sp;            =   (- (org-element-property :end element) 1))
         (mapconcat 'identity = contents ""))
   (goto-char (org-element-property :begin element))
   (unfill-paragraph)))
#+END_SRC

marvin doyley writes:

Hi there,

Does anybody know how to convert a paragraph to a plain list, and vice vers= a. For example, I would like to convert

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse viverr= a consectetur euismod. Donec non tempor turpis.

to

1. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
2.  Suspendisse viverra consectetur euismod.
3.  Donec non tempor turpis.

In one key stroke, this would speed up my brain storming process.

Thanks,
M

--
Professor John Kitchin
Doherty Hall A207F
Department of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
412-268-7803
@johnkitchin
http://kitchingrou= p.cheme.cmu.edu

--_000_B6C0FC2E9E4944E5944719E0EFB5F009urrochesteredu_--