[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[emacs-wiki-discuss] Replacing IDs with images
From: |
Sacha Chua |
Subject: |
[emacs-wiki-discuss] Replacing IDs with images |
Date: |
Thu, 17 Feb 2005 17:37:29 +0900 |
User-agent: |
Gnus/5.110003 (No Gnus v0.3) Emacs/21.3.50 (gnu/linux) |
Hello, everyone!
Here's some proof-of-concept code that replaces task IDs with images
and can optionally do other strange things to strings like {{...}}.
For example, you can probably set up something to display different
images depending on the number of days to a deadline or the urgency of
a task.
http://sacha.free.net.ph/notebook/pics/screen/20050217-id.png shows it
in action. There's a small ID tag on the first task. <laugh>
----------------------------------------------------------------
(defun planner-id-image (id)
"Return the image to mark up ID as, or nil if none."
(save-match-data (when (string-match "Tasks" id)
"~/notebook/pics/screen/id-small.png")))
(defun planner-id-highlight-images (beg end &optional verbose)
"Highlight IDs as pictures from BEG to END.
VERBOSE is ignored."
(goto-char beg)
(while (re-search-forward "{{[^}]+}}" end t)
(let ((image (planner-id-image (match-string 0))))
(emacs-wiki-inline-image (match-beginning 0)
(match-end 0)
image
(match-string 0)))))
(add-hook 'emacs-wiki-highlight-buffer-hook 'planner-id-highlight-images)
----------------------------------------------------------------
You'll also want to apply this patch to emacs-wiki to center small images
nicely.
----------------------------------------------------------------
--- orig/emacs-wiki-colors.el
+++ mod/emacs-wiki-colors.el
@@ -858,7 +858,7 @@
(if (fboundp 'create-image)
;; Use the much nicer `create-image'
(add-text-properties
- beg end (list 'display (create-image filename)
+ beg end (list 'display (create-image filename nil nil :ascent
'center)
'keymap emacs-wiki-local-map
'help-echo (or desc url)))
;; If we get a valid glyph, use it
--
Sacha Chua <address@hidden> - open source geekette
http://sacha.free.net.ph/ - PGP Key ID: 0xE7FDF77C
interests: emacs, gnu/linux, personal information management, CS ed
sachac on irc.freenode.net#emacs . YM: sachachua83
- [emacs-wiki-discuss] Replacing IDs with images,
Sacha Chua <=