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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T20:22:06+00:00 2026-05-11T20:22:06+00:00

How do I apply a set of formatting rules to an existing source file

  • 0

How do I apply a set of formatting rules to an existing source file in emacs?

Specifically I have an assembly (*.s) file, but I would like a generic command for all types of files.

I am trying to use M-x c-set-style with gnu style, but I am getting an error:

Buffer *.s is not a CC Mode buffer (c-set-style)

  • 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-11T20:22:06+00:00Added an answer on May 11, 2026 at 8:22 pm

    Open the file and then indent it by indenting the entire region:

    M-x find-file /path/to/file RET
    C-x h                             (M-x mark-whole-buffer)
    C-M-\                             (M-x indent-region)
    

    Now, it looks like you’re trying to apply C indentation to a buffer that’s not in C mode. To get it into C mode

    M-x c-mode
    

    Or c++-mode, or whatever mode you want. But, since it’s assembler code, you probably want assembler mode (which Emacs will do by default for .s files). In which case, the indentation command above (C-M-\ is also known as M-x indent-region) should work for you.

    Note: the command sequence at the top can be rolled into a single command like this:

    (defun indent-file (file)
      "prompt for a file and indent it according to its major mode"
      (interactive "fWhich file do you want to indent: ")
      (find-file file)
      ;; uncomment the next line to force the buffer into a c-mode
      ;; (c-mode)
      (indent-region (point-min) (point-max)))
    

    And, if you want to learn how to associate major-modes with files based on extensions, check out the documentation for auto-mode-alist. To be fair, it’s not necessarily extension based, just regular expressions matched against the filename.

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

Sidebar

Ask A Question

Stats

  • Questions 123k
  • Answers 123k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Use the Inspectable metadata tag. In your case you'll want… May 12, 2026 at 12:55 am
  • Editorial Team
    Editorial Team added an answer UniObjects for .NET is free, and part of the UniData… May 12, 2026 at 12:55 am
  • Editorial Team
    Editorial Team added an answer I'm a bit perplexed by your code and why there… May 12, 2026 at 12:55 am

Related Questions

I need to display a formatted log in Delphi 2009. The formatting does not
I have a SQLite database that contains a huge set of log messages. I
How do I apply a repeating texture that always maintains its original scale (1
I have a set of changes which work perfectly against a certain linux version,

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.