big-lambda.el
Click here to get the file
Size
3.4 kB
-
File type
text/x-emacs-lisp
File contents
;;; big-lambda.el --- Display big lambda.
;; Copyright (C) 2007 Taiki SUGAWARA <buzz.taiki@gmail.com>
;; Author: Taiki SUGAWARA <buzz.taiki@gmail.com>
;; Keywords: lisp, convenience
;; This file is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.
;; This file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING. If not, write to
;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
;; Boston, MA 02110-1301, USA.
;;; Installation:
;;
;; Put the following in your .emacs:
;; (require 'big-lambda)
;; (add-hook 'emacs-lisp-mode-hook 'big-lambda-mode-turn-on)
;; (add-hook 'lisp-mode-hook 'big-lambda-mode-turn-on)
;; (add-hook 'lisp-interaction-mode-hook 'big-lambda-mode-turn-on)
;;; Code:
(defvar big-lambda-image
(create-image
(base64-decode-string
"/9j/4AAQSkZJRgABAQEASABIAAD/2wBDAAsICAoIBwsKCQoNDAsNERwSEQ8PESIZGhQcKSQrKigk
JyctMkA3LTA9MCcnOEw5PUNFSElIKzZPVU5GVEBHSEX/2wBDAQwNDREPESESEiFFLicuRUVFRUVF
RUVFRUVFRUVFRUVFRUVFRUVFRUVFRUVFRUVFRUVFRUVFRUVFRUVFRUVFRUX/wAARCAAwAEADASIA
AhEBAxEB/8QAGgABAQEBAAMAAAAAAAAAAAAAAAUEAwIGB//EACgQAAEEAQIEBgMAAAAAAAAAAAEA
AgMEERIhBTFhcQYUIjJBgRVRkf/EABcBAQEBAQAAAAAAAAAAAAAAAAABAwL/xAAcEQEBAQACAwEA
AAAAAAAAAAAAAQIRIQMxQVH/2gAMAwEAAhEDEQA/APriIiAThZqvEKd5zxUtQzmP3CN4dj+Lyu1G
XqklaRzmxyDDtJwSM7jsRsehWHiUbKlrh1qJgYWTCu7TtmN/p09g7QfpaYznXX1FVERZqIiICIiA
ofiK6IvJV2t1vdZhkfv7I2yNy4/ZAHforM80deCSaZ4ZHG0uc48gBuSoTqE13g1+1Kwi5dj1MYec
bW7xs+uZ6krfwyTU1r0lewIuNOyy5ThsR+yZgeOxGV2WNnF4qiIigIiIJd+N/EL8NIsd5WPE87iN
n4PoZ13GT0AHyqiIurrmSfgixT/gpJa9hjxRc4vgmYwuEeTksdgbYJJB5YOPjffQuOvNllETo4Ne
InPBaZG4GXYO4Gc4/eMrWi61ua7s7QREWav/2Q==")
'jpeg t))
(defvar big-lambda-font-lock-keywords
'((".+" (0 (prog1 nil
(big-lambda-remove-region
(match-beginning 0) (match-end 0)))))
("(\\(lambda\\)\\>"
(0 (prog1 nil
(big-lambda-region (match-beginning 1) (match-end 1)))))))
(defun big-lambda-remove-region (beg end)
"Remove big lambda property in region between BEG and END."
(let (pos)
(while (setq pos (text-property-any beg end 'display big-lambda-image))
(remove-text-properties
pos
(or (next-single-property-change pos 'display) end)
'(display)))))
(defun big-lambda-region (beg end)
"Add big lambda property in region between BEG and END."
(put-text-property beg end 'display big-lambda-image))
(define-minor-mode big-lambda-mode
"Display big lambda."
nil " Lambda" nil
(if big-lambda-mode
(progn
(save-restriction
(widen)
(let ((font-lock-keywords big-lambda-font-lock-keywords))
(font-lock-fontify-buffer)))
(font-lock-add-keywords nil big-lambda-font-lock-keywords))
(font-lock-remove-keywords nil big-lambda-font-lock-keywords)
(save-restriction
(widen)
(let ((modified-p (buffer-modified-p)))
(big-lambda-remove-region (point-min) (point-max))
(set-buffer-modified-p modified-p)))))
(defun big-lambda-mode-turn-on ()
"Turn on `big-lambda-mode'."
(interactive)
(big-lambda-mode 1))
(provide 'big-lambda)
;;; big-lambda.el ends here