[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Lisp question: odd fontification problem
From: |
thorne |
Subject: |
Lisp question: odd fontification problem |
Date: |
Sun, 22 Apr 2007 06:32:12 -0700 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/23.0.51 (gnu/linux) |
Hello. I have been tinkering with setting up a comfortable editing
onvironment (comfortable for me, that is) for editing fiction
manuscripts. I asked a question about this a while back and got very
useful help, so i now have another, odder question. I have a function
that is meant to toggle fontification of strings dimlimited by a
character as underlined. So, in my use, a string with underscores
would be underlined, and the underscores themselves would be
invisible. So it works. Horray! But when i toggle it back off,
something strange happens: the underlining disappears, but the
invisible underscores stay invisible... even if i go to
fundamental-mode, do (font-lock-fontify-buffer) or (and this is what i
don't understand) even if i do (kill-all-local-variables)--the
underscores stay invisible. I am guessing my whole approach is bad,
but in any case, i am pretty mystified, so here's the code:
(defun toggle-underline-by-font-lock (delimiter)
"Toggle font-lock-based underlinging of text between DELIMITER.
Simultaneusly make the string DELIMITER itself invisible.
Default delimiter defined by `underline-by-font-lock-delimiter'."
(interactive "P")
(let* ((delim (if delimiter
(read-string "Delimiter: ")
underline-by-font-lock-delimiter))
(delim-regex
(concat "\\(" delim "\\)\\([^" delim
"]*\\)\\(" delim "\\)\\(.\\)")))
(funcall (if underline-by-font-lock-flag
#'font-lock-remove-keywords
#'font-lock-add-keywords)
nil
`((,delim-regex
(1 '(face nil invisible t))
(2 'underline)
(3 '(face nil invisible t))
(4 'default))))
(setq underline-by-font-lock-flag
(not underline-by-font))
(font-lock-fontify-buffer)))
--
þ theron tlåx þ
(compose-mail (concat "thorne@" (rot13 "gvzoeny") ".net"))
- Lisp question: odd fontification problem,
thorne <=