summary refs log tree commit diff stats
path: root/lisp/+titlecase.el
blob: 6defda76368ab335fb62df18c5fb35f84e9788dc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
;;; +titlecase.el --- Titlecase extras -*- lexical-binding: t; -*-

;;; Commentary:

;;; Code:

(require 'titlecase)

(defun +titlecase-sentence-style-dwim (&optional arg)
  "Titlecase a sentence.
With prefix ARG, toggle the value of
`titlecase-downcase-sentences' before sentence-casing."
  (interactive "P")
  (let ((titlecase-downcase-sentences (if arg (not titlecase-downcase-sentences)
                                        titlecase-downcase-sentences)))
    (titlecase-dwim 'sentence)))

(defun +titlecase-org-headings ()
  (interactive)
  (save-excursion
    (goto-char (point-min))
    ;; See also `org-map-tree'.  I'm not using that function because I want to
    ;; skip the first headline.  A better solution would be to patch
    ;; `titlecase-line' to ignore org-mode metadata (TODO cookies, tags, etc).
    (let ((level (funcall outline-level))
          (org-special-ctrl-a/e t))
      (while (and (progn (outline-next-heading)
                         (> (funcall outline-level) level))
                  (not (eobp)))
        (titlecase-region (org-beginning-of-line)
                          (org-end-of-line))))))

(provide '+titlecase)
;;; +titlecase.el ends here