Skip to content

tsuu32/emacs-scsnowman

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

scsnowman.el

scsnowman.el is a Emacs Lisp port of LaTeX scsnowman.sty.

You can insert customizable scsnowman to buffer in graphical Emacs.

Screenshot

scsnowmans.png

Usage

You can insert scsnowman to buffer simply by scsnowman function.

(scsnowman :mouth-shape 'frown :snow "skyblue" :sweat t)

In scsnowman.el scsnowman is a SVG derived from svg.el.

scsnowman-create creates a scsnowman SVG, so you can use some functions from svg.el such as svg-print and svg-image.

Get image descriptor:

(svg-image (scsnowman-create))
;; you can insert the image with got image descriptor
;; (insert-image (svg-image (scsnowman-create)))

See SVG source:

(svg-print (scsnowman-create :body t :arms t :hat t :muffler "blue"))

Extensibility

As well as original scsnowman.sty You can define new scsnowman shape. Use scsnowman-define-shape-function macro to define new shape.

(scsnowman-define-shape-function "myfavorite"
  (let ((svg (svg-create 100 100)))
    ;; define scsnowman SVG
    ;; you can use `body', `eyes', `nose'... arguments in this form
    ;; useful scsnowman attributes such as `body-path', `eye-path'... also can be used

    ;; make sure that finally return created svg
    svg))

Examples

scsnowman-replace-snowman-mode

Replace ☃(U+2603), ⛄(U+26c4) and ⛇(U+26c7) characters in the buffer with scsnowman images.

(defvar scsnowman-replace-snowman-alist
  `(("" . (svg-image (scsnowman-create :muffler t :snow t) :scale 0.2 :ascent 80))
    ("" . (svg-image (scsnowman-create :muffler t) :scale 0.2 :ascent 80))
    ("" . (svg-image (scsnowman-create :body t :muffler t :snow t) :scale 0.2 :ascent 80))))

(define-minor-mode scsnowman-replace-snowman-mode
  "Toggle SCsnowman replace snowman mode."
  :lighter " SCsnowman"
  :global nil
  (if scsnowman-replace-snowman-mode
      (let* ((light-p (eq (frame-parameter nil 'background-mode) 'light))
             (scsnowman-defaultcolor (if light-p "black" "white"))
             (scsnowman-defaultanticolor (if light-p "white" "black")))
        (save-excursion
          (dolist (snowman scsnowman-replace-snowman-alist)
            (goto-char (point-min))
            (while (search-forward (car snowman) nil t)
              (add-text-properties (car (match-data t)) (cadr (match-data t))
                                   `(display ,(eval (cdr snowman))))))))
    (save-excursion
      (dolist (snowman scsnowman-replace-snowman-alist)
        (goto-char (point-min))
        (while (search-forward (car snowman) nil t)
          (remove-text-properties (car (match-data t)) (cadr (match-data t))
                                  '(display nil)))))))
あ、雪だるまだ☃

雪が降ってるね☃

⛄あっちは雪が降ってないみたい

!⛇大雪だ!

replaced.png

Bouncing scsnowman

Please download bouncing-dvd-logo.el and make sure that Emacs loads bouncing-dvd-logo.el.

You can enjoy editing with boucing scsnowman :)

(setq bouncing-dvd-logo-insert-form '(scsnowman :hat "green"
                                                :arms "brown"
                                                :muffler "blue"
                                                :buttons t
                                                :note t))
;; And M-x bouncing-dvd-logo-mode

bouncing.png

About

Emacs Lisp port of scsnowman.sty ☃︎

Resources

Stars

Watchers

Forks

Packages

No packages published