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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T20:56:12+00:00 2026-05-20T20:56:12+00:00

total Emacs noob here. So right now I’m working on a fairly big LaTeX

  • 0

total Emacs noob here. So right now I’m working on a fairly big LaTeX project in Emacs in which there are couple of places where I need to index some words, using the makeidx package. Because I also wanted indexed words to be bold, I created my own command \ind{} which would make the argument go bold and indexed. But right now I’m dissatisifed with this command so I’d like to change every instance of \ind{whatever} in my text by \textbf{whatever}\index{whatever by default}.

The thing is I know exactly what I want :

  1. Go through the text, look for any instance of \ind{ and replace by \textbf{ using search-and-replace
  2. Save the argument of \ind (“whatever” in this case) in memory
  3. Ask me the user what should the argument of \index be. By default (by striking enter), it should be the first argument, but I can also change my mind and enter something different (“whatever by default” in this case). If there’s no input (only a space " " for example) stop the program.
  4. Write down \index{, the new argument and }.
  5. Go to next occurance in the text.

But, alas!, I know not how to achieve this, so I need someone’s help. If it should take too much time to explain how to do such a thing, would you please send me some tutorial about writing my own functions?

I hope I’m being clear, and thanks for your patience!

  • 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-20T20:56:12+00:00Added an answer on May 20, 2026 at 8:56 pm

    This approach seems vaguely unorthodox to me, but it works and seems sufficient for a one-off job…

    In the replacement text for replace-regexp and query-replace-regexp (C-M-%), one newer escape sequence is \,(...), where ... can be any Lisp expression. There’s a Lisp function read-from-minibuffer which reads arbitrary text typed by the user, with an optional default. Therefore:

    C-M-%: Start query-replace-regexp.

    \\ind{\([^}]+?\)}: The pattern to search for.

    \\textbf{\1}\\index{\,(read-from-minibuffer "index content? " \1)}: The replacement text. The user will be prompted for the text to put in the braces following the \index{} element, using the original text between the braces following the \ind{} element as a default.

    Note that when using query-replace-regexp, you’ll have to confirm each choice by typing y after each. Use M-x replace-regexp if you want to avoid this step.

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

Sidebar

Related Questions

total noob here. I've an array which looks like: Array ( [15] => Array
Total noob here with javascript. I'm trying to alter a function. This is the
Total noob here. This is my first c# attempt, its a console application that
Total noob question, but here. CSS .product__specfield_8_arrow { /*background-image:url(../../upload/orng_bg_arrow.png); background-repeat:no-repeat;*/ background-color:#fc0; width:50px !important; height:33px
Total noob question. I am building a simple photoblog in Rails which consists of
Total noob question here, but not finding the answer via search. What is the
Total Python noob here, probably missing something obvious. I've searched everywhere and haven't found
Total OO noob question here. I have these two methods in a class private
Total noob here learning openGL and I don't have any code to post because
total noob here with about 2 months of C++ experience (no other background) so

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.