use cooper theme -- end of git, I am trying livemesh
[srid.dotfiles.git] / emacs / external / ljupdate / lj-fill.el
bloba16aad48c45da54f3611f6767c57c316bebbb5e4
1 ;;; lj-fill.el --- various filling methods for livejournal posts
3 ;; Copyright (C) 2002, 2003, 2004, 2005 Edward O'Connor <ted@oconnor.cx>
5 ;; Author: Edward O'Connor <ted@oconnor.cx>
6 ;; Keywords: convenience
8 ;; This file is part of ljupdate, a LiveJournal client for Emacs.
10 ;; ljupdate is free software; you can redistribute it and/or
11 ;; modify it under the terms of the GNU General Public License as
12 ;; published by the Free Software Foundation; either version 2, or
13 ;; {at your option} any later version.
15 ;; ljupdate is distributed in the hope that it will be useful, but
16 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 ;; General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING, or type `C-h C-c'. If
22 ;; not, write to the Free Software Foundation at this address:
24 ;; Free Software Foundation
25 ;; 51 Franklin Street, Fifth Floor
26 ;; Boston, MA 02110-1301
27 ;; USA
29 ;;; Commentary:
31 ;; The intent is for several different filling methods to live here.
32 ;; Currently, there are only two recommended values of
33 ;; `lj-fill-function': `lj-fill-by-paragraph' and `ignore'.
34 ;; Read the `lj-fill-function' doc string for more.
36 ;;; History:
39 ;;; Code:
41 (require 'lj-custom)
43 (defvar lj-fill-by-paragraph-fill-column 10000
44 "*Value to be used for `fill-column' by `lj-fill-by-paragraph'.")
46 (defvar lj-fill-flush-empty-lines-flag t
47 "*Non-nil means that `lj-fill-by-paragraph' will remove blank lines.")
49 (defvar lj-fill-inter-paragraph-newline-count 2
50 "*How many newlines to use in between paragraphs.
51 Yuo probably want this to be at least 1.")
53 (defun lj-fill-by-paragraph ()
54 "Fills your LiveJournal post while assuming you wrote text with auto fill.
56 Assumes that consecutive non-blank lines are paragraphs, unfills them,
57 and kills any extra blank lines. If your posts are predominately text,
58 with little to no markup, this is probably the behavior you will like.
60 This is like the default filling behavior of the old ljupdate code. If
61 you didn't like it then, you won't like it now. You may want to fiddle
62 with the values of `lj-fill-by-paragraph-fill-column',
63 `lj-fill-flush-empty-lines-flag', and/or
64 `lj-fill-inter-paragraph-newline-count' in order to produce the sort of
65 behavior you'd like this function to exhibit. Or, you may change the
66 value of `lj-fill-function' to a function more to your liking (e.g.
67 `ignore')."
68 ;; Fill paragraphs
69 (goto-char (point-min))
70 (let ((fill-column lj-fill-by-paragraph-fill-column))
71 (fill-paragraph nil)
72 (while (zerop (forward-paragraph 1))
73 (fill-paragraph nil)))
74 ;; Kill blank lines
75 (when lj-fill-flush-empty-lines-flag
76 (flush-lines "^$" (point-min) (point-max)))
77 ;; Restore paragraph separation
78 (goto-char (point-min))
79 (let ((newlines (make-string lj-fill-inter-paragraph-newline-count ?\n)))
80 (while (search-forward "\n" nil t)
81 (replace-match newlines))))
83 (defun lj-fill-by-shell-command ()
84 "Filters your LiveJournal post through a shell command."
85 (shell-command-on-region (point-min) (point-max)
86 lj-fill-by-shell-command-command t))
89 (provide 'lj-fill)
90 ;;; lj-fill.el ends here