]> code.delx.au - gnu-emacs-elpa/blob - etc/compact-docstrings-screenshot.el
Add copyright to screenshot.el
[gnu-emacs-elpa] / etc / compact-docstrings-screenshot.el
1 ;;; compact-docstrings-screenshot.el --- Make a screenshot of compact-docstrings
2
3 ;; Copyright (C) 2016 Free Software Foundation, Inc.
4
5 ;; This program is free software; you can redistribute it and/or modify
6 ;; it under the terms of the GNU General Public License as published by
7 ;; the Free Software Foundation, either version 3 of the License, or
8 ;; (at your option) any later version.
9
10 ;; This program is distributed in the hope that it will be useful,
11 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
12 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 ;; GNU General Public License for more details.
14
15 ;; You should have received a copy of the GNU General Public License
16 ;; along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 ;;; Commentary:
19
20 ;; This just makes a screenshot for this package's homepage.
21
22 ;;; Code:
23
24 (defvar cds-fringe-width 6)
25
26 (defconst cds-script-dir
27 (file-name-directory (or load-file-name
28 buffer-file-name)))
29
30 (defun cds-cleanup ()
31 (dolist (buffer (buffer-list))
32 (kill-buffer buffer)))
33
34 (defun cds-prepare-UI ()
35 "Prepare UI for taking a screenshot."
36 (ido-mode)
37 (tool-bar-mode -1)
38 (menu-bar-mode -1)
39 (scroll-bar-mode -1)
40 (column-number-mode)
41 (fringe-mode (cons cds-fringe-width cds-fringe-width))
42 (blink-cursor-mode -1)
43 (setq-default cursor-type 'bar
44 split-width-threshold 80
45 truncate-partial-width-windows t
46 frame-title-format (format "Compact docstrings @ Emacs %s" emacs-version)
47 x-gtk-use-system-tooltips nil)
48 (load-theme 'tango t)
49 ;; (set-face-attribute 'tooltip nil :height 60)
50 (set-face-attribute 'match nil :background "yellow1")
51 (set-face-attribute 'default nil :family "Ubuntu Mono" :height 110)
52 (set-face-attribute 'mode-line nil :foreground "gray60" :background "black")
53 (set-face-attribute 'mode-line-inactive nil :foreground "gray60" :background "#404045")
54 (set-face-attribute 'mode-line-buffer-id nil :foreground "#eab700")
55 (set-fontset-font t 'unicode "Ubuntu Mono")
56 (set-frame-size nil 100 13)
57 (redisplay t))
58
59 (defun cds-load-package ()
60 "Load package."
61 (package-initialize)
62 (load-library "compact-docstrings"))
63
64 (defun cds-load-example ()
65 "Prepare files and layout windows."
66 (find-file "etc/before.py")
67 (setq buffer-name "Regular docstrings")
68 (find-file-other-window "after.py")
69 (setq buffer-name "Compact docstrings")
70 (compact-docstrings-mode))
71
72 (defun cds-prepare-screenshot-1 ()
73 "Prepare for taking a screenshot."
74 (cds-prepare-UI)
75 (cds-load-package)
76 (cds-load-example)
77 (message nil))
78
79 (defun cds-save-screenshot ()
80 "Save screenshot of current frame."
81 (let ((fname (expand-file-name "compact-docstrings.png" cds-script-dir)))
82 (process-lines "import" "-window" (frame-parameter nil 'outer-window-id)
83 fname)
84 (process-lines "mogrify" "-strip" "-matte"
85 "-bordercolor" (face-attribute 'fringe :background)
86 "-border" (format "0x%d" cds-fringe-width) fname)
87 (process-lines "optipng" "-o3" fname))
88 (kill-emacs))
89
90 (defun cds-take-screenshot ()
91 (cds-prepare-screenshot-1)
92 (redisplay t)
93 (run-with-idle-timer 1 nil #'cds-save-screenshot))
94
95 (print default-directory)
96 (run-with-idle-timer 0 nil #'cds-take-screenshot)
97
98 (provide 'compact-docstrings-screenshot)
99 ;; compact-docstrings-screenshot.el ends here