I don't know if I'm using the command correctly or not.
I select the region to be underlined and then pass the command M-x underline-region and it doesn't work.
For example

if the text is SAMPLE which I select and pass the command within Emacs, the output looks like this


How should I be using this command? I found this command by co-incidence.
When I searched on this topic, I found ul.el. I'm not good at elisp yet, so couldn't make any sense of the code.
The comment in the code says:

"Underline all nonblank characters in the region.
Works by overstriking underscores.
Called from program, takes two arguments START and END
which specify the range to operate on."

Which means that the output should look this SAMPLE (with an underline below it - I'm unable to get it in Markdown)


It appears to work as advertised. Note that what looks like ^H in the emacs buffer is really a backspace character. If you were to print _^HS on an old fashioned dot matrix printer, it would print the underscore, then the print head would go back one step, and it would print the S. Result: an underlined S! And so on for the next characters.

Basically, this shows the age of emacs. Emacs is old, from before dot matrix printers even (I think), and this was a common technique back then. Even now, you will find that programs like less will emulate this behaviour! So if you take a file in which you have run M-x underline-region on some text, then save it, and view it with less in a terminal, you will see underlined text.

What this will not do, however, is to display the text as underlined in the emacs buffer. Though it is conceivable that some modes exist (or could be written) that will display it that way.

  • I mention dot matrix printers, but there were earlier printers that would print characters one by one, and the backspace technique works on those too. – Harald Hanche-Olsen Sep 26 '16 at 18:59
  • Are u referring to this comment? ;;; Commentary: ;; This package deals with the primitive form of underlining ;; consisting of prefixing each character with "_\^h". The entry ;; point underline-region' performs such underlining on a region. ;; The entry point ununderline-region' removes it. – Prasanna Sep 26 '16 at 19:00
  • I admit I had only read the doc string and not looked into the source code. So no, I did not refer to that comment, but it is saying the same thing. – Harald Hanche-Olsen Sep 26 '16 at 19:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.