[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: underline with character e.g. '-' or '='
From: |
Brian Adkins |
Subject: |
Re: underline with character e.g. '-' or '=' |
Date: |
Wed, 14 May 2008 15:05:50 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux) |
David Hansen <david.hansen@gmx.net> writes:
> On Tue, 13 May 2008 16:03:34 -0400 Brian Adkins wrote:
>
>> I often underline text with a hyphen or equal sign manually. I would
>> appreciate any info regarding how to accomplish this with a small elisp
>> function. Actually, if I had a function to compute the length of the
>> line, I think I would be all set.
>>
>> For example, if I had the following line:
>>
>> Section One
>>
>> I would like to position the the cursor on the 'S' and invoke:
>> M-x underline-line-with-char
>>
>> Which would prompte for a character in the minibuffer. If = was
>> supplied, the result would be:
>>
>> Section One
>> ===========
>
> (defun underline-with-char (char)
> (interactive (list (read-from-minibuffer "Char: ")))
> (when (= 0 (length char))
> (error "Need a character"))
> (setq char (aref char 0)) ; Ignore everything but the first
> char.
> (save-excursion
> (goto-char (point-at-eol))
> (insert "\n"
> (make-string (- (point-at-eol)
> (point-at-bol))
> char))))
Perfect - thanks! I love how extensible Emacs is. I just need to find
some time to research elisp programming. I've added a few things to my
tool belt from your code above.
> If it's only about visual feedback in emacs: tried outline-mode?
I have tried outline-mode briefly, but the function above is precisely
what I want.
>
> David