Last active
August 29, 2015 14:19
-
-
Save mieki256/42a2777a177bee60e7e9 to your computer and use it in GitHub Desktop.
xyzzyでLorem ipsum(ダミーテキスト)を挿入
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; -*-lisp-*- | |
;; Last updated: <2015/04/12 07:39:04 +0900> | |
;; | |
;; # Lorem-ipsum - xyzzy | |
;; | |
;; lorem-ipsum.el を移植。 | |
;; http://www.emacswiki.org/emacs/lorem-ipsum.el | |
;; | |
;; ## インストール | |
;; | |
;; site-lisp/ に loremipsum.l をコピー。 | |
;; 必要ならバイトコンパイル。 | |
;; | |
;; ~/.xyzzy に以下を記述。 | |
;; | |
;; (require "loremipsum") | |
;; | |
;; | |
;; ## 使い方 | |
;; | |
;; M-x lorem-ipsum-insert-paragraphs | |
;; C-u 5 M-x lorem-ipsum-insert-paragraphs | |
;; | |
;; M-x lorem-ipsum-insert-sentences | |
;; C-u 5 M-x lorem-ipsum-insert-sentences | |
;; | |
;; M-x lorem-ipsum-insert-list | |
;; C-u 5 M-x lorem-ipsum-insert-list | |
;; | |
(provide "loremipsum") | |
(defconstant *lorem-ipsum-text* | |
'( | |
("Lorem ipsum dolor sit amet, consectetuer adipiscing elit." | |
"Donec hendrerit tempor tellus." "Donec pretium posuere tellus." | |
"Proin quam nisl, tincidunt et, mattis eget, convallis nec, purus." | |
"Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus." | |
"Nulla posuere." | |
"Donec vitae dolor." | |
"Nullam tristique diam non turpis." | |
"Cras placerat accumsan nulla." | |
"Nullam rutrum." | |
"Nam vestibulum accumsan nisl.") | |
("Pellentesque dapibus suscipit ligula." | |
"Donec posuere augue in quam." | |
"Etiam vel tortor sodales tellus ultricies commodo." | |
"Suspendisse potenti." | |
"Aenean in sem ac leo mollis blandit." | |
"Donec neque quam, dignissim in, mollis nec, sagittis eu, wisi." | |
"Phasellus lacus." | |
"Etiam laoreet quam sed arcu." | |
"Phasellus at dui in ligula mollis ultricies." | |
"Integer placerat tristique nisl." | |
"Praesent augue." | |
"Fusce commodo." | |
"Vestibulum convallis, lorem a tempus semper, dui dui euismod elit, vitae placerat urna tortor vitae lacus." | |
"Nullam libero mauris, consequat quis, varius et, dictum id, arcu." | |
"Mauris mollis tincidunt felis." | |
"Aliquam feugiat tellus ut neque." | |
"Nulla facilisis, risus a rhoncus fermentum, tellus tellus lacinia purus, et dictum nunc justo sit amet elit.") | |
("Aliquam erat volutpat." | |
"Nunc eleifend leo vitae magna." | |
"In id erat non orci commodo lobortis." | |
"Proin neque massa, cursus ut, gravida ut, lobortis eget, lacus." | |
"Sed diam." | |
"Praesent fermentum tempor tellus." | |
"Nullam tempus." | |
"Mauris ac felis vel velit tristique imperdiet." | |
"Donec at pede." | |
"Etiam vel neque nec dui dignissim bibendum." | |
"Vivamus id enim." | |
"Phasellus neque orci, porta a, aliquet quis, semper a, massa." | |
"Phasellus purus." | |
"Pellentesque tristique imperdiet tortor." | |
"Nam euismod tellus id erat.") | |
("Nullam eu ante vel est convallis dignissim." | |
"Fusce suscipit, wisi nec facilisis facilisis, est dui fermentum leo, quis tempor ligula erat quis odio." | |
"Nunc porta vulputate tellus." | |
"Nunc rutrum turpis sed pede." | |
"Sed bibendum." | |
"Aliquam posuere." | |
"Nunc aliquet, augue nec adipiscing interdum, lacus tellus malesuada massa, quis varius mi purus non odio." | |
"Pellentesque condimentum, magna ut suscipit hendrerit, ipsum augue ornare nulla, non luctus diam neque sit amet urna." | |
"Curabitur vulputate vestibulum lorem." | |
"Fusce sagittis, libero non molestie mollis, magna orci ultrices dolor, at vulputate neque nulla lacinia eros." | |
"Sed id ligula quis est convallis tempor." | |
"Curabitur lacinia pulvinar nibh." "Nam a sapien.") | |
)) | |
(defvar *lorem-ipsum-paragraph-separator* "\n\n") | |
(defvar *lorem-ipsum-sentence-separator* " ") | |
(defvar *lorem-ipsum-list-beginning* "") | |
(defvar *lorem-ipsum-list-bullet* "* ") | |
(defvar *lorem-ipsum-list-item-end* "\n") | |
(defvar *lorem-ipsum-list-end* "") | |
(defun lorem-mapconcat (fun list sep) | |
(when list | |
(let ((~sep (with-output-to-string (*standard-output*) | |
(map nil (lambda (ch) (princ (if (char= #\~ ch) "~~" ch))) sep)))) | |
(format nil (format nil "~~A~~{~A~~A~~}" ~sep) | |
(funcall fun (first list)) | |
(mapcar fun (rest list)))))) | |
(defun lorem-ipsum-insert-paragraphs (&optional num) | |
(interactive "p") | |
(if (not num) (setq num 1)) | |
(if (> num 0) | |
(progn | |
(insert (concat | |
(lorem-mapconcat 'identity | |
(nth (if (interactive-p) 0 (random (length *lorem-ipsum-text*))) | |
*lorem-ipsum-text*) " ") | |
*lorem-ipsum-paragraph-separator*)) | |
(lorem-ipsum-insert-paragraphs (- num 1))))) | |
(defun lorem-ipsum-insert-sentences (&optional num) | |
(interactive "p") | |
(if (not num) (setq num 1)) | |
(if (> num 0) | |
(progn | |
(let ((para (nth (if (interactive-p) 0 (random (length *lorem-ipsum-text*))) *lorem-ipsum-text*))) | |
(insert (concat (nth (if (interactive-p) 0 (random (length para))) para) *lorem-ipsum-sentence-separator*))) | |
(lorem-ipsum-insert-sentences (- num 1))))) | |
(defun lorem-ipsum-insert-list (&optional num) | |
(interactive "p") | |
(if (not num) (setq num 1)) | |
(if (> num 0) | |
(progn | |
(if (interactive-p) (insert *lorem-ipsum-list-beginning*)) | |
(let ((para (nth (if (interactive-p) 0 (random (length *lorem-ipsum-text*))) *lorem-ipsum-text*))) | |
(insert (concat *lorem-ipsum-list-bullet* | |
(nth (if (interactive-p) 0 (random (length para))) para) | |
*lorem-ipsum-list-item-end*))) | |
(lorem-ipsum-insert-list (- num 1))) | |
(insert *lorem-ipsum-list-end*))) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment