Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7408059
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T05:50:33+00:00 2026-05-29T05:50:33+00:00

So I’m hacking up some elisp to test a web service, and I’m running

  • 0

So I’m hacking up some elisp to test a web service, and I’m running into trouble with syntax highlighting. I’m using url-retrieve-synchronously to get an HTTP response, then editing the text to get down to just the XML I need to see. Unfortunately, syntax highlighting doesn’t work in the returned buffer, even though I’ve set it to nxml-mode and used “font-lock-fontify-buffer” in the script. However, if I do “M-x font-lock-fontify-buffer”, the highlighting works as I would expect. Is there some difference between using it in elisp and from inside emacs?

Here are the relevant parts of the script I’m putting together. I admit up front that this is the first elisp scripting I’ve ever done, and I’m probably doing things in a ludicrously incorrect manner, but it’s all worked thus far.

(defun modality-http-request (url args request-type)
    (let ((url-request-method request-type)
        (url-request-extra-headers '(("Content-Type" . "application/x-www-form-urlencoded")))
        (url-request-data
            (mapconcat (lambda (arg)
                (concat  (url-hexify-string (car arg))
                    "="
                    (url-hexify-string (cdr arg))))
                    args
                    "&")))
        (url-retrieve-synchronously url)))

(defun modality-http-get (url args)
    (modality-http-request url args "GET"))

(defun modality-http-post (url args)
    (modality-http-request url args "POST"))

(defun test-modality (test)
    (interactive "s\Test: ")
        (let ((buffer (modality-http-get (concat (get-modality-path) test) nil)))
            (set-buffer buffer)
            (setq modality-beginning (point))
            (forward-paragraph)
            (next-line)
            (beginning-of-line)
            (setq modality-end (point))
            (delete-region modality-beginning modality-end)
            (bf-pretty-print-xml-region)
            (switch-to-buffer buffer)
            (font-lock-fontify-buffer)))

(defun bf-pretty-print-xml-region ()
  "Pretty format XML markup in region. You need to have nxml-mode
http://www.emacswiki.org/cgi-bin/wiki/NxmlMode installed to do
this.  The function inserts linebreaks to separate tags that have
nothing but whitespace between them.  It then indents the markup
by using nxml's indentation rules."
  (interactive "r")
  (save-excursion
      (nxml-mode)
      (goto-char (point-min))
      (while (search-forward-regexp "\>[ \\t]*\<" nil t) 
        (backward-char) (insert "\n"))
      (indent-region (point-min) (point-max))
      ))
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T05:50:34+00:00Added an answer on May 29, 2026 at 5:50 am

    URL uses temporary/internal buffers (recognized by the fact that their name starts with a space). They’re plain normal, but some functions treat them specially: font-lock will not be activated, and the buffer will usually not be shown to the user (e.g. C-x b TAB will not show those buffers).
    So either rename the buffer before enabling font-lock, or copy the text you need into another buffer whose name doesn’t start with a space.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a French site that I want to parse, but am running into
I am currently running into a problem where an element is coming back from
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I am reading a book about Javascript and jQuery and using one of the
Seemingly simple, but I cannot find anything relevant on the web. What is the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.