help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Lisp question: odd fontification problem


From: thorne
Subject: Re: Lisp question: odd fontification problem
Date: Sun, 22 Apr 2007 06:41:12 -0700
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/23.0.51 (gnu/linux)

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)))


reply via email to

[Prev in Thread] Current Thread [Next in Thread]