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

Related Questions

I would like to apply FileIOPermission on set of files using mask in file
I have a service exposing 2 endpoint and I would like to apply message
Given a list, I would like to apply some set of operations to a
Can I apply transitions for images in my wp7 application? I have a set
I have a set of transforms that I apply to make a fancy reflection
I need to apply formatting - specifically, bold text - to the tooltip used
How to set a bitmap as a button so that i can apply button
I am using the following code to apply a hover effect to a set
I have a massive set of files (4000+) that are in an old Apple
I have a UITableView in an iOS5.1 app where I set self.tableView.allowsMultipleSelection=YES; The Apple

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.