* Re: underline with character e.g. '-' or '='
[not found] <mailman.11566.1210714703.18990.help-gnu-emacs@gnu.org>
@ 2008-05-14 19:05 ` Brian Adkins
0 siblings, 0 replies; 3+ messages in thread
From: Brian Adkins @ 2008-05-14 19:05 UTC (permalink / raw)
To: help-gnu-emacs
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* underline with character e.g. '-' or '='
@ 2008-05-13 20:03 Brian Adkins
2008-05-13 21:33 ` David Hansen
0 siblings, 1 reply; 3+ messages in thread
From: Brian Adkins @ 2008-05-13 20:03 UTC (permalink / raw)
To: help-gnu-emacs
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
===========
It seems like a simple task:
1) Prompt for a character
2) Compute the length of the line
3) Insert a line below the current line
4) Insert <length> number of characters
Thanks,
Brian Adkins
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: underline with character e.g. '-' or '='
2008-05-13 20:03 Brian Adkins
@ 2008-05-13 21:33 ` David Hansen
0 siblings, 0 replies; 3+ messages in thread
From: David Hansen @ 2008-05-13 21:33 UTC (permalink / raw)
To: help-gnu-emacs
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))))
If it's only about visual feedback in emacs: tried outline-mode?
David
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2008-05-14 19:05 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <mailman.11566.1210714703.18990.help-gnu-emacs@gnu.org>
2008-05-14 19:05 ` underline with character e.g. '-' or '=' Brian Adkins
2008-05-13 20:03 Brian Adkins
2008-05-13 21:33 ` David Hansen
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.