summary refs log tree commit diff stats
path: root/lisp/+titlecase.el
blob: 92668073eac1127d9a1064f6b9b8908566a5667f (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
;;; +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)))
      (while (and (progn (outline-next-heading)
                         (> (funcall outline-level) level))
                  (not (eobp)))
        (titlecase-line)))))

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