├── .gitignore
├── README.md
└── lorem-ipsum.el
/.gitignore:
--------------------------------------------------------------------------------
1 | *.elc
2 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | [](https://elpa.nongnu.org/nongnu/lorem-ipsum.html)
2 |
3 | # Lorem Ipsum for Emacs #
4 |
5 | Add filler lorem ipsum text in Emacs.
6 |
7 | ## Installation
8 |
9 | **NonGNU ELPA or MELPA**
10 |
11 | This package is available via [NonGNU ELPA](https://elpa.nongnu.org/)
12 | and MELPA. You can install it by calling:
13 |
14 | M-x package-install RET lorem-ipsum RET
15 |
16 | That's it, all the functions you need are `autoload`ed.
17 |
18 | **Manual Installation**
19 |
20 | Add `lorem-ipsum.el` to your `load-path`. Finally, the package must
21 | be required:
22 |
23 | (require 'lorem-ipsum)
24 |
25 | ## Setup
26 |
27 | Use the default keybindings by adding the following to your .emacs
28 | file:
29 |
30 | (lorem-ipsum-use-default-bindings)
31 |
32 |
33 | This will setup the following keybindings:
34 |
35 | Key Binding | Function
36 | ------------|------------------------------
37 | `C-c l p` | `lorem-ipsum-insert-paragraphs`
38 | `C-c l s` | `lorem-ipsum-insert-sentences`
39 | `C-c l l` | `lorem-ipsum-insert-list`
40 |
41 | If you want different keybinding, say you want the prefix `C-c C-l`,
42 | use a variation of the following:
43 |
44 | (global-set-key (kbd "C-c C-l s") 'lorem-ipsum-insert-sentences)
45 | (global-set-key (kbd "C-c C-l p") 'lorem-ipsum-insert-paragraphs)
46 | (global-set-key (kbd "C-c C-l l") 'lorem-ipsum-insert-list)
47 |
--------------------------------------------------------------------------------
/lorem-ipsum.el:
--------------------------------------------------------------------------------
1 | ;;; lorem-ipsum.el --- Insert dummy pseudo Latin text -*- lexical-binding: t -*-
2 |
3 | ;; Copyright (c) 2003 Jean-Philippe Theberge
4 |
5 | ;; Author: Jean-Philippe Theberge (jphil21@sourceforge.net)
6 | ;; Maintainer: Joe Schafer (joe@jschaf.com)
7 | ;; Version: 0.4
8 | ;; Keywords: tools, language, convenience
9 | ;; URL: https://github.com/jschaf/emacs-lorem-ipsum
10 |
11 | ;; Special Thanks: The emacswiki users, the #emacs@freenode.net citizens
12 | ;; and Marcus Tullius Cicero
13 |
14 | ;; This file is not part of GNU Emacs.
15 |
16 | ;; Contains code from GNU Emacs ,
17 | ;; released under the GNU General Public License version 3 or later.
18 |
19 | ;; lorem-ipsum.el is free software; you can redistribute it and/or modify it
20 | ;; under the terms of the GNU General Public License as published by
21 | ;; the Free Software Foundation; either version 3, or (at your option)
22 | ;; any later version.
23 |
24 | ;; lorem-ipsum.el is distributed in the hope that it will be useful,
25 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
26 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
27 | ;; General Public License for more details.
28 |
29 | ;; You should have received a copy of the GNU General Public License
30 | ;; along with lorem-ipsum.el. If not, see .
31 |
32 | ;;; Commentary:
33 |
34 | ;; This package provides convenience functions to insert dummy Latin
35 | ;; text into a buffer.
36 | ;;
37 | ;; To install manually, add this file to your `load-path'. Use the
38 | ;; default keybindings by adding the following to your init file:
39 | ;;
40 | ;; (lorem-ipsum-use-default-bindings)
41 | ;;
42 | ;; This will setup the following keybindings:
43 | ;;
44 | ;; C-c l p: lorem-ipsum-insert-paragraphs
45 | ;; C-c l s: lorem-ipsum-insert-sentences
46 | ;; C-c l l: lorem-ipsum-insert-list
47 | ;;
48 | ;; If you want a different keybinding, say you want the prefix C-c C-l, use a
49 | ;; variation of the following:
50 | ;;
51 | ;; (global-set-key (kbd "C-c C-l s") 'lorem-ipsum-insert-sentences)
52 | ;; (global-set-key (kbd "C-c C-l p") 'lorem-ipsum-insert-paragraphs)
53 | ;; (global-set-key (kbd "C-c C-l l") 'lorem-ipsum-insert-list)
54 |
55 | ;;; History:
56 |
57 | ;; Version 0.1 released by Jean-Philippe Theberge in 2003. After
58 | ;; attempting to contact Jean-Philippe, Joe Schafer took over as
59 | ;; maintainer and published to Github.
60 |
61 | ;;; Code:
62 |
63 | (defconst lorem-ipsum-version "0.3")
64 |
65 | (defgroup lorem-ipsum nil
66 | "Insert filler text."
67 | :group 'tools
68 | :group 'convenience)
69 |
70 | ;;;###autoload
71 | (defun lorem-ipsum-use-default-bindings ()
72 | "Use the default keybindings of `C-c l [spl]'."
73 | (global-set-key (kbd "C-c l s") 'lorem-ipsum-insert-sentences)
74 | (global-set-key (kbd "C-c l p") 'lorem-ipsum-insert-paragraphs)
75 | (global-set-key (kbd "C-c l l") 'lorem-ipsum-insert-list))
76 |
77 | (defconst lorem-ipsum-text
78 | '(("Lorem ipsum dolor sit amet, consectetuer adipiscing elit."
79 | "Donec hendrerit tempor tellus."
80 | "Donec pretium posuere tellus."
81 | "Proin quam nisl, tincidunt et, mattis eget, convallis nec, purus."
82 | "Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus."
83 | "Nulla posuere."
84 | "Donec vitae dolor."
85 | "Nullam tristique diam non turpis."
86 | "Cras placerat accumsan nulla."
87 | "Nullam rutrum."
88 | "Nam vestibulum accumsan nisl.")
89 |
90 | ("Pellentesque dapibus suscipit ligula."
91 | "Donec posuere augue in quam."
92 | "Etiam vel tortor sodales tellus ultricies commodo."
93 | "Suspendisse potenti."
94 | "Aenean in sem ac leo mollis blandit."
95 | "Donec neque quam, dignissim in, mollis nec, sagittis eu, wisi."
96 | "Phasellus lacus."
97 | "Etiam laoreet quam sed arcu."
98 | "Phasellus at dui in ligula mollis ultricies."
99 | "Integer placerat tristique nisl."
100 | "Praesent augue."
101 | "Fusce commodo."
102 | "Vestibulum convallis, lorem a tempus semper, dui dui euismod elit, vitae placerat urna tortor vitae lacus."
103 | "Nullam libero mauris, consequat quis, varius et, dictum id, arcu."
104 | "Mauris mollis tincidunt felis."
105 | "Aliquam feugiat tellus ut neque."
106 | "Nulla facilisis, risus a rhoncus fermentum, tellus tellus lacinia purus, et dictum nunc justo sit amet elit.")
107 |
108 | ("Aliquam erat volutpat."
109 | "Nunc eleifend leo vitae magna."
110 | "In id erat non orci commodo lobortis."
111 | "Proin neque massa, cursus ut, gravida ut, lobortis eget, lacus."
112 | "Sed diam."
113 | "Praesent fermentum tempor tellus."
114 | "Nullam tempus."
115 | "Mauris ac felis vel velit tristique imperdiet."
116 | "Donec at pede."
117 | "Etiam vel neque nec dui dignissim bibendum."
118 | "Vivamus id enim."
119 | "Phasellus neque orci, porta a, aliquet quis, semper a, massa."
120 | "Phasellus purus."
121 | "Pellentesque tristique imperdiet tortor."
122 | "Nam euismod tellus id erat.")
123 |
124 | ("Nullam eu ante vel est convallis dignissim."
125 | "Fusce suscipit, wisi nec facilisis facilisis, est dui fermentum leo, quis tempor ligula erat quis odio."
126 | "Nunc porta vulputate tellus."
127 | "Nunc rutrum turpis sed pede."
128 | "Sed bibendum."
129 | "Aliquam posuere."
130 | "Nunc aliquet, augue nec adipiscing interdum, lacus tellus malesuada massa, quis varius mi purus non odio."
131 | "Pellentesque condimentum, magna ut suscipit hendrerit, ipsum augue ornare nulla, non luctus diam neque sit amet urna."
132 | "Curabitur vulputate vestibulum lorem."
133 | "Fusce sagittis, libero non molestie mollis, magna orci ultrices dolor, at vulputate neque nulla lacinia eros."
134 | "Sed id ligula quis est convallis tempor."
135 | "Curabitur lacinia pulvinar nibh."
136 | "Nam a sapien.")))
137 |
138 | (defvar lorem-ipsum-paragraph-separator "\n\n")
139 | (defvar lorem-ipsum-sentence-separator " ")
140 | (defvar lorem-ipsum-list-beginning "")
141 | (defvar lorem-ipsum-list-bullet "* ")
142 | (defvar lorem-ipsum-list-item-end "\n")
143 | (defvar lorem-ipsum-list-end "")
144 |
145 | (make-variable-buffer-local 'lorem-ipsum-paragraph-separator)
146 | (make-variable-buffer-local 'lorem-ipsum-sentence-separator)
147 | (make-variable-buffer-local 'lorem-ipsum-list-beginning)
148 | (make-variable-buffer-local 'lorem-ipsum-list-bullet)
149 | (make-variable-buffer-local 'lorem-ipsum-list-item-end)
150 | (make-variable-buffer-local 'lorem-ipsum-list-end)
151 |
152 | (defun lorem-ipsum-sgml-mode-hook ()
153 | "Set some variables for lorem-ipsum in `sgml-mode'."
154 | (setq lorem-ipsum-paragraph-separator "
\n"
155 | lorem-ipsum-sentence-separator " "
156 | lorem-ipsum-list-beginning "
\n"
157 | lorem-ipsum-list-bullet "- "
158 | lorem-ipsum-list-item-end "
\n"
159 | lorem-ipsum-list-end "
\n"))
160 |
161 | (add-hook 'sgml-mode-hook #'lorem-ipsum-sgml-mode-hook)
162 |
163 | ;;;###autoload
164 | (defun lorem-ipsum-insert-paragraphs (&optional num)
165 | "Insert lorem ipsum paragraphs into buffer.
166 | If NUM is non-nil, insert NUM paragraphs."
167 | (interactive "p")
168 | (if (not num) (setq num 1))
169 | (when (> num 0)
170 | (insert (concat
171 | (mapconcat #'identity
172 | (nth (random (length lorem-ipsum-text))
173 | lorem-ipsum-text)
174 | lorem-ipsum-sentence-separator)
175 | lorem-ipsum-paragraph-separator))
176 | (lorem-ipsum-insert-paragraphs (- num 1))))
177 |
178 | ;;;###autoload
179 | (defun lorem-ipsum-insert-sentences (&optional num)
180 | "Insert lorem ipsum sentences into buffer.
181 | If NUM is non-nil, insert NUM sentences."
182 | (interactive "p")
183 | (if (not num) (setq num 1))
184 | (when (> num 0)
185 | (let ((para
186 | (nth (random (length lorem-ipsum-text)) lorem-ipsum-text)))
187 | (insert (concat (nth (random (length para)) para) lorem-ipsum-sentence-separator)))
188 | (lorem-ipsum-insert-sentences (- num 1))))
189 |
190 | ;;;###autoload
191 | (defun lorem-ipsum-insert-list (&optional num)
192 | "Insert lorem ipsum list items into buffer.
193 | If NUM is non-nil, insert NUM list items."
194 | (interactive "p")
195 | (if (not num) (setq num 1))
196 | (when (> num 0)
197 | (insert lorem-ipsum-list-beginning)
198 | (dotimes (_ num)
199 | (let ((para (nth (random (length lorem-ipsum-text)) lorem-ipsum-text)))
200 | (insert (concat lorem-ipsum-list-bullet
201 | (nth (random (length para)) para)
202 | lorem-ipsum-list-item-end))))
203 | (insert lorem-ipsum-list-end)))
204 |
205 | ;;;###autoload
206 | (define-obsolete-function-alias 'Lorem-ipsum-insert-paragraphs
207 | 'lorem-ipsum-insert-paragraphs "29.1")
208 | ;;;###autoload
209 | (define-obsolete-function-alias 'Lorem-ipsum-insert-sentences
210 | 'lorem-ipsum-insert-sentences "29.1")
211 | ;;;###autoload
212 | (define-obsolete-function-alias 'Lorem-ipsum-insert-list
213 | 'lorem-ipsum-insert-list "29.1")
214 |
215 | (provide 'lorem-ipsum)
216 |
217 | ;;; lorem-ipsum.el ends here
218 |
--------------------------------------------------------------------------------