[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[cgreek:00012] Re: Rough implementation of works-list utilities
TAKAHASHI Naoto <ntakahas@xxxxxxxxx> writes:
> The hook post-command-hook is executed after each command is executed.
> You could register a function to display the text properties under
> cursor in the modeline, but Handa-san told me that there is a better
> hook for such a purpose. The name, however, escapes me. What was
> that?
They are point-entered and point-left text properties.
Here's a simple example program. After you load it, please
try:
(1) C-x b temp RET -- to switch to temporary buffer "temp"
(2) M-x modify-mode-line RET -- setup new mode-line-format
(3) M-x temp RET -- insert sample lines
Then, when you move cursor, the mode-line shows the `tag'
property of a text under the cursor. If there's no `tag'
property, "no tag" is shown.
However, currently, alpha version of Emacs 21 has a bug.
C-f doesn't update mode-line properly if C-f doesn't change
a line for a while, i.e, the mode-line is udpated 3 seconds
later.
---
Ken'ichi HANDA
handa@xxxxxxxxx
(defvar mode-line-tag nil)
(defun show-tag (old new)
(setq mode-line-tag (get-text-property new 'tag))
(force-mode-line-update))
(defun hide-tag (old new)
(setq mode-line-tag nil)
(force-mode-line-update))
(defun modify-mode-line ()
(interactive)
(setq mode-line-format (copy-sequence mode-line-format))
(let ((slot (or (memq 'mode-line-buffer-identification mode-line-format)
(memq 'mode-line-modified mode-line-format))))
(if slot
(setcdr slot
(cons '(mode-line-tag mode-line-tag "no tag") (cdr slot))))))
(defun temp ()
(interactive)
(let ((str1 "the first line")
(str2 "the second line"))
(add-text-properties 0 (length str1)
'(tag "tag1"
point-entered show-tag
point-left hide-tag)
str1)
(add-text-properties 0 (length str2)
'(tag "tag2"
point-entered show-tag
point-left hide-tag)
str2)
(insert str1 "\n" str2 "\n")))