From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Markus Triska Newsgroups: gmane.emacs.help Subject: Re: copy-word-from-line-above Date: Thu, 25 Jan 2007 21:13:25 +0100 Message-ID: <87sldy3lwa.fsf@gmx.at> 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> <1169741235.558505.251180@v45g2000cwv.googlegroups.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1169761230 9974 80.91.229.12 (25 Jan 2007 21:40:30 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 25 Jan 2007 21:40:30 +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 22:40:28 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 1HACKY-0006vt-E8 for geh-help-gnu-emacs@m.gmane.org; Thu, 25 Jan 2007 22:40:26 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HACKX-0003er-Ta for geh-help-gnu-emacs@m.gmane.org; Thu, 25 Jan 2007 16:40:25 -0500 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!postnews.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!t-online.de!newsfeed.freenet.de!news.albasani.net!texta.sil.at!newscore.univie.ac.at!aconews-feed.univie.ac.at!aconews.univie.ac.at!not-for-mail Original-Newsgroups: gnu.emacs.help Cancel-Lock: sha1:Ecu9qkAapz0340aVRhCrEwnKSz4= Original-Lines: 24 Original-NNTP-Posting-Host: news-access-from.tuwien.ac.at Original-X-Trace: 1169756005 tunews.univie.ac.at 11610 192.35.241.118 Original-X-Complaints-To: abuse@tuwien.ac.at Original-Xref: shelby.stanford.edu gnu.emacs.help:145051 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:40654 Archived-At: "HS" wrote: > Hello! > Thanks Triska! > But your function would not copy symbols like '(' so I tried something, > and think I just wrote my first defun :) Cool; I changed "copy-region-as-kill-nomark" to "copy-region-as-kill" to get it working. To preserve the kill ring, you can use: (defun insert-word-above () (interactive) (let (string beg end) (save-excursion (let ((col (current-column))) (forward-line -1) (move-to-column col)) (setq beg (point)) (forward-word) (setq end (point))) (insert (buffer-substring beg end)))) All the best, Markus Triska