Loading ...
Sorry, an error occurred while loading the content.

[jasspa] How about auto-numbering?

Expand Messages
  • Thomas Hundt
    All right, how about a nice-to-have: (Auto-)Numbering paragraphs. Let s say you have this text: 1. Buy the gun 2. Find the guy who told me AOL was a good buy
    Message 1 of 2 , Aug 15, 1999
    • 0 Attachment
      All right, how about a nice-to-have: (Auto-)Numbering paragraphs.

      Let's say you have this text:

      1. Buy the gun
      2. Find the guy who told me AOL was a good buy at $110/share
      3. Show him who's boss
      4. Hide the body

      and now you remember, Damn, I wanted to put in:

      2. Buy some ammunition

      And now you have to go and change numbers 2, 3, and 4 to 3, 4, and 5. What
      a pain. If you're using the numbering in Word, it does it for you. How
      about Emacs? :-)

      This is one of the things I really like about MS-Word but don't have
      available to me in a text editor (but would like to). And yes, I could
      write it myself; I'm just throwing it out there in case somebody else has
      it already (or it's built in and I just don't know it) or somebody feels
      inspired (or even that it's a good idea or lousy idea). Maybe a new
      $fill-mode for "numbered"?

      Have I mentioned how much I love the fact that me32 will properly format
      bullet lists, with indentation and everything? Mmmm... bullets... :-)

      (BTW, typo in the manpage for ifill-paragraph: ("sub-bullllllet")
      "This is the main paragraph which can be as long as required,
      following is a list of bullets, some with a sub-bulllet list. Here
      is the list: ")

      -Th
    • Detlef Groth
      ... There is an easy solution if the numbers are always at the beginng of the line and not larger than 9 and your replacementtext is not longer than 30 lines
      Message 2 of 2 , Aug 22, 1999
      • 0 Attachment
        At 22:14 15.08.99 -0700, you wrote:
        >All right, how about a nice-to-have: (Auto-)Numbering paragraphs.
        >
        >Let's say you have this text:
        >
        >1. Buy the gun
        >2. Find the guy who told me AOL was a good buy at $110/share
        >3. Show him who's boss
        >4. Hide the body
        >
        >and now you remember, Damn, I wanted to put in:
        >
        >2. Buy some ammunition
        >
        >And now you have to go and change numbers 2, 3, and 4 to 3, 4, and 5. What
        >a pain. If you're using the numbering in Word, it does it for you. How
        >about Emacs? :-)
        >
        >This is one of the things I really like about MS-Word but don't have
        >available to me in a text editor (but would like to). And yes, I could
        >write it myself; I'm just throwing it out there in case somebody else has
        >it already (or it's built in and I just don't know it) or somebody feels
        >inspired (or even that it's a good idea or lousy idea). Maybe a new
        >$fill-mode for "numbered"?
        >

        There is an easy solution if the numbers are always at the beginng of the line and not larger than 9 and your replacementtext is not longer than 30 lines long and no other list comes at the next 30 lines. Limitation to 30 lines is for avoiding undesired replacements through the whole document. Try:

        define-macro change-numbers
        -30 replace-string "^1" "2"
        -30 replace-string "^2" "3"
        -30 replace-string "^3" "4"
        -30 replace-string "^4" "5"
        -30 replace-string "^5" "6"
        -30 replace-string "^6" "7"
        -30 replace-string "^7" "8"
        -30 replace-string "^8" "9"
        -30 replace-string "^9" "10"
        -30 replace-string "^10" "11"
        -30 replace-string "^11" "12"
        !emacro
        global-bind-key change-numbers "C-9"

        your....
        1. Buy the gun
        2. Buy some ammunition |Place the cursor here and press "C-9"|
        2. Find the guy who told me AOL was a good buy at $110/share
        3. Show him who's boss
        4. Hide the body

        will convert rapidly to:

        1. Buy the gun
        2. Buy some ammunition
        3. Find the guy who told me AOL was a good buy at $110/share
        4. Show him who's boss
        5. Hide the body

        However ..

        1. Buy the gun
        2. Buy some ammunition |Place the cursor here and press "C-9"|
        2. Find the guy who told me AOL was a good buy at $110/share
        3. Show him who's boss
        4. Hide the body

        1. Buy the gun
        2. Buy some ammunition
        3. Find the guy who told me AOL was a good buy at $110/share
        4. Show him who's boss
        5. Hide the body

        is converted to:

        1. Buy the gun
        2. Buy some ammunition
        2. Find the guy who told me AOL was a good buy at $110/share
        3. Show him who's boss
        4. Hide the body

        2. Buy the gun
        2. Buy some ammunition
        3. Find the guy who told me AOL was a good buy at $110/share
        4. Show him who's boss
        5. Hide the body

        sorry. So here you have to copy your list to a new buffer and than press C-9.
        That means it only works if two lists should be more than 30 lines far away. Therefore it would be nice to replace only a marked region. What are the experts saying.....?

        Here is a trial....

        define-macro change-numbers2
        set-variable $buffer-bname #10
        kill-region
        osd-1-new
        yank
        beginning-of-buffer
        -30 replace-string "^1" "2"
        -30 replace-string "^2" "3"
        -30 replace-string "^3" "4"
        -30 replace-string "^4" "5"
        -30 replace-string "^5" "6"
        -30 replace-string "^6" "7"
        -30 replace-string "^7" "8"
        -30 replace-string "^8" "9"
        -30 replace-string "^9" "10"
        beginning-of-buffer
        set-mark
        end-of-buffer
        kill-region
        find-buffer #10
        yank
        !emacro

        does not refind the right buffer and does not close the new-buffer....

        Best regards, Detlef
      Your message has been successfully submitted and would be delivered to recipients shortly.