1 ;;; compact-docstrings-screenshot.el --- Make a screenshot of compact-docstrings
3 ;; Copyright (C) 2016 Free Software Foundation, Inc.
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.
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.
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/>.
20 ;; This just makes a screenshot for this package's homepage.
24 (defvar cds-fringe-width 6)
26 (defconst cds-script-dir
27 (file-name-directory (or load-file-name
31 (dolist (buffer (buffer-list))
32 (kill-buffer buffer)))
34 (defun cds-prepare-UI ()
35 "Prepare UI for taking a screenshot."
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)
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)
59 (defun cds-load-package ()
62 (load-library "compact-docstrings"))
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))
72 (defun cds-prepare-screenshot-1 ()
73 "Prepare for taking a screenshot."
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)
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))
90 (defun cds-take-screenshot ()
91 (cds-prepare-screenshot-1)
93 (run-with-idle-timer 1 nil #'cds-save-screenshot))
95 (print default-directory)
96 (run-with-idle-timer 0 nil #'cds-take-screenshot)
98 (provide 'compact-docstrings-screenshot)
99 ;; compact-docstrings-screenshot.el ends here