emacs-wiki-discuss
[Top][All Lists]
Advanced

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

Re: [emacs-wiki-discuss] Re: Indenting <example> tags


From: Allen Halsey
Subject: Re: [emacs-wiki-discuss] Re: Indenting <example> tags
Date: Wed, 22 Jun 2005 10:23:15 -1000
User-agent: Mozilla Thunderbird 1.0.2-6 (X11/20050513)

Thank you Sacha and Michael! This works great!

My source documents will now be a lot easier for me to visually
scan and find my place.

Allen

Sacha Chua wrote:
Michael Olson <address@hidden> writes:


Try adding the following to your .emacs.
(defun emacs-wiki-example-tag (beg end highlight-p)


Hmm, this deletes all starting whitespace, which breaks
nicely-indented code segments.

What about this?

   (defun emacs-wiki-example-tag (beg end highlight-p)
     (if highlight-p
         (progn
           (remove-text-properties
            beg end '(face nil font-lock-multiline nil
                           invisible nil intangible nil display nil
                           mouse-face nil keymap nil help-echo nil))
           (goto-char end))
       ;; Figure out how much whitespace precedes the example tag
       (let (offset)
         (goto-char beg)
         (when (looking-back (concat "^[" emacs-wiki-regexp-blank "]+"))
           (setq offset (concat "^" (match-string 0)))
           (replace-match "")
           (setq beg (point)))
         (save-restriction
           (narrow-to-region (point) end)
           (insert "<pre class=\"example\">")
           (when offset
             (while (re-search-forward offset nil t)
               (replace-match "")
               (forward-line)))
           (emacs-wiki-escape-html-specials end)
           (goto-char (point-max))
           (insert "</pre>"))
         (add-text-properties beg (point) '(rear-nonsticky (read-only)
                                                           read-only t)))))


Mind you, the prefix whitespace needs to be exactly the same right now... =)





reply via email to

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