From: "rgb" <rbielaws@i1.net>
To: help-gnu-emacs@gnu.org
Subject: Re: copy-word-from-line-above
Date: 25 Jan 2007 08:16:16 -0800 [thread overview]
Message-ID: <1169741776.423586.287790@v45g2000cwv.googlegroups.com> (raw)
In-Reply-To: <87fya0dvl2.fsf@gmx.at>
> (defun insert-word-above ()
> (interactive)
> (let (word whitespace)
> (save-excursion
> (let ((col (current-column)))
> (forward-line -1)
> (move-to-column col))
> (setq word (or (thing-at-point 'word)
> (error "No word above")))
> (forward-word)
> (setq whitespace (or (thing-at-point 'whitespace) "")))
> (insert word whitespace)))
>
> (global-set-key [f2] 'insert-word-above)
This does all kinds of bizar things whenever a seperator
other than whitespace surrounds a word. So it's probably
a good thing that it doesn't accept a count argument.
It acted slightly better (for me) replacing 'word with 'symbol
and (forward-word) with (forward-symbol 1).
I suspect that the OP is running Emacs remotely
and so the repeat key rate using insert-prior-line-char
is insufficient :-(
A solution like this might work better under such
circumstances.
(defun insert-prior-line-word (cnt)
"Insert chars in prior line starting above point until whitespace.
With prefix arg, do it CNT times."
(interactive "p")
(while (< 0 cnt)
(setq cnt (1- cnt))
(let (word whitespace)
(save-excursion
(let ((col (current-column)))
(forward-line -1)
(move-to-column col))
(save-match-data
(setq word (if (looking-at "\\S-+")
(prog1 (match-string 0)
(goto-char (match-end 0))))
whitespace (and (looking-at "\\s-+")
(match-string 0)))))
(or word whitespace (error "No word above"))
(if word (insert word whitespace)
(insert whitespace)))))
prev parent reply other threads:[~2007-01-25 16:16 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-01-18 17:51 copy-word-from-line-above HS
2007-01-18 20:50 ` copy-word-from-line-above Marc Tfardy
2007-01-19 0:36 ` copy-word-from-line-above Nikos Apostolakis
2007-01-19 20:25 ` copy-word-from-line-above rgb
2007-01-21 5:36 ` copy-word-from-line-above Greg Bognar
2007-01-21 16:15 ` copy-word-from-line-above rgb
2007-01-22 13:02 ` copy-word-from-line-above HS
2007-01-24 12:19 ` copy-word-from-line-above rgb
2007-01-24 17:34 ` copy-word-from-line-above HS
2007-01-24 20:21 ` copy-word-from-line-above Markus Triska
2007-01-25 16:07 ` copy-word-from-line-above HS
2007-01-25 20:13 ` copy-word-from-line-above Markus Triska
2007-01-25 16:16 ` rgb [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1169741776.423586.287790@v45g2000cwv.googlegroups.com \
--to=rbielaws@i1.net \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).