help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: copy-word-from-line-above


From: HS
Subject: Re: copy-word-from-line-above
Date: 25 Jan 2007 08:07:15 -0800
User-agent: G2/1.0

Hello!
Thanks Triska!
But your function would not copy symbols like '(' so I tried something,
and think I just wrote my first defun :)
Here it is:

(defun insert-word-above ()
  (interactive)
  (save-excursion
        (let ((col (current-column)))
          (forward-line -1)
          (move-to-column col))
        (let ((beg (point)))
          (forward-word)
          (copy-region-as-kill-nomark beg (point))))
        (yank))

It seems to work!
Cheers,
HS

On 24 jan, 17:21, Markus Triska <markus.tri...@gmx.at> wrote:
> "HS" <hug...@gmail.com> writes:
> > insert-prior-line-wordWhat about:
>
> (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)
> 
> All the best,
> Markus Triska



reply via email to

[Prev in Thread] Current Thread [Next in Thread]