all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Renumbering paragraphs automatically
@ 2004-02-24 20:15 Timur Aydin
  2004-02-24 21:18 ` Reiner Steib
  2004-02-24 21:22 ` Benjamin Rutt
  0 siblings, 2 replies; 4+ messages in thread
From: Timur Aydin @ 2004-02-24 20:15 UTC (permalink / raw)


When writing an itemized list as follows:

1) Sentences in first paragraph.

2) The second paragraph.

3) The third paragraph.

Can emacs help me regenerate the paragraph numbers when I
insert/delete items or if I move items around?

-- 
Timur Aydin

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

* Re: Renumbering paragraphs automatically
  2004-02-24 20:15 Renumbering paragraphs automatically Timur Aydin
@ 2004-02-24 21:18 ` Reiner Steib
  2004-02-24 21:22 ` Benjamin Rutt
  1 sibling, 0 replies; 4+ messages in thread
From: Reiner Steib @ 2004-02-24 21:18 UTC (permalink / raw)


On Tue, Feb 24 2004, Timur Aydin wrote:

> When writing an itemized list as follows:
>
> 1) Sentences in first paragraph.
>
> 2) The second paragraph.
>
> 3) The third paragraph.
>
> Can emacs help me regenerate the paragraph numbers when I
> insert/delete items or if I move items around?

IIRC, Karl Pflästerer has written such a package (enumerate.el?).  It
used to be on <URL:http://my.gnus.org>.

Bye, Reiner.
-- 
       ,,,
      (o o)
---ooO-(_)-Ooo--- PGP key available via WWW   http://rsteib.home.pages.de/

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

* Re: Renumbering paragraphs automatically
  2004-02-24 20:15 Renumbering paragraphs automatically Timur Aydin
  2004-02-24 21:18 ` Reiner Steib
@ 2004-02-24 21:22 ` Benjamin Rutt
  2004-02-24 21:26   ` Benjamin Rutt
  1 sibling, 1 reply; 4+ messages in thread
From: Benjamin Rutt @ 2004-02-24 21:22 UTC (permalink / raw)


Timur Aydin <ta@taydin.org> writes:

> When writing an itemized list as follows:
>
> 1) Sentences in first paragraph.
>
> 2) The second paragraph.
>
> 3) The third paragraph.
>
> Can emacs help me regenerate the paragraph numbers when I
> insert/delete items or if I move items around?

I use outline-mode directly to build lists like this for maximum
flexibility.  When I want to produce numbered output for laymen to
read, I use the following shell script:

# filename: indentN.awk
#   author: Eric Pement - pemente@northpark.edu
#     date: 02/14/2001
#
#  purpose: awk script to modify files created and saved in GNU Emacs
#           "outline-mode" to a numbered, indented output format. E.g.,
#
#  INPUT FILE        OUTPUT FILE
#  ==============    ===========================            
#  * Line 1        | 1. Line 1
#  ** Line 2       |   1.1. Line 2
#  *** Line 3      |     1.1.1. Line 3
#  *** Line 4      |     1.1.2. Line 4
#  **** Line 5     |       1.1.2.1. Line 5
#  ***** Line 6    |         1.1.2.1.1. Line 6
#  ***** Line 7    |         1.1.2.1.2. Line 7
#  ** Line 8       |   1.2. Line 8
#  * Line 9        | 2. Line 9
#  ** Line 10      |   2.1. Line 10
#
# Note: this script can handle any number of asterisks on a line. 
# Lines of plain text (no asterisks) in source file are NOT indented.
/^\*/ {

  this_len = match($0,/\*[^*]/);  # get number of stars in 1st field
  array[this_len]++;              # increment index of current leaf

  if ( this_len < last_len ) {    # if we have moved up a branch...
     for (i = this_len + 1; i <= last_len; i++)
        array[i] = 0;             # .. reset the leaves below us
  }

  for (j=1; j <= this_len; j++) {   # build up the prefix string
     if   (j == 1)   prefix = array[j] "."
     else            prefix = "  " prefix array[j] "."
  }

  sub(/^\*+/, prefix)
  last_len = this_len
  prefix = ""
}
{ print }
# --- end of script ---

which I call from emacs using:

(defun my-outline-produce-numbered ()
  (interactive)
  (assert (string-match "\\.otl$" (buffer-file-name)))
  (let ((s (shell-command-to-string
	    (format "nawk -f ~/bin/indentN.awk < %s" (buffer-file-name)))))
    (find-file (my-re-replace-in-string "otl$" "txt" (buffer-file-name)))
    (erase-buffer)
    (insert s)
    (goto-char (point-min))))
-- 
Benjamin

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

* Re: Renumbering paragraphs automatically
  2004-02-24 21:22 ` Benjamin Rutt
@ 2004-02-24 21:26   ` Benjamin Rutt
  0 siblings, 0 replies; 4+ messages in thread
From: Benjamin Rutt @ 2004-02-24 21:26 UTC (permalink / raw)


Benjamin Rutt <brutt+news@bloomington.in.us> writes:

> which I call from emacs using:
>
> (defun my-outline-produce-numbered ()
>   (interactive)
>   (assert (string-match "\\.otl$" (buffer-file-name)))
>   (let ((s (shell-command-to-string
> 	    (format "nawk -f ~/bin/indentN.awk < %s" (buffer-file-name)))))
>     (find-file (my-re-replace-in-string "otl$" "txt" (buffer-file-name)))

Forgot to mention I do

(add-to-list 'auto-mode-alist '("\\.otl$" . outline-mode))

in my ~/.emacs.
-- 
Benjamin

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

end of thread, other threads:[~2004-02-24 21:26 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-02-24 20:15 Renumbering paragraphs automatically Timur Aydin
2004-02-24 21:18 ` Reiner Steib
2004-02-24 21:22 ` Benjamin Rutt
2004-02-24 21:26   ` Benjamin Rutt

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.