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 8451583
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T11:16:49+00:00 2026-06-10T11:16:49+00:00

I needed to go through an XML file looking for certain tags whose contents

  • 0

I needed to go through an XML file looking for certain tags whose contents were human-recognizable but not regex-recognizable and to work on those tags. I put together a keyboard macro that did the work I needed, then tried to use the following elisp to let me step through the file and just press y or n for each tag instead of going back and forth between movement commands and macro executions.

(while t
  (progn
    (search-forward "<Name>")
    (move-beginning-of-line nil)
    (if (y-or-n-p "Problem? ")
        (call-last-kbd-macro)
      (next-line)
      )))

However, when I M-: evaluated this, it got to y-or-n-p and then emacs became unresponsive. I am using emacs on an OS X 10.7 machine. In Activity Monitor, emacs was taking up the normal amount of RAM and CPU time, not making escalating resource requests, so I don’t think I ran into an infinite loop. Emacs simply stopped responding to typing and clicks altogether, including things like repeatedly hitting Escape or C-g. An additional detail: the one y-or-n-p interaction I got was a dialog box, not in the minibuffer, which was strange – I clicked Yes on it and the dialog box went away, which was the last interaction I was able to get with emacs before it disappeared into deep space.

Is there something in the above elisp code that’s inherently dangerous? My thought was that the (search-forward) would fail at the end of the buffer, signal an error, and the loop would end.

  • 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-06-10T11:16:51+00:00Added an answer on June 10, 2026 at 11:16 am

    Try this so that the search fails the loop terminates. This code could still loop forever if the call-last-kbd-macro moves point back before the previous search.

    (while (search-forward "<Name>" nil t)
      (progn
        (move-beginning-of-line nil)
        (if (y-or-n-p "Problem? ")
            (call-last-kbd-macro)
          (next-line))))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Trying to simply grab an XML file and spit its contents through an API
A little help needed. I'm receiving an xml file similar to this: <?xml version=1.0
I'm new to JavaScript. I've worked my work through Learning JavaScript (o'reilly) but am
I looked through other questions and couldn't find what I needed. Best if I
Needed to write a server text file as the output of a business process
Needed Finfo but deleted msi package, so uninstalled php 5.3.0, downloaded 5.3.2 and installed.
I needed to store various strings in a map but I wanted to keep
I needed to change a work item field from PlainText -> String. As I
I have this very huge XML file of size 2.8GB. This is Polish Wikipedia's
I'm looking for a way to have an external file (resources, resx, assembly, config,

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.