emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] new rule to capitalise the first word in a sentence? but how?


From: Samuel Wales
Subject: Re: [O] new rule to capitalise the first word in a sentence? but how?
Date: Wed, 27 Apr 2016 14:15:37 -0700

very old code, maybe can be adjusted slightly to do what you want.

(defun alpha-capitalize-sentences ()
  (interactive)
  (let ((b (region-beginning))
        (e (region-end))
        ;;i always use double spaces but i want sentence movement
        ;;to be liberal -- that is to count more things as
        ;;sentences.
        (sentence-end-double-space nil)
        ;;need to make it understand org headlines etc. also.
        ;;don't know if this will help.  will fail on *bold*.
        ;;non-idempotent.  use a vector function.
        (sentence-end-without-space
         (concat sentence-end-without-space "*")))
    (save-excursion
      (goto-char b)
      (loop
            while (< (point) (max b e))
            do
            (when (y-or-n-p "capitalize this sentence?")
              (capitalize-word 1))
            ;;forward-sentence-incl-org (headlines, items, other)
            do
            (let ((sentence-end-without-period t))
              (forward-sentence))))
;;;    (replace-regexp "i" "I" t (region-beginning) (region-end))
    (save-excursion
      (perform-replace "i" "I"
                       nil t t nil nil
                       b e))))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]