- (smiley-buffer (current-buffer) beg end))
-
-(defun smiley-toggle-extent (event)
- "Toggle smiley at given point."
- (interactive "e")
- (let* ((ant (event-glyph-extent event))
- (pt (event-closest-point event))
- ext)
- (if (annotationp ant)
- (when (extentp (setq ext (extent-property ant 'smiley-extent)))
- (set-extent-property ext 'invisible nil)
- (hide-annotation ant))
- (when pt
- (while (setq ext (extent-at pt (event-buffer event) nil ext 'at))
- (when (annotationp (setq ant
- (extent-property ext 'smiley-annotation)))
- (reveal-annotation ant)
- (set-extent-property ext 'invisible t)))))))
-
-;; FIXME::
-(defun smiley-toggle-extent-ems (event)
- "Toggle smiley at given point.
-Note -- this function hasn't been implemented yet."
- (interactive "e")
- (error "This function hasn't been implemented yet"))
-
-(defun smiley-toggle-extents (e)
- (interactive "e")
- (map-extents
- (lambda (e void)
- (let (ant)
- (if (annotationp (setq ant (extent-property e 'smiley-annotation)))
- (if (eq (extent-property e 'invisible) nil)
- (progn
- (reveal-annotation ant)
- (set-extent-property e 'invisible t)
- )
- (hide-annotation ant)
- (set-extent-property e 'invisible nil)))
- nil))
- (event-buffer e)))
-
-;; FIXME::
-(defun smiley-toggle-extents-ems (e)
- (interactive "e")
- (error "This function hasn't been implemented yet"))
-
-;;;###autoload
-(defun smiley-buffer (&optional buffer st nd)
- (interactive)
- (when (featurep '(or x gtk mswindows))
- (save-excursion
- (when buffer
- (set-buffer buffer))
- (let ((buffer-read-only nil)
- (alist (if (symbolp smiley-regexp-alist)
- (symbol-value smiley-regexp-alist)
- smiley-regexp-alist))
- (case-fold-search nil)
- entry regexp beg group file)
- (map-extents
- (lambda (e void)
- (when (or (extent-property e 'smiley-extent)
- (extent-property e 'smiley-annotation))
- (delete-extent e)))
- buffer st nd)
- (goto-char (or st (point-min)))
- (setq beg (point))
- ;; loop through alist
- (while (setq entry (pop alist))
- (setq regexp (car entry)
- group (cadr entry)
- file (caddr entry))
- (goto-char beg)
- (while (re-search-forward regexp nd t)
- (let* ((start (match-beginning group))
- (end (match-end group))
- (glyph (smiley-create-glyph (buffer-substring start end)
- file)))
- (when glyph
- (mapcar 'delete-annotation (annotations-at end))
- (let ((ext (make-extent start end))
- (ant (make-annotation glyph end 'text)))
- ;; set text extent params
- (set-extent-property ext 'end-open t)
- (set-extent-property ext 'start-open t)
- (set-extent-property ext 'invisible t)
- (set-extent-property ext 'keymap smiley-map)
- (set-extent-property ext 'mouse-face smiley-mouse-face)
- (set-extent-property ext 'intangible t)
- ;; set annotation params
- (set-extent-property ant 'mouse-face smiley-mouse-face)
- (set-extent-property ant 'keymap smiley-map)
- ;; remember each other
- (set-extent-property ant 'smiley-extent ext)
- (set-extent-property ext 'smiley-annotation ant)
- ;; Help
- (set-extent-property
- ext 'help-echo
- "button2 toggles smiley, button3 pops up menu")
- (set-extent-property
- ant 'help-echo
- "button2 toggles smiley, button3 pops up menu")
- (set-extent-property ext 'balloon-help
- "Mouse button2 - toggle smiley
-Mouse button3 - menu")
- (set-extent-property ant 'balloon-help
- "Mouse button2 - toggle smiley
-Mouse button3 - menu"))
- (when (smiley-end-paren-p start end)
- (make-annotation ")" end 'text))
- (goto-char end)))))))))
-
-;; FIXME: No popup menu, no customized color
-(defun smiley-buffer-ems (&optional buffer st nd)
- (interactive)
- (when window-system