From mboxrd@z Thu Jan 1 00:00:00 1970 From: John Kitchin Subject: Re: Continued lists Date: Sat, 2 Nov 2019 13:20:26 -0400 Message-ID: References: <87v9s2k4fc.fsf@iki.fi> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="0000000000001886190596604dd4" Return-path: Received: from eggs.gnu.org ([2001:470:142:3::10]:46515) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iQx4t-0002z4-5W for emacs-orgmode@gnu.org; Sat, 02 Nov 2019 13:20:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iQx4r-0005Vc-JX for emacs-orgmode@gnu.org; Sat, 02 Nov 2019 13:20:42 -0400 Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]:34900) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iQx4r-0005IN-6u for emacs-orgmode@gnu.org; Sat, 02 Nov 2019 13:20:41 -0400 Received: by mail-wr1-x42e.google.com with SMTP id l10so12690393wrb.2 for ; Sat, 02 Nov 2019 10:20:39 -0700 (PDT) In-Reply-To: <87v9s2k4fc.fsf@iki.fi> 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" To: Jarmo Hurri Cc: org-mode-email --0000000000001886190596604dd4 Content-Type: text/plain; charset="UTF-8" It seems a little tricky to do much better. With numbering you can do something like this where you find the last element of the previous list, and then continue it. This won't do what you want for nested lists I guess. For lettering, you would need to figure out how to increment the letter. but for simple numbered lists, this might do the trick for you. #+BEGIN_SRC emacs-lisp (defun auto-continue () (interactive) (when-let (p (org-in-item-p)) (save-excursion (goto-char (line-end-position)) (goto-char (org-element-property :contents-begin (org-element-context))) (let* ((lists (org-element-map (org-element-parse-buffer) 'plain-list (lambda (lst) (when (eq 'ordered (org-element-property :type lst)) (cons (org-element-property :end lst) (length (org-element-property :structure lst))))))) (last-list (nth (- (or (-find-index (lambda (x) (> (car x) (point))) lists) (length lists)) 1) lists))) (insert (format "[@%s] " (+ 1 (cdr last-list)))) (org-ctrl-c-ctrl-c))))) #+END_SRC John ----------------------------------- 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 On Sat, Nov 2, 2019 at 5:49 AM Jarmo Hurri wrote: > > Greetings. > > I know that lists can be continued using the following syntax: > > # ----------------------------------------------------------- > * First heading > 1. a list begins here > * Second heading > 2. [@2] list continues > # ----------------------------------------------------------- > > I find myself doing this all the time, especially when working on Beamer > slides. > > Given how smart org mode is (it is!), I find manual list continuation > weird. My questions are: > > a. Is there already a better way? > b. [@b] Could we have one? > > Jarmo > > > --0000000000001886190596604dd4 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
It seems a little tricky to do much better.

=
With numbering you can do something like this where you find the last = element of the previous list, and then continue it. This won't do what = you want for nested lists I guess. For lettering, you would need to figure = out how to increment the letter. but for simple numbered lists, this might = do the trick for you.

#+BEGIN_SRC emacs-lisp
(d= efun auto-continue ()
=C2=A0 (interactive)
=C2=A0 (when-let (p (org-i= n-item-p))
=C2=A0 =C2=A0 (save-excursion
=C2=A0 =C2=A0 =C2=A0 (goto-c= har (line-end-position))
=C2=A0 =C2=A0 =C2=A0 (goto-char (org-element-pr= operty :contents-begin (org-element-context)))
=C2=A0 =C2=A0 =C2=A0 (let= * ((lists (org-element-map (org-element-parse-buffer) 'plain-list
= =C2=A0 =C2=A0 =C2=A0(lambda (lst)
(when (eq 'ordered (org-elemen= t-property :type lst))
=C2=A0(cons
=C2=A0 (org-element-proper= ty :end lst)
=C2=A0 (length (org-element-property :structure lst))))= )))
=C2=A0 =C2=A0 (last-list (nth (- (or (-find-index (lambda (x)
= =C2=A0 (> (car x) (point)))
lists)
=C2=A0 =C2=A0= (length lists))
1)
=C2=A0 =C2=A0 lists)))
(insert (format= "[@%s] " (+ 1 (cdr last-list))))
(org-ctrl-c-ctrl-c)))))
=
#+END_SRC


John

-----------------------------------
Prof= essor John Kitchin=C2=A0
Doherty Hall A207F
Department of Chemical En= gineering
Carnegie Mellon University
Pittsburgh, PA 15213
412-268-= 7803


On Sat, Nov 2, 2019 at 5:49= AM Jarmo Hurri <jarmo.hurri@iki.f= i> wrote:

Greetings.

I know that lists can be continued using the following syntax:

# -----------------------------------------------------------
* First heading
=C2=A0 1. a list begins here
* Second heading
=C2=A0 2. [@2] list continues
# -----------------------------------------------------------

I find myself doing this all the time, especially when working on Beamer slides.

Given how smart org mode is (it is!), I find manual list continuation
weird. My questions are:

a. Is there already a better way?
b. [@b] Could we have one?

Jarmo


--0000000000001886190596604dd4--