* Lisp question: odd fontification problem
@ 2007-04-22 13:32 thorne
2007-04-22 13:41 ` thorne
0 siblings, 1 reply; 2+ messages in thread
From: thorne @ 2007-04-22 13:32 UTC (permalink / raw)
To: help-gnu-emacs
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"))
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Lisp question: odd fontification problem
2007-04-22 13:32 Lisp question: odd fontification problem thorne
@ 2007-04-22 13:41 ` thorne
0 siblings, 0 replies; 2+ messages in thread
From: thorne @ 2007-04-22 13:41 UTC (permalink / raw)
To: help-gnu-emacs
Ugh. It doesn't matter how careful i try to be. Here's a (hopefully)
unmangled version:
(defvar underline-by-font-lock-delimiter "_")
(defvar underline-by-font-lock-flag nil)
(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-lock-flag))
(font-lock-fontify-buffer)))
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2007-04-22 13:41 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-04-22 13:32 Lisp question: odd fontification problem thorne
2007-04-22 13:41 ` thorne
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).