From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "rgb" Newsgroups: gmane.emacs.help Subject: Re: copy-word-from-line-above Date: 25 Jan 2007 08:16:16 -0800 Organization: http://groups.google.com Message-ID: <1169741776.423586.287790@v45g2000cwv.googlegroups.com> References: <1169142712.291197.26770@a75g2000cwd.googlegroups.com> <1169238317.347524.324700@m58g2000cwm.googlegroups.com> <1169396144.659778.206270@a75g2000cwd.googlegroups.com> <1169470945.549075.73090@51g2000cwl.googlegroups.com> <1169641168.728984.258820@a75g2000cwd.googlegroups.com> <1169660063.651858.123660@v33g2000cwv.googlegroups.com> <87fya0dvl2.fsf@gmx.at> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Trace: sea.gmane.org 1169743265 3153 80.91.229.12 (25 Jan 2007 16:41:05 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 25 Jan 2007 16:41:05 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Jan 25 17:40:58 2007 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1HA7ej-0007je-5g for geh-help-gnu-emacs@m.gmane.org; Thu, 25 Jan 2007 17:40:57 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HA7ei-00045P-In for geh-help-gnu-emacs@m.gmane.org; Thu, 25 Jan 2007 11:40:56 -0500 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!postnews.google.com!v45g2000cwv.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 50 Original-NNTP-Posting-Host: 168.208.215.220 Original-X-Trace: posting.google.com 1169741803 15651 127.0.0.1 (25 Jan 2007 16:16:43 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Thu, 25 Jan 2007 16:16:43 +0000 (UTC) In-Reply-To: <87fya0dvl2.fsf@gmx.at> User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; InfoPath.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727),gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: v45g2000cwv.googlegroups.com; posting-host=168.208.215.220; posting-account=C7LM4w0AAAD23IRuMuUUJVCLQTuHhTK8 Original-Xref: shelby.stanford.edu gnu.emacs.help:145041 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:40644 Archived-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)))))