Emacs - How can I enable tab indentation in Assembly?

1

I have been using emacs for c programming and now that I want to write some Assmebly code, when I press tab, emacs just inserts the spaces. How can I force it to ident the current line with the Tab key?

George Stamatiou

Posted 2012-09-30T17:55:30.087

Reputation:

A thousand internets to the person that names an editor that does what I think OP is after in Linux. A "soft whitespace" editor. – Jens Björnhager – 2012-09-30T22:07:28.313

Answers

0

Using el-patch:

(el-patch-defun asm-calculate-indentation ()
  (or
   ;; Flush labels to the left margin.
   (and (looking-at "\\(\\sw\\|\\s_\\)+:") 0)
   ;; Same thing for `;;;' comments.
   (and (looking-at "\\s<\\s<\\s<") 0)
   (el-patch-remove
     ;; Simple `;' comments go to the comment-column.
     (and (looking-at "\\s<\\(\\S<\\|\\'\\)") comment-column))
   ;; The rest goes at the first tab stop.
   (or (indent-next-tab-stop 0))))

(defun my--indent-asm-setup ()
  "Set up indentation variables.
Indent with tabs, and make the TAB key behave like it's supposed
to."
  (setq-local indent-tabs-mode t)
  (setq-local tab-always-indent (default-value 'tab-always-indent)))

(add-hook 'asm-mode-hook #'my--indent-asm-setup)

Radon Rosborough

Posted 2012-09-30T17:55:30.087

Reputation: 323

How 'bout contributing this directly to Emacs's asm-mode ;-) ? – Stefan – 2019-02-25T16:18:42.267

@Stefan While I would love to in principle, past experience has shown me conclusively that contributing to Emacs is not worth the pain except in the most extreme of circumstances :/ -- I'll hold out for remacs though.

– Radon Rosborough – 2019-02-25T20:43:44.283

I'm sorry to hear that. – Stefan – 2019-02-25T21:05:54.777

0

Try gas-mode instead of the built in asm-mode.

rwb

Posted 2012-09-30T17:55:30.087

Reputation: 159

That mode is unmaintained since 2009. – Radon Rosborough – 2019-02-25T04:44:09.387

-1

Leave it this way. Most editors have an option to convert a tab to spaces. Why would you want the editor to convert tabs to spaces? You can take your code (either in saved file form or copied to clipboard) and use it in any editor and it will look the same. If you force it to use tabs, and you paste it here, or (we) open it in our editor it will most likely look like crap because we might have a tab set up to be a certain size.

If you really must use tabs instead of spaces, just do us a favor and convert the tabs to spaces before you post here or give it to someone else.

Gunner

Posted 2012-09-30T17:55:30.087

Reputation: 99

Sorry, I was probably misunderstood. When pressing the tab key, emacs moves the entire line enough spaces so it could be apropriately idented. – None – 2012-09-30T18:16:25.683

bugger off, if everyone used tabs we wouldn't have "8 vs. 4. vs. 2" wars. – Miles Rout – 2014-01-16T09:06:05.773